From 50aab509ce84f85e17379abc186953b39c117d0e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Dec 2020 19:31:33 +0100 Subject: [PATCH] LibGUI: Add ScrollableWidget helpers for rect conversion to_content_rect() and to_widget_rect() help you convert rects from one coordinate space to the other. --- Libraries/LibGUI/ScrollableWidget.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Libraries/LibGUI/ScrollableWidget.h b/Libraries/LibGUI/ScrollableWidget.h index 9604e5005d..349a16a5c7 100644 --- a/Libraries/LibGUI/ScrollableWidget.h +++ b/Libraries/LibGUI/ScrollableWidget.h @@ -77,6 +77,9 @@ public: Gfx::IntPoint to_content_position(const Gfx::IntPoint& widget_position) const; Gfx::IntPoint to_widget_position(const Gfx::IntPoint& content_position) const; + Gfx::IntRect to_content_rect(const Gfx::IntRect& widget_rect) const { return { to_content_position(widget_rect.location()), widget_rect.size() }; } + Gfx::IntRect to_widget_rect(const Gfx::IntRect& content_rect) const { return { to_widget_position(content_rect.location()), content_rect.size() }; } + protected: ScrollableWidget(); virtual void custom_layout() override;