summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-03 09:15:57 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-03 09:15:57 +0200
commita181cae3e015edbc9ddbdfb79edc14f884863ad4 (patch)
treef474f5d76f97ca4e3770fbc847a2a480248e8872 /Libraries/LibGUI
parentf02c9aaac4ccb648ff88ac0ff596df26d1da5da0 (diff)
downloadserenity-a181cae3e015edbc9ddbdfb79edc14f884863ad4.zip
GScrollableWidget: Add to_content_position(Point)
A handy helper function for converting a widget space coordinate into a content space coordinate.
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/GScrollableWidget.cpp8
-rw-r--r--Libraries/LibGUI/GScrollableWidget.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GScrollableWidget.cpp b/Libraries/LibGUI/GScrollableWidget.cpp
index 246158d9f4..e9fb3bc464 100644
--- a/Libraries/LibGUI/GScrollableWidget.cpp
+++ b/Libraries/LibGUI/GScrollableWidget.cpp
@@ -180,3 +180,11 @@ Rect GScrollableWidget::widget_inner_rect() const
rect.set_height(rect.height() - height_occupied_by_horizontal_scrollbar());
return rect;
}
+
+Point GScrollableWidget::to_content_position(const Point& widget_position) const
+{
+ auto content_position = widget_position;
+ content_position.move_by(horizontal_scrollbar().value(), vertical_scrollbar().value());
+ content_position.move_by(-frame_thickness(), -frame_thickness());
+ return content_position;
+}
diff --git a/Libraries/LibGUI/GScrollableWidget.h b/Libraries/LibGUI/GScrollableWidget.h
index dbef80042a..a5231cc456 100644
--- a/Libraries/LibGUI/GScrollableWidget.h
+++ b/Libraries/LibGUI/GScrollableWidget.h
@@ -41,6 +41,8 @@ public:
void set_should_hide_unnecessary_scrollbars(bool b) { m_should_hide_unnecessary_scrollbars = b; }
bool should_hide_unnecessary_scrollbars() const { return m_should_hide_unnecessary_scrollbars; }
+ Point to_content_position(const Point& widget_position) const;
+
protected:
explicit GScrollableWidget(GWidget* parent);
virtual void custom_layout() override;