diff options
author | crupest <crupest@outlook.com> | 2020-06-22 01:09:24 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-22 01:09:24 +0800 |
commit | 4f0a2f32c273780c32cc3937615c2a8bbd993aab (patch) | |
tree | 6e1f45447854a40fe2d16ef9bec79f3c0fef030a /src/ui/render/TextRenderObject.cpp | |
parent | d86a71f79afe0e4dac768f61d6bff690567aca5b (diff) | |
download | cru-4f0a2f32c273780c32cc3937615c2a8bbd993aab.tar.gz cru-4f0a2f32c273780c32cc3937615c2a8bbd993aab.tar.bz2 cru-4f0a2f32c273780c32cc3937615c2a8bbd993aab.zip |
...
Diffstat (limited to 'src/ui/render/TextRenderObject.cpp')
-rw-r--r-- | src/ui/render/TextRenderObject.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index 05acd086..ececfbc2 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -4,8 +4,10 @@ #include "cru/platform/graph/Factory.hpp" #include "cru/platform/graph/TextLayout.hpp" #include "cru/platform/graph/util/Painter.hpp" +#include "cru/ui/render/LayoutUtility.hpp" #include <algorithm> +#include <limits> namespace cru::ui::render { TextRenderObject::TextRenderObject( @@ -158,10 +160,10 @@ RenderObject* TextRenderObject::HitTest(const Point& point) { return padding_rect.IsPointInside(point) ? this : nullptr; } -Size TextRenderObject::OnMeasureContent(const Size& available_size) { - text_layout_->SetMaxWidth(available_size.width); - text_layout_->SetMaxHeight(available_size.height); - return text_layout_->GetTextBounds().GetSize(); +Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement) { + text_layout_->SetMaxWidth(requirement.max_height.GetLength()); + text_layout_->SetMaxHeight(requirement.max_height.GetLength()); + return Min(text_layout_->GetTextBounds().GetSize(), requirement.GetMaxSize()); } void TextRenderObject::OnLayoutContent(const Rect& content_rect) { |