diff options
Diffstat (limited to 'src/ui/render')
-rw-r--r-- | src/ui/render/border_render_object.cpp | 16 | ||||
-rw-r--r-- | src/ui/render/flex_layout_render_object.cpp | 4 | ||||
-rw-r--r-- | src/ui/render/text_render_object.cpp | 19 | ||||
-rw-r--r-- | src/ui/render/window_render_object.cpp | 6 |
4 files changed, 22 insertions, 23 deletions
diff --git a/src/ui/render/border_render_object.cpp b/src/ui/render/border_render_object.cpp index 541be473..99c2cb4c 100644 --- a/src/ui/render/border_render_object.cpp +++ b/src/ui/render/border_render_object.cpp @@ -3,20 +3,20 @@ #include "cru/platform/debug.hpp" #include "cru/platform/graph/geometry.hpp" #include "cru/platform/graph/graph_factory.hpp" -#include "cru/platform/graph/painter_util.hpp" +#include "cru/platform/graph/util/painter_util.hpp" #include <algorithm> #include <cassert> namespace cru::ui::render { BorderRenderObject::BorderRenderObject( - std::shared_ptr<platform::graph::Brush> brush) { + std::shared_ptr<platform::graph::IBrush> brush) { assert(brush); this->border_brush_ = std::move(brush); RecreateGeometry(); } -void BorderRenderObject::Draw(platform::graph::Painter* painter) { +void BorderRenderObject::Draw(platform::graph::IPainter* painter) { painter->FillGeometry(geometry_.get(), border_brush_.get()); if (const auto child = GetChild()) { auto offset = child->GetOffset(); @@ -154,7 +154,7 @@ void BorderRenderObject::RecreateGeometry() { geometry_.reset(); border_outer_geometry_.reset(); - auto f = [](platform::graph::GeometryBuilder* builder, const Rect& rect, + auto f = [](platform::graph::IGeometryBuilder* builder, const Rect& rect, const CornerRadius& corner) { builder->BeginFigure(Point(rect.left + corner.left_top.x, rect.top)); builder->LineTo(Point(rect.GetRight() - corner.right_top.x, rect.top)); @@ -181,18 +181,18 @@ void BorderRenderObject::RecreateGeometry() { const Rect outer_rect{margin.left, margin.top, size.width - margin.GetHorizontalTotal(), size.height - margin.GetVerticalTotal()}; - const auto graph_factory = platform::graph::GraphFactory::GetInstance(); - std::unique_ptr<platform::graph::GeometryBuilder> builder{ + const auto graph_factory = platform::graph::IGraphFactory::GetInstance(); + std::unique_ptr<platform::graph::IGeometryBuilder> builder{ graph_factory->CreateGeometryBuilder()}; f(builder.get(), outer_rect, corner_radius_); - border_outer_geometry_.reset(builder->Build()); + border_outer_geometry_.reset(builder->End()); builder.reset(); const Rect inner_rect = outer_rect.Shrink(border_thickness_); builder.reset(graph_factory->CreateGeometryBuilder()); f(builder.get(), outer_rect, corner_radius_); f(builder.get(), inner_rect, corner_radius_); - geometry_.reset(builder->Build()); + geometry_.reset(builder->End()); builder.reset(); } } // namespace cru::ui::render diff --git a/src/ui/render/flex_layout_render_object.cpp b/src/ui/render/flex_layout_render_object.cpp index 7528439f..0093f1ad 100644 --- a/src/ui/render/flex_layout_render_object.cpp +++ b/src/ui/render/flex_layout_render_object.cpp @@ -1,7 +1,7 @@ #include "cru/ui/render/flex_layout_render_object.hpp" #include "cru/platform/debug.hpp" -#include "cru/platform/graph/painter_util.hpp" +#include "cru/platform/graph/util/painter_util.hpp" #include <algorithm> #include <cassert> @@ -15,7 +15,7 @@ FlexChildLayoutData* FlexLayoutRenderObject::GetChildLayoutData(int position) { return &child_layout_data_[position]; } -void FlexLayoutRenderObject::Draw(platform::graph::Painter* painter) { +void FlexLayoutRenderObject::Draw(platform::graph::IPainter* painter) { for (const auto child : GetChildren()) { auto offset = child->GetOffset(); platform::graph::util::WithTransform( diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp index c886ee7a..849bff11 100644 --- a/src/ui/render/text_render_object.cpp +++ b/src/ui/render/text_render_object.cpp @@ -1,7 +1,7 @@ #include "cru/ui/render/text_render_object.hpp" #include "cru/platform/graph/graph_factory.hpp" -#include "cru/platform/graph/painter_util.hpp" +#include "cru/platform/graph/util/painter_util.hpp" #include "cru/platform/graph/text_layout.hpp" #include <algorithm> @@ -9,9 +9,9 @@ namespace cru::ui::render { TextRenderObject::TextRenderObject( - std::shared_ptr<platform::graph::Brush> brush, - std::shared_ptr<platform::graph::FontDescriptor> font, - std::shared_ptr<platform::graph::Brush> selection_brush) { + std::shared_ptr<platform::graph::IBrush> brush, + std::shared_ptr<platform::graph::IFontDescriptor> font, + std::shared_ptr<platform::graph::IBrush> selection_brush) { assert(brush); assert(font); assert(selection_brush); @@ -20,8 +20,7 @@ TextRenderObject::TextRenderObject( font.swap(font_); selection_brush.swap(selection_brush_); - const auto graph_factory = platform::graph::GraphFactory::GetInstance(); - + const auto graph_factory = platform::graph::IGraphFactory::GetInstance(); text_layout_.reset(graph_factory->CreateTextLayout(font_, L"")); } @@ -33,22 +32,22 @@ void TextRenderObject::SetText(std::wstring new_text) { text_layout_->SetText(std::move(new_text)); } -std::shared_ptr<platform::graph::FontDescriptor> TextRenderObject::GetFont() +std::shared_ptr<platform::graph::IFontDescriptor> TextRenderObject::GetFont() const { return text_layout_->GetFont(); } void TextRenderObject::SetFont( - std::shared_ptr<platform::graph::FontDescriptor> font) { + std::shared_ptr<platform::graph::IFontDescriptor> 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()); diff --git a/src/ui/render/window_render_object.cpp b/src/ui/render/window_render_object.cpp index 4fc57ad1..f2e29603 100644 --- a/src/ui/render/window_render_object.cpp +++ b/src/ui/render/window_render_object.cpp @@ -1,6 +1,6 @@ #include "cru/ui/render/window_render_object.hpp" -#include "cru/platform/graph/painter_util.hpp" +#include "cru/platform/graph/util/painter_util.hpp" #include "cru/platform/native/native_window.hpp" #include "cru/ui/window.hpp" @@ -13,13 +13,13 @@ void WindowRenderObject::MeasureAndLayout() { Layout(Rect{Point{}, client_size}); } -void WindowRenderObject::Draw(platform::graph::Painter* painter) { +void WindowRenderObject::Draw(platform::graph::IPainter* painter) { painter->Clear(colors::white); if (const auto child = GetChild()) { auto offset = child->GetOffset(); platform::graph::util::WithTransform( painter, platform::Matrix::Translation(offset.x, offset.y), - [child](auto rt) { child->Draw(rt); }); + [child](platform::graph::IPainter* p) { child->Draw(p); }); } } |