commit 12195122fe66b503d61bfb36f39e29471e8444e4
parent 8b4cc9ebbf39ed0752693bf318d90ae37eeaff3b
Author: Hans Petter Selasky <[email protected]>
Date: Wed, 2 Aug 2017 22:52:15 +0200
Add support for searching banks by name in the FLTK GUI.
Signed-off-by: Hans Petter Selasky <[email protected]>
Diffstat:
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/UI/BankUI.fl b/src/UI/BankUI.fl
@@ -23,6 +23,9 @@ decl {\#include <FL/Fl_Button.H>} {public local
decl {\#include <FL/Fl_File_Chooser.H>} {public local
}
+decl {\#include <FL/Fl_Input.H>} {public local
+}
+
decl {\#include "Fl_Osc_Interface.h"} {public local
}
@@ -95,6 +98,15 @@ refreshmainwindow();}
banklist->value(0);}
tooltip {Refresh the bank list (rescan)} xywh {230 8 105 20} box THIN_UP_BOX color 50 labelsize 11
}
+ Fl_Input {} {
+ label {Search by name: }
+ code0 {o->when(FL_WHEN_CHANGED);}
+ callback {
+ std::string str = o->value();
+ update_search(str)}
+ tooltip {Enter text to search for}
+ xywh {460 8 105 20} box THIN_UP_BOX color 50 labelsize 11
+ }
}
}
Function {BankUI(int *npart_, Fl_Osc_Interface *osc_)} {open
@@ -139,6 +151,15 @@ bankview->refresh();} {}
if (banklist->size() == 0)
banklist->add(" ");} {}
}
+ Function {update_search(std::string search_string)} {open
+ } {
+ code {if (search_string.empty()) {
+ refreshmainwindow();
+} else {
+ osc->write("/bank/search", "s", search_string.c_str());
+}
+ } {}
+ }
decl {Fl_Osc_Interface *osc;} {private local
}
decl {Fl_Valuator *cbwig;} {public local
diff --git a/src/UI/BankView.cpp b/src/UI/BankView.cpp
@@ -232,8 +232,10 @@ BankView::BankView(int x,int y, int w, int h, const char *label)
BankView::~BankView(void)
{
- if(osc)
- osc->removeLink("/bankview", this);
+ if(osc) {
+ osc->removeLink("/bankview", this);
+ osc->removeLink("/bank/search_results", this);
+ }
}
void BankView::init(Fl_Osc_Interface *osc_, BankViewControls *bvc_, int *npart_)
@@ -245,6 +247,7 @@ void BankView::init(Fl_Osc_Interface *osc_, BankViewControls *bvc_, int *npart_)
npart = npart_;
osc->createLink("/bankview", this);
+ osc->createLink("/bank/search_results", this);
//Element Size
const float width = w()/5.0;
@@ -346,14 +349,30 @@ void BankView::react(int event, int nslot)
void BankView::OSC_raw(const char *msg)
{
- if(!strcmp(rtosc_argument_string(msg), "iss")) {
+ if(!strcmp(msg, "/bank/search_results")) {
+ const char *ptr = rtosc_argument_string(msg);
+ int slot = 0;
+
+ while (ptr[0] == 's' && ptr[1] == 's') {
+ const char *bank = rtosc_argument(msg, 2*slot).s;
+ const char *fname = rtosc_argument(msg, 2*slot + 1).s;
+
+ /* store search results directly into slot */
+ slots[slot]->update(bank, fname);
+ if (++slot == 160)
+ break;
+ ptr += 2;
+ }
+ while (slot < 160)
+ slots[slot++]->update("", "");
+ } else if(!strcmp(rtosc_argument_string(msg), "iss")) {
int nslot = rtosc_argument(msg,0).i;
const char *name = rtosc_argument(msg,1).s;
const char *fname = rtosc_argument(msg,2).s;
if(0 <= nslot && nslot < 160)
slots[nslot]->update(name, fname);
- } if(!strcmp(rtosc_argument_string(msg), "ss")) {
+ } else if(!strcmp(rtosc_argument_string(msg), "ss")) {
while(*msg && !isdigit(*msg)) msg++;
int nslot = atoi(msg);
const char *name = rtosc_argument(msg,0).s;