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. --- ChangeLog | 1 + dillorc | 6 ++++++ doc/user_help.in.html | 9 +++++++++ dw/fltkviewport.cc | 19 ++++++++++++++++++- dw/fltkviewport.hh | 22 ++++++++++++++++++++++ src/prefs.c | 1 + src/prefs.h | 1 + src/prefsparser.cc | 1 + src/uicmd.cc | 1 + 9 files changed, 60 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b6f9be06..9af82cf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ dillo-3.2.0 [Not released yet] - Perform an emergency stop of the layout engine loop after 1000 iterations to prevent a hang. - Fix use-after-free on errors in TLS connection. + - Add scrollbar_page_mode option to easily scroll full pages with the mouse. Patches: Rodrigo Arias Mallo +- Add primitive support for SVG using the nanosvg.h library. - Add support for ch, rem, vw, vh, vmin and vmax CSS units. diff --git a/dillorc b/dillorc index 99aa1e65..bcd556d3 100644 --- a/dillorc +++ b/dillorc @@ -49,6 +49,12 @@ # Place the vertical scrollbar on the left side (default right). #scrollbar_on_left=NO +# Enable the page mode for the vertical scrollbar. When this mode is enabled, +# clicking anywhere on the vertical scrollbar with the left button scrolls one +# page down. With the right button, one page up. Click with the middle button to +# jump to a given position. +#scrollbar_page_mode=NO + #------------------------------------------------------------------------- # RENDERING SECTION #------------------------------------------------------------------------- diff --git a/doc/user_help.in.html b/doc/user_help.in.html index a35bb63b..25129668 100644 --- a/doc/user_help.in.html +++ b/doc/user_help.in.html @@ -213,6 +213,15 @@ scrollbar can be positioned on the left side setting the scrollbar_on_left option to YES, by default it is on the right side.

+The vertical scrollbar has another mode of operation to navigate full +pages that can be enabled by setting the +scrollbar_page_mode option to YES or temporarily by +holding the Shift key. When this mode is active, left-clicking anywhere on the +scrollbar will scroll down one page and right-clicking will scroll up one page. +Middle clicking on the scrollbar will move the thumb to that position, which can +also be dragged. The Shift key can also be used to temporarily disable this +mode if it was enabled in the configuration. +

Find text

To find text in a document right-click to open the Page menu and select 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; diff --git a/dw/fltkviewport.hh b/dw/fltkviewport.hh index fdcbb3be..62d4fa21 100644 --- a/dw/fltkviewport.hh +++ b/dw/fltkviewport.hh @@ -1,3 +1,23 @@ +/* + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef __DW_FLTKVIEWPORT_HH__ #define __DW_FLTKVIEWPORT_HH__ @@ -24,6 +44,7 @@ private: int scrollbarOnLeft; int hasDragScroll, dragScrolling, dragX, dragY; int horScrolling, verScrolling; + bool scrollbarPageMode; Fl_Scrollbar *vscrollbar, *hscrollbar; @@ -78,6 +99,7 @@ public: void setDragScroll (bool enable) { hasDragScroll = enable ? 1 : 0; } void addGadget (Fl_Widget *gadget); void setScrollbarOnLeft (bool enable); + void setScrollbarPageMode(bool enable); }; } // namespace fltk diff --git a/src/prefs.c b/src/prefs.c index 29b4f349..36415647 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -92,6 +92,7 @@ void a_Prefs_init(void) dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL)); prefs.search_url_idx = 0; prefs.scrollbar_on_left = FALSE; + prefs.scrollbar_page_mode = FALSE; prefs.show_back = TRUE; prefs.show_bookmarks = TRUE; prefs.show_clear_url = TRUE; diff --git a/src/prefs.h b/src/prefs.h index f51d0a4c..6f8f4fdb 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -78,6 +78,7 @@ typedef struct { int32_t font_min_size; int32_t scroll_step; bool_t scrollbar_on_left; + bool_t scrollbar_page_mode; bool_t show_back; bool_t show_forw; bool_t show_home; diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 3669b8d4..864a6736 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -201,6 +201,7 @@ void PrefsParser::parse(FILE *fp) { "save_dir", &prefs.save_dir, PREFS_STRING, 0 }, { "scroll_step", &prefs.scroll_step, PREFS_INT32, 0 }, { "scrollbar_on_left", &prefs.scrollbar_on_left, PREFS_BOOL, 0 }, + { "scrollbar_page_mode", &prefs.scrollbar_page_mode, PREFS_BOOL, 0 }, { "search_url", &prefs.search_urls, PREFS_STRINGS, 0 }, { "show_back", &prefs.show_back, PREFS_BOOL, 0 }, { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL, 0 }, diff --git a/src/uicmd.cc b/src/uicmd.cc index 07593892..ad6e67c1 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -629,6 +629,7 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) viewport->setBufferedDrawing (prefs.buffered_drawing ? true : false); viewport->setDragScroll (prefs.middle_click_drags_page ? true : false); viewport->setScrollbarOnLeft (prefs.scrollbar_on_left ? true : false); + viewport->setScrollbarPageMode (prefs.scrollbar_page_mode ? true : false); layout->attachView (viewport); new_ui->set_render_layout(viewport); viewport->setScrollStep(prefs.scroll_step); -- cgit v1.2.3