From 4f0a2f32c273780c32cc3937615c2a8bbd993aab Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 22 Jun 2020 01:09:24 +0800 Subject: ... --- src/ui/render/TextRenderObject.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ui/render/TextRenderObject.cpp') 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 +#include 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) { -- cgit v1.2.3