Fix behavior of vertical sliders.
This commit is contained in:
parent
23107541c8
commit
1aafc5330f
|
@ -26,6 +26,8 @@
|
|||
void
|
||||
Fl_SliderX::draw ( int X, int Y, int W, int H)
|
||||
{
|
||||
slider_size( horizontal() ? H / (float)W : W / (float)H );
|
||||
|
||||
int act = active_r();
|
||||
|
||||
if (damage()&FL_DAMAGE_ALL) draw_box();
|
||||
|
@ -125,7 +127,7 @@ Fl_SliderX::slider_position ( double value, int w )
|
|||
if (B == A) return 0;
|
||||
bool flip = B < A;
|
||||
if (flip) {A = B; B = minimum();}
|
||||
if (!horizontal()) flip = !flip;
|
||||
// if (!horizontal()) flip = !flip;
|
||||
// if both are negative, make the range positive:
|
||||
if (B <= 0) {flip = !flip; double t = A; A = -B; B = -t; value = -value;}
|
||||
double fraction;
|
||||
|
@ -161,7 +163,7 @@ Fl_SliderX::slider_value ( int X, int w )
|
|||
double B = maximum();
|
||||
bool flip = B < A;
|
||||
if (flip) {A = B; B = minimum();}
|
||||
if (!horizontal()) flip = !flip;
|
||||
// if (!horizontal()) flip = !flip;
|
||||
if (flip) X = w-X;
|
||||
double fraction = double(X)/w;
|
||||
if (fraction <= 0) return A;
|
||||
|
@ -223,12 +225,11 @@ int Fl_SliderX::handle(int event, int X, int Y, int W, int H) {
|
|||
|
||||
int ww = (horizontal() ? W : H);
|
||||
|
||||
|
||||
if ( event == FL_PUSH )
|
||||
{
|
||||
int x = slider_position( value(), ww );
|
||||
|
||||
offcenter = (Fl::event_x()-X) - x;
|
||||
offcenter = (horizontal() ? (Fl::event_x()-X) - x : (Fl::event_y()-Y) - x );
|
||||
}
|
||||
|
||||
try_again:
|
||||
|
@ -236,11 +237,16 @@ int Fl_SliderX::handle(int event, int X, int Y, int W, int H) {
|
|||
int mx = (horizontal() ? Fl::event_x()-X : Fl::event_y()-Y) - offcenter;
|
||||
double v = slider_value( mx, ww );
|
||||
|
||||
if (event == FL_PUSH && v == value()) {
|
||||
offcenter = int(slider_size()*ww+0.5)/2;
|
||||
if (event == FL_PUSH ) // && v == value()) {
|
||||
{
|
||||
int os = int(slider_size()*ww+0.5)/2;
|
||||
if ( abs( offcenter ) > os )
|
||||
{
|
||||
offcenter = os;
|
||||
event = FL_DRAG;
|
||||
goto try_again;
|
||||
}
|
||||
}
|
||||
|
||||
handle_drag(clamp(v));
|
||||
} return 1;
|
||||
|
@ -333,11 +339,3 @@ int Fl_SliderX::handle(int event) {
|
|||
w()-Fl::box_dw(box()),
|
||||
h()-Fl::box_dh(box()));
|
||||
}
|
||||
|
||||
void
|
||||
Fl_SliderX::resize ( int X, int Y, int W, int H )
|
||||
{
|
||||
Fl_Slider::resize(X,Y,W,H);
|
||||
|
||||
slider_size( horizontal() ? H / (float)W : W / (float)H );
|
||||
}
|
||||
|
|
|
@ -47,7 +47,4 @@ public:
|
|||
|
||||
virtual int handle(int event, int X, int Y, int W, int H);
|
||||
virtual int handle(int event);
|
||||
|
||||
virtual void resize ( int X, int Y, int W, int H );
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue