diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-10-12 21:39:14 +0200 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2024-10-13 13:59:01 +0200 |
commit | 1f7e5f5c258c3d66e1704ee48a11c79c65f8354b (patch) | |
tree | 366023d896055972c5bb981057083b7fc6823b37 /dw/fltkviewport.cc | |
parent | 7bade294672a638bcd1b0451333be5bb948cbbf7 (diff) |
Add new scrollbar page mode
The scroll page mode changes the behavior of the mouse when clicking on
the vertical scrollbar. When enabled with scrollbar_page_mode=YES,
clicking with the left button anywhere on the vertical scrollbar will
cause the page to scroll down one page. With the right button, to scroll
up one page. Holding Shift temporarily reverts the value of the option.
Diffstat (limited to 'dw/fltkviewport.cc')
-rw-r--r-- | dw/fltkviewport.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index 28c4101c..f0b69cb8 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2024 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -71,6 +72,7 @@ FltkViewport::FltkViewport (int X, int Y, int W, int H, const char *label): hasDragScroll = 1; scrollX = scrollY = scrollDX = scrollDY = 0; horScrolling = verScrolling = dragScrolling = 0; + scrollbarPageMode = false; gadgetOrientation[0] = GADGET_HORIZONTAL; gadgetOrientation[1] = GADGET_HORIZONTAL; @@ -292,8 +294,18 @@ int FltkViewport::handle (int event) case FL_PUSH: if (vscrollbar->visible() && Fl::event_inside(vscrollbar)) { - if (vscrollbar->handle(event)) + if (scrollbarPageMode ^ (bool) Fl::event_shift()) { + if (Fl::event_button() == FL_LEFT_MOUSE) { + scroll(core::SCREEN_DOWN_CMD); + return 1; + } else if (Fl::event_button() == FL_RIGHT_MOUSE) { + scroll(core::SCREEN_UP_CMD); + return 1; + } + } + if (vscrollbar->handle(event)) { verScrolling = 1; + } } else if (hscrollbar->visible() && Fl::event_inside(hscrollbar)) { if (hscrollbar->handle(event)) horScrolling = 1; @@ -412,6 +424,11 @@ void FltkViewport::setScrollStep(int step) hscrollbar->linesize(step); } +void FltkViewport::setScrollbarPageMode(bool enable) +{ + scrollbarPageMode = enable; +} + bool FltkViewport::usesViewport () { return true; |