|
|
DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR Active]
Link: https://www.fltk.org/str.php?L3521
Version: 1.4-feature
Please see attached file
'0001-Switch-hor.-vert.-scrolling-with-SHIFT-STR-3521.patch' for a proof of
concept. Please apply with `git am' (hint: after creating a feature branch)
or `patch -p1' for testing.
This patch does *unconditionally* change scrollbar behavior by exchanging
horizontal and vertical mousewheel movement values (Fl::event_dx and
Fl::event_dy) if the Shift key is pressed during mousewheel movement.
As said above this *may* break existing programs that don't care about
shift key state when interpreting mousewheel events.
I don't know if these concerns are critical though. If yes, I suggest to
use a global flag for the entire program that can /disable/ the new feature
as opposed to a per-scrollbar flag.
Note that the patch is local in Fl_Scrollbar mousewheel event handling
since this had already the distinction of horizontal and vertical
scrollbars.
Link: https://www.fltk.org/str.php?L3521
Version: 1.4-feature From d5b0ba2a17ab277f0e9f074ae243642e8577cdfb Mon Sep 17 00:00:00 2001
From: Albrecht Schlosser <albrechts.fltk@online.de>
Date: Fri, 17 May 2019 14:23:37 +0200
Subject: [PATCH] Switch hor./vert. scrolling with SHIFT (STR 3521)
This is only a proof of concept. The new scrolling feature simply
exchanges horizontal and vertical mousewheel movement if the
Shift key is pressed while the mousewheel is used.
This *may* break existing programs that don't care about Shift key
state, but it's a local, simple and efficient solution.
---
src/Fl_Scrollbar.cxx | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/Fl_Scrollbar.cxx b/src/Fl_Scrollbar.cxx
index a659e8e14..eab29f086 100644
--- a/src/Fl_Scrollbar.cxx
+++ b/src/Fl_Scrollbar.cxx
@@ -104,6 +104,7 @@ int Fl_Scrollbar::handle(int event) {
else area = 8;
}
+ int e_dx = 0, e_dy = 0; // used in FL_MOUSEWHEEL event handling
switch (event) {
case FL_ENTER:
case FL_LEAVE:
@@ -131,15 +132,22 @@ int Fl_Scrollbar::handle(int event) {
if (pushed_) return 1;
return Fl_Slider::handle(event, X,Y,W,H);
case FL_MOUSEWHEEL :
+ if (Fl::event_state() & FL_SHIFT) { // shift key was down during mousewheel event
+ e_dx = Fl::e_dy; // flip mousewheel movement (horizontal/vertical)
+ e_dy = Fl::e_dx;
+ } else {
+ e_dx = Fl::e_dx; // normal mousewheel movement
+ e_dy = Fl::e_dy;
+ }
if (horizontal()) {
- if (Fl::e_dx==0) return 0;
+ if (e_dx == 0) return 0;
int ls = maximum()>=minimum() ? linesize_ : -linesize_;
- handle_drag(clamp(value() + ls * Fl::e_dx));
+ handle_drag(clamp(value() + ls * e_dx));
return 1;
} else {
- if (Fl::e_dy==0) return 0;
+ if (e_dy == 0) return 0;
int ls = maximum()>=minimum() ? linesize_ : -linesize_;
- handle_drag(clamp(value() + ls * Fl::e_dy));
+ handle_drag(clamp(value() + ls * e_dy));
return 1;
}
case FL_SHORTCUT:
--
2.17.1
[ Direct Link to Message ] | |
|
| |