-Fixing bindings window, adding Author / Email details
parent
50b34ebaa7
commit
f9e1950777
|
@ -78,12 +78,20 @@ std::string GenericMIDI::getName()
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GenericMIDI::getAuthor()
|
||||||
|
{
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
std::string GenericMIDI::getEmail()
|
||||||
|
{
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
void GenericMIDI::volume(int t, float f)
|
void GenericMIDI::volume(int t, float f)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenericMIDI::recordArm(int t, bool enabled)
|
void GenericMIDI::recordArm(int t, bool enabled)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < actionToMidi.size(); i++)
|
for(unsigned int i = 0; i < actionToMidi.size(); i++)
|
||||||
|
@ -389,11 +397,13 @@ void GenericMIDI::midi(unsigned char* midi)
|
||||||
int data = midi[1];
|
int data = midi[1];
|
||||||
float value = midi[2] / 127.f;
|
float value = midi[2] / 127.f;
|
||||||
|
|
||||||
//LUPPP_NOTE("GenericMIDI::midi() %i %i %f", status, data, value );
|
|
||||||
|
|
||||||
// create new MIDI binding?
|
// create new MIDI binding?
|
||||||
if ( jack->bindingEventRecordEnable )
|
if ( jack->bindingEventRecordEnable )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LUPPP_NOTE("making binding from: %i %i %f", status, data, value );
|
||||||
|
|
||||||
setupBinding( jack->bindingEventType, status, data,
|
setupBinding( jack->bindingEventType, status, data,
|
||||||
jack->bindingTrack,
|
jack->bindingTrack,
|
||||||
jack->bindingScene,
|
jack->bindingScene,
|
||||||
|
@ -402,11 +412,11 @@ void GenericMIDI::midi(unsigned char* midi)
|
||||||
|
|
||||||
// binding is now created, so disable GUI binding enable button
|
// binding is now created, so disable GUI binding enable button
|
||||||
jack->bindingEventRecordEnable = false;
|
jack->bindingEventRecordEnable = false;
|
||||||
EventControllerBindingEnable e( false );
|
EventControllerBindingEnable e( getID(), false );
|
||||||
writeToGuiRingbuffer( &e );
|
writeToGuiRingbuffer( &e );
|
||||||
|
|
||||||
// update GUI of new binding
|
// update GUI of new binding
|
||||||
EventControllerBindingMade e2( (void*)midiToAction.back() );
|
EventControllerBindingMade e2( getID(), (void*)midiToAction.back() );
|
||||||
writeToGuiRingbuffer( &e2 );
|
writeToGuiRingbuffer( &e2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,6 +598,28 @@ int GenericMIDI::loadController( std::string file )
|
||||||
LUPPP_NOTE("Has no name field");
|
LUPPP_NOTE("Has no name field");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cJSON* authorJson = cJSON_GetObjectItem( controllerJson, "author" );
|
||||||
|
if ( authorJson )
|
||||||
|
{
|
||||||
|
author = authorJson->valuestring;
|
||||||
|
LUPPP_NOTE("Author %s", author.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LUPPP_NOTE("Has no author field");
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* linkJson = cJSON_GetObjectItem( controllerJson, "email" );
|
||||||
|
if ( linkJson )
|
||||||
|
{
|
||||||
|
email = linkJson->valuestring;
|
||||||
|
LUPPP_NOTE("Email %s", email.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LUPPP_NOTE("Has no email field");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int nInputBindings = 0;
|
int nInputBindings = 0;
|
||||||
cJSON* inputBindings = cJSON_GetObjectItem( controllerJson, "inputBindings");
|
cJSON* inputBindings = cJSON_GetObjectItem( controllerJson, "inputBindings");
|
||||||
|
@ -634,7 +666,7 @@ int GenericMIDI::loadController( std::string file )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LUPPP_WARN("No output bindings array in .ctlr map." );
|
LUPPP_NOTE("No output bindings array in .ctlr map." );
|
||||||
nOutputBindings++; // hack to avoid 2 prints
|
nOutputBindings++; // hack to avoid 2 prints
|
||||||
}
|
}
|
||||||
if ( nOutputBindings == 0 )
|
if ( nOutputBindings == 0 )
|
||||||
|
|
|
@ -32,6 +32,8 @@ class GenericMIDI : public Controller, public MidiIO
|
||||||
|
|
||||||
void setName(std::string );
|
void setName(std::string );
|
||||||
std::string getName();
|
std::string getName();
|
||||||
|
std::string getAuthor();
|
||||||
|
std::string getEmail();
|
||||||
|
|
||||||
/// track actions
|
/// track actions
|
||||||
//void mute(int t, bool b);
|
//void mute(int t, bool b);
|
||||||
|
@ -73,6 +75,8 @@ class GenericMIDI : public Controller, public MidiIO
|
||||||
STATUS stat;
|
STATUS stat;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string author;
|
||||||
|
std::string email;
|
||||||
|
|
||||||
/// contains midi binding instances
|
/// contains midi binding instances
|
||||||
std::vector<Binding*> midiToAction;
|
std::vector<Binding*> midiToAction;
|
||||||
|
|
|
@ -128,8 +128,9 @@ class EventControllerBindingMade : public EventBase
|
||||||
public:
|
public:
|
||||||
int type() { return int(CONTROLLER_BINDING_MADE); }
|
int type() { return int(CONTROLLER_BINDING_MADE); }
|
||||||
uint32_t size() { return sizeof(EventControllerBindingMade); }
|
uint32_t size() { return sizeof(EventControllerBindingMade); }
|
||||||
|
int controllerID;
|
||||||
void* binding;
|
void* binding;
|
||||||
EventControllerBindingMade(void* b=0): binding(b){}
|
EventControllerBindingMade(int id = 0, void* b=0): controllerID(id), binding(b){}
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventControllerBindingEnable : public EventBase
|
class EventControllerBindingEnable : public EventBase
|
||||||
|
@ -137,8 +138,9 @@ class EventControllerBindingEnable : public EventBase
|
||||||
public:
|
public:
|
||||||
int type() { return int(CONTROLLER_BINDING_ENABLE); }
|
int type() { return int(CONTROLLER_BINDING_ENABLE); }
|
||||||
uint32_t size() { return sizeof(EventControllerBindingEnable); }
|
uint32_t size() { return sizeof(EventControllerBindingEnable); }
|
||||||
|
int controllerID;
|
||||||
bool enable;
|
bool enable;
|
||||||
EventControllerBindingEnable(bool e=false):enable(e){}
|
EventControllerBindingEnable(int id = 0, bool e=false):controllerID(id),enable(e){}
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventGridSelectClipEvent : public EventBase
|
class EventGridSelectClipEvent : public EventBase
|
||||||
|
|
|
@ -297,27 +297,29 @@ void handleGuiEvents()
|
||||||
if ( availableRead >= sizeof(EventControllerBindingEnable) ) {
|
if ( availableRead >= sizeof(EventControllerBindingEnable) ) {
|
||||||
EventControllerBindingEnable ev;
|
EventControllerBindingEnable ev;
|
||||||
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingEnable) );
|
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingEnable) );
|
||||||
|
ControllerUI* c = gui->getOptionsWindow()->getControllerUI( ev.controllerID );
|
||||||
// FIXME: needs to include controllerID!
|
if ( c )
|
||||||
//gui->getOptionsWindow()->setBindEnable( ev.enable );
|
c->setBindEnable( ev.enable );
|
||||||
|
else
|
||||||
|
LUPPP_WARN("ControllerUI %i doesn't exist in the UI", ev.controllerID );
|
||||||
} break; }
|
} break; }
|
||||||
|
|
||||||
case Event::CONTROLLER_BINDING_TARGET: {
|
case Event::CONTROLLER_BINDING_TARGET: {
|
||||||
if ( availableRead >= sizeof(EventControllerBindingTarget) ) {
|
if ( availableRead >= sizeof(EventControllerBindingTarget) ) {
|
||||||
EventControllerBindingTarget ev;
|
EventControllerBindingTarget ev;
|
||||||
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingTarget) );
|
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingTarget) );
|
||||||
|
gui->getOptionsWindow()->setTarget( ev.target );
|
||||||
// FIXME: needs to include controllerID!
|
|
||||||
//gui->getOptionsWindow()->setTarget( ev.target );
|
|
||||||
} break; }
|
} break; }
|
||||||
|
|
||||||
case Event::CONTROLLER_BINDING_MADE: {
|
case Event::CONTROLLER_BINDING_MADE: {
|
||||||
if ( availableRead >= sizeof(EventControllerBindingMade) ) {
|
if ( availableRead >= sizeof(EventControllerBindingMade) ) {
|
||||||
EventControllerBindingMade ev;
|
EventControllerBindingMade ev;
|
||||||
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingMade) );
|
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingMade) );
|
||||||
|
ControllerUI* c = gui->getOptionsWindow()->getControllerUI( ev.controllerID );
|
||||||
// FIXME: needs to include controllerID!
|
if ( c )
|
||||||
//gui->getOptionsWindow()->addBinding( (Binding*)ev.binding );
|
c->addBinding( (Binding*)ev.binding );
|
||||||
|
else
|
||||||
|
LUPPP_WARN("ControllerUI %i doesn't exist in the UI", ev.controllerID );
|
||||||
} break; }
|
} break; }
|
||||||
|
|
||||||
case Event::CONTROLLER_INSTANCE_GET_TO_WRITE: {
|
case Event::CONTROLLER_INSTANCE_GET_TO_WRITE: {
|
||||||
|
|
|
@ -27,6 +27,8 @@ static void addControllerUiDsp(OptionsWindow* self, GenericMIDI* c)
|
||||||
self->tabs->insert( *self->controllers.back()->widget, self->addGroup );
|
self->tabs->insert( *self->controllers.back()->widget, self->addGroup );
|
||||||
|
|
||||||
// tell the ControllerUI to add the bindings from this Controller*
|
// tell the ControllerUI to add the bindings from this Controller*
|
||||||
|
self->controllers.back()->setAuthor( c->getAuthor() );
|
||||||
|
self->controllers.back()->setEmail( c->getEmail() );
|
||||||
self->controllers.back()->addBindings( c );
|
self->controllers.back()->addBindings( c );
|
||||||
|
|
||||||
self->tabs->redraw();
|
self->tabs->redraw();
|
||||||
|
@ -44,7 +46,8 @@ static void writeBindEnable(Fl_Widget* w, void* data)
|
||||||
Avtk::LightButton* l = (Avtk::LightButton*)w;
|
Avtk::LightButton* l = (Avtk::LightButton*)w;
|
||||||
l->value( !l->value() );
|
l->value( !l->value() );
|
||||||
|
|
||||||
EventControllerBindingEnable e( l->value() );
|
int controllerID = -1; // waste?
|
||||||
|
EventControllerBindingEnable e( controllerID, l->value() );
|
||||||
writeToDspRingbuffer( &e );
|
writeToDspRingbuffer( &e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,15 +160,20 @@ ControllerUI::ControllerUI(int x, int y, int w, int h, std::string n, int ID)
|
||||||
|
|
||||||
widget = new Fl_Group( x, y, w, h, name);
|
widget = new Fl_Group( x, y, w, h, name);
|
||||||
{
|
{
|
||||||
targetLabelStat = new Fl_Box(x + 100,y + 5, 75, 25,"Target: ");
|
// author / link
|
||||||
targetLabel = new Fl_Box(x + 140,y + 5, 200, 25,"");
|
authorLabel = new Fl_Box( x, y + 0, 200, 30, "Author: -" );
|
||||||
bindEnable = new Avtk::LightButton(x + 5, y + 5, 100, 25, "Bind Enable");
|
emailLabel = new Fl_Box( x + w/2, y + 0, 200, 30, "Email: -" );
|
||||||
|
|
||||||
|
// binding / target
|
||||||
|
targetLabelStat = new Fl_Box(x + 100,y + 25, 75, 25,"Target: ");
|
||||||
|
targetLabel = new Fl_Box(x + 140,y + 25, 200, 25,"");
|
||||||
|
bindEnable = new Avtk::LightButton(x + 5, y + 25, 100, 25, "Bind Enable");
|
||||||
|
|
||||||
writeControllerBtn = new Avtk::Button( x + 5, y + h - 27, 100, 25, "Save" );
|
writeControllerBtn = new Avtk::Button( x + 5, y + h - 27, 100, 25, "Save" );
|
||||||
//ctlrButton = new Avtk::Button(x + 110, y + 275, 100, 25, "Load");
|
//ctlrButton = new Avtk::Button(x + 110, y + 275, 100, 25, "Load");
|
||||||
removeController = new Avtk::Button(x + 110, y + h - 27, 100, 25, "Remove");
|
removeController = new Avtk::Button(x + 110, y + h - 27, 100, 25, "Remove");
|
||||||
|
|
||||||
Fl_Scroll* s = new Fl_Scroll( x + 5, y + 35, 400, 180 );
|
Fl_Scroll* s = new Fl_Scroll( x + 5, y + 75, 400, 180 );
|
||||||
s->box( FL_UP_BOX );
|
s->box( FL_UP_BOX );
|
||||||
bindings = new Avtk::Bindings( x + 5, y + 35, 398, 10 );
|
bindings = new Avtk::Bindings( x + 5, y + 35, 398, 10 );
|
||||||
s->end();
|
s->end();
|
||||||
|
@ -182,7 +190,15 @@ ControllerUI::ControllerUI(int x, int y, int w, int h, std::string n, int ID)
|
||||||
writeControllerBtn->callback( writeControllerFile, this );
|
writeControllerBtn->callback( writeControllerFile, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerUI::setTarget(const char* n)
|
void OptionsWindow::setTarget(const char* n)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < controllers.size(); i++ )
|
||||||
|
{
|
||||||
|
controllers.at(i)->setTarget( n );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerUI::setTarget( const char* n )
|
||||||
{
|
{
|
||||||
if ( target )
|
if ( target )
|
||||||
free (target);
|
free (target);
|
||||||
|
@ -192,19 +208,45 @@ void ControllerUI::setTarget(const char* n)
|
||||||
targetLabel->redraw();
|
targetLabel->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControllerUI::setAuthor(std::string a)
|
||||||
|
{
|
||||||
|
stringstream s;
|
||||||
|
s << "Author: " << a;
|
||||||
|
author = s.str();
|
||||||
|
authorLabel->label( author.c_str() );
|
||||||
|
authorLabel->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerUI::setEmail(std::string e)
|
||||||
|
{
|
||||||
|
stringstream s;
|
||||||
|
s << "Email: " << e;
|
||||||
|
email = s.str();
|
||||||
|
emailLabel->label( email.c_str() );
|
||||||
|
emailLabel->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerUI::setBindEnable( bool b )
|
void ControllerUI::setBindEnable( bool b )
|
||||||
{
|
{
|
||||||
bindEnable->value( b );
|
bindEnable->value( b );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControllerUI::addBinding( Binding* b )
|
||||||
|
{
|
||||||
|
// add individual bindings as they're made
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerUI::addBindings( GenericMIDI* c )
|
void ControllerUI::addBindings( GenericMIDI* c )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// FIXME: add binding to Avtk::Binding here
|
// FIXME: add binding to Avtk::Binding here
|
||||||
std::vector<Binding*> bindingVector= c->getMidiToAction();
|
std::vector<Binding*> bindingVector= c->getMidiToAction();
|
||||||
|
|
||||||
for( int i = 0; i < bindingVector.size() && i < 5; i++ )
|
for(unsigned int i = 0; i < bindingVector.size() && i < 5; i++ )
|
||||||
{
|
{
|
||||||
bindings->add( bindingVector.at(i) );
|
bindings->add( bindingVector.at(i) );
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerUI::~ControllerUI()
|
ControllerUI::~ControllerUI()
|
||||||
|
|
|
@ -27,9 +27,13 @@ class ControllerUI
|
||||||
ControllerUI( int x, int y, int w, int h, std::string name,int id);
|
ControllerUI( int x, int y, int w, int h, std::string name,int id);
|
||||||
~ControllerUI();
|
~ControllerUI();
|
||||||
|
|
||||||
void setTarget(const char* n);
|
void setAuthor(std::string author);
|
||||||
|
void setEmail (std::string email );
|
||||||
|
|
||||||
|
void setTarget(const char* n);
|
||||||
void setBindEnable( bool b );
|
void setBindEnable( bool b );
|
||||||
|
|
||||||
|
void addBinding( Binding* b );
|
||||||
void addBindings( GenericMIDI* c );
|
void addBindings( GenericMIDI* c );
|
||||||
|
|
||||||
// the ControllerID this UI class represents
|
// the ControllerID this UI class represents
|
||||||
|
@ -45,6 +49,12 @@ class ControllerUI
|
||||||
private:
|
private:
|
||||||
// bindings
|
// bindings
|
||||||
char* target;
|
char* target;
|
||||||
|
|
||||||
|
std::string author;
|
||||||
|
std::string email;
|
||||||
|
Fl_Box* authorLabel;
|
||||||
|
Fl_Box* emailLabel;
|
||||||
|
|
||||||
Fl_Box* targetLabel;
|
Fl_Box* targetLabel;
|
||||||
Fl_Box* targetLabelStat;
|
Fl_Box* targetLabelStat;
|
||||||
Avtk::Bindings* bindings;
|
Avtk::Bindings* bindings;
|
||||||
|
@ -66,6 +76,7 @@ class OptionsWindow
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
|
void setTarget(const char* n);
|
||||||
ControllerUI* getControllerUI(int id);
|
ControllerUI* getControllerUI(int id);
|
||||||
|
|
||||||
// public for static methods only
|
// public for static methods only
|
||||||
|
|
Loading…
Reference in New Issue