aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/render')
-rw-r--r--src/ui/render/border_render_object.cpp32
-rw-r--r--src/ui/render/flex_layout_render_object.cpp11
-rw-r--r--src/ui/render/render_object.cpp8
-rw-r--r--src/ui/render/text_render_object.cpp28
-rw-r--r--src/ui/render/window_render_object.cpp8
5 files changed, 43 insertions, 44 deletions
diff --git a/src/ui/render/border_render_object.cpp b/src/ui/render/border_render_object.cpp
index 97e386dd..541be473 100644
--- a/src/ui/render/border_render_object.cpp
+++ b/src/ui/render/border_render_object.cpp
@@ -1,26 +1,26 @@
- #include "cru/ui/render/border_render_object.hpp"
+#include "cru/ui/render/border_render_object.hpp"
#include "cru/platform/debug.hpp"
-#include "cru/platform/geometry.hpp"
-#include "cru/platform/graph_factory.hpp"
-#include "cru/platform/painter_util.hpp"
-#include "cru/platform/ui_applicaition.hpp"
+#include "cru/platform/graph/geometry.hpp"
+#include "cru/platform/graph/graph_factory.hpp"
+#include "cru/platform/graph/painter_util.hpp"
#include <algorithm>
#include <cassert>
namespace cru::ui::render {
-BorderRenderObject::BorderRenderObject(std::shared_ptr<platform::Brush> brush) {
+BorderRenderObject::BorderRenderObject(
+ std::shared_ptr<platform::graph::Brush> brush) {
assert(brush);
this->border_brush_ = std::move(brush);
RecreateGeometry();
}
-void BorderRenderObject::Draw(platform::Painter* painter) {
+void BorderRenderObject::Draw(platform::graph::Painter* painter) {
painter->FillGeometry(geometry_.get(), border_brush_.get());
if (const auto child = GetChild()) {
auto offset = child->GetOffset();
- platform::util::WithTransform(
+ platform::graph::util::WithTransform(
painter, platform::Matrix::Translation(offset.x, offset.y),
[child](auto p) { child->Draw(p); });
}
@@ -75,13 +75,13 @@ void BorderRenderObject::OnMeasureCore(const Size& available_size) {
auto coerced_margin_border_padding_size = margin_border_padding_size;
if (coerced_margin_border_padding_size.width > available_size.width) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Measure: horizontal length of padding, border and margin is bigger "
L"than available length.");
coerced_margin_border_padding_size.width = available_size.width;
}
if (coerced_margin_border_padding_size.height > available_size.height) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Measure: vertical length of padding, border and margin is bigger "
L"than available length.");
coerced_margin_border_padding_size.height = available_size.height;
@@ -113,13 +113,13 @@ void BorderRenderObject::OnLayoutCore(const Rect& rect) {
auto coerced_content_available_size = content_available_size;
if (coerced_content_available_size.width < 0) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Layout: horizontal length of padding, border and margin is bigger "
L"than available length.");
coerced_content_available_size.width = 0;
}
if (coerced_content_available_size.height < 0) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Layout: vertical length of padding, border and margin is bigger "
L"than "
L"available length.");
@@ -154,7 +154,7 @@ void BorderRenderObject::RecreateGeometry() {
geometry_.reset();
border_outer_geometry_.reset();
- auto f = [](platform::GeometryBuilder* builder, const Rect& rect,
+ auto f = [](platform::graph::GeometryBuilder* 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,9 +181,9 @@ void BorderRenderObject::RecreateGeometry() {
const Rect outer_rect{margin.left, margin.top,
size.width - margin.GetHorizontalTotal(),
size.height - margin.GetVerticalTotal()};
- const auto graph_factory =
- platform::UiApplication::GetInstance()->GetGraphFactory();
- std::unique_ptr<platform::GeometryBuilder> builder{graph_factory->CreateGeometryBuilder()};
+ const auto graph_factory = platform::graph::GraphFactory::GetInstance();
+ std::unique_ptr<platform::graph::GeometryBuilder> builder{
+ graph_factory->CreateGeometryBuilder()};
f(builder.get(), outer_rect, corner_radius_);
border_outer_geometry_.reset(builder->Build());
builder.reset();
diff --git a/src/ui/render/flex_layout_render_object.cpp b/src/ui/render/flex_layout_render_object.cpp
index e7840b7e..7528439f 100644
--- a/src/ui/render/flex_layout_render_object.cpp
+++ b/src/ui/render/flex_layout_render_object.cpp
@@ -1,15 +1,13 @@
#include "cru/ui/render/flex_layout_render_object.hpp"
#include "cru/platform/debug.hpp"
-#include "cru/platform/painter_util.hpp"
+#include "cru/platform/graph/painter_util.hpp"
#include <algorithm>
#include <cassert>
#include <functional>
namespace cru::ui::render {
-using namespace platform;
-
FlexChildLayoutData* FlexLayoutRenderObject::GetChildLayoutData(int position) {
assert(position >= 0 &&
position < child_layout_data_.size()); // Position out of bound.
@@ -17,11 +15,12 @@ FlexChildLayoutData* FlexLayoutRenderObject::GetChildLayoutData(int position) {
return &child_layout_data_[position];
}
-void FlexLayoutRenderObject::Draw(platform::Painter* painter) {
+void FlexLayoutRenderObject::Draw(platform::graph::Painter* painter) {
for (const auto child : GetChildren()) {
auto offset = child->GetOffset();
- util::WithTransform(painter, Matrix::Translation(offset.x, offset.y),
- [child](auto p) { child->Draw(p); });
+ platform::graph::util::WithTransform(
+ painter, platform::Matrix::Translation(offset.x, offset.y),
+ [child](auto p) { child->Draw(p); });
}
}
diff --git a/src/ui/render/render_object.cpp b/src/ui/render/render_object.cpp
index 111128b2..3cb7e4df 100644
--- a/src/ui/render/render_object.cpp
+++ b/src/ui/render/render_object.cpp
@@ -54,13 +54,13 @@ void RenderObject::OnMeasureCore(const Size& available_size) {
auto coerced_margin_padding_size = margin_padding_size;
if (coerced_margin_padding_size.width > available_size.width) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Measure: horizontal length of padding and margin is bigger than "
L"available length.");
coerced_margin_padding_size.width = available_size.width;
}
if (coerced_margin_padding_size.height > available_size.height) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Measure: vertical length of padding and margin is bigger than "
L"available length.");
coerced_margin_padding_size.height = available_size.height;
@@ -82,13 +82,13 @@ void RenderObject::OnLayoutCore(const Rect& rect) {
auto coerced_content_available_size = content_available_size;
if (coerced_content_available_size.width < 0) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Layout: horizontal length of padding and margin is bigger than "
L"available length.");
coerced_content_available_size.width = 0;
}
if (coerced_content_available_size.height < 0) {
- platform::debug::DebugMessage(
+ platform::DebugMessage(
L"Layout: vertical length of padding and margin is bigger than "
L"available length.");
coerced_content_available_size.height = 0;
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());
diff --git a/src/ui/render/window_render_object.cpp b/src/ui/render/window_render_object.cpp
index 781087aa..4fc57ad1 100644
--- a/src/ui/render/window_render_object.cpp
+++ b/src/ui/render/window_render_object.cpp
@@ -1,7 +1,7 @@
#include "cru/ui/render/window_render_object.hpp"
-#include "cru/platform/native_window.hpp"
-#include "cru/platform/painter_util.hpp"
+#include "cru/platform/graph/painter_util.hpp"
+#include "cru/platform/native/native_window.hpp"
#include "cru/ui/window.hpp"
#include <cassert>
@@ -13,11 +13,11 @@ void WindowRenderObject::MeasureAndLayout() {
Layout(Rect{Point{}, client_size});
}
-void WindowRenderObject::Draw(platform::Painter* painter) {
+void WindowRenderObject::Draw(platform::graph::Painter* painter) {
painter->Clear(colors::white);
if (const auto child = GetChild()) {
auto offset = child->GetOffset();
- platform::util::WithTransform(
+ platform::graph::util::WithTransform(
painter, platform::Matrix::Translation(offset.x, offset.y),
[child](auto rt) { child->Draw(rt); });
}