diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-10-09 21:16:49 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-09 21:16:49 +0200 |
commit | 33043941f97e89cfdb2148265dda379a489e5247 (patch) | |
tree | c6303de02d5ea8361007ed930ba70998b8453219 | |
parent | fc5386793708b7d5d1694f2914b1f62326f74ebd (diff) | |
download | serenity-33043941f97e89cfdb2148265dda379a489e5247.zip |
LibGUI: Add GScrollableWidget::to_widget_position()
This is a complement to to_content_position() :^)
-rw-r--r-- | Libraries/LibGUI/GScrollableWidget.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibGUI/GScrollableWidget.h | 1 |
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); |