aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/TextRenderObject.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-12 21:43:40 +0800
committercrupest <crupest@outlook.com>2022-03-12 21:43:40 +0800
commit3ce391f85443ce8bb47a7e0ff3bef0051cf4006e (patch)
tree59f8c4b4a6c66676d206bda5bfce3ff5020e4d26 /src/ui/render/TextRenderObject.cpp
parentf3b5009040a05e8efd15c385cacf5dd594ecf801 (diff)
downloadcru-3ce391f85443ce8bb47a7e0ff3bef0051cf4006e.tar.gz
cru-3ce391f85443ce8bb47a7e0ff3bef0051cf4006e.tar.bz2
cru-3ce391f85443ce8bb47a7e0ff3bef0051cf4006e.zip
...
Diffstat (limited to 'src/ui/render/TextRenderObject.cpp')
-rw-r--r--src/ui/render/TextRenderObject.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp
index 0b9009c5..11548106 100644
--- a/src/ui/render/TextRenderObject.cpp
+++ b/src/ui/render/TextRenderObject.cpp
@@ -6,6 +6,7 @@
#include "cru/platform/graphics/Painter.h"
#include "cru/platform/graphics/TextLayout.h"
#include "cru/ui/DebugFlags.h"
+#include "cru/ui/render/RenderObject.h"
#include <algorithm>
#include <limits>
@@ -226,6 +227,17 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement,
return result;
}
+Size TextRenderObject::OnMeasureContent1(const BoxConstraint& constraint) {
+ text_layout_->SetMaxWidth(constraint.max.width);
+ text_layout_->SetMaxHeight(std::numeric_limits<float>::max());
+
+ const Size text_size(
+ text_layout_->GetTextBounds(is_measure_including_trailing_space_)
+ .GetRightBottom());
+
+ return constraint.Coerce(text_size);
+}
+
void TextRenderObject::OnLayoutContent(const Rect& content_rect) {
CRU_UNUSED(content_rect)
}