mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
GScrollableWidget: Add to_content_position(Point)
A handy helper function for converting a widget space coordinate into a content space coordinate.
This commit is contained in:
parent
f02c9aaac4
commit
a181cae3e0
Notes:
sideshowbarker
2024-07-19 11:50:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a181cae3e01
2 changed files with 10 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue