diff options
author | crupest <crupest@outlook.com> | 2019-03-24 21:59:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-24 21:59:29 +0800 |
commit | b506c349b793f723df6da170ffa0f412200e26e9 (patch) | |
tree | 59030d1af23c5c72caa2e8956a1687d4e0c6c804 /src/ui/render/text_render_object.cpp | |
parent | 475ae9b12867f25f037792ae8b59c27d45119f54 (diff) | |
download | cru-b506c349b793f723df6da170ffa0f412200e26e9.tar.gz cru-b506c349b793f723df6da170ffa0f412200e26e9.tar.bz2 cru-b506c349b793f723df6da170ffa0f412200e26e9.zip |
...
Diffstat (limited to 'src/ui/render/text_render_object.cpp')
-rw-r--r-- | src/ui/render/text_render_object.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
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<UINT32>(text_.size()), text_format_, |