Collection of tools useful for audio production
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.

378 lines
11KB

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