diff options
Diffstat (limited to 'src/ui/render/text_render_object.cpp')
-rw-r--r-- | src/ui/render/text_render_object.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp index a21dc028..9afb9f6e 100644 --- a/src/ui/render/text_render_object.cpp +++ b/src/ui/render/text_render_object.cpp @@ -1,17 +1,20 @@ #include "cru/ui/render/text_render_object.hpp" -#include "cru/platform/graph/graph_factory.hpp" +#include "../helper.hpp" +#include "cru/platform/graph/factory.hpp" #include "cru/platform/graph/text_layout.hpp" -#include "cru/platform/graph/util/painter_util.hpp" +#include "cru/platform/graph/util/painter.hpp" #include <algorithm> #include <cassert> +//TODO: Null Check!!! + namespace cru::ui::render { TextRenderObject::TextRenderObject( - std::shared_ptr<platform::graph::Brush> brush, - std::shared_ptr<platform::graph::Font> font, - std::shared_ptr<platform::graph::Brush> selection_brush) { + std::shared_ptr<platform::graph::IBrush> brush, + std::shared_ptr<platform::graph::IFont> font, + std::shared_ptr<platform::graph::IBrush> selection_brush) { assert(brush); assert(font); assert(selection_brush); @@ -22,32 +25,32 @@ TextRenderObject::TextRenderObject( font.swap(font_); selection_brush.swap(selection_brush_); - const auto graph_factory = platform::graph::GraphFactory::GetInstance(); - text_layout_.reset(graph_factory->CreateTextLayout(font_, L"")); + const auto graph_factory = GetGraphFactory(); + text_layout_ = graph_factory->CreateTextLayout(font_, ""); } -std::wstring TextRenderObject::GetText() const { +std::string TextRenderObject::GetText() const { return text_layout_->GetText(); } -void TextRenderObject::SetText(std::wstring new_text) { +void TextRenderObject::SetText(std::string new_text) { text_layout_->SetText(std::move(new_text)); } -std::shared_ptr<platform::graph::Font> TextRenderObject::GetFont() const { +std::shared_ptr<platform::graph::IFont> 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::IFont> font) { text_layout_->SetFont(std::move(font)); } -void TextRenderObject::Draw(platform::graph::Painter* painter) { +void TextRenderObject::Draw(platform::graph::IPainter* painter) { platform::graph::util::WithTransform( painter, platform::Matrix::Translation(GetMargin().left + GetPadding().left, GetMargin().top + GetPadding().top), - [this](platform::graph::Painter* p) { + [this](platform::graph::IPainter* p) { if (this->selection_range_.has_value()) { const auto&& rects = text_layout_->TextRangeRect(this->selection_range_.value()); |