summaryrefslogtreecommitdiff
path: root/LibGUI/GScrollableWidget.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-23 03:53:51 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-23 03:54:45 +0100
commit19fa70c8211739949c95404d9a87230656a9227f (patch)
treee11444f26703d7e67653728bb99713e915ed9481 /LibGUI/GScrollableWidget.cpp
parent5707d7f547026544f4d9c7a320d97ccd6e055784 (diff)
downloadserenity-19fa70c8211739949c95404d9a87230656a9227f.zip
LibGUI: Add a GItemView class.
This is a GAbstractView subclass that implements a icon-based view onto a GModel. It still need a bunch of work, but it's in basic usable shape.
Diffstat (limited to 'LibGUI/GScrollableWidget.cpp')
-rw-r--r--LibGUI/GScrollableWidget.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/LibGUI/GScrollableWidget.cpp b/LibGUI/GScrollableWidget.cpp
index 8a7be7536c..a47e99e1d6 100644
--- a/LibGUI/GScrollableWidget.cpp
+++ b/LibGUI/GScrollableWidget.cpp
@@ -39,14 +39,21 @@ void GScrollableWidget::resize_event(GResizeEvent& event)
}
}
-void GScrollableWidget::update_scrollbar_ranges()
+Size GScrollableWidget::available_size() const
{
+ int available_width = width() - m_size_occupied_by_fixed_elements.width() - width_occupied_by_vertical_scrollbar();
int available_height = height() - m_size_occupied_by_fixed_elements.height() - height_occupied_by_horizontal_scrollbar();
- int excess_height = max(0, m_content_size.height() - available_height);
+ return { available_width, available_height };
+}
+
+void GScrollableWidget::update_scrollbar_ranges()
+{
+ auto available_size = this->available_size();
+
+ int excess_height = max(0, m_content_size.height() - available_size.height());
m_vertical_scrollbar->set_range(0, excess_height);
- int available_width = width() - m_size_occupied_by_fixed_elements.width() - width_occupied_by_vertical_scrollbar();
- int excess_width = max(0, m_content_size.width() - available_width);
+ int excess_width = max(0, m_content_size.width() - available_size.width());
m_horizontal_scrollbar->set_range(0, excess_width);
m_vertical_scrollbar->set_big_step(visible_content_rect().height() - m_vertical_scrollbar->step());