summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LibGUI/GScrollBar.cpp17
-rw-r--r--LibGUI/GScrollBar.h1
2 files changed, 13 insertions, 5 deletions
diff --git a/LibGUI/GScrollBar.cpp b/LibGUI/GScrollBar.cpp
index 9f0c235726..f1d28de914 100644
--- a/LibGUI/GScrollBar.cpp
+++ b/LibGUI/GScrollBar.cpp
@@ -151,9 +151,9 @@ Rect GScrollBar::lower_gutter_rect() const
int GScrollBar::scrubbable_range_in_pixels() const
{
if (orientation() == Orientation::Vertical)
- return height() - button_size() * 3;
+ return height() - button_size() * 2 - scrubber_size();
else
- return width() - button_size() * 3;
+ return width() - button_size() * 2 - scrubber_size();
}
bool GScrollBar::has_scrubber() const
@@ -161,6 +161,13 @@ bool GScrollBar::has_scrubber() const
return m_max != m_min;
}
+int GScrollBar::scrubber_size() const
+{
+ int pixel_range = (orientation() == Orientation::Vertical ? height() : width()) - button_size() * 2;
+ int value_range = m_max - m_min;
+ return ::max(pixel_range - value_range, button_size());
+}
+
Rect GScrollBar::scrubber_rect() const
{
if (!has_scrubber())
@@ -169,7 +176,7 @@ Rect GScrollBar::scrubber_rect() const
if (m_value == m_min)
x_or_y = button_size();
else if (m_value == m_max)
- x_or_y = ((orientation() == Orientation::Vertical ? height() : width()) - (button_size() * 2)) + 1;
+ x_or_y = ((orientation() == Orientation::Vertical ? height() : width()) - button_size() - scrubber_size()) + 1;
else {
float range_size = m_max - m_min;
float available = scrubbable_range_in_pixels();
@@ -178,9 +185,9 @@ Rect GScrollBar::scrubber_rect() const
}
if (orientation() == Orientation::Vertical)
- return { 0, (int)x_or_y, button_size(), button_size() };
+ return { 0, (int)x_or_y, button_size(), scrubber_size() };
else
- return { (int)x_or_y, 0, button_size(), button_size() };
+ return { (int)x_or_y, 0, scrubber_size(), button_size() };
}
void GScrollBar::paint_event(GPaintEvent& event)
diff --git a/LibGUI/GScrollBar.h b/LibGUI/GScrollBar.h
index dca2c08475..b29e9f3811 100644
--- a/LibGUI/GScrollBar.h
+++ b/LibGUI/GScrollBar.h
@@ -38,6 +38,7 @@ private:
Rect upper_gutter_rect() const;
Rect lower_gutter_rect() const;
Rect scrubber_rect() const;
+ int scrubber_size() const;
int scrubbable_range_in_pixels() const;
int m_min { 0 };