diff options
| author | Matthias Melcher <git@matthiasm.com> | 2019-02-04 23:12:02 +0100 |
|---|---|---|
| committer | Matthias Melcher <git@matthiasm.com> | 2019-02-04 23:12:02 +0100 |
| commit | 0cac8d52e3433a3816399797439017b2ca929451 (patch) | |
| tree | 377eda9f003f96b97bf6f253bf5721b0dcbfcbc3 /src/Fl_Roller.cxx | |
| parent | 67f0bf6feeaeaa58f205a3a3065136df68163420 (diff) | |
Fl_Roller can now be controlled via the mouse wheel (STR #3120).
Diffstat (limited to 'src/Fl_Roller.cxx')
| -rw-r--r-- | src/Fl_Roller.cxx | 105 |
1 files changed, 60 insertions, 45 deletions
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; } } |
