summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2019-02-04 23:12:02 +0100
committerMatthias Melcher <git@matthiasm.com>2019-02-04 23:12:02 +0100
commit0cac8d52e3433a3816399797439017b2ca929451 (patch)
tree377eda9f003f96b97bf6f253bf5721b0dcbfcbc3
parent67f0bf6feeaeaa58f205a3a3065136df68163420 (diff)
Fl_Roller can now be controlled via the mouse wheel (STR #3120).
-rw-r--r--CHANGES.txt1
-rw-r--r--FL/Fl_Roller.H5
-rw-r--r--src/Fl_Roller.cxx105
3 files changed, 66 insertions, 45 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index c282898b4..e73473fb7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -102,6 +102,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019
Other Improvements
- (add new items here)
+ - Fl_Roller can now be controlled via the mouse wheel (STR #3120).
- Tooltips hide by themselves after 12 seconds (STR #2584).
- Added widget visibility indicator to Fluid (STR #2669).
- Added Fl_Input_::append() method (STR #2953).
diff --git a/FL/Fl_Roller.H b/FL/Fl_Roller.H
index b96e92638..c9a77bea4 100644
--- a/FL/Fl_Roller.H
+++ b/FL/Fl_Roller.H
@@ -29,6 +29,11 @@
/**
The Fl_Roller widget is a "dolly" control commonly used to
move 3D objects.
+
+ The Roller can be controlled by clicking an ddragging the mouse, by the
+ corresponding arrow keys when the roller has the keyboard focus, or by the
+ mousewheels when the mouse pointer is positioned over the roller widget.
+
<P ALIGN=CENTER>\image html Fl_Roller.png
\image latex Fl_Roller.png "Fl_Roller" width=4cm
*/
diff --git a/src/Fl_Roller.cxx b/src/Fl_Roller.cxx
index 24a990160..d6c878252 100644
--- a/src/Fl_Roller.cxx
+++ b/src/Fl_Roller.cxx
@@ -27,53 +27,68 @@ int Fl_Roller::handle(int event) {
static int ipos;
int newpos = horizontal() ? Fl::event_x() : Fl::event_y();
switch (event) {
- case FL_PUSH:
- if (Fl::visible_focus()) {
- Fl::focus(this);
- redraw();
- }
- handle_push();
- ipos = newpos;
- return 1;
- case FL_DRAG:
- handle_drag(clamp(round(increment(previous_value(),newpos-ipos))));
- return 1;
- case FL_RELEASE:
- handle_release();
- return 1;
- case FL_KEYBOARD :
- switch (Fl::event_key()) {
- case FL_Up:
- if (horizontal()) return 0;
- handle_drag(clamp(increment(value(),-1)));
- return 1;
- case FL_Down:
- if (horizontal()) return 0;
- handle_drag(clamp(increment(value(),1)));
- return 1;
- case FL_Left:
- if (!horizontal()) return 0;
- handle_drag(clamp(increment(value(),-1)));
- return 1;
- case FL_Right:
- if (!horizontal()) return 0;
- handle_drag(clamp(increment(value(),1)));
- return 1;
- default:
+ case FL_PUSH:
+ if (Fl::visible_focus()) {
+ Fl::focus(this);
+ redraw();
+ }
+ handle_push();
+ ipos = newpos;
+ return 1;
+ case FL_DRAG:
+ handle_drag(clamp(round(increment(previous_value(),newpos-ipos))));
+ return 1;
+ case FL_RELEASE:
+ handle_release();
+ return 1;
+ case FL_MOUSEWHEEL :
+ if (Fl::belowmouse()==this) {
+ if (horizontal()) {
+ if (Fl::e_dx!=0) {
+ handle_drag(clamp(round(increment(value(),-Fl::e_dx))));
+ }
+ } else {
+ if (Fl::e_dy!=0) {
+ handle_drag(clamp(round(increment(value(),-Fl::e_dy))));
+ }
+ }
+ return 1;
+ } else {
return 0;
- }
- // break not required because of switch...
- case FL_FOCUS :
- case FL_UNFOCUS :
- if (Fl::visible_focus()) {
- redraw();
+ }
+ case FL_KEYBOARD :
+ switch (Fl::event_key()) {
+ case FL_Up:
+ if (horizontal()) return 0;
+ handle_drag(clamp(increment(value(),-1)));
+ return 1;
+ case FL_Down:
+ if (horizontal()) return 0;
+ handle_drag(clamp(increment(value(),1)));
+ return 1;
+ case FL_Left:
+ if (!horizontal()) return 0;
+ handle_drag(clamp(increment(value(),-1)));
+ return 1;
+ case FL_Right:
+ if (!horizontal()) return 0;
+ handle_drag(clamp(increment(value(),1)));
+ return 1;
+ default:
+ return 0;
+ }
+ // break not required because of switch...
+ case FL_FOCUS :
+ case FL_UNFOCUS :
+ if (Fl::visible_focus()) {
+ redraw();
+ return 1;
+ } else return 0;
+ case FL_ENTER :
+ case FL_LEAVE :
return 1;
- } else return 0;
- case FL_ENTER :
- case FL_LEAVE :
- return 1;
- default:
- return 0;
+ default:
+ return 0;
}
}