diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-12-11 23:51:58 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-12-11 23:51:58 +0800 |
| commit | c0c0106cf47fdff397756913b8646541f3bb9928 (patch) | |
| tree | 945d0a3662ac92577c966f49578e46ba743ea84b /include/cru/ui/render/LayoutRenderObject.h | |
| parent | e833e810aaa324d7de1630c2fb0528564b182742 (diff) | |
| download | cru-c0c0106cf47fdff397756913b8646541f3bb9928.tar.gz cru-c0c0106cf47fdff397756913b8646541f3bb9928.tar.bz2 cru-c0c0106cf47fdff397756913b8646541f3bb9928.zip | |
Add paint invalid area.
Diffstat (limited to 'include/cru/ui/render/LayoutRenderObject.h')
| -rw-r--r-- | include/cru/ui/render/LayoutRenderObject.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/include/cru/ui/render/LayoutRenderObject.h b/include/cru/ui/render/LayoutRenderObject.h index 5cb70680..99dd8057 100644 --- a/include/cru/ui/render/LayoutRenderObject.h +++ b/include/cru/ui/render/LayoutRenderObject.h @@ -1,8 +1,6 @@ #pragma once #include "RenderObject.h" -#include "cru/platform/graphics/Painter.h" - namespace cru::ui::render { template <typename TChildLayoutData> class LayoutRenderObject : public RenderObject { @@ -81,16 +79,6 @@ class LayoutRenderObject : public RenderObject { InvalidateLayout(); } - void Draw(platform::graphics::IPainter* painter) override { - for (const auto& child : children_) { - painter->PushState(); - painter->ConcatTransform( - Matrix::Translation(child.render_object->GetOffset())); - child.render_object->Draw(painter); - painter->PopState(); - } - } - RenderObject* HitTest(const Point& point) override { const auto child_count = GetChildCount(); for (auto i = child_count - 1; i >= 0; --i) { @@ -104,6 +92,14 @@ class LayoutRenderObject : public RenderObject { return GetPaddingRect().IsPointInside(point) ? this : nullptr; } + protected: + void OnDraw(RenderObjectDrawContext& context) override { + auto painter = context.painter; + for (const auto& child : children_) { + context.DrawChild(child.render_object); + } + } + private: std::vector<ChildData> children_; }; |
