From 1f7e5f5c258c3d66e1704ee48a11c79c65f8354b Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Sat, 12 Oct 2024 21:39:14 +0200 Subject: 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. --- dw/fltkviewport.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'dw/fltkviewport.cc') 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 + * Copyright 2024 Rodrigo Arias Mallo * * 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; -- cgit v1.2.3