summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--src/Fl_Scrollbar.cxx45
2 files changed, 29 insertions, 17 deletions
diff --git a/CHANGES b/CHANGES
index bd37621e9..7c4ccacdf 100644
--- a/CHANGES
+++ b/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
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: