diff options
author | crupest <crupest@outlook.com> | 2019-04-10 19:42:46 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-10 19:42:46 +0800 |
commit | 7351020a582d70a1495249fba87d342c8a1fb634 (patch) | |
tree | e80f225041dc3816b3dce21c7e15aadbb211602e /src/ui/render/text_render_object.cpp | |
parent | a94a806f69586e08a30fff0cdb3e52b0ce7acfa5 (diff) | |
download | cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.gz cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.bz2 cru-7351020a582d70a1495249fba87d342c8a1fb634.zip |
Refactor.
Diffstat (limited to 'src/ui/render/text_render_object.cpp')
-rw-r--r-- | src/ui/render/text_render_object.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp index bdf48c9a..c886ee7a 100644 --- a/src/ui/render/text_render_object.cpp +++ b/src/ui/render/text_render_object.cpp @@ -1,18 +1,17 @@ #include "cru/ui/render/text_render_object.hpp" -#include "cru/platform/graph_factory.hpp" -#include "cru/platform/painter_util.hpp" -#include "cru/platform/text_layout.hpp" -#include "cru/platform/ui_applicaition.hpp" +#include "cru/platform/graph/graph_factory.hpp" +#include "cru/platform/graph/painter_util.hpp" +#include "cru/platform/graph/text_layout.hpp" #include <algorithm> #include <cassert> namespace cru::ui::render { TextRenderObject::TextRenderObject( - std::shared_ptr<platform::Brush> brush, - std::shared_ptr<platform::FontDescriptor> font, - std::shared_ptr<platform::Brush> selection_brush) { + std::shared_ptr<platform::graph::Brush> brush, + std::shared_ptr<platform::graph::FontDescriptor> font, + std::shared_ptr<platform::graph::Brush> selection_brush) { assert(brush); assert(font); assert(selection_brush); @@ -21,8 +20,7 @@ TextRenderObject::TextRenderObject( font.swap(font_); selection_brush.swap(selection_brush_); - const auto graph_factory = - platform::UiApplication::GetInstance()->GetGraphFactory(); + const auto graph_factory = platform::graph::GraphFactory::GetInstance(); text_layout_.reset(graph_factory->CreateTextLayout(font_, L"")); } @@ -35,20 +33,22 @@ void TextRenderObject::SetText(std::wstring new_text) { text_layout_->SetText(std::move(new_text)); } -std::shared_ptr<platform::FontDescriptor> TextRenderObject::GetFont() const { +std::shared_ptr<platform::graph::FontDescriptor> TextRenderObject::GetFont() + const { return text_layout_->GetFont(); } -void TextRenderObject::SetFont(std::shared_ptr<platform::FontDescriptor> font) { +void TextRenderObject::SetFont( + std::shared_ptr<platform::graph::FontDescriptor> font) { text_layout_->SetFont(std::move(font)); } -void TextRenderObject::Draw(platform::Painter* painter) { - platform::util::WithTransform( +void TextRenderObject::Draw(platform::graph::Painter* painter) { + platform::graph::util::WithTransform( painter, platform::Matrix::Translation(GetMargin().left + GetPadding().left, GetMargin().top + GetPadding().top), - [this](platform::Painter* p) { + [this](platform::graph::Painter* p) { if (this->selection_range_.has_value()) { const auto&& rects = text_layout_->TextRangeRect(this->selection_range_.value()); |