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 /src/ui/render/TextRenderObject.cpp | |
parent | 0026d1f9b50270cd96d8a2a44c55410bc9dc2f7a (diff) | |
download | cru-1e1170a89330881c5fad60988bc27c824dfcf454.tar.gz cru-1e1170a89330881c5fad60988bc27c824dfcf454.tar.bz2 cru-1e1170a89330881c5fad60988bc27c824dfcf454.zip |
...
Diffstat (limited to 'src/ui/render/TextRenderObject.cpp')
-rw-r--r-- | src/ui/render/TextRenderObject.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index 9faab622..06092d52 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -57,7 +57,8 @@ std::shared_ptr<platform::graphics::IFont> TextRenderObject::GetFont() const { return text_layout_->GetFont(); } -void TextRenderObject::SetFont(std::shared_ptr<platform::graphics::IFont> font) { +void TextRenderObject::SetFont( + std::shared_ptr<platform::graphics::IFont> font) { Expects(font); text_layout_->SetFont(std::move(font)); } @@ -154,6 +155,12 @@ Rect TextRenderObject::GetCaretRect() { return rect; } +void TextRenderObject::SetMeasureIncludingTrailingSpace(bool including) { + if (is_measure_including_trailing_space_ == including) return; + is_measure_including_trailing_space_ = including; + InvalidateLayout(); +} + RenderObject* TextRenderObject::HitTest(const Point& point) { const auto padding_rect = GetPaddingRect(); return padding_rect.IsPointInside(point) ? this : nullptr; @@ -185,7 +192,9 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement, text_layout_->SetMaxWidth(measure_width); text_layout_->SetMaxHeight(std::numeric_limits<float>::max()); - const auto text_size = text_layout_->GetTextBounds().GetSize(); + const auto text_size = + text_layout_->GetTextBounds(is_measure_including_trailing_space_) + .GetSize(); auto result = text_size; if (requirement.max.width.IsSpecified() && |