diff options
author | crupest <crupest@outlook.com> | 2019-12-13 01:02:47 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-12-13 01:02:47 +0800 |
commit | 9110574bb51e9e2959842a7641f598d34c3cd847 (patch) | |
tree | 96ee1f5b3c40095e4e923fc763de0663ee6a01aa /include/cru/ui/render/text_render_object.hpp | |
parent | f2aa96fba0b72eeeadf5160ea5df2c8143ec8aa0 (diff) | |
download | cru-9110574bb51e9e2959842a7641f598d34c3cd847.tar.gz cru-9110574bb51e9e2959842a7641f598d34c3cd847.tar.bz2 cru-9110574bb51e9e2959842a7641f598d34c3cd847.zip |
...
Diffstat (limited to 'include/cru/ui/render/text_render_object.hpp')
-rw-r--r-- | include/cru/ui/render/text_render_object.hpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/include/cru/ui/render/text_render_object.hpp b/include/cru/ui/render/text_render_object.hpp index a10e3b74..6c01ed93 100644 --- a/include/cru/ui/render/text_render_object.hpp +++ b/include/cru/ui/render/text_render_object.hpp @@ -6,33 +6,33 @@ // forward declarations namespace cru::platform::graph { -class Brush; -class Font; -class TextLayout; +struct IBrush; +struct IFont; +struct ITextLayout; } // namespace cru::platform::graph namespace cru::ui::render { class TextRenderObject : public RenderObject { public: - TextRenderObject(std::shared_ptr<platform::graph::Brush> brush, - std::shared_ptr<platform::graph::Font> font, - std::shared_ptr<platform::graph::Brush> selection_brush); + TextRenderObject(std::shared_ptr<platform::graph::IBrush> brush, + std::shared_ptr<platform::graph::IFont> font, + std::shared_ptr<platform::graph::IBrush> selection_brush); TextRenderObject(const TextRenderObject& other) = delete; TextRenderObject(TextRenderObject&& other) = delete; TextRenderObject& operator=(const TextRenderObject& other) = delete; TextRenderObject& operator=(TextRenderObject&& other) = delete; ~TextRenderObject() override = default; - std::wstring GetText() const; - void SetText(std::wstring new_text); + std::string GetText() const; + void SetText(std::string new_text); - std::shared_ptr<platform::graph::Brush> GetBrush() const { return brush_; } - void SetBrush(std::shared_ptr<platform::graph::Brush> new_brush) { + std::shared_ptr<platform::graph::IBrush> GetBrush() const { return brush_; } + void SetBrush(std::shared_ptr<platform::graph::IBrush> new_brush) { new_brush.swap(brush_); } - std::shared_ptr<platform::graph::Font> GetFont() const; - void SetFont(std::shared_ptr<platform::graph::Font> font); + std::shared_ptr<platform::graph::IFont> GetFont() const; + void SetFont(std::shared_ptr<platform::graph::IFont> font); std::optional<TextRange> GetSelectionRange() const { return selection_range_; @@ -41,14 +41,14 @@ class TextRenderObject : public RenderObject { selection_range_ = std::move(new_range); } - std::shared_ptr<platform::graph::Brush> GetSelectionBrush() const { + std::shared_ptr<platform::graph::IBrush> GetSelectionBrush() const { return selection_brush_; } - void SetSelectionBrush(std::shared_ptr<platform::graph::Brush> new_brush) { + void SetSelectionBrush(std::shared_ptr<platform::graph::IBrush> new_brush) { new_brush.swap(selection_brush_); } - void Draw(platform::graph::Painter* painter) override; + void Draw(platform::graph::IPainter* painter) override; RenderObject* HitTest(const Point& point) override; @@ -59,11 +59,11 @@ class TextRenderObject : public RenderObject { void OnAfterLayout() override; private: - std::shared_ptr<platform::graph::Brush> brush_; - std::shared_ptr<platform::graph::Font> font_; - std::shared_ptr<platform::graph::TextLayout> text_layout_; + std::shared_ptr<platform::graph::IBrush> brush_; + std::shared_ptr<platform::graph::IFont> font_; + std::unique_ptr<platform::graph::ITextLayout> text_layout_; std::optional<TextRange> selection_range_ = std::nullopt; - std::shared_ptr<platform::graph::Brush> selection_brush_; + std::shared_ptr<platform::graph::IBrush> selection_brush_; }; } // namespace cru::ui::render |