diff options
author | crupest <crupest@outlook.com> | 2020-12-31 18:27:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-12-31 18:27:57 +0800 |
commit | 1e1170a89330881c5fad60988bc27c824dfcf454 (patch) | |
tree | 9abebbcff045edbea24ea25a377cf34374074907 /include/cru | |
parent | 0026d1f9b50270cd96d8a2a44c55410bc9dc2f7a (diff) | |
download | cru-1e1170a89330881c5fad60988bc27c824dfcf454.tar.gz cru-1e1170a89330881c5fad60988bc27c824dfcf454.tar.bz2 cru-1e1170a89330881c5fad60988bc27c824dfcf454.zip |
...
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/platform/graphics/TextLayout.hpp | 4 | ||||
-rw-r--r-- | include/cru/ui/render/TextRenderObject.hpp | 11 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/TextLayout.hpp | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/include/cru/platform/graphics/TextLayout.hpp b/include/cru/platform/graphics/TextLayout.hpp index efd017d6..b363fb77 100644 --- a/include/cru/platform/graphics/TextLayout.hpp +++ b/include/cru/platform/graphics/TextLayout.hpp @@ -16,9 +16,9 @@ struct ITextLayout : virtual IGraphResource { virtual void SetMaxWidth(float max_width) = 0; virtual void SetMaxHeight(float max_height) = 0; - virtual Rect GetTextBounds() = 0; + virtual Rect GetTextBounds(bool includingTrailingSpace = false) = 0; virtual std::vector<Rect> TextRangeRect(const TextRange& text_range) = 0; virtual Point TextSinglePoint(Index position, bool trailing) = 0; virtual TextHitTestResult HitTest(const Point& point) = 0; }; -} // namespace cru::platform::graph +} // namespace cru::platform::graphics diff --git a/include/cru/ui/render/TextRenderObject.hpp b/include/cru/ui/render/TextRenderObject.hpp index fa569c8c..bdec18d1 100644 --- a/include/cru/ui/render/TextRenderObject.hpp +++ b/include/cru/ui/render/TextRenderObject.hpp @@ -38,7 +38,9 @@ class TextRenderObject : public RenderObject { std::u16string_view GetTextView() const; void SetText(std::u16string new_text); - std::shared_ptr<platform::graphics::IBrush> GetBrush() const { return 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::graphics::IFont> GetFont() const; @@ -80,6 +82,11 @@ class TextRenderObject : public RenderObject { 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: @@ -104,5 +111,7 @@ class TextRenderObject : public RenderObject { gsl::index caret_position_ = 0; 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 diff --git a/include/cru/win/graphics/direct/TextLayout.hpp b/include/cru/win/graphics/direct/TextLayout.hpp index 3320431f..aa040278 100644 --- a/include/cru/win/graphics/direct/TextLayout.hpp +++ b/include/cru/win/graphics/direct/TextLayout.hpp @@ -38,7 +38,7 @@ class DWriteTextLayout : public DirectGraphResource, void SetMaxWidth(float max_width) override; void SetMaxHeight(float max_height) override; - Rect GetTextBounds() override; + Rect GetTextBounds(bool includingTrailingSpace = false) override; // Return empty vector if text_range.count is 0. Text range could be in // reverse direction, it should be normalized first in implementation. std::vector<Rect> TextRangeRect(const TextRange& text_range) override; |