summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-02-26 20:44:35 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-02-26 20:44:35 +0000
commit2668a87af7bbec1bf8a2ae971748f65885fe6fcf (patch)
tree07bd2375cee9867ed24ec3ce4a4c546e96c4b878 /src
parente582f8bb1ced5a16cf8a5ee22bb76c60121bdced (diff)
Fixed Scrollbar events when max is less than min (STR #2283)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7161 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Scrollbar.cxx45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/Fl_Scrollbar.cxx b/src/Fl_Scrollbar.cxx
index d01472268..5ef37385d 100644
--- a/src/Fl_Scrollbar.cxx
+++ b/src/Fl_Scrollbar.cxx
@@ -36,23 +36,32 @@
#define REPEAT .05
void Fl_Scrollbar::increment_cb() {
- int ls = maximum()>=minimum() ? linesize_ : -linesize_;
+ char inv = maximum()<minimum();
+ int ls = inv ? -linesize_ : linesize_;
int i;
switch (pushed_) {
- case 1:
- i = -ls;
- break;
- default:
- i = ls;
- break;
- case 5:
- i = -int((maximum()-minimum())*slider_size()/(1.0-slider_size())) + ls;
- if (i > -ls) i = -ls;
- break;
- case 6:
- i = int((maximum()-minimum())*slider_size()/(1.0-slider_size())) - ls;
- if (i < ls) i = ls;
- break;
+ case 1: // clicked on arrow left
+ i = -ls;
+ break;
+ default: // clicked on arrow right
+ i = ls;
+ break;
+ case 5: // clicked into the box next to the slider on the left
+ i = -(int((maximum()-minimum())*slider_size()/(1.0-slider_size())));
+ if (inv) {
+ if (i<-ls) i = -ls;
+ } else {
+ if (i>-ls) i = -ls; // err
+ }
+ break;
+ case 6: // clicked into the box next to the slider on the right
+ i = (int((maximum()-minimum())*slider_size()/(1.0-slider_size())));
+ if (inv) {
+ if (i>ls) i = ls;
+ } else {
+ if (i<ls) i = ls; // err
+ }
+ break;
}
handle_drag(clamp(value() + i));
}
@@ -133,11 +142,13 @@ int Fl_Scrollbar::handle(int event) {
case FL_MOUSEWHEEL :
if (horizontal()) {
if (Fl::e_dx==0) return 0;
- handle_drag(clamp(value() + linesize_ * Fl::e_dx));
+ int ls = maximum()>=minimum() ? linesize_ : -linesize_;
+ handle_drag(clamp(value() + ls * Fl::e_dx));
return 1;
} else {
if (Fl::e_dy==0) return 0;
- handle_drag(clamp(value() + linesize_ * Fl::e_dy));
+ int ls = maximum()>=minimum() ? linesize_ : -linesize_;
+ handle_drag(clamp(value() + ls * Fl::e_dy));
return 1;
}
case FL_SHORTCUT: