summaryrefslogtreecommitdiff
path: root/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-25 05:03:40 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-25 05:03:40 +0100
commit108b663618e893c804c150205a21f2e8d95088c2 (patch)
tree60b1a7b51acbedd47765d763a7a0bc6fcd3e429f /LibGUI
parent614dafea327148874aadbcdb82ac02ec5b09df9c (diff)
downloadserenity-108b663618e893c804c150205a21f2e8d95088c2.zip
GScrollBar: Clicking in the gutter should jump directly to that position.
I think I like how this feels but I'm not 100% sure yet, so I'm leaving the old feel in behind an #ifdef.
Diffstat (limited to 'LibGUI')
-rw-r--r--LibGUI/GScrollBar.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/LibGUI/GScrollBar.cpp b/LibGUI/GScrollBar.cpp
index 6b942f21c5..e0ae0eaf86 100644
--- a/LibGUI/GScrollBar.cpp
+++ b/LibGUI/GScrollBar.cpp
@@ -4,6 +4,8 @@
#include <SharedGraphics/GraphicsBitmap.h>
#include <SharedGraphics/Painter.h>
+//#define GUTTER_DOES_PAGEUP_PAGEDOWN
+
static const char* s_up_arrow_bitmap_data = {
" "
" # "
@@ -210,6 +212,7 @@ void GScrollBar::mousedown_event(GMouseEvent& event)
set_value(value() + m_step);
return;
}
+#ifdef GUTTER_DOES_PAGEUP_PAGEDOWN
if (has_scrubber() && upper_gutter_rect().contains(event.position())) {
set_value(value() - m_big_step);
return;
@@ -218,6 +221,7 @@ void GScrollBar::mousedown_event(GMouseEvent& event)
set_value(value() + m_big_step);
return;
}
+#endif
if (has_scrubber() && scrubber_rect().contains(event.position())) {
m_scrubbing = true;
m_scrub_start_value = value();
@@ -225,6 +229,27 @@ void GScrollBar::mousedown_event(GMouseEvent& event)
update();
return;
}
+#ifndef GUTTER_DOES_PAGEUP_PAGEDOWN
+ if (has_scrubber()) {
+ float range_size = m_max - m_min;
+ float available = scrubbable_range_in_pixels();
+
+ float x = ::max(0, event.position().x() - button_size() - button_size() / 2);
+ float y = ::max(0, event.position().y() - button_size() - button_size() / 2);
+
+ float rel_x = x / available;
+ float rel_y = y / available;
+
+ if (orientation() == Orientation::Vertical)
+ set_value(m_min + rel_y * range_size);
+ else
+ set_value(m_min + rel_x * range_size);
+
+ m_scrubbing = true;
+ m_scrub_start_value = value();
+ m_scrub_origin = event.position();
+ }
+#endif
}
void GScrollBar::mouseup_event(GMouseEvent& event)