From b506c349b793f723df6da170ffa0f412200e26e9 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 24 Mar 2019 21:59:29 +0800 Subject: ... --- src/ui/render/text_render_object.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/ui/render/text_render_object.cpp') diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp index b66fffa3..69563ad7 100644 --- a/src/ui/render/text_render_object.cpp +++ b/src/ui/render/text_render_object.cpp @@ -114,15 +114,9 @@ RenderObject* TextRenderObject::HitTest(const Point& point) { void TextRenderObject::OnSizeChanged(const Size& old_size, const Size& new_size) { - const auto margin = GetMargin(); - const auto padding = GetPadding(); - ThrowIfFailed(text_layout_->SetMaxWidth( - std::max(new_size.width - margin.GetHorizontalTotal() - - padding.GetHorizontalTotal(), - 0.0f))); - ThrowIfFailed(text_layout_->SetMaxHeight(std::max( - new_size.height - margin.GetVerticalTotal() - padding.GetVerticalTotal(), - 0.0f))); + const auto&& size = GetContentRect().GetSize(); + ThrowIfFailed(text_layout_->SetMaxWidth(size.width)); + ThrowIfFailed(text_layout_->SetMaxHeight(size.height)); } Size TextRenderObject::OnMeasureContent(const Size& available_size) { @@ -145,7 +139,7 @@ void TextRenderObject::RecreateTextLayout() { const auto dwrite_factory = graph::GraphManager::GetInstance()->GetDWriteFactory(); - const auto&& size = GetSize(); + const auto&& size = GetContentRect().GetSize(); ThrowIfFailed(dwrite_factory->CreateTextLayout( text_.c_str(), static_cast(text_.size()), text_format_, -- cgit v1.2.3