zynaddsubfx

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

commit 7670f852d815c6919a2c13de5f53deb5d42b4ada
parent fd48567d6ab8dcbe63634855b9afeb0be78e0547
Author: fundamental <[email protected]>
Date:   Thu, 19 Feb 2015 13:39:22 -0500

Bank: Fix Mode Mutal-Exclusion And Init. Bank Sel

Diffstat:
Msrc/Misc/Bank.cpp | 8++++++++
Msrc/UI/BankView.cpp | 40+++++++++++++++++++++++++++-------------
Msrc/UI/BankView.h | 4++--
3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp @@ -51,7 +51,15 @@ Bank::Bank() { clearbank(); bankfiletitle = dirname; + rescanforbanks(); loadbank(config.cfg.currentBankDir); + + for(unsigned i=0; i<banks.size(); ++i) { + if(banks[i].dir == config.cfg.currentBankDir) { + bankpos = i; + break; + } + } } Bank::~Bank() diff --git a/src/UI/BankView.cpp b/src/UI/BankView.cpp @@ -21,17 +21,21 @@ void BankList::init(std::string path) void BankList::OSC_raw(const char *msg) { - if(strcmp(msg, "/bank-list")) - return; + if(!strcmp(msg, "/bank-list")) { - const int pos = rtosc_argument(msg, 0).i; - const char *path = rtosc_argument(msg, 1).s; + const int pos = rtosc_argument(msg, 0).i; + const char *path = rtosc_argument(msg, 1).s; - value(0); - if(pos == 0) - this->clear(); + value(0); + if(pos == 0) + this->clear(); - this->add(path); + this->add(path); + osc->write("/loadbank"); + } + if(!strcmp(msg, "/loadbank")) { + value(rtosc_argument(msg, 0).i); + } } BankSlot::BankSlot(int x,int y, int w, int h, const char *label) @@ -79,7 +83,7 @@ void BankSlot::update(const char *name__, const char *fname__) filename_ = fname__; snprintf(labelstr, 127, "%d. %s", nslot, name_.c_str()); label(labelstr); - + color(empty() ? 46 : 51); #ifdef NTK_GUI redraw(); @@ -124,13 +128,13 @@ highlight=0; void BankSlot::refresh() { if (bank->emptyslot(nslot)) color(46); - else if (bank->isPADsynth_used(nslot)) + else if (bank->isPADsynth_used(nslot)) color(26); - else + else color(51); - if (*nselected==nslot) + if (*nselected==nslot) color(6); @@ -150,6 +154,12 @@ static int modeCb(const char *label) return -1; } +static void modeButtonCb(Fl_Widget *w, void *v) +{ + BankViewControls *bvc = (BankViewControls*)v; + bvc->mode(modeCb(w->label())); +} + BankViewControls::BankViewControls(int x, int y, int w, int h, const char *label) :Fl_Group(x,y,w,h,label) { @@ -162,6 +172,10 @@ BankViewControls::BankViewControls(int x, int y, int w, int h, const char *label write = new Fl_Light_Button(x+m+1*W, y+m, W-2*m, h-2*m, "Write"); clear = new Fl_Light_Button(x+m+2*W, y+m, W-2*m, h-2*m, "Clear"); swap = new Fl_Light_Button(x+m+3*W, y+m, W-2*m, h-2*m, "Swap"); + read->callback(modeButtonCb, this); + write->callback(modeButtonCb, this); + clear->callback(modeButtonCb, this); + swap->callback(modeButtonCb, this); mode(1); } @@ -270,7 +284,7 @@ void BankView::react(int event, int nslot) //bank->savetoslot(slot,master->part[*npart]); //pthread_mutex_unlock(&master->part[*npart]->load_mutex); - bvc->mode(1);//readbutton->value(1);writebutton->value(0); + bvc->mode(1); } diff --git a/src/UI/BankView.h b/src/UI/BankView.h @@ -37,7 +37,7 @@ class BankSlot : public Fl_Button std::string name_; std::string filename_; char labelstr[128]; - int nslot; + int nslot; BankView *bv; }; @@ -56,7 +56,7 @@ class BankViewControls: public Fl_Group Fl_Light_Button *write; Fl_Light_Button *clear; Fl_Light_Button *swap; - + //1 -> read //2 -> write //3 -> clear