zynaddsubfx

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

PresetsUI.fl (9955B)


      1 # data file for the Fltk User Interface Designer (fluid)
      2 version 1.0110 
      3 header_name {.h} 
      4 code_name {.cc}
      5 decl {\#include <FL/fl_ask.H>} {selected public
      6 } 
      7 
      8 decl {\#include <cstdio>} {public
      9 } 
     10 
     11 decl {\#include <cstdlib>} {public
     12 } 
     13 
     14 decl {\#include <string>} {public
     15 } 
     16 
     17 decl {\#include "Osc_ListModel.h"} {public
     18 } 
     19 
     20 decl {\#include "Osc_DataModel.h"} {public
     21 } 
     22 
     23 class PresetsUI_ {} {
     24     Function {refresh()} {open return_type {virtual void}
     25     } {
     26         code {;} {}
     27     }
     28     Function {~PresetsUI_()} {open return_type virtual
     29     } {
     30         code {;} {}
     31     }
     32 } 
     33 
     34 class PresetsUI {} {
     35     Function {PresetsUI(Fl_Osc_Interface *osc_):listmodel(osc_), datamodel(osc_)} {} {
     36         code {osc = osc_;
     37             arraymode = false;
     38             make_window();
     39             listmodel.callback = [this](Osc_ListModel::list_t list) {
     40                 copybrowse->clear();
     41                 pastebrowse->clear();
     42                 files.clear();
     43                 printf("adding entries<%s>...\\n", datamodel.value.c_str());
     44                 if(datamodel.value.empty())
     45                     return; 
     46                 for(unsigned i=0;i<list.size();++i){
     47                     std::string type = std::get<2>(list[i]);
     48                     std::string comp = datamodel.value.substr(1);
     49                     if(arraymode)
     50                         comp += "n";
     51                     bool same = comp == type;
     52                     same |= strstr(type.c_str(), "Plfo") && strstr(comp.c_str(), "Plfo");
     53                     if(!same)
     54                         continue;
     55                     files.push_back(std::get<0>(list[i]));
     56                     copybrowse->add(std::get<1>(list[i]).c_str());
     57                     pastebrowse->add(std::get<1>(list[i]).c_str());
     58             }};
     59             datamodel.callback = [this](Osc_DataModel::value_t val) {
     60                 printf("Value = %s\\n", val.c_str());
     61                 copytypetext->label(val.c_str());
     62                 pastetypetext->label(val.c_str());
     63                 listmodel.doUpdate("/presets/scan-for-presets");
     64             };
     65         
     66         } {}
     67     }
     68     Function {~PresetsUI()} {} {
     69         code {copywin->hide();delete(copywin);
     70             pastewin->hide();delete(pastewin);} {}
     71     }
     72     Function {make_window()} {} {
     73         Fl_Window copywin {
     74             label {Copy to Clipboard/Preset}
     75             xywh {190 173 265 430} type Double box THIN_UP_BOX color 238 hide modal
     76         } {
     77             Fl_Browser copybrowse {
     78                 callback {int val=o->value();
     79                     if (val!=0){
     80                         presetname->cut(0,presetname->maximum_size());
     81                         presetname->insert(o->text(val));
     82                     };}
     83                 xywh {10 25 245 320} type Select
     84             }
     85             Fl_Button copypbutton {
     86                 label {Copy to Preset}
     87                 callback {const char *tmp=presetname->value();
     88                     if (tmp!=NULL) {
     89                         if (strlen(tmp)>0){
     90                             if(arraymode)
     91                                 osc->write("/presets/copy", "ssi", url.c_str(), tmp, arrayidx);
     92                             else
     93                                 osc->write("/presets/copy", "ss", url.c_str(), tmp);
     94                             copywin->hide();
     95                         };
     96                     };}
     97                 xywh {145 355 110 20} box THIN_UP_BOX
     98             }
     99             Fl_Button copybutton {
    100                 label {Copy to Clipboard}
    101                 callback {
    102                     if(arraymode)
    103                         osc->write("/presets/copy", "si", url.c_str(), arrayidx);
    104                     else
    105                         osc->write("/presets/copy", "s", url.c_str());
    106                     copywin->hide();}
    107                 xywh {25 385 90 35} box THIN_UP_BOX align 192
    108             }
    109             Fl_Button {} {
    110                 label Cancel
    111                     callback {copywin->hide();}
    112                 xywh {160 385 80 35} box THIN_UP_BOX align 192
    113             }
    114             Fl_Box {} {
    115                 label {Type:}
    116                 xywh {10 5 40 15} labelsize 11 align 20
    117             }
    118             Fl_Box copytypetext {
    119                 xywh {50 5 205 15} box FLAT_BOX color 238 labelfont 1 labelsize 11 align 20
    120             }
    121             Fl_Input presetname {
    122                 callback {const char *tmp=o->value();
    123                     if (tmp==NULL) tmp="";
    124                     if (strlen(tmp)>0) {
    125                         copybutton->deactivate();
    126                         copypbutton->activate();
    127                     } else {
    128                         copybutton->activate();
    129                         copypbutton->deactivate();
    130                     };}
    131                 xywh {10 355 130 20} when 1
    132             }
    133         }
    134         Fl_Window pastewin {
    135             label {Paste from Clipboard/Preset}
    136             xywh {463 173 265 430} type Double box THIN_UP_BOX color 238 hide modal
    137         } {
    138             Fl_Browser pastebrowse {
    139                 callback {if (o->value()==0) {
    140                     pastepbutton->deactivate();
    141                     deletepbutton->deactivate();
    142                 }else{
    143                     pastepbutton->activate();
    144                     deletepbutton->activate();
    145                 };}
    146                 xywh {10 25 245 320} type Hold
    147             }
    148             Fl_Button pastepbutton {
    149                 label {Paste from Preset}
    150                 callback {int n=pastebrowse->value()-1;
    151                     if (n>=0){
    152                         if(arraymode)
    153                             osc->write("/presets/paste", "ssi", url.c_str(), files[n].c_str(), arrayidx);
    154                         else
    155                             osc->write("/presets/paste", "ss", url.c_str(), files[n].c_str());
    156                     }
    157                     pastewin->hide();
    158                     pui->refresh();}
    159                 xywh {10 355 160 20} box THIN_UP_BOX
    160             }
    161             Fl_Button pastebutton {
    162                 label {Paste from Clipboard}
    163                 callback {
    164                     if(arraymode)
    165                         osc->write("/presets/paste", "si", url.c_str(), arrayidx);
    166                     else
    167                         osc->write("/presets/paste", "s", url.c_str());
    168                     pastewin->hide();
    169                     pui->refresh();}
    170                 xywh {25 385 90 35} box THIN_UP_BOX align 192
    171             }
    172             Fl_Button {} {
    173                 label Cancel
    174                     callback {pastewin->hide();}
    175                 xywh {160 385 80 35} box THIN_UP_BOX align 192
    176             }
    177             Fl_Box pastetypetext {
    178                 xywh {55 5 200 15} box FLAT_BOX color 238 labelfont 1 labelsize 11 align 20
    179             }
    180             Fl_Box {} {
    181                 label {Type:}
    182                 xywh {15 5 40 15} labelsize 11 align 20
    183             }
    184             Fl_Button deletepbutton {
    185                 label Delete
    186                     callback {int n=pastebrowse->value()-1;
    187 
    188                         if (n>=0) {
    189                             osc->write("/presets/delete", "s", files[n].c_str());
    190                         }
    191                         rescan(url);
    192                     } selected
    193                 xywh {180 355 75 20} box THIN_UP_BOX
    194             }
    195         }
    196     }
    197     Function {paste(std::string url_, PresetsUI_ *pui, int idx)} {} {code {
    198     url = url_;
    199     this->pui=pui;
    200     bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
    201     pastepbutton->deactivate();
    202     deletepbutton->deactivate();
    203     arraymode = true;
    204     arrayidx  = idx;
    205 
    206     if(but) {
    207         osc->write("/presets/paste", "si", url.c_str(), idx);
    208         pui->refresh();
    209     } else {
    210         rescan(url_);
    211         pastewin->show();
    212     }
    213     } {}}
    214     Function {copy(std::string url_, int idx)} {} {code {
    215         copybutton->activate();
    216         copypbutton->deactivate();
    217         arraymode = true;
    218         arrayidx  = idx;
    219         url = url_;
    220         this->pui=NULL;
    221         bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
    222         presetname->cut(0,presetname->maximum_size());
    223 
    224         if(but) {
    225             osc->write("/presets/copy", "si", url_.c_str(), idx);
    226         } else {
    227             rescan(url_);
    228             copywin->show();
    229         }
    230     } {}}
    231     Function {copy(std::string url_)} {} {
    232         code {
    233             copybutton->activate();
    234             copypbutton->deactivate();
    235             arraymode = false;
    236 
    237             url = url_;
    238             this->pui=NULL;
    239             bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
    240             presetname->cut(0,presetname->maximum_size());
    241 
    242             if(but) {
    243                 osc->write("/presets/copy", "s", url_.c_str());
    244             } else {
    245                 rescan(url_);
    246                 copywin->show();
    247             };} {}
    248     }
    249     Function {paste(std::string url_, PresetsUI_ *pui)} {} {
    250         code {
    251             url = url_;
    252             this->pui=pui;
    253             bool but=(Fl::event_button()!=FL_LEFT_MOUSE);
    254             pastepbutton->deactivate();
    255             deletepbutton->deactivate();
    256             arraymode = false;
    257 
    258             if(but) {
    259                 osc->write("/presets/paste", "s", url.c_str());
    260                 pui->refresh();
    261             } else {
    262                 rescan(url_);
    263                 pastewin->show();
    264             };} {}
    265     }
    266     Function {rescan(std::string url)} {} {
    267         code {copybrowse->clear();
    268             pastebrowse->clear();
    269 
    270             printf("Datamodel Update...");
    271             datamodel.doUpdate(url+"preset-type");
    272             } {}
    273     }
    274     decl {std::string url;} {public local
    275     }
    276     decl {Fl_Osc_Interface *osc;} {public local
    277     }
    278     decl {Osc_ListModel listmodel;} {public local
    279     }
    280     decl {Osc_DataModel datamodel;} {public local
    281     }
    282     decl {std::vector<std::string> files;} {public local
    283     }
    284     decl {bool arraymode;} {public local
    285     }
    286     decl {int arrayidx;} {public local
    287     }
    288     decl {PresetsUI_ *pui;} {public local
    289     }
    290 } 
    291 
    292 decl {PresetsUI *presetsui;} {public
    293 }