zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 729164aa379a457be7137e6d630b80485dae50c0
parent 88ba4923bf2f148eb89755a581dc06b24cf6c8c4
Author: fundamental <[email protected]>
Date:   Sun, 22 Feb 2015 15:39:35 -0500

UI: Add MIDI Learn to Sliders

Diffstat:
Msrc/UI/Fl_Osc_Dial.cpp | 1-
Msrc/UI/Fl_Osc_Slider.H | 3+++
Msrc/UI/Fl_Osc_Slider.cpp | 13++++++++++++-
Msrc/UI/Fl_Osc_VSlider.H | 3+++
Msrc/UI/Fl_Osc_VSlider.cpp | 11+++++++++++
5 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/UI/Fl_Osc_Dial.cpp b/src/UI/Fl_Osc_Dial.cpp @@ -104,7 +104,6 @@ void Fl_Osc_Dial::mark_dead(void) dead = true; } - void Fl_Osc_Dial::rebase(std::string new_base) { if(dead || loc == "/") diff --git a/src/UI/Fl_Osc_Slider.H b/src/UI/Fl_Osc_Slider.H @@ -20,6 +20,9 @@ class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget //Refetch parameter information void update(void); void callback(Fl_Callback *cb, void *p = NULL); + + //MIDI Learn + int handle(int); void cb(void); static void _cb(Fl_Widget *w, void *); diff --git a/src/UI/Fl_Osc_Slider.cpp b/src/UI/Fl_Osc_Slider.cpp @@ -1,3 +1,4 @@ +#include <FL/Fl.H> #include "Fl_Osc_Slider.H" #include "Fl_Osc_Interface.h" #include "Fl_Osc_Pane.H" @@ -60,7 +61,7 @@ void Fl_Osc_Slider::cb(void) oscWrite(ext, "i", (int)(val-min_)); } //OSC_value(val); - + if(cb_data.first) cb_data.first(this, cb_data.second); } @@ -71,6 +72,16 @@ void Fl_Osc_Slider::callback(Fl_Callback *cb, void *p) cb_data.second = p; } +int Fl_Osc_Slider::handle(int ev) +{ + if(ev == FL_PUSH && Fl::event_state(FL_BUTTON2)) { + printf("Trying to learn...\n"); + osc->write("/learn", "s", (loc+ext).c_str()); + return 1; + } + return Fl_Slider::handle(ev); +} + void Fl_Osc_Slider::update(void) { oscWrite(ext, ""); diff --git a/src/UI/Fl_Osc_VSlider.H b/src/UI/Fl_Osc_VSlider.H @@ -18,6 +18,9 @@ class Fl_Osc_VSlider:public Fl_Value_Slider, public Fl_Osc_Widget //Refetch parameter information void update(void); void callback(Fl_Callback *cb, void *p = NULL); + + //MIDI Learn + int handle(int); void cb(void); static void _cb(Fl_Widget *w, void *); diff --git a/src/UI/Fl_Osc_VSlider.cpp b/src/UI/Fl_Osc_VSlider.cpp @@ -1,3 +1,4 @@ +#include <FL/Fl.H> #include "Fl_Osc_VSlider.H" #include "Fl_Osc_Interface.h" #include "Fl_Osc_Pane.H" @@ -62,6 +63,16 @@ void Fl_Osc_VSlider::callback(Fl_Callback *cb, void *p) cb_data.second = p; } +int Fl_Osc_VSlider::handle(int ev) +{ + if(ev == FL_PUSH && Fl::event_state(FL_BUTTON2)) { + printf("Trying to learn...\n"); + osc->write("/learn", "s", (loc+ext).c_str()); + return 1; + } + return Fl_Value_Slider::handle(ev); +} + void Fl_Osc_VSlider::update(void) { oscWrite(ext, "");