diff options
author | 杨宇千 <crupest@outlook.com> | 2019-09-17 16:05:17 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-09-17 16:05:17 +0800 |
commit | e8dd10eec26d26c3fb30f2712ccf58ac72edc8a2 (patch) | |
tree | 75293a2bb477fb1872087fab8bfd2c89b6d2051f /src/ui/render/text_render_object.cpp | |
parent | 465d89b4207cce929dc8e0b6ac93c3533ba19408 (diff) | |
download | cru-e8dd10eec26d26c3fb30f2712ccf58ac72edc8a2.tar.gz cru-e8dd10eec26d26c3fb30f2712ccf58ac72edc8a2.tar.bz2 cru-e8dd10eec26d26c3fb30f2712ccf58ac72edc8a2.zip |
...
Diffstat (limited to 'src/ui/render/text_render_object.cpp')
-rw-r--r-- | src/ui/render/text_render_object.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp index 49d7bcb4..a21dc028 100644 --- a/src/ui/render/text_render_object.cpp +++ b/src/ui/render/text_render_object.cpp @@ -1,8 +1,8 @@ #include "cru/ui/render/text_render_object.hpp" #include "cru/platform/graph/graph_factory.hpp" -#include "cru/platform/graph/util/painter_util.hpp" #include "cru/platform/graph/text_layout.hpp" +#include "cru/platform/graph/util/painter_util.hpp" #include <algorithm> #include <cassert> @@ -34,13 +34,11 @@ void TextRenderObject::SetText(std::wstring new_text) { text_layout_->SetText(std::move(new_text)); } -std::shared_ptr<platform::graph::Font> TextRenderObject::GetFont() - const { +std::shared_ptr<platform::graph::Font> TextRenderObject::GetFont() const { return text_layout_->GetFont(); } -void TextRenderObject::SetFont( - std::shared_ptr<platform::graph::Font> font) { +void TextRenderObject::SetFont(std::shared_ptr<platform::graph::Font> font) { text_layout_->SetFont(std::move(font)); } @@ -71,13 +69,6 @@ RenderObject* TextRenderObject::HitTest(const Point& point) { : nullptr; } -void TextRenderObject::OnSizeChanged(const Size& old_size, - const Size& new_size) { - const auto&& size = GetContentRect().GetSize(); - text_layout_->SetMaxWidth(size.width); - text_layout_->SetMaxHeight(size.height); -} - Size TextRenderObject::OnMeasureContent(const Size& available_size) { text_layout_->SetMaxWidth(available_size.width); text_layout_->SetMaxHeight(available_size.height); @@ -85,4 +76,11 @@ Size TextRenderObject::OnMeasureContent(const Size& available_size) { } void TextRenderObject::OnLayoutContent(const Rect& content_rect) {} + +void TextRenderObject::OnAfterLayout() { + const auto&& size = GetContentRect().GetSize(); + text_layout_->SetMaxWidth(size.width); + text_layout_->SetMaxHeight(size.height); +} + } // namespace cru::ui::render |