#include #include "Fl_Osc_Slider.H" #include "Fl_Osc_Interface.h" #include "Fl_Osc_Pane.H" #include #include #include #include #include #include "../Misc/Util.h" static double min__(double a, double b) { return awrite("/learn", "s", (loc+ext).c_str()); return 1; } else if(shift_middle) { osc->write("/unlearn", "s", (loc+ext).c_str()); return 1; } int handled; float rounded; if (ev != FL_MOUSEWHEEL) handled = Fl_Slider::handle(ev, X, Y, W, H); switch (ev) { case FL_PUSH: denominator = 2.0; old_value = value(); start_pos = horizontal() ? Fl::event_x() : Fl::event_y(); { float range = maximum() - minimum(); float absrng = range > 0 ? range : -range; if (absrng / W / step() > 32 && Fl::event_button1()) denominator = 0.25; if (range < 0) denominator *= -1; } break; case FL_MOUSEWHEEL: if (this == Fl::belowmouse() && Fl::e_dy != 0) { int step = 1, divisor = 16; switch (Fl::event_state() & ( FL_CTRL | FL_SHIFT)) { case FL_SHIFT: step = 8; case FL_SHIFT | FL_CTRL: break; case FL_CTRL: divisor = 128; default: step = (fabs(maximum() - minimum()) + 1) / divisor; if (step < 1) step = 1; } int dy = minimum() <= maximum() ? -Fl::e_dy : Fl::e_dy; // Flip sense for vertical sliders. dy = this->horizontal() ? dy : -dy; handle_drag(clamp(value() + step * dy)); } return 1; case FL_RELEASE: if (Fl::event_clicks() == 1) { Fl::event_clicks(0); value(reset_value); } else { rounded = floorf(value() + 0.5); value(clamp(rounded)); } value_damage(); do_callback(); break; case FL_DRAG: if (Fl::event_shift()) { int delta = (horizontal() ? Fl::event_x() : Fl::event_y()) - start_pos; rounded = floor(clamp(old_value + delta/denominator) + 0.5); value(rounded); value_damage(); do_callback(); } } return handled; } int Fl_Osc_Slider::handle(int ev) { return handle(ev, x()+Fl::box_dx(box()), y()+Fl::box_dy(box()), w()-Fl::box_dw(box()), h()-Fl::box_dh(box())); } void Fl_Osc_Slider::update(void) { oscWrite(ext, ""); } void Fl_Osc_Slider::_cb(Fl_Widget *w, void *) { static_cast(w)->cb(); }