[yoshimi] Help Please

  • From: Will Godfrey <willgodfrey@xxxxxxxxxxxxxxx>
  • To: yoshimi@xxxxxxxxxxxxx
  • Date: Thu, 2 Jun 2016 14:06:31 +0100

On 't 'net I've discovered a code snippet that allows you to get scroll wheel
control of FLTK sliders. The demo works perfectly (still allowing normal
control), but I can't for the life of me work out how to integrate it into
Yoshimi - possibly I'm missing something quite obvious.

I've attached the code here, and would think the logical pace for it would be
in UI/WidgetPDialUI.fl

It would be great if we could get this in the next release, so are there any
coders with a bit of spare time?

-- 
Will J Godfrey
http://www.musically.me.uk
Say you have a poem and I have a tune.
Exchange them and we can both have a poem, a tune, and a song.
// fltk slider scroll wheel example

// g++ -Wall -lfltk /home/will/wheel.cxx -o /home/will/wheel

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Value_Slider.H>

class wheel_slider: public Fl_Value_Slider
{
    int handle(int);
public:
    wheel_slider(int x, int y, int w, int h, const char *l=0) :
        Fl_Value_Slider (x,y,w,h,l) {}
};

int wheel_slider::handle(int ev)
{
    double v1;
    int res = Fl_Value_Slider::handle(ev); // do the base-class actions

    if (ev == FL_MOUSEWHEEL) // now check for wheel-mouse events
    {
        // for wheel - use dy
        int dy = Fl::event_dy();
        v1 = value(); // current value
        v1 = increment(v1, dy); // change
        v1 = clamp(v1); // clamp to valuator limits
        value(v1); // update widget
        return 1; // say we ate this event
    }
    return res;
}

static wheel_slider *level, *l2;

int main(int argc, char **argv)
{
    Fl_Double_Window *main_win = new Fl_Double_Window(300, 400,
"Slider Window");
    main_win->begin();

    level = new wheel_slider(135, 20, 30, 195, "Level");
    level->type(FL_VERT_NICE_SLIDER);
    level->minimum(100);
    level->maximum(0);
    level->step(1);

    l2 = new wheel_slider(20, 270, 260, 30, "Pan");
    l2->type(FL_HOR_NICE_SLIDER);
    l2->minimum(0);
    l2->maximum(100);
    l2->step(-1);

    main_win->end();
    main_win->show(argc, argv);
    return Fl::run();
}

Other related posts:

  • » [yoshimi] Help Please - Will Godfrey