Skip to content

Commit

Permalink
Fixed Scrollbar events when max is less than min (STR #2283)
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7161 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Feb 26, 2010
1 parent e582f8b commit 2668a87
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.3.0

- Fixed Scrollbar events when max is less than min (STR #2283)
- Added argument-less constructor in Fuid Widget Class
- Fixed menu item counting issue in Fluid (STR #2322)
- Added Fl_Menu_::find_item by callback
Expand Down
45 changes: 28 additions & 17 deletions src/Fl_Scrollbar.cxx
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2668a87

Please sign in to comment.