summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-09 21:16:49 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-09 21:16:49 +0200
commit33043941f97e89cfdb2148265dda379a489e5247 (patch)
treec6303de02d5ea8361007ed930ba70998b8453219
parentfc5386793708b7d5d1694f2914b1f62326f74ebd (diff)
downloadserenity-33043941f97e89cfdb2148265dda379a489e5247.zip
LibGUI: Add GScrollableWidget::to_widget_position()
This is a complement to to_content_position() :^)
-rw-r--r--Libraries/LibGUI/GScrollableWidget.cpp8
-rw-r--r--Libraries/LibGUI/GScrollableWidget.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GScrollableWidget.cpp b/Libraries/LibGUI/GScrollableWidget.cpp
index e9fb3bc464..e1d78aa98a 100644
--- a/Libraries/LibGUI/GScrollableWidget.cpp
+++ b/Libraries/LibGUI/GScrollableWidget.cpp
@@ -188,3 +188,11 @@ Point GScrollableWidget::to_content_position(const Point& widget_position) const
content_position.move_by(-frame_thickness(), -frame_thickness());
return content_position;
}
+
+Point GScrollableWidget::to_widget_position(const Point& content_position) const
+{
+ auto widget_position = content_position;
+ widget_position.move_by(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
+ widget_position.move_by(frame_thickness(), frame_thickness());
+ return widget_position;
+}
diff --git a/Libraries/LibGUI/GScrollableWidget.h b/Libraries/LibGUI/GScrollableWidget.h
index a5231cc456..d1fc8f8ecd 100644
--- a/Libraries/LibGUI/GScrollableWidget.h
+++ b/Libraries/LibGUI/GScrollableWidget.h
@@ -42,6 +42,7 @@ public:
bool should_hide_unnecessary_scrollbars() const { return m_should_hide_unnecessary_scrollbars; }
Point to_content_position(const Point& widget_position) const;
+ Point to_widget_position(const Point& content_position) const;
protected:
explicit GScrollableWidget(GWidget* parent);