# data file for the Fltk User Interface Designer (fluid)
version 1.0302 
header_name {.h} 
code_name {.cc}
decl {//Copyright (c) 2002-2009 Nasca Octavian Paul - (c) 2009-2017 Mark McCurry} {private local
} 

decl {//License: GNU GPL version 2 or later} {private local
} 

decl {\#include <stdlib.h>} {public local
} 

decl {\#include <stdio.h>} {public local
} 

decl {\#include <string.h>} {public local
} 

decl {\#if ! defined(PLUGINVERSION) && HAS_X11
\#include "zynaddsubfx.xpm"
\#endif} {private local
} 

decl {\#include "WidgetPDial.h"} {public local
} 

decl {\#include "ADnoteUI.h"} {public local
} 

decl {\#include "SUBnoteUI.h"} {public local
} 

decl {\#include "EffUI.h"} {public local
} 

decl {\#include "VirKeyboard.h"} {public local
} 

decl {\#include "ConfigUI.h"} {public local
} 

decl {\#include "BankUI.h"} {public local
} 

decl {\#include "PartUI.h"} {public local
} 

decl {\#include "MicrotonalUI.h"} {public local
} 

decl {\#include "PresetsUI.h"} {public local
} 

decl {\#include "NioUI.h"} {public global
} 

decl {\#include "VuPartMeter.h"} {public local
} 

decl {\#include "Fl_Osc_Dial.H"} {private local
} 

decl {\#include "Osc_DataModel.h"} {private local
} 

decl {\#include "Fl_Osc_TSlider.H"} {private local
} 

decl {\#include "VuMasterMeter.h"} {public local
} 

decl {\#include "PartNameButton.h"} {public local
} 

decl {\#include "common.H"} {public local
} 

decl {\#if USE_NSM
\#include "NSM.H"
extern NSM_Client *nsm;
\#endif} {public local
} 

decl {\#if !defined(PLUGINVERSION) && HAS_X11
\#include <X11/xpm.h>
\#endif} {public local
} 

decl {\#include "../globals.h"} {public local
} 

class SysEffSend {: {public Fl_Osc_Dial}
} {
  Function {SysEffSend(int x,int y, int w, int h, const char *label=0):Fl_Osc_Dial(x,y,w,h,label)} {} {
    code {} {}
  }
  Function {init(int neff1,int neff2)} {} {
    code {//TODO figure out if this extra class is even needed
minimum(0);
maximum(127);
step(1);
labelfont(1);
labelsize(10);
align(FL_ALIGN_TOP);

Fl_Osc_Dial::init("part"+to_s(neff1)+"/sysefxsend"+to_s(neff2));
char tmp[20];snprintf(tmp,20,"%d->%d",neff1+1,neff2+1);
this->copy_label(tmp);} {}
  }
  Function {~SysEffSend()} {} {
    code {hide();} {}
  }
} 

class Panellistitem {open : {public Fl_Osc_Group}
} {
  Function {make_window()} {open private
  } {
    Fl_Window panellistitem {open
      private xywh {632 715 100 260} type Double box NO_BOX
      class Fl_Group visible
    } {
      Fl_Group panellistitemgroup {open
        private xywh {0 20 70 240} box UP_FRAME
        code0 {/*if (master->part[npart]->Penabled==0) o->deactivate();*/}
        code1 {set_module_parameters( o );}
      } {
        Fl_Group {} {open
          xywh {45 65 15 110} box ENGRAVED_FRAME
        } {
          Fl_Box partvu {
            label {V U}
            xywh {45 65 15 110} box FLAT_BOX color 0 selection_color 75 labelcolor 55 align 128
            class VuPartMeter
          }
        }
        Fl_Button partname {
          label {  }
          callback {if ((int)bankui->cbwig->value()!=(npart+1)){
   bankui->cbwig->value(npart+1);
   bankui->cbwig->do_callback();
};
bankui->show();}
          xywh {5 27 60 30} box THIN_DOWN_BOX down_box FLAT_BOX labelfont 1 labelsize 10 align 208
          code0 {o->ext = "Pname";o->oscRegister("Pname");}
          class PartNameButton
        }
        Fl_Slider partvolume {
          xywh {10 65 30 110} type {Vert Knob} box NO_BOX minimum 127 maximum 0 step 1 value 127
          code0 {o->init("Pvolume", 'i');o->reset_value=96;}
          class Fl_Osc_TSlider
        }
        Fl_Dial partpanning {
          xywh {20 180 30 30} maximum 127 step 1
          code0 {o->init("Ppanning");o->reset_value=64;}
          class Fl_Osc_Dial
        }
        Fl_Button {} {
          label edit
          callback {if ((int)bankui->cbwig->value()!=(npart+1)){
   bankui->cbwig->value(npart+1);
   bankui->cbwig->do_callback();
   }
   if (Fl::event_shift())
        partui->instrumenteditwindow->show();
   else if (Fl::event_ctrl())
        partui->instrumentkitlist->show();
}
          xywh {15 235 40 20} labelsize 10
        }
        Fl_Choice partrcv {
          tooltip {receive from Midi channel} xywh {10 213 50 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
          code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};}
          code1 {o->init("Prcvchn");}
          class Fl_Osc_Choice
        } {}
      }
      Fl_Check_Button partenabled {
        label 01
        callback {
            if ((int) o->value()==0) panellistitemgroup->deactivate();
            else {
                panellistitemgroup->activate();
            };

            o->redraw();}
        private xywh {5 0 45 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 24
        code0 {char tmp[10];snprintf(tmp,10,"%d",npart+1);o->copy_label(tmp);}
        code1 {o->init("Penabled");}
        class Fl_Osc_Check
      }
    }
  }
  Function {Panellistitem(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
    code {npart=0;
bankui=NULL;} {}
  }
  Function {init(int npart_,BankUI *bankui_, PartUI *partui_)} {} {
    code {npart=npart_;
bankui=bankui_;
partui=partui_;
ext = "part"+to_s(npart)+"/";

make_window();
panellistitem->show();
end();} {}
  }
  Function {refresh()} {} {
    code {
    partenabled->update();
    partrcv->update();
    partpanning->update();
    partvolume->update();
    partname->update();
    
    if ((int)bankui->cbwig->value()!=(npart+1))
   panellistitemgroup->color(fl_rgb_color(160,160,160));
else 
   panellistitemgroup->color(fl_rgb_color(50,190,240));

panellistitemgroup->redraw();} {}
  }
  Function {~Panellistitem()} {} {
    code {} {}
  }
  decl {int npart;} {private local
  }
  decl {BankUI *bankui;} {private local
  }
  decl {PartUI *partui;} {private local
  }
} 

class MasterUI {open
} {
  Function {make_window()} {open
  } {
    Fl_Window masterwindow {
      label zynaddsubfx
      callback {if ((isPlugin
\#if USE_NSM
 || (nsm && nsm->is_active())
\#endif
 || fl_choice("Exit and leave the unsaved data?","No","Yes",NULL))) {
    close();
};} open
      xywh {330 365 390 525} type Double xclass zynaddsubfx visible
      class Fl_Osc_Window
    } {
        Fl_Box dummy_again {
          xywh {25 25 25 25}
          code0 {masterwindow->init(osc, "");}
        }

      Fl_Group win_root {open
        xywh {0 0 390 525}
        class Fl_Osc_Group
      } {
        Fl_Menu_Bar mastermenu {
          xywh {0 0 390 25}
        } {
          Submenu {} {
            label {&File}
            xywh {5 5 100 20}
          } {
            MenuItem {} {
              label {&New (erase all)...}
              callback {do_new_master();}
              xywh {25 25 100 20}
            }
            MenuItem {} {
              label {&Revert changes...}
              callback {do_revert_changes();}
              xywh {25 25 100 20}
            }
            MenuItem {} {
              label {&Open Parameters...}
              callback {\#if USE_NSM
            if ( nsm && nsm->is_active() )
            {
                do_load_master();
                do_save_master( nsm->project_filename );
            }
            else
\#endif
            {
                do_load_master();
            }}
              xywh {25 25 100 20}
            }
            MenuItem {} {
              label {&Save All Parameters...}
              callback {\#if USE_NSM
            if ( nsm && nsm->is_active() )
            {
                do_save_master( nsm->project_filename );
            }
            else
\#endif
            {
                 do_save_master();
            }}
              xywh {15 15 100 20} divider
            }
            MenuItem {} {
              label {&Load Midi Learn...}
              callback {char *filename;
filename=fl_file_chooser("Open:","({*.xlz})",NULL,0);
if (filename==NULL) return;

osc->write("/load_xlz", "s", filename);}
              xywh {40 40 100 20}
            }
            MenuItem {} {
              label {Clear Midi Learn...}
              callback {osc->write("/clear_xlz", "");}
              xywh {40 40 100 20}
            }
            MenuItem {} {
              label {Save Midi Learn...}
              callback {char *filename;
int result;
filename=fl_file_chooser("Save:","({*.xlz})",NULL,0);
if (filename==NULL) return;
filename=fl_filename_setext(filename,".xlz");

result=fileexists(filename);
if (result) {
    result=0;
   if (!fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL)) return;
};

osc->write("/save_xlz", "s", filename);}
              xywh {30 30 100 20} divider
            }
            MenuItem {} {
              label {&Load Scale Settings...}
              callback {char *filename;
filename=fl_file_chooser("Open:","({*.xsz})",NULL,0);
if (filename==NULL) return;

osc->write("/load_xsz", "s", filename);
}
              xywh {40 40 100 20}
            }
            MenuItem {} {
              label {Save Sc&ale Settings ..}
              callback {char *filename;
int result=0;

filename=fl_file_chooser("Save:","({*.xsz})",NULL,0);
if (filename==NULL) return;
filename=fl_filename_setext(filename,".xsz");

result=fileexists(filename);
if (result) {
    result=0;
   if (!fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL)) return;
       
};


osc->write("/save_xsz", "s", filename); }
              xywh {30 30 100 20}
            }
            MenuItem {} {
              label {Show Scale Settings...}
              callback {microtonalui->show();}
              xywh {5 5 100 20} divider
            }
            MenuItem {} {
              label {&Settings...}
              callback {configui->show();}
              xywh {30 30 100 20}
            }
            MenuItem {} {
              label {N&io Settings}
              callback {nioui.refresh();
nioui.show();}
              xywh {5 5 36 21} divider
            }
            MenuItem {} {
              label {&Copyright...}
              callback {aboutwindow->show();}
              xywh {20 20 100 20} divider
            }
            MenuItem {} {
              label {E&xit}
              callback {masterwindow->do_callback();}
              xywh {15 15 100 20}
            }
          }
          Submenu {} {
            label {&Instrument}
            xywh {15 15 100 20}
          } {
            MenuItem {} {
              label {&Clear Instrument...}
              callback {if (fl_choice("Clear instrument's parameters ?","No","Yes",NULL)){
//       int npart=(int)npartcounter->value()-1;
       osc->write("/part"+to_s(npart)+"/clear");
};

updatepanel();}
              xywh {40 40 100 20}
            }
            MenuItem {} {
              label {&Open Instrument...}
              callback {const char *filename;
filename=fl_file_chooser("Load:","({*.xiz})",NULL,0);
if (filename==NULL) return;


osc->write("/load_xiz", "is", npart, filename);
npartcounter->do_callback();
updatepanel();

/*
if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an instrument file.");
      else if (result<0) fl_alert("Error: Could not load the file.");*/}
              xywh {35 35 100 20}
            }
            MenuItem {} {
              label {&Save Instrument ...}
              callback {char *filename;

filename=fl_file_chooser("Save:","({*.xiz})",NULL,0);
if (filename==NULL) return;
filename=fl_filename_setext(filename,".xiz");

int result=fileexists(filename);
if (result) {
    result=0;
   if (!fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL)) return;
       
};

osc->write("/save_xiz", "is", npart, filename);
/*if (result<0) fl_alert("Error: Could not save the file.");*/}
              xywh {25 25 100 20} divider
            }
            MenuItem {} {
              label {Show Instrument &Bank...}
              callback {bankui->show();}
              xywh {5 5 100 20} divider
            }
            MenuItem {} {
              label {&Virtual Keyboard...}
              callback {virkeyboard->show();}
              xywh {15 15 100 20}
            }
          }
          Submenu recordmenu {
            label {&Record}
            xywh {5 5 100 20}
          } {
            MenuItem {} {
              label {&Choose WAV file...}
              callback {char *filename;
recordbutton->deactivate();
pausebutton->deactivate();
pauselabel->deactivate();
stopbutton->deactivate();
filename=fl_file_chooser("Record to audio file:","(*.wav)",NULL,0);
if (filename==NULL) return;
fl_filename_setext(filename,".wav");

//TODO TODO Test if a file exists
if (fl_choice("The file *might* exist. \\nOverwrite it?","No","Yes",NULL)) {
    osc->write("/HDDRecorder/preparefile", "s", filename);
    recordbutton->activate();//TODO make this button osc controlled
}

/*if (result!=0) fl_alert("Error: Could not save the file.");*/}
              xywh {5 5 100 20}
            }
          }
          Submenu {} {
            label Misc
            xywh {15 15 100 20}
          } {
            MenuItem {} {
              label {Switch User Interface Mode}
              callback {if (fl_choice("Switch the User Interface to Beginner mode ?","No","Yes",NULL)){
	masterwindow->hide();
	refresh_master_ui();
	simplemasterwindow->show();
    osc->write("/cfg.UserInterfaceMode", "i", 2);
};}
              xywh {15 15 100 20}
            }
          }
        }
        Fl_Box dummy {
          xywh {25 25 25 25}
          code0 {win_root->osc = osc;}
          code1 {win_root->base = "/";}
        }
        Fl_Dial mastervolumedial {
          label {Master Volume}
          tooltip {Master Volume} xywh {15 32 55 55} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1
          code2 {o->init("volume"); o->selection_color(FL_RED); o->reset_value=80;}
          class Fl_Osc_Dial
        }
        Fl_Counter masterkeyshiftcounter {
          label {Master KeyShift}
          xywh {150 97 120 23} type Simple labelsize 9 minimum -64 maximum 64 step 1
          code0 {o->lstep(12);}
          code1 {o->init("Pkeyshift",'i',-64);}
          class Fl_Osc_Counter
        }
        Fl_Button {} {
          label {Panic!}
          callback {virkeyboard->releaseallkeys();
          o->oscWrite("Panic");}
          xywh {280 29 105 53} color 90 labelfont 1
          class Fl_Osc_Button
        }
        Fl_Group partuigroup {open
          xywh {0 310 390 205}
        } {
          Fl_Group partui {open
            xywh {0 310 383 175}
            code0 {o->init("/part0/", 0,bankui,"/part0/", osc);}
            code1 {o->show();}
            class PartUI
          } {}
        }
        Fl_Tabs {} {open
          xywh {0 145 390 165} box UP_FRAME
        } {
          Fl_Group {} {
            label {System Effects} open
            xywh {0 162 390 145} labelsize 15 align 9
          } {
            Fl_Counter syseffnocounter {
              label {Sys.Effect No.}
              callback {nsyseff=(int) o->value()-1;
              syseffectuigroup->reext("sysefx"+to_s(nsyseff)+"/");
              sysefftype->oscMove("sysefx"+to_s(nsyseff)+"/efftype");
syseffectui->refresh();}
              xywh {5 181 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
              code0 {o->bounds(1,NUM_SYS_EFX);}
              code1 {o->value(nsyseff+1);}
            }
            Fl_Choice sysefftype {
              label EffType
              callback {syseffectui->efftype = o->value();
syseffectui->refresh();}
              xywh {285 176 100 22} down_box BORDER_BOX labelsize 10
              code0 {o->init("sysefx"+to_s(nsyseff)+"/efftype");}
              class Fl_Osc_Choice
            } {
              MenuItem {} {
                label {No Effect}
                xywh {15 15 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Reverb
                xywh {25 25 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Echo
                xywh {35 35 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Chorus
                xywh {45 45 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Phaser
                xywh {55 55 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label AlienWah
                xywh {65 65 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Distortion
                xywh {75 75 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label EQ
                xywh {85 85 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label DynFilter
                xywh {95 95 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Group syseffectuigroup {
              xywh {5 203 380 95} color 48
              class Fl_Osc_Group
            } {
              Fl_Box {} {
                xywh {5 203 0 0}
                code0 {syseffectuigroup->ext = "sysefx0/";}
              }
              Fl_Group syseffectui {
                xywh {5 203 380 95}
                code0 {o->init(false);}
                class EffUI
              } {}
            }
            Fl_Button {} {
              label {Send to...}
              callback {syseffsendwindow->show();}
              xywh {90 181 85 22} box THIN_UP_BOX labelfont 1 labelsize 11
            }
            Fl_Button {} {
              label C
              callback {presetsui->copy("/sysefx"+to_s(nsyseff)+"/");}
              xywh {180 187 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
            }
            Fl_Button {} {
              label P
              callback { presetsui->paste("/sysefx"+to_s(nsyseff)+"/",syseffectui);} selected
              xywh {210 187 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
            }
          }
          Fl_Group {} {
            label {Insertion Effects} open
            xywh {0 165 390 145} labelsize 15 align 9 hide
          } {
            Fl_Counter inseffnocounter {
              label {Ins.Effect No.}
              callback {ninseff=(int) o->value()-1;
              insefftype->oscMove("insefx"+to_s(ninseff)+"/efftype");
              inseffectuigroup->reext("insefx"+to_s(ninseff)+"/");
              inseffpart->oscMove("Pinsparts"+to_s(ninseff));

              /*
insefftype->value(master->insefx[ninseff]->geteffect());
inseffpart->value(master->Pinsparts[ninseff]+2);
inseffectui->refresh();

if (master->Pinsparts[ninseff]!=-1) {
        insefftype->activate();
	inseffectui->activate();
        inseffectuigroup->activate();
} else {
	insefftype->deactivate();
 	inseffectui->deactivate();
        inseffectuigroup->deactivate();
};*/}
              xywh {5 183 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
              code0 {o->bounds(1,NUM_INS_EFX);}
              code1 {o->value(ninseff+1);}
            }
            Fl_Choice insefftype {
              label EffType
              callback {/*pthread_mutex_lock(&master->mutex);
master->insefx[ninseff]->changeeffect((int) o->value());
pthread_mutex_unlock(&master->mutex);*/
inseffectui->efftype = o->value();
inseffectui->refresh();
inseffectui->show();}
              xywh {285 173 100 22} down_box BORDER_BOX labelsize 10
              code0 {/*o->value(master->insefx[ninseff]->geteffect());*/}
              code1 {/*if (master->Pinsparts[ninseff]== -1) o->deactivate();*/}
              code2 {o->init("insefx"+to_s(ninseff)+"/efftype");}
              class Fl_Osc_Choice
            } {
              MenuItem {} {
                label {No Effect}
                xywh {30 30 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Reverb
                xywh {40 40 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Echo
                xywh {50 50 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Chorus
                xywh {60 60 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Phaser
                xywh {65 65 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label AlienWah
                xywh {75 75 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Distortion
                xywh {85 85 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label EQ
                xywh {95 95 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label DynFilter
                xywh {105 105 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Group inseffectuigroup {open
              xywh {5 205 380 95} box FLAT_BOX color 48
              class Fl_Osc_Group
            } {
              Fl_Box {} {
                xywh {5 205 0 0}
                code0 {inseffectuigroup->ext = "insefx0/";}
              }
              Fl_Group inseffectui {
                xywh {5 205 380 90} box UP_FRAME
                code0 {o->init(true);}
                class EffUI
              } {}
            }
            Fl_Choice inseffpart {
              label {Insert To.}
              callback {/*master->Pinsparts[ninseff]=(int) o->value()-2;*/
if ((int) o->value()==1){
    inseffectuigroup->deactivate();
    insefftype->deactivate();
    inseffectui->deactivate();
} else {
    inseffectuigroup->activate();
    insefftype->activate();
    inseffectui->activate();
};
/*master->insefx[ninseff]->cleanup();*/} open
              xywh {95 183 80 22} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
              code0 {o->add("Master Out");o->add("Off");}
              code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
              code3 {o->init("Pinsparts"+to_s(ninseff),-2);}
              class Fl_Osc_Choice
            } {}
            Fl_Button {} {
              label C
              callback {presetsui->copy(inseffectuigroup->loc());}
              xywh {180 185 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
            }
            Fl_Button {} {
              label P
              callback {presetsui->paste(inseffectuigroup->loc(),inseffectui);}
              xywh {210 185 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
            }
          }
        }
        Fl_Button {} {
          label Scales
          callback {microtonalui->show();}
          xywh {320 87 65 23} color 51 labelfont 1
        }
        Fl_Group {} {
          xywh {150 40 117 45} box UP_FRAME
        } {
          Fl_Button recordbutton {
            label {Rec.}
            callback {o->deactivate();
recordmenu->deactivate();
recordmenu->label("&Record(*)");
stopbutton->activate();
pausebutton->activate();
pauselabel->activate();
o->oscWrite("HDDRecorder/start");
o->oscWrite("reset-vu");
mastermenu->redraw();}
            tooltip {Start Recording} xywh {159 46 21 21} box ROUND_UP_BOX color 88 labelfont 1 labelsize 10 align 2 deactivate
            class Fl_Osc_Button
          }
          Fl_Button stopbutton {
            label Stop
            callback {o->deactivate();
            o->oscWrite("HDDRecorder/stop");
recordbutton->deactivate();
pausebutton->deactivate();
pauselabel->deactivate();
recordmenu->activate();
recordmenu->label("&Record");
mastermenu->redraw();}
            tooltip {Stop Recording and close the audio file} xywh {237 46 21 21} box THIN_UP_BOX color 4 labelfont 1 labelsize 10 align 2 deactivate
            class Fl_Osc_Button
          }
          Fl_Button pausebutton {
            label {| |}
            callback {o->deactivate();
o->oscWrite("HDDRecorder/pause");
recordbutton->activate();
mastermenu->redraw();}
            tooltip {Pause Recording} xywh {198 46 21 21} box THIN_UP_BOX color 4 selection_color 4 labelfont 1 labelcolor 3 align 16 deactivate
            class Fl_Osc_Button
          }
          Fl_Box pauselabel {
            label Pause
            xywh {192 66 30 15} labelfont 1 labelsize 10 deactivate
          }
        }
        Fl_Group {} {
          xywh {1 490 389 55}
        } {
          Fl_Box mastervu {
            label {VU-Meter}
            xywh {5 490 380 30} box FLAT_BOX color 48 selection_color 75
            code0 {o->init(osc);}
            class VuMasterMeter
          }
        }
        Fl_Check_Button nrpnbutton {
          label NRPN
          tooltip {Receive NRPNs} xywh {10 115 60 25} down_box DOWN_BOX labelsize 12
          code0 {o->init("ctl/NRPN.receive");}
          class Fl_Osc_Check
        }
        Fl_Counter npartcounter {
          callback {int nval=(int) o->value()-1;
/*partuigroup->remove(partui);
delete partui;
partui=new PartUI(0,0,765,525);
partuigroup->add(partui);
char buffer[1024];
snprintf(buffer, 1024, "/part%d/", nval);
partui->init(master->part[nval], buffer, master, nval, bankui, "/part"+to_s(nval)+"/", osc);
partui->redraw();
o->redraw();
*/
npart=nval;
partui->rebase("/part"+to_s(npart)+"/");

updatepanel();
simplenpartcounter->value(nval+1);
simplenpartcounter->do_callback();}
          tooltip {The part number} xywh {5 312 50 18} type Simple labelfont 1 minimum 0 maximum 127 step 1 value 1 textfont 1
          code0 {o->bounds(1,NUM_MIDI_PARTS);}
          code1 {bankui->init(o);}
        }
        Fl_Button {} {
          label vK
          callback {virkeyboard->show();}
          tooltip {Virtual Keyboard} xywh {280 87 40 23} color 51 labelfont 1
        }
        Fl_Group {} {
          xywh {85 32 55 110} box UP_FRAME
        } {
          Fl_Button {} {
            label Reset
            callback {globalfinedetuneslider->value(64.0);
globalfinedetuneslider->do_callback();}
            tooltip {Master fine detune reset} xywh {90 37 45 23} box THIN_UP_BOX labelsize 10
          }
          Fl_Dial globalfinedetuneslider {
            label {Fine Detune}
            tooltip {global fine detune} xywh {90 68 45 45} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1 value 64
            code0 {o->init("microtonal/Pglobalfinedetune");o->reset_value=64;}
            class Fl_Osc_Dial
          }
        }
        Fl_Button {} {
          label {Panel Window}
          callback {updatepanel();
panelwindow->show();}
          tooltip {Panel Window} xywh {280 112 105 23} color 51 labelfont 1 labelsize 10
        }
        Fl_Button sm_indicator1 {
          label SM
          xywh {350 5 35 15} box ROUNDED_BOX down_box ROUNDED_BOX color 45 selection_color 93 labelfont 3 labelcolor 39 deactivate
        }
      }
    }
    Fl_Window aboutwindow {
      label {Copyright...}
      xywh {411 344 365 280} type Double hide
    } {
      Fl_Box {} {
        label {Copyright (c) 2002-2009 Nasca O. PAUL, 2009-2016 Mark McCurry, and others. Please read AUTHORS.txt}
        xywh {15 35 335 55} labeltype EMBOSSED_LABEL labelsize 15 align 208
      }
      Fl_Box {} {
        label {This is free software; you may redistribute it and/or modify it under the terms of the 
version 2 (or any later version) of the GNU General Public License as published by the Free Software Fundation.
  This program comes with
 ABSOLUTELY NO WARRANTY. 
 See the version 2 (or any later version) of the 
GNU General Public License for details.}
        xywh {15 90 335 145} labelfont 1 labelsize 11 align 144
      }
      Fl_Button {} {
        label {Close this window}
        callback {aboutwindow->hide();}
        xywh {80 245 190 25} box THIN_UP_BOX labelsize 11
      }
      Fl_Box {} {
        label ZynAddSubFX
        xywh {15 5 335 30} labeltype EMBOSSED_LABEL labelfont 1 labelsize 20 align 16
      }
    }
    Fl_Window syseffsendwindow {
      label {System Effects Send}
      xywh {171 234 120 250} type Double hide resizable
      class Fl_Osc_Window
    } {
      Fl_Box {} {
        xywh {0 0 0 0}
        code0 {syseffsendwindow->init(osc,"");}
      }
      Fl_Scroll syseffscroll {open
        xywh {0 45 120 170} box FLAT_BOX resizable
        code0 {syseffsendwindow->begin();for (int neff1=0;neff1<NUM_SYS_EFX;neff1++) for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)}
        code1 {{syseffsend[neff1][neff2]=new Fl_Osc_Dial(o->x()+(neff2-1)*35,o->y()+15+neff1*50,30,30);syseffsend[neff1][neff2]->label(strdup((to_s(neff1) + "->" + to_s(neff2)).c_str()));syseffsend[neff1][neff2]->init("/sysefxfrom"+to_s(neff1)+"/to"+to_s(neff2));};syseffsendwindow->end();}
      } {}
      Fl_Button {} {
        label Close
        callback {syseffsendwindow->hide();}
        xywh {25 220 80 25} box THIN_UP_BOX
      }
      Fl_Box {} {
        label {Send system effect's output to other system effects}
        xywh {5 5 110 35} labelsize 10 align 192
      }
    }
    Fl_Window panelwindow {
      label {ZynAddSubFX Panel} open
      xywh {615 247 630 635} type Double
      class Fl_Osc_Window visible
    } {
      Fl_Box {} {
        xywh {0 0 0 0}
        code0 {panelwindow->init(osc,"/");}
      }
      Fl_Scroll {} {open
        xywh {0 5 570 310} type HORIZONTAL box THIN_UP_BOX
      } {
        Fl_Pack {} {open
          xywh {5 10 560 285} type HORIZONTAL
          code0 {for (int i=0;i<NUM_MIDI_PARTS/2;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(i,bankui,partui);}}
        } {}
      }
      Fl_Scroll {} {open
        xywh {0 320 570 310} type HORIZONTAL box THIN_UP_BOX
      } {
        Fl_Pack {} {open
          xywh {5 325 560 285} type HORIZONTAL
          code0 {for (int i=NUM_MIDI_PARTS/2;i<NUM_MIDI_PARTS;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(i,bankui,partui);}}
        } {}
      }
      Fl_Button {} {
        label Close
        callback {panelwindow->hide();
updatepanel();}
        xywh {575 605 50 25} box THIN_UP_BOX labelsize 13
      }
      Fl_Button {} {
        label Refresh
        callback {updatepanel();}
        xywh {575 570 55 25} box THIN_UP_BOX labelsize 13
      }
    }
    Fl_Window simplemasterwindow {
      label ZynAddSubFX
      callback {
if (isPlugin || fl_choice("Exit and leave the unsaved data?","No","Yes",NULL))
{
	*exitprogram=1;
};} open
      xywh {655 378 600 335} type Double
      class Fl_Osc_Window visible
    } {
      Fl_Box {} {
        xywh {0 0 0 0}
        code0 {simplemasterwindow->init(osc, "/");}
      }
      Fl_Menu_Bar simplemastermenu {
        xywh {0 0 600 25}
      } {
        Submenu {} {
          label {&File}
          xywh {10 10 100 20}
        } {
          MenuItem {} {
            label {&New (erase all)...}
            callback {do_new_master();}
            xywh {30 30 100 20}
          }
          MenuItem {} {
            label {&Revert changes...}
            callback {do_revert_changes();}
            xywh {30 30 100 20}
          }
          MenuItem {} {
            label {&Open Parameters...}
            callback {do_load_master();}
            xywh {30 30 100 20}
          }
          MenuItem {} {
            label {&Save All Parameters...}
            callback {\#if USE_NSM
            if ( nsm && nsm->is_active() )
            {
                do_save_master( nsm->project_filename );
            }
            else
\#endif
            {
                 do_save_master();
            }}
            xywh {20 20 100 20} divider
          }
          MenuItem {} {
            label {&Settings...}
            callback {configui->show();}
            xywh {35 35 100 20} divider
          }
          MenuItem {} {
            label {&Copyright...}
            callback {aboutwindow->show();}
            xywh {25 25 100 20} divider
          }
          MenuItem {} {
            label {E&xit}
            callback {masterwindow->do_callback();}
            xywh {20 20 100 20}
          }
        }
        Submenu {} {
          label {&Instrument}
          xywh {20 20 100 20}
        } {
          MenuItem {} {
            label {&Open Instrument...}
            callback {const char *filename;
filename=fl_file_chooser("Load:","({*.xiz})",NULL,0);
if (filename==NULL) return;


osc->write("/load_xiz", "si", filename, npart);
simplenpartcounter->do_callback();
/*
if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an instrument file.");
      else if (result<0) fl_alert("Error: Could not load the file.");*/}
            xywh {40 40 100 20}
          }
          MenuItem {} {
            label {Show Instrument &Bank...}
            callback {bankui->show();}
            xywh {10 10 100 20} divider
          }
        }
        Submenu {} {
          label Misc
          xywh {0 0 100 20}
        } {
          MenuItem {} {
            label {Switch User Interface Mode}
            callback {if (fl_choice("Switch the User Interface to Advanced mode ?","No","Yes",NULL)){
	simplemasterwindow->hide();
	refresh_master_ui();
	masterwindow->show();
    osc->write("/cfg.UserInterfaceMode", "i", 1);
};}
            xywh {0 0 100 20}
          }
        }
      }
      Fl_Group simplelistitemgroup {
        private xywh {125 65 215 145} box UP_FRAME
        class Fl_Osc_Group
      } {
        Fl_Box {} {
          xywh {125 65 0 0}
          code0 {simplelistitemgroup->ext = "part0/";}
        }
        Fl_Button partname {
          callback {if ((int)bankui->cbwig->value()!=(npart+1)){
   bankui->cbwig->value(npart+1);
   bankui->cbwig->do_callback();
};
bankui->show();}
          xywh {130 72 205 18} box THIN_DOWN_BOX down_box FLAT_BOX color 50 labelfont 1 labelsize 11 align 208
          code0 {o->ext = "Pname";o->oscRegister("Pname");}
          class PartNameButton
        }
        Fl_Slider partpanning {
          label Pan
          xywh {185 95 145 15} type {Horz Knob} box NO_BOX labelsize 11 maximum 127 step 1 value 64
          code0 {o->init("Ppanning",'i'); o->reset_value=64;}
          class Fl_Osc_TSlider
        }
        Fl_Choice partrcv {
          label {Midi Channel Receive}
          callback {virkeys->releaseallkeys(0);
virkeys->midich=(int) o->value();} open
          tooltip {receive from Midi channel} xywh {140 157 65 18} down_box BORDER_BOX labelsize 10 align 130 textfont 1
          code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};}
          code1 {o->init("Prcvchn");}
          class Fl_Osc_Choice
        } {}
        Fl_Dial partvolume {
          xywh {135 95 45 40} labelsize 9 maximum 127 step 1
          code0 {o->init("Pvolume"); o->reset_value=96;}
          class Fl_Osc_Dial
        }
        Fl_Box {} {
          label Volume
          xywh {130 130 55 20} labelsize 10
        }
        Fl_Check_Button simplepartportamento {
          label Portamento
          tooltip {Enable/Disable the portamento} xywh {193 127 79 23} down_box DOWN_BOX labelsize 9
          code0 {o->init("ctl/portamento.portamento");}
          class Fl_Osc_Check
        }
        Fl_Counter simpleminkcounter {
          label {Min.key}
          callback {if (simpleminkcounter->value()>simplemaxkcounter->value()) o->textcolor(FL_RED);
              else o->textcolor(FL_BLACK);}
          tooltip {Minimum key (that the part receives NoteOn messages)} xywh {210 158 40 15} type Simple labelsize 10 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->init("Pminkey");}
          class Fl_Osc_Counter
        }
        Fl_Counter simplemaxkcounter {
          label {Max.key}
          callback {if (simpleminkcounter->value()>simplemaxkcounter->value()) o->textcolor(FL_RED);
              else o->textcolor(FL_BLACK);}
          tooltip {Maximum key (that the part receives NoteOn messages)} xywh {255 158 40 15} type Simple labelsize 10 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->init("Pmaxkey");}
          class Fl_Osc_Counter
        }
        Fl_Button {} {
          label m
          callback {o->oscWrite("grabMinNote");}
          tooltip {set the minimum key to the last pressed key} xywh {230 188 15 12} box THIN_UP_BOX labelsize 10
          class Fl_Osc_Button
        }
        Fl_Button {} {
          label M
          callback {o->oscWrite("grabMaxNote");}
          tooltip {set the maximum key to the last pressed key} xywh {260 188 15 12} box THIN_UP_BOX labelsize 10
          class Fl_Osc_Button
        }
        Fl_Button {} {
          label R
          callback {simpleminkcounter->value(0);
simpleminkcounter->do_callback();
simplemaxkcounter->value(127);
simplemaxkcounter->do_callback();}
          tooltip {reset the minimum key to 0 and maximum key to 127} xywh {245 188 15 12} box THIN_UP_BOX labelfont 1 labelsize 10
        }
        Fl_Counter simplepartkeyshiftcounter {
          label KeyShift
          xywh {280 120 50 20} type Simple labelsize 11 minimum -64 maximum 64 step 1
          code0 {o->lstep(12);}
          code1 {o->init("Pkeyshift", 'i', -64);}
          class Fl_Osc_Counter
        }
        Fl_Dial simplesyseffsend {
          xywh {300 160 30 30} maximum 127 step 1
          code0 {o->alt_init("/","Psysefxvol"+to_s(nsyseff)+"/part"+to_s(npart));}
          class Fl_Osc_Dial
        }
        Fl_Box {} {
          label Effect
          xywh {295 190 40 15} labelsize 10
        }
      }
      Fl_Check_Button partenabled {
        label Enabled
        callback {if ((int) o->value()==0) simplelistitemgroup->deactivate();
  else {
    simplelistitemgroup->activate();
    if ((int)bankui->cbwig->value()!=(npart+1)){
       bankui->cbwig->value(npart+1);
       bankui->cbwig->do_callback();
    };
};

o->redraw();}
        private xywh {250 40 85 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 24
        code0 {//char tmp[10];snprintf(tmp,10,"%d",npart+1);o->copy_label(tmp);}
        code1 {o->init("part0/Penabled");}
        class Fl_Osc_Check
      }
      Fl_Box virkeys {
        label Keyboard
        xywh {5 215 590 80} box BORDER_BOX color 17
        code0 {o->init(osc, "/");}
        class VirKeys
      }
      Fl_Group {} {
        xywh {340 30 255 185}
      } {
        Fl_Tabs {} {
          xywh {345 35 245 175} box UP_FRAME align 18
        } {
          Fl_Group {} {
            label {System Effects}
            xywh {345 55 245 155} box UP_FRAME labelfont 1 labelsize 12 align 18
          } {
            Fl_Counter simplesyseffnocounter {
              label {Sys.Effect No.}
              callback {nsyseff=(int) o->value()-1;
/*simplesysefftype->value(master->sysefx[nsyseff]->geteffect());*/
simplesyseffectui->refresh();
simplesysefftype->oscMove("sysefx"+to_s(nsyseff)+"/efftype");
simplesyseffectuigroup->reext("sysefx"+to_s(nsyseff)+"/");
simplesyseffsend->oscMove("Psysefxvol"+to_s(nsyseff)+"/part"+to_s(npart));
simplerefresh();}
              xywh {350 75 80 20} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
              code0 {o->bounds(1,NUM_SYS_EFX);}
              code1 {o->value(nsyseff+1);}
            }
            Fl_Choice simplesysefftype {
              label EffType
              callback {
              simplesyseffectui->efftype = o->value();
simplesyseffectui->refresh();
              }
              xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5
              code0 {o->init("sysefx"+to_s(nsyseff)+"/efftype");}
              class Fl_Osc_Choice
            } {
              MenuItem {} {
                label {No Effect}
                xywh {20 20 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Reverb
                xywh {30 30 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Echo
                xywh {40 40 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Chorus
                xywh {50 50 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Phaser
                xywh {60 60 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label AlienWah
                xywh {70 70 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Distortion
                xywh {80 80 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label EQ
                xywh {90 90 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label DynFilter
                xywh {100 100 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Group simplesyseffectuigroup {
              xywh {350 95 235 95} color 48
              class Fl_Osc_Group
            } {
              Fl_Box {} {
                xywh {350 95 0 0}
                code0 {simplesyseffectuigroup->ext = "sysefx0/";}
              }
              Fl_Group simplesyseffectui {
                xywh {350 95 234 95}
                code0 {o->init(false);}
                code1 {o->refresh();}
                class SimpleEffUI
              } {}
            }
            Fl_Button {} {
              label {Send to...}
              callback {syseffsendwindow->show();}
              xywh {435 75 75 20} box THIN_UP_BOX labelfont 1 labelsize 11
            }
            Fl_Button {} {
              label P
              callback {/*pthread_mutex_lock(&master->mutex);
presetsui->paste(master->sysefx[nsyseff],simplesyseffectui);
pthread_mutex_unlock(&master->mutex);*/}
              xywh {560 65 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
            }
          }
          Fl_Group {} {
            label {Insertion Effects}
            xywh {345 55 245 155} box UP_FRAME labelfont 1 labelsize 12 align 18 hide
          } {
            Fl_Counter simpleinseffnocounter {
              label {Ins.Effect No.}
              callback {ninseff=(int) o->value()-1;
/*simpleinsefftype->value(master->insefx[ninseff]->geteffect());
simpleinseffpart->value(master->Pinsparts[ninseff]+2);*/
simpleinseffectuigroup->reext("insefx"+to_s(ninseff)+"/");
simpleinsefftype->oscMove("insefx"+to_s(ninseff)+"/efftype");
simpleinseffectui->refresh();

/*
if (master->Pinsparts[ninseff]!=-1) {
        simpleinsefftype->activate();
	simpleinseffectui->activate();
        simpleinseffectuigroup->activate();
} else {
	simpleinsefftype->deactivate();
 	simpleinseffectui->deactivate();
        simpleinseffectuigroup->deactivate();
};*/}
              xywh {350 75 80 20} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
              code0 {o->bounds(1,NUM_INS_EFX);}
              code1 {o->value(ninseff+1);}
            }
            Fl_Choice simpleinsefftype {
              label EffType
              callback {/*pthread_mutex_lock(&master->mutex);
master->insefx[ninseff]->changeeffect((int) o->value());
pthread_mutex_unlock(&master->mutex);*/
simpleinseffectui->efftype = o->value();
simpleinseffectui->refresh();
simpleinseffectui->show();}
              xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5
              code0 {/*o->value(master->insefx[ninseff]->geteffect());*/}
              code1 {/*if (master->Pinsparts[ninseff]== -1) o->deactivate();*/}
              code2 {o->init("insefx"+to_s(ninseff)+"/efftype");}
              class Fl_Osc_Choice
            } {
              MenuItem {} {
                label {No Effect}
                xywh {35 35 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Reverb
                xywh {45 45 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Echo
                xywh {55 55 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Chorus
                xywh {65 65 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Phaser
                xywh {70 70 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label AlienWah
                xywh {80 80 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Distortion
                xywh {90 90 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label EQ
                xywh {100 100 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label DynFilter
                xywh {110 110 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Group simpleinseffectuigroup {
              xywh {350 95 234 95} box FLAT_BOX color 48
              class Fl_Osc_Group
            } {
              Fl_Box {} {
                xywh {350 95 0 0}
                code0 {simpleinseffectuigroup->ext = "insefx0/";}
              }
              Fl_Group simpleinseffectui {
                xywh {350 95 234 95}
                code0 {o->init(true);}
                class SimpleEffUI
              } {}
            }
            Fl_Choice simpleinseffpart {
              label {Insert To.}
              callback {/*master->Pinsparts[ninseff]=(int) o->value()-2;*/
if ((int) o->value()==1){
    simpleinseffectuigroup->deactivate();
    simpleinsefftype->deactivate();
    simpleinseffectui->deactivate();
} else {
    simpleinseffectuigroup->activate();
    simpleinsefftype->activate();
    simpleinseffectui->activate();
};
/*master->insefx[ninseff]->cleanup();*/} open
              xywh {435 75 80 20} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
              code0 {o->add("Master Out");o->add("Off");}
              code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
              code3 {/*o->value(master->Pinsparts[ninseff]+2);*/}
            } {}
            Fl_Button {} {
              label P
              callback {/*pthread_mutex_lock(&master->mutex);
presetsui->paste(master->insefx[ninseff],simpleinseffectui);
pthread_mutex_unlock(&master->mutex);*/}
              xywh {560 65 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
            }
          }
        }
      }
      Fl_Group {} {
        xywh {5 300 590 30} box ENGRAVED_FRAME
      } {
        Fl_Box simplemastervu {
          label {VU-Meter}
          xywh {5 300 590 30} box FLAT_BOX color 41 selection_color 75
          code0 {o->init(osc);}
          class VuMasterMeter
        }
      }
      Fl_Dial simplemastervolumedial {
        label {Master Volume}
        tooltip {Master Volume} xywh {10 35 40 40} box ROUND_UP_BOX labelfont 1 labelsize 11 align 130 maximum 127 step 1
        code0 {o->init("Pvolume");o->reset_value=80;}
        class Fl_Osc_Dial
      }
      Fl_Counter simplemasterkeyshiftcounter {
        label {Master KeyShift}
        xywh {15 110 90 20} labelsize 11 minimum -64 maximum 64 step 1
        code0 {o->lstep(12);}
        code1 {o->init("Pkeyshift",'i',-64);}
        class Fl_Osc_Counter
      }
      Fl_Button {} {
        label {Stop ALL sounds!}
        callback {virkeyboard->releaseallkeys();
        o->oscWrite("Panic");}
        xywh {5 149 115 31} color 90 labelfont 1 labelsize 10
        class Fl_Osc_Button
      }
      Fl_Button {} {
        label Reset
        callback {simpleglobalfinedetuneslider->value(64.0);
simpleglobalfinedetuneslider->do_callback();}
        tooltip {Master fine detune reset} xywh {70 30 50 17} box THIN_UP_BOX labelsize 11 align 128
      }
      Fl_Dial simpleglobalfinedetuneslider {
        label {Fine Detune}
        tooltip {global fine detune} xywh {80 50 30 30} box ROUND_UP_BOX labelsize 11 align 130 maximum 127 step 1 value 64
        code0 {o->init("microtonal/Pglobalfinedetune");o->reset_value=64;}
        class Fl_Osc_Dial
      }
      Fl_Counter simplenpartcounter {
        label Part
        callback {virkeys->releaseallkeys(0);
npartcounter->value(o->value());
npart=(int) o->value()-1;

simplelistitemgroup->reext("part"+to_s(npart)+"/");
partenabled->oscMove("part"+to_s(npart)+"/Penabled");
simplerefresh();}
        tooltip {The part number} xywh {170 40 70 20} type Simple labelfont 1 align 4 minimum 0 maximum 127 step 1 value 1 textfont 1
        code0 {o->bounds(1,NUM_MIDI_PARTS);}
      }
      Fl_Counter {} {
        label {Keyb.Oct.}
        callback {virkeys->releaseallkeys(0);
virkeys->midioct=(int) o->value();
virkeys->take_focus();}
        tooltip {Midi Octave} xywh {5 190 55 20} type Simple labelsize 11 align 8 when 6 minimum 0 maximum 5 step 1 textfont 1 textsize 11
        code0 {o->value(virkeys->midioct);}
      }
      Fl_Button sm_indicator2 {
        label SM
        xywh {560 5 35 15} box ROUNDED_BOX down_box ROUNDED_BOX color 45 selection_color 93 labelfont 3 labelcolor 39 deactivate
      }
    }
    Fl_Window selectuiwindow {
      label {User Interface mode}
      callback {*exitprogram=1;}
      xywh {342 246 430 250} type Double hide non_modal
      class Fl_Osc_Window
    } {
      Fl_Box {} {
        label {Welcome to ZynAddSubFX}
        xywh {5 5 425 40} labeltype SHADOW_LABEL labelfont 1 labelsize 26
      }
      Fl_Box {} {
        label {Please choose the interface mode:}
        xywh {10 50 265 25} labelfont 1 labelsize 13
      }
      Fl_Button {} {
        label Advanced
        callback {
        osc->write("/config/cfg.UserInterfaceMode", "i", 1);
masterwindow->show();
selectuiwindow->hide();}
        xywh {10 165 100 35} color 229 labelfont 1 labelsize 16
      }
      Fl_Box {} {
        label {.. if you have used ZynAddSubFX before, or you like to have full control to all parameters.}
        xywh {110 165 310 35} labelfont 1 labelsize 11 align 144
      }
      Fl_Button {} {
        label Beginner
        callback {simplemasterwindow->show();
selectuiwindow->hide();
osc->write("/config/cfg.UserInterfaceMode", "i", 2);}
        xywh {10 80 100 65} color 238 labelfont 1 labelsize 16
      }
      Fl_Box {} {
        label {..if you are a beginner, you prefer using presets or you prefer to use simpler user interfaces. Most functionality of ZynAddSubFX will be hidden in this mode to make simple the learning/using it.}
        xywh {110 75 320 75} labelfont 1 labelsize 11 align 144
      }
      Fl_Box {} {
        label {You can switch the interface modes anytime you want.}
        xywh {30 215 360 25} box BORDER_BOX color 51 labelfont 1 labelsize 11 align 144
      }
    }
  }
  Function {updatesendwindow()} {} {
    code {/*for (int neff1=0;neff1<NUM_SYS_EFX;neff1++) 
  for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)
    syseffsend[neff1][neff2]->value(master->Psysefxsend[neff1][neff2]);*/} {}
  }
  Function {updatepanel()} {} {
    code {for (int npart=0;npart<NUM_MIDI_PARTS;npart++){
  panellistitem[npart]->refresh();
};} {}
  }
  Function {setfilelabel(const char *filename)} {} {
    code {if (filename!=NULL) snprintf(&masterwindowlabel[0],100,"%s - ZynAddSubFX",fl_filename_name(filename));
  else snprintf(&masterwindowlabel[0],100,"%s","ZynAddSubFX");
masterwindowlabel[99]='\\0';
masterwindow->label(&masterwindowlabel[0]);
simplemasterwindow->label(&masterwindowlabel[0]);
masterwindow->update_title();
simplemasterwindow->update_title();
} {}
  }
  Function {MasterUI(int *exitprogram_, class Fl_Osc_Interface *osc_):nioui(osc_)} {open
  } {
    code {exitprogram=exitprogram_;
osc=osc_;
ninseff=0;
nsyseff=0;
npart=0;
last_loaded[0]=0;
loading_next[0]=0;
last_xmz = new Osc_DataModel(osc);
last_xmz->callback = [this](std::string filestr) {
    const char *filename = filestr.c_str();
    if (filename[0] != 0)
       strncpy(last_loaded, filename, XMZ_PATH_MAX);
    else if (loading_next[0] != 0) {
       strncpy(last_loaded, loading_next, XMZ_PATH_MAX);
       loading_next[0] = 0;
    } else
       last_loaded[0] = 0;
    last_loaded[XMZ_PATH_MAX - 1] = 0;
    char *label = NULL;
    if(last_loaded[0] != 0) {
        label = strrchr(last_loaded, '/');
        if(label && *label)
            label = label+1;
        else
            label = last_loaded;
    }

    setfilelabel(label);
};
last_xmz->doUpdate("/last_xmz");

for (int i=0;i<NUM_SYS_EFX;i++)
   for (int j=0;j<NUM_SYS_EFX;j++)
     syseffsend[i][j]=NULL;

microtonalui=new MicrotonalUI(osc, "/microtonal/");
virkeyboard=new VirKeyboard(osc, "/");
bankui=new BankUI(&npart, osc);
configui=new ConfigUI(osc);

make_window();
fl_open_display();

\#if !defined(PLUGINVERSION) && HAS_X11
Pixmap p, mask;
XCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
                                 (char**)zynaddsubfx_xpm, &p, &mask, NULL);
masterwindow->icon((char *)p);
\#endif
assert(osc);
presetsui=new PresetsUI(osc);
setfilelabel(NULL);
swapefftype=0;
simplerefresh();} {}
  }
  Function {~MasterUI()} {} {
    code {masterwindow->hide();
delete masterwindow;
simplemasterwindow->hide();
delete simplemasterwindow;
aboutwindow->hide();
delete aboutwindow;
syseffsendwindow->hide();
delete syseffsendwindow;

delete virkeyboard;
delete microtonalui;
delete bankui;
delete configui;

delete presetsui;
delete panelwindow;
delete selectuiwindow;} {}
  }
  Function {showUI(int UIMode)} {} {
    code {switch (UIMode){
	case 0:selectuiwindow->show();
	break;
	case 1:masterwindow->show();
	break;
	case 2:simplemasterwindow->show();
	break;
};} {}
  }
  Function {simplerefresh()} {} {
    code {/*
     if (master->part[npart]->Pname[0]!=0) partname->label((char *)master->part[npart]->Pname);
     else partname->label("Click here to load a instrument");
     */

simplelistitemgroup->redraw();} {}
  }
  Function {do_new_master_unconditional()} {} {
    code {delete microtonalui;
microtonalui=new MicrotonalUI(osc, "/microtonal/");

    osc->write("/reset_master");
       osc->write("/last_xmz");
       npartcounter->value(1);
       refresh_master_ui();
       updatepanel();} {}
  }
  Function {do_new_master()} {} {
    code {if (fl_choice("Clear *ALL* the parameters ?","No","Yes",NULL)){
         do_new_master_unconditional();
         }} {}
  }
  Function {do_revert_changes_unconditional()} {return_type int
  } {
    code {strncpy(loading_next, last_loaded, XMZ_PATH_MAX);
    osc->write("/load_xmz", "s", last_loaded);
    osc->write("/last_xmz");
    refresh_master_ui();
    updatepanel();

return 1;} {}
  }
  Function {do_revert_changes()} {} {
    code {if (last_loaded[0] == 0)
         do_new_master();
         else
         if (fl_choice("Revert *ALL* the parameters ?","No","Yes",NULL)){
         do_revert_changes_unconditional();
         }} {}
  }
  Function {do_load_master_unconditional(const char *filename, const char *display_name)} {return_type int
  } {
    code {strncpy(loading_next, filename, XMZ_PATH_MAX);
    osc->write("/load_xmz", "s", filename);
    osc->write("/last_xmz");
    refresh_master_ui();
    updatepanel();

    setfilelabel(display_name);
    
    return 1;} {}
  }
  Function {do_load_master(const char* file = NULL)} {} {
    code {const char *filename;
  if (file == NULL) {
    filename=fl_file_chooser("Open:","({*.xmz})",NULL,0);
    if (filename==NULL) return;
  }
  else {
    filename = file;
  }

  int result = do_load_master_unconditional( filename, filename );

if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not a zynaddsubfx parameters file.");
      else if (result<0) fl_alert("Error: Could not load the file.");} {}
  }
  Function {do_save_master(const char* file = NULL)} {} {
    code {const char *filename;
char *tmp;
  int result=0;
  if (file == NULL) {
    tmp=fl_file_chooser("Save:","({*.xmz})",NULL,0);
    if (tmp==NULL) return;
    tmp=fl_filename_setext(tmp,".xmz");
    filename=tmp;
    result=fileexists(tmp);
    if (result) {
      result=0;
      if (!fl_choice("The file exists. Overwrite it?","No","Yes",NULL)) return;
      
    }
  }
  else {
    filename = file;
  }


    osc->write("/save_xmz", "s", filename);
if (result<0) fl_alert("Error: Could not save the file.");
	else
{
    osc->write("/last_xmz", "s", filename);
\#if USE_NSM
        if ( nsm && nsm->is_active() )
             setfilelabel( nsm->display_name );
        else
\#endif
             setfilelabel(filename);
}
updatepanel();} {}
  }
  Function {refresh_master_ui()} {} {
    code {ninseff=0;
nsyseff=0;
npart=0;

//the Master UI
npartcounter->do_callback();
syseffnocounter->do_callback();
inseffnocounter->do_callback();
delete microtonalui;
microtonalui=new MicrotonalUI(osc, "/microtonal/");
updatesendwindow();
updatepanel();

//the simle MasterUI
simplenpartcounter->value(1);
simplesyseffnocounter->value(1);
simpleinseffnocounter->value(1);
simplenpartcounter->do_callback();
simplesyseffnocounter->do_callback();
simpleinseffnocounter->do_callback();

simplerefresh();
bankui->hide();} {}
  }
  decl {class Osc_DataModel *last_xmz;} {public local
  }
  decl {MicrotonalUI *microtonalui;} {private local
  }
  decl {BankUI *bankui;} {private local
  }
  decl {int ninseff,npart;} {private local
  }
  decl {int nsyseff;} {private local
  }
  decl {int *exitprogram;} {private local
  }
  decl {Fl_Osc_Dial *syseffsend[NUM_SYS_EFX][NUM_SYS_EFX];} {private local
  }
  decl {VirKeyboard *virkeyboard;} {private local
  }
  decl {ConfigUI *configui;} {private local
  }
  decl {int swapefftype;} {private local
  }
  decl {char masterwindowlabel[100];} {private local
  }
  decl {Panellistitem *panellistitem[NUM_MIDI_PARTS];} {public local
  }
  decl {NioUI nioui;} {private local
  }
  decl {class Fl_Osc_Interface *osc;} {public local
  }
  decl {char last_loaded[XMZ_PATH_MAX];} {public local
  }
  decl {char loading_next[XMZ_PATH_MAX];} {public local
  }
  Function {close()} {open return_type void
  } {
    code {*exitprogram=1;} {}
  }
} 
