diff options
Diffstat (limited to 'include/cru/ui/render/TextRenderObject.hpp')
-rw-r--r-- | include/cru/ui/render/TextRenderObject.hpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/include/cru/ui/render/TextRenderObject.hpp b/include/cru/ui/render/TextRenderObject.hpp index 3be42bbb..bdec18d1 100644 --- a/include/cru/ui/render/TextRenderObject.hpp +++ b/include/cru/ui/render/TextRenderObject.hpp @@ -24,10 +24,10 @@ class TextRenderObject : public RenderObject { constexpr static float default_caret_width = 2; public: - TextRenderObject(std::shared_ptr<platform::graph::IBrush> brush, - std::shared_ptr<platform::graph::IFont> font, - std::shared_ptr<platform::graph::IBrush> selection_brush, - std::shared_ptr<platform::graph::IBrush> caret_brush); + TextRenderObject(std::shared_ptr<platform::graphics::IBrush> brush, + std::shared_ptr<platform::graphics::IFont> font, + std::shared_ptr<platform::graphics::IBrush> selection_brush, + std::shared_ptr<platform::graphics::IBrush> caret_brush); TextRenderObject(const TextRenderObject& other) = delete; TextRenderObject(TextRenderObject&& other) = delete; TextRenderObject& operator=(const TextRenderObject& other) = delete; @@ -38,25 +38,27 @@ class TextRenderObject : public RenderObject { std::u16string_view GetTextView() const; void SetText(std::u16string new_text); - std::shared_ptr<platform::graph::IBrush> GetBrush() const { return brush_; } - void SetBrush(std::shared_ptr<platform::graph::IBrush> new_brush); + std::shared_ptr<platform::graphics::IBrush> GetBrush() const { + return brush_; + } + void SetBrush(std::shared_ptr<platform::graphics::IBrush> new_brush); - std::shared_ptr<platform::graph::IFont> GetFont() const; - void SetFont(std::shared_ptr<platform::graph::IFont> font); + std::shared_ptr<platform::graphics::IFont> GetFont() const; + void SetFont(std::shared_ptr<platform::graphics::IFont> font); std::vector<Rect> TextRangeRect(const TextRange& text_range); Point TextSinglePoint(gsl::index position, bool trailing); - platform::graph::TextHitTestResult TextHitTest(const Point& point); + platform::graphics::TextHitTestResult TextHitTest(const Point& point); std::optional<TextRange> GetSelectionRange() const { return selection_range_; } void SetSelectionRange(std::optional<TextRange> new_range); - std::shared_ptr<platform::graph::IBrush> GetSelectionBrush() const { + std::shared_ptr<platform::graphics::IBrush> GetSelectionBrush() const { return selection_brush_; } - void SetSelectionBrush(std::shared_ptr<platform::graph::IBrush> new_brush); + void SetSelectionBrush(std::shared_ptr<platform::graphics::IBrush> new_brush); bool IsDrawCaret() const { return draw_caret_; } void SetDrawCaret(bool draw_caret); @@ -72,18 +74,23 @@ class TextRenderObject : public RenderObject { // Lefttop relative to render object lefttop. Rect GetCaretRect(); - std::shared_ptr<platform::graph::IBrush> GetCaretBrush() const { + std::shared_ptr<platform::graphics::IBrush> GetCaretBrush() const { return caret_brush_; } - void GetCaretBrush(std::shared_ptr<platform::graph::IBrush> brush); + void GetCaretBrush(std::shared_ptr<platform::graphics::IBrush> brush); float GetCaretWidth() const { return caret_width_; } void SetCaretWidth(float width); + bool IsMeasureIncludingTrailingSpace() const { + return is_measure_including_trailing_space_; + } + void SetMeasureIncludingTrailingSpace(bool including); + RenderObject* HitTest(const Point& point) override; protected: - void OnDrawContent(platform::graph::IPainter* painter) override; + void OnDrawContent(platform::graphics::IPainter* painter) override; // See remarks of this class. Size OnMeasureContent(const MeasureRequirement& requirement, @@ -93,16 +100,18 @@ class TextRenderObject : public RenderObject { void OnAfterLayout() override; private: - std::shared_ptr<platform::graph::IBrush> brush_; - std::shared_ptr<platform::graph::IFont> font_; - std::unique_ptr<platform::graph::ITextLayout> text_layout_; + std::shared_ptr<platform::graphics::IBrush> brush_; + std::shared_ptr<platform::graphics::IFont> font_; + std::unique_ptr<platform::graphics::ITextLayout> text_layout_; std::optional<TextRange> selection_range_ = std::nullopt; - std::shared_ptr<platform::graph::IBrush> selection_brush_; + std::shared_ptr<platform::graphics::IBrush> selection_brush_; bool draw_caret_ = false; gsl::index caret_position_ = 0; - std::shared_ptr<platform::graph::IBrush> caret_brush_; + std::shared_ptr<platform::graphics::IBrush> caret_brush_; float caret_width_ = default_caret_width; + + bool is_measure_including_trailing_space_ = false; }; } // namespace cru::ui::render |