Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

369 lines
11KB

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0110
  3. header_name {.h}
  4. code_name {.cc}
  5. decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
  6. decl {//License: GNU GPL version 2 or later} {}
  7. decl {\#include <stdlib.h>} {public
  8. }
  9. decl {\#include <stdio.h>} {public
  10. }
  11. decl {\#include <string.h>} {public
  12. }
  13. decl {\#include <FL/Fl_Button.H>} {public
  14. }
  15. decl {\#include <FL/Fl_File_Chooser.H>} {public
  16. }
  17. decl {\#include "../Misc/Master.h"} {public
  18. }
  19. decl {\#include "../Misc/Part.h"} {public
  20. }
  21. decl {\#include "../Misc/Bank.h"} {public
  22. }
  23. decl {\#include "../Misc/Config.h"} {public
  24. }
  25. decl {\#include "../Misc/Util.h"} {public
  26. }
  27. class BankProcess_ {} {
  28. Function {process()} {open return_type {virtual void}
  29. } {
  30. code {;} {}
  31. }
  32. decl {Bank *bank;} {public
  33. }
  34. }
  35. class BankSlot {open : {public Fl_Button,BankProcess_}
  36. } {
  37. Function {BankSlot(int x,int y, int w, int h, const char *label=0):Fl_Button(x,y,w,h,label)} {open
  38. } {
  39. code {what=NULL;
  40. whatslot=NULL;
  41. nslot=0;
  42. nselected=NULL;} {selected
  43. }
  44. }
  45. Function {handle(int event)} {return_type int
  46. } {
  47. code {if (what==NULL) return(0);
  48. if (Fl::event_inside(this)){
  49. *what=0;*whatslot=nslot;
  50. if ((event==FL_RELEASE)&&(Fl::event_button()==1))*what=1;
  51. if ((event==FL_RELEASE)&&(Fl::event_button()==3))*what=2;
  52. if (event==FL_PUSH) highlight=1;
  53. }else highlight=0;
  54. int tmp=Fl_Button::handle(event);
  55. if ((*what!=0) && Fl::event_inside(this)) (bp->*fnc)();
  56. return(tmp);} {}
  57. }
  58. Function {init(int nslot_, int *what_, int *whatslot_,void (BankProcess_:: *fnc_)(void),BankProcess_ *bp_,Bank *bank_,int *nselected_)} {} {
  59. code {nslot=nslot_;
  60. what=what_;
  61. whatslot=whatslot_;
  62. fnc=fnc_;
  63. bp=bp_;
  64. bank=bank_;
  65. nselected=nselected_;
  66. box(FL_THIN_UP_BOX);
  67. labelfont(0);
  68. labelsize(13);
  69. align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
  70. highlight=0;
  71. refresh();} {}
  72. }
  73. Function {refresh()} {} {
  74. code {if (bank->emptyslot(nslot))
  75. color(46);
  76. else if (bank->isPADsynth_used(nslot))
  77. color(124);
  78. else
  79. color(51);
  80. if (*nselected==nslot)
  81. color(6);
  82. copy_label(bank->getnamenumbered(nslot).c_str());} {}
  83. }
  84. decl {int *what,*whatslot,nslot,highlight, *nselected;} {}
  85. decl {void (BankProcess_:: *fnc)(void);} {}
  86. decl {BankProcess_ *bp;} {}
  87. }
  88. class BankUI {open : {public BankProcess_}
  89. } {
  90. Function {make_window()} {open
  91. } {
  92. Fl_Window bankuiwindow {
  93. label Bank
  94. xywh {492 406 785 575} type Double
  95. code0 {o->label(bank->bankfiletitle.c_str());}
  96. code1 {if (bank->bankfiletitle.empty()) o->label ("Choose a bank from the bank list on the left (or go to settings if to configure the bank location) or choose 'New Bank...' to make a new bank.");} visible
  97. } {
  98. Fl_Button {} {
  99. label Close
  100. callback {bankuiwindow->hide();}
  101. xywh {705 546 70 24} box THIN_UP_BOX
  102. }
  103. Fl_Group {} {
  104. xywh {5 34 772 491} box ENGRAVED_FRAME
  105. } {
  106. Fl_Pack {} {
  107. xywh {10 39 150 481} box BORDER_FRAME
  108. code0 {o->box(FL_NO_BOX);}
  109. code1 {for (int i=0;i<32;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
  110. } {}
  111. Fl_Pack {} {
  112. xywh {163 39 150 481} box BORDER_FRAME
  113. code0 {o->box(FL_NO_BOX);}
  114. code1 {for (int i=32;i<64;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
  115. } {}
  116. Fl_Pack {} {
  117. xywh {316 39 150 481} box BORDER_FRAME
  118. code0 {o->box(FL_NO_BOX);}
  119. code1 {for (int i=64;i<96;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
  120. } {}
  121. Fl_Pack {} {
  122. xywh {469 39 150 481} box BORDER_FRAME
  123. code0 {o->box(FL_NO_BOX);}
  124. code1 {for (int i=96;i<128;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
  125. } {}
  126. Fl_Pack {} {
  127. xywh {622 39 150 481} box BORDER_FRAME
  128. code0 {o->box(FL_NO_BOX);}
  129. code1 {for (int i=128;i<160;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
  130. } {}
  131. }
  132. Fl_Group modeselect {
  133. xywh {5 528 425 42} box ENGRAVED_BOX
  134. } {
  135. Fl_Check_Button writebutton {
  136. label WRITE
  137. callback {if (o->value()>0.5) mode=2;
  138. removeselection();}
  139. xywh {116 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
  140. code0 {if (bank->locked()) o->deactivate();}
  141. }
  142. Fl_Check_Button readbutton {
  143. label READ selected
  144. callback {if (o->value()>0.5) mode=1;
  145. removeselection();}
  146. xywh {11 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
  147. code0 {o->value(1);}
  148. }
  149. Fl_Check_Button clearbutton {
  150. label CLEAR
  151. callback {if (o->value()>0.5) mode=3;
  152. removeselection();}
  153. xywh {221 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
  154. code0 {if (bank->locked()) o->deactivate();}
  155. }
  156. Fl_Check_Button swapbutton {
  157. label SWAP
  158. callback {if (o->value()>0.5) mode=4;
  159. removeselection();}
  160. xywh {325 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
  161. code0 {if (bank->locked()) o->deactivate();}
  162. }
  163. }
  164. Fl_Button {} {
  165. label {New Bank...}
  166. callback {const char *dirname;
  167. dirname=fl_input("New empty Bank:");
  168. if (dirname==NULL) return;
  169. int result=bank->newbank(dirname);
  170. if (result!=0) fl_alert("Error: Could not make a new bank (directory)..");
  171. refreshmainwindow();}
  172. xywh {685 5 93 25} labelfont 1 labelsize 11 align 128
  173. }
  174. Fl_Check_Button {} {
  175. label {auto close}
  176. callback {config.cfg.BankUIAutoClose=(int) o->value();}
  177. tooltip {automatically close the bank window if the instrument is loaded} xywh {705 529 60 15} down_box DOWN_BOX labelsize 10
  178. code0 {o->value(config.cfg.BankUIAutoClose);}
  179. }
  180. Fl_Choice banklist {
  181. callback {int n=o->value();
  182. std::string dirname=bank->banks[n].dir;
  183. if (dirname.empty()) return;
  184. if (bank->loadbank(dirname)==2)
  185. fl_alert("Error: Could not load the bank from the directory\\n%s.",dirname.c_str());
  186. for (int i=0;i<BANK_SIZE;i++) bs[i]->refresh();
  187. refreshmainwindow();}
  188. xywh {5 8 220 20} down_box BORDER_BOX labelfont 1 align 0 textfont 1 textsize 11
  189. } {}
  190. Fl_Button {} {
  191. label {Refresh bank list}
  192. callback {rescan_for_banks();
  193. banklist->value(0);}
  194. tooltip {Refresh the bank list (rescan)} xywh {230 8 105 20} box THIN_UP_BOX color 50 labelsize 11
  195. }
  196. Fl_Check_Button {} {
  197. label {Show PADsynth status}
  198. callback {config.cfg.CheckPADsynth=(int) o->value();
  199. refreshmainwindow();}
  200. xywh {435 530 150 15} down_box DOWN_BOX labelsize 11
  201. code0 {o->value(config.cfg.CheckPADsynth);}
  202. }
  203. }
  204. }
  205. Function {BankUI(Master *master_,int *npart_)} {} {
  206. code {fnc=&BankProcess_::process;
  207. master=master_;
  208. npart=npart_;
  209. bank=&master_->bank;
  210. what=0;
  211. nselected=-1;
  212. make_window();
  213. mode=1;} {}
  214. }
  215. Function {~BankUI()} {return_type virtual
  216. } {
  217. code {bankuiwindow->hide();
  218. delete(bankuiwindow);} {}
  219. }
  220. Function {show()} {} {
  221. code {bankuiwindow->show();
  222. simplesetmode(config.cfg.UserInterfaceMode==2);} {}
  223. }
  224. Function {hide()} {} {
  225. code {bankuiwindow->hide();} {}
  226. }
  227. Function {init(Fl_Valuator *cbwig_)} {} {
  228. code {cbwig=cbwig_;
  229. rescan_for_banks();} {}
  230. }
  231. Function {process()} {return_type void
  232. } {
  233. code {int slot=this->slot;
  234. if ((what==2)&&(bank->emptyslot(slot)==0)&&(mode!=4)) {//Rename slot
  235. const char *tmp=fl_input("Slot (instrument) name:",bank->getname(slot).c_str());
  236. if (tmp!=NULL) bank->setname(slot,tmp,-1);
  237. bs[slot]->refresh();
  238. };
  239. if ((what==1)&&(mode==1)&&(!bank->emptyslot(slot))){//Reads from slot
  240. pthread_mutex_lock(&master->part[*npart]->load_mutex);
  241. bank->loadfromslot(slot,master->part[*npart]);
  242. pthread_mutex_unlock(&master->part[*npart]->load_mutex);
  243. master->part[*npart]->applyparameters();
  244. snprintf((char *)master->part[*npart]->Pname,PART_MAX_NAME_LEN,"%s",bank->getname(slot).c_str());
  245. cbwig->do_callback();
  246. if (config.cfg.BankUIAutoClose!=0)
  247. bankuiwindow->hide();
  248. };
  249. if ((what==1)&&(mode==2)){//save(write) to slot
  250. if (!bank->emptyslot(slot)){
  251. if (!fl_choice("Overwrite the slot no. %d ?","No","Yes",NULL,slot+1)) goto nooverwriteslot;
  252. };
  253. pthread_mutex_lock(&master->part[*npart]->load_mutex);
  254. bank->savetoslot(slot,master->part[*npart]);
  255. pthread_mutex_unlock(&master->part[*npart]->load_mutex);
  256. bs[slot]->refresh();
  257. mode=1;readbutton->value(1);writebutton->value(0);
  258. nooverwriteslot:;
  259. };
  260. if ((what==1)&&(mode==3)&&(!bank->emptyslot(slot))){//Clears the slot
  261. if (fl_choice("Clear the slot no. %d ?","No","Yes",NULL,slot+1)){
  262. bank->clearslot(slot);
  263. bs[slot]->refresh();
  264. };
  265. };
  266. if (mode==4){//swap
  267. bool done=false;
  268. if ((what==1)&&(nselected>=0)){
  269. bank->swapslot(nselected,slot);
  270. int ns=nselected;
  271. nselected=-1;
  272. bs[slot]->refresh();
  273. bs[ns]->refresh();
  274. done=true;
  275. };
  276. if (((nselected<0)||(what==2))&&(!done)){
  277. int ns=nselected;
  278. nselected=slot;
  279. if (ns>0) bs[ns]->refresh();
  280. bs[slot]->refresh();
  281. };
  282. };
  283. if (mode!=4) refreshmainwindow();} {}
  284. }
  285. Function {refreshmainwindow()} {} {
  286. code {bankuiwindow->label(bank->bankfiletitle.c_str());
  287. mode=1;readbutton->value(1);writebutton->value(0);clearbutton->value(0);swapbutton->value(0);
  288. nselected=-1;
  289. if (bank->locked()){
  290. writebutton->deactivate();
  291. clearbutton->deactivate();
  292. swapbutton->deactivate();
  293. } else {
  294. writebutton->activate();
  295. clearbutton->activate();
  296. swapbutton->activate();
  297. };
  298. for (int i=0;i<BANK_SIZE;i++)
  299. bs[i]->refresh();} {}
  300. }
  301. Function {removeselection()} {} {
  302. code {if (nselected>=0) {
  303. int ns=nselected;
  304. nselected=-1;
  305. bs[ns]->refresh();
  306. };} {}
  307. }
  308. Function {rescan_for_banks()} {} {
  309. code {banklist->clear();
  310. bank->rescanforbanks();
  311. for (unsigned int i=0;i<bank->banks.size();i++) {
  312. banklist->add(bank->banks[i].name.c_str());
  313. }
  314. if (banklist->size() == 0)
  315. banklist->add(" ");} {}
  316. }
  317. Function {simplesetmode(bool beginnerui)} {} {
  318. code {readbutton->value(1);
  319. mode=1;
  320. removeselection();
  321. if (beginnerui) modeselect->hide();
  322. else modeselect->show();} {}
  323. }
  324. decl {BankSlot *bs[BANK_SIZE];} {}
  325. decl {int slot,what;//"what"=what button is pressed} {}
  326. decl {int mode,*npart,nselected;} {}
  327. decl {Master *master;} {}
  328. decl {void (BankProcess_::* fnc)(void);} {}
  329. decl {Fl_Valuator *cbwig;} {public
  330. }
  331. }