aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/TextRenderObject.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-06-22 01:09:24 +0800
committercrupest <crupest@outlook.com>2020-06-22 01:09:24 +0800
commit4f0a2f32c273780c32cc3937615c2a8bbd993aab (patch)
tree6e1f45447854a40fe2d16ef9bec79f3c0fef030a /src/ui/render/TextRenderObject.cpp
parentd86a71f79afe0e4dac768f61d6bff690567aca5b (diff)
downloadcru-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.cpp10
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) {