aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-10-26 17:59:57 +0800
committercrupest <crupest@outlook.com>2021-10-26 17:59:57 +0800
commit253341d93d8e3cb38a204b539822ca1cc8597754 (patch)
treef692c9998dccd288c38871dcf43db9f8ddadc3b1 /src/ui/render
parent82431bd0b7e971b956a6a6942538adc8df2ac38c (diff)
downloadcru-253341d93d8e3cb38a204b539822ca1cc8597754.tar.gz
cru-253341d93d8e3cb38a204b539822ca1cc8597754.tar.bz2
cru-253341d93d8e3cb38a204b539822ca1cc8597754.zip
...
Diffstat (limited to 'src/ui/render')
-rw-r--r--src/ui/render/TextRenderObject.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp
index ff9ebc58..189c5532 100644
--- a/src/ui/render/TextRenderObject.cpp
+++ b/src/ui/render/TextRenderObject.cpp
@@ -5,6 +5,7 @@
#include "cru/platform/graphics/Factory.hpp"
#include "cru/platform/graphics/TextLayout.hpp"
#include "cru/platform/graphics/util/Painter.hpp"
+#include "cru/ui/DebugFlags.hpp"
#include <algorithm>
#include <limits>
@@ -161,6 +162,15 @@ RenderObject* TextRenderObject::HitTest(const Point& point) {
}
void TextRenderObject::OnDrawContent(platform::graphics::IPainter* painter) {
+ if constexpr (debug_flags::draw) {
+ log::TagDebug(log_tag,
+ u"Begin to paint, total_offset: {}, size: {}, text_layout: "
+ u"{}, brush: {}.",
+ this->GetTotalOffset(), this->GetSize(),
+ this->text_layout_->GetDebugString(),
+ this->brush_->GetDebugString());
+ }
+
if (this->selection_range_.has_value()) {
const auto&& rects =
text_layout_->TextRangeRect(this->selection_range_.value());
@@ -186,9 +196,9 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement,
text_layout_->SetMaxWidth(measure_width);
text_layout_->SetMaxHeight(std::numeric_limits<float>::max());
- const auto text_size =
+ const Size text_size(
text_layout_->GetTextBounds(is_measure_including_trailing_space_)
- .GetSize();
+ .GetRightBottom());
auto result = text_size;
result.width = std::max(result.width, preferred_size.width.GetLengthOr0());
@@ -205,10 +215,5 @@ void TextRenderObject::OnLayoutContent(const Rect& content_rect) {
CRU_UNUSED(content_rect)
}
-void TextRenderObject::OnAfterLayout() {
- const auto&& size = GetContentRect().GetSize();
- text_layout_->SetMaxWidth(size.width);
- text_layout_->SetMaxHeight(size.height);
-}
-
+void TextRenderObject::OnAfterLayout() {}
} // namespace cru::ui::render