From 427bd31059fcdca5806a149238e91173667953c1 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 28 Jun 2020 22:17:14 +0800 Subject: ... --- src/ui/render/ScrollRenderObject.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/ui/render/ScrollRenderObject.cpp') diff --git a/src/ui/render/ScrollRenderObject.cpp b/src/ui/render/ScrollRenderObject.cpp index e4cc27f3..aab8c003 100644 --- a/src/ui/render/ScrollRenderObject.cpp +++ b/src/ui/render/ScrollRenderObject.cpp @@ -31,17 +31,6 @@ Point CoerceScroll(const Point& scroll_offset, const Size& content_size, } } // namespace -void ScrollRenderObject::Draw(platform::graph::IPainter* painter) { - if (const auto child = GetSingleChild()) { - painter->PushLayer(this->GetPaddingRect()); - const auto offset = child->GetOffset(); - platform::graph::util::WithTransform( - painter, Matrix::Translation(offset.x, offset.y), - [child](platform::graph::IPainter* p) { child->Draw(p); }); - painter->PopLayer(); - } -} - RenderObject* ScrollRenderObject::HitTest(const Point& point) { if (const auto child = GetSingleChild()) { const auto offset = child->GetOffset(); @@ -53,6 +42,18 @@ RenderObject* ScrollRenderObject::HitTest(const Point& point) { return rect.IsPointInside(point) ? this : nullptr; } // namespace cru::ui::render +void ScrollRenderObject::OnDrawCore(platform::graph::IPainter* painter) { + DefaultDrawContent(painter); + if (const auto child = GetSingleChild()) { + painter->PushLayer(this->GetPaddingRect()); + const auto offset = child->GetOffset(); + platform::graph::util::WithTransform( + painter, Matrix::Translation(offset.x, offset.y), + [child](platform::graph::IPainter* p) { child->Draw(p); }); + painter->PopLayer(); + } +} + Point ScrollRenderObject::GetScrollOffset() { if (const auto child = GetSingleChild()) return CoerceScroll(scroll_offset_, GetContentRect().GetSize(), -- cgit v1.2.3