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
This commit is contained in:
Matthias Melcher 2010-02-26 20:44:35 +00:00
parent e582f8bb1c
commit 2668a87af7
2 changed files with 29 additions and 17 deletions

View File

@ -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

View File

@ -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: