aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/RenderObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/render/RenderObject.cpp')
-rw-r--r--src/ui/render/RenderObject.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp
index ac38c6b5..d9977f2a 100644
--- a/src/ui/render/RenderObject.cpp
+++ b/src/ui/render/RenderObject.cpp
@@ -1,6 +1,7 @@
#include "cru/ui/render/RenderObject.hpp"
#include "cru/common/Logger.hpp"
+#include "cru/platform/graph/util/Painter.hpp"
#include "cru/ui/UiHost.hpp"
#include <algorithm>
@@ -76,6 +77,10 @@ void RenderObject::Layout(const Point& offset) {
OnLayoutCore();
}
+void RenderObject::Draw(platform::graph::IPainter* painter) {
+ OnDrawCore(painter);
+}
+
RenderObject* RenderObject::GetSingleChild() const {
Expects(child_mode_ == ChildMode::Single);
const auto& children = GetChildren();
@@ -107,6 +112,32 @@ void RenderObject::OnRemoveChild(RenderObject* removed_child, Index position) {
InvalidatePaint();
}
+void RenderObject::DefaultDrawChildren(platform::graph::IPainter* painter) {
+ for (const auto child : GetChildren()) {
+ auto offset = child->GetOffset();
+ platform::graph::util::WithTransform(
+ painter, platform::Matrix::Translation(offset.x, offset.y),
+ [child](auto p) { child->Draw(p); });
+ }
+}
+
+void RenderObject::DefaultDrawContent(platform::graph::IPainter* painter) {
+ const auto content_rect = GetContentRect();
+
+ platform::graph::util::WithTransform(
+ painter, Matrix::Translation(content_rect.left, content_rect.top),
+ [this](auto p) { this->OnDrawContent(p); });
+}
+
+void RenderObject::OnDrawCore(platform::graph::IPainter* painter) {
+ DefaultDrawContent(painter);
+ DefaultDrawChildren(painter);
+}
+
+void RenderObject::OnDrawContent(platform::graph::IPainter* painter) {
+ CRU_UNUSED(painter);
+}
+
Size RenderObject::OnMeasureCore(const MeasureRequirement& requirement,
const MeasureSize& preferred_size) {
const Size space_size{