#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, rounded; bool reset_requested = false; switch (ev) { 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->type() & 1) ? dy : -dy; handle_drag(clamp(value() + step * dy)); } return 1; case FL_RELEASE: rounded = value() + 0.5; value(clamp((double)rounded)); if (Fl::event_clicks() == 1) { Fl::event_clicks(0); reset_requested = true; } } if (!Fl::event_shift()) { handled = Fl_Slider::handle(ev, X, Y, W, H); if (reset_requested) { value(reset_value); value_damage(); if (this->when() != 0) do_callback(); } return handled; } // Slow down the drag. // Handy if the slider has a large delta bigger than a mouse quantum. // Somewhat tricky to use with OSC feedback. // To change direction of movement, one must reclick the handle. int old_value = value(); handled = Fl_Slider::handle(ev, X, Y, W, H); int delta = value() - old_value; if (ev == FL_DRAG && (delta < -1 || delta > 1)) { value(clamp((old_value + (delta > 0 ? 1 : -1)))); 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(); }