commit 2312c48bf5fca0b284560502562213eb14931513
parent 1e0d0b21e98716788ba55c96fa336ab4849101e1
Author: fundamental <[email protected]>
Date: Thu, 13 Feb 2014 14:17:45 -0500
Fix Control Maping in Voice Window
- Fix bad rebase in knobs
- Fix bad rebase in vertical sliders
- Fix missing osc handler for integer values on sliders
Diffstat:
10 files changed, 89 insertions(+), 30 deletions(-)
diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp
@@ -647,6 +647,9 @@ class UI_Interface:public Fl_Osc_Interface
void writeRaw(const char *msg) override
{
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
+ fprintf(stderr, "write(%s)\n", msg);
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
impl->handleMsg(msg);
}
@@ -784,6 +787,8 @@ class UI_Interface:public Fl_Osc_Interface
void dumpLookupTable(void)
{
+ if(map.size() != 0)
+ printf("Leaked controls:\n");
for(auto i = map.begin(); i != map.end(); ++i) {
printf("Known control '%s' (%p)...\n", i->first.c_str(), i->second);
}
diff --git a/src/UI/FilterUI.fl b/src/UI/FilterUI.fl
@@ -201,15 +201,15 @@ delete (formantparswindow);} {}
Fl_Dial vsnsadial {
label {V.SnsA.}
tooltip {Velocity sensing amount of the Filter} xywh {145 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScale");}
- code1 {else {o->deactivate(); o->value(127);}}
+ code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScale"); }
+ code1 {else {o->deactivate(); o->value(127);o->mark_dead();}}
class Fl_Osc_Dial
}
Fl_Dial vsnsdial {
label {V.Sns.}
tooltip {Velocity Sensing Function of the Filter} xywh {180 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScaleFunction");}
- code1 {else {o->deactivate(); o->value(127);}}
+ code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScaleFunction"); }
+ code1 {else {o->deactivate(); o->value(127);o->mark_dead();}}
class Fl_Osc_Dial
}
Fl_Dial gaindial {
diff --git a/src/UI/Fl_Osc_Dial.H b/src/UI/Fl_Osc_Dial.H
@@ -26,7 +26,12 @@ class Fl_Osc_Dial:public WidgetPDial, public Fl_Osc_Widget
void update(void);
void callback(Fl_Callback *cb, void *p = NULL);
+ void mark_dead(void);
+ virtual void rebase(std::string new_base) override;
+
void cb(void);
private:
+ bool alt_style;
+ bool dead;
std::pair<Fl_Callback*, void*> cb_data;
};
diff --git a/src/UI/Fl_Osc_Dial.cpp b/src/UI/Fl_Osc_Dial.cpp
@@ -24,7 +24,7 @@ Fl_Osc_Pane *fetch_osc_pane(Fl_Widget *w)
}
Fl_Osc_Dial::Fl_Osc_Dial(int X, int Y, int W, int H, const char *label)
- :WidgetPDial(X,Y,W,H, label), Fl_Osc_Widget(this)
+ :WidgetPDial(X,Y,W,H, label), Fl_Osc_Widget(this), alt_style(false), dead(false)
{
bounds(0.0, 127.0f);
WidgetPDial::callback(callback_fn);
@@ -46,6 +46,8 @@ void Fl_Osc_Dial::alt_init(std::string base, std::string path_)
assert(osc);
loc = base;
oscRegister(path_.c_str());
+ ext = path_;
+ alt_style = true;
}
Fl_Osc_Dial::~Fl_Osc_Dial(void)
@@ -84,3 +86,45 @@ void Fl_Osc_Dial::cb(void)
if(cb_data.first)
cb_data.first(this, cb_data.second);
}
+
+void Fl_Osc_Dial::mark_dead(void)
+{
+ dead = true;
+}
+
+
+void Fl_Osc_Dial::rebase(std::string new_base)
+{
+ if(dead)
+ return;
+ if(!alt_style) {
+ Fl_Osc_Widget::rebase(new_base);
+ return;
+ }
+
+ //ok, for a simple hack here lets just assume that there is one branch
+ //missing
+ int depth = 0;
+ for(int i=0; i<(int)loc.size(); ++i)
+ depth += loc[i] == '/';
+ int match_depth = 0;
+ int match_pos = 0;
+ for(int i=0; i<(int)new_base.size(); ++i) {
+ match_depth += new_base[i] == '/';
+ if(match_depth == depth) {
+ match_pos = i;
+ break;
+ }
+ }
+
+ if(match_pos == 0) {
+ //well, that didn't work
+ assert(!"good enough hack");
+ }
+
+ std::string new_loc = new_base.substr(0, match_pos+1);
+ printf("Moving '%s' to\n", (loc+ext).c_str());
+ printf(" '%s'\n", (new_loc+ext).c_str());
+ oscMove(loc+ext, new_loc+ext);
+ loc = new_loc;
+}
diff --git a/src/UI/Fl_Osc_Slider.H b/src/UI/Fl_Osc_Slider.H
@@ -3,8 +3,6 @@
#include "Fl_Osc_Widget.H"
#include <string>
-using std::string; //yes this is bad form FIXME
-
class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget
{
@@ -14,8 +12,9 @@ class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget
// const char *metadata);
virtual ~Fl_Osc_Slider(void);
- void OSC_value(float);
- void OSC_value(char);
+ void OSC_value(int) override;
+ void OSC_value(float) override;
+ void OSC_value(char) override;
void init(std::string, char type = 'f');
//Refetch parameter information
@@ -25,9 +24,6 @@ class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget
void cb(void);
static void _cb(Fl_Widget *w, void *);
private:
- string label_str;
- std::string full_path;
- std::string path;
double real_value;
char osc_type;
std::pair<Fl_Callback*, void*> cb_data;
diff --git a/src/UI/Fl_Osc_Slider.cpp b/src/UI/Fl_Osc_Slider.cpp
@@ -22,13 +22,19 @@ Fl_Osc_Slider::Fl_Osc_Slider(int X, int Y, int W, int H, const char *label)
void Fl_Osc_Slider::init(std::string path_, char type_)
{
osc_type = type_;
- path = path_;
- oscRegister(path.c_str());
+ ext = path_;
+ oscRegister(ext.c_str());
}
Fl_Osc_Slider::~Fl_Osc_Slider(void)
{}
+void Fl_Osc_Slider::OSC_value(int v)
+{
+ const float min_ = min__(minimum(), maximum());//flipped sliders
+ Fl_Slider::value(v+min_);
+}
+
void Fl_Osc_Slider::OSC_value(float v)
{
const float min_ = min__(minimum(), maximum());//flipped sliders
@@ -46,11 +52,11 @@ void Fl_Osc_Slider::cb(void)
const float min_ = min__(minimum(), maximum());//flipped sliders
const float val = Fl_Slider::value();
if(osc_type == 'f')
- oscWrite(path, "f", val-min_);
+ oscWrite(ext, "f", val-min_);
else if(osc_type == 'i')
- oscWrite(path, "i", (int)(val-min_));
+ oscWrite(ext, "i", (int)(val-min_));
else
- oscWrite(path, "c", (char)(val-min_));
+ oscWrite(ext, "c", (char)(val-min_));
//OSC_value(val);
if(cb_data.first)
@@ -65,7 +71,7 @@ void Fl_Osc_Slider::callback(Fl_Callback *cb, void *p)
void Fl_Osc_Slider::update(void)
{
- oscWrite(path, "");
+ oscWrite(ext, "");
}
void Fl_Osc_Slider::_cb(Fl_Widget *w, void *)
diff --git a/src/UI/Fl_Osc_VSlider.H b/src/UI/Fl_Osc_VSlider.H
@@ -3,9 +3,7 @@
#include "Fl_Osc_Widget.H"
#include <string>
-using std::string; //yes this is bad form FIXME
-
-class Fl_Osc_VSlider:public Fl_Value_Slider, Fl_Osc_Widget
+class Fl_Osc_VSlider:public Fl_Value_Slider, public Fl_Osc_Widget
{
public:
@@ -23,9 +21,6 @@ class Fl_Osc_VSlider:public Fl_Value_Slider, Fl_Osc_Widget
void cb(void);
static void _cb(Fl_Widget *w, void *);
private:
- string label_str;
- std::string full_path;
- std::string path;
double real_value;
char osc_type;
std::pair<Fl_Callback*, void*> cb_data;
diff --git a/src/UI/Fl_Osc_VSlider.cpp b/src/UI/Fl_Osc_VSlider.cpp
@@ -17,8 +17,8 @@ Fl_Osc_VSlider::Fl_Osc_VSlider(int X, int Y, int W, int H, const char *label)
void Fl_Osc_VSlider::init(std::string path_, char type_)
{
osc_type = type_;
- path = path_;
- oscRegister(path.c_str());
+ ext = path_;
+ oscRegister(ext.c_str());
}
Fl_Osc_VSlider::~Fl_Osc_VSlider(void)
@@ -38,11 +38,11 @@ void Fl_Osc_VSlider::cb(void)
{
const float val = Fl_Slider::value();
if(osc_type == 'f')
- oscWrite(path, "f", val-minimum());
+ oscWrite(ext, "f", val-minimum());
else if(osc_type == 'i')
- oscWrite(path, "i", (int)(val-minimum()));
+ oscWrite(ext, "i", (int)(val-minimum()));
else
- oscWrite(path, "c", (char)(val-minimum()));
+ oscWrite(ext, "c", (char)(val-minimum()));
//OSC_value(val);
if(cb_data.first)
@@ -57,7 +57,7 @@ void Fl_Osc_VSlider::callback(Fl_Callback *cb, void *p)
void Fl_Osc_VSlider::update(void)
{
- oscWrite(path, "");
+ oscWrite(ext, "");
}
void Fl_Osc_VSlider::_cb(Fl_Widget *w, void *)
diff --git a/src/UI/Fl_Osc_Widget.H b/src/UI/Fl_Osc_Widget.H
@@ -44,6 +44,8 @@ class Fl_Osc_Widget
//Smoothly change the base path
virtual void rebase(std::string new_base);
void oscMove(std::string new_ext);
+ //Explict version for weirdly routed controls
+ void oscMove(std::string old_loc, std::string new_loc);
//Base path
std::string loc;
diff --git a/src/UI/Fl_Osc_Widget.cpp b/src/UI/Fl_Osc_Widget.cpp
@@ -105,3 +105,9 @@ void Fl_Osc_Widget::oscMove(std::string new_ext)
ext = new_ext;
osc->requestValue(loc+ext);
}
+
+void Fl_Osc_Widget::oscMove(std::string old_loc, std::string new_loc)
+{
+ osc->renameLink(old_loc, new_loc, this);
+ osc->requestValue(new_loc);
+}