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

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

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

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

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

decl {\#include <FL/Fl_File_Chooser.H>} {public local
} 

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

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

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

decl {extern Dump dump;} {public local
} 

class ConfigUI {} {
  Function {make_window()} {} {
    Fl_Window configwindow {
      label {ZynAddSubFX Settings}
      callback {writebankcfg();
o->hide();}
      xywh {554 443 510 370} type Double visible
    } {
      Fl_Tabs {} {
        xywh {5 5 500 330}
      } {
        Fl_Group {} {
          label {Main settings}
          xywh {5 25 500 310}
        } {
          Fl_Group {} {
            label {Sample Rate}
            xywh {15 45 165 30} box ENGRAVED_FRAME
          } {
            Fl_Choice {} {
              callback {if ((int)o->value()==0) samplerateinput->activate();
       else samplerateinput->deactivate();

int samplerates[8]={44100,16000,22050,32000,44100,48000,88200,96000};
config.cfg.SampleRate=samplerates[(int)o->value()];

setsamplerateinput();}
              xywh {20 50 85 20} down_box BORDER_BOX textsize 10
              code0 {o->value(getsamplerateorder());}
            } {
              MenuItem {} {
                label Custom
                xywh {10 10 100 20} labelfont 1
              }
              MenuItem {} {
                label 16000Hz
                xywh {30 30 100 20} labelfont 1
              }
              MenuItem {} {
                label 22050Hz
                xywh {20 20 100 20} labelfont 1
              }
              MenuItem {} {
                label 32000Hz
                xywh {30 30 100 20} labelfont 1
              }
              MenuItem {} {
                label 44100Hz
                xywh {40 40 100 20} labelfont 1
              }
              MenuItem {} {
                label 48000Hz
                xywh {50 50 100 20} labelfont 1
              }
              MenuItem {} {
                label 88200Hz
                xywh {60 60 100 20} labelfont 1
              }
              MenuItem {} {
                label 96000Hz
                xywh {70 70 100 20} labelfont 1
              }
            }
            Fl_Input samplerateinput {
              callback {char *tmp;
config.cfg.SampleRate=strtoul(o->value(),&tmp,10);}
              xywh {115 50 60 20} type Int textfont 1
              code0 {setsamplerateinput();}
              code1 {if (getsamplerateorder()!=0) o->deactivate();}
            }
          }
          Fl_Input {} {
            label {Buffer Size}
            callback {char *tmp;
config.cfg.SoundBufferSize=strtoul(o->value(),&tmp,10);}
            tooltip {Internal Sound Buffer Size (samples)} xywh {190 45 60 20} type Int labelsize 11 align 129 textfont 1
            code0 {char *tmpbuf=new char[100];o->cut(0,o->maximum_size());}
            code1 {snprintf(tmpbuf,100,"%d",config.cfg.SoundBufferSize);o->insert(tmpbuf);}
            code2 {delete []tmpbuf;}
          }
          Fl_Check_Button {} {
            label {Swap Stereo }
            callback {config.cfg.SwapStereo=(int) o->value();}
            xywh {15 80 95 20} box NO_BOX labelsize 11
            code0 {o->value(config.cfg.SwapStereo);}
          }
          Fl_Choice {} {
            label OscilSize
            callback {config.cfg.OscilSize=128<<o->value();}
            tooltip {ADSynth Oscillator Size (samples)} xywh {175 80 75 20} down_box BORDER_BOX labelfont 1 labelsize 11 textsize 10
            code0 {o->value( (int) (log(config.cfg.OscilSize/128.0-1.0)/log(2)) +1);}
          } {
            MenuItem {} {
              label 128
              xywh {25 25 100 20} labelfont 1
            }
            MenuItem {} {
              label 256
              xywh {35 35 100 20} labelfont 1
            }
            MenuItem {} {
              label 512
              xywh {45 45 100 20} labelfont 1
            }
            MenuItem {} {
              label 1024
              xywh {45 45 100 20} labelfont 1
            }
            MenuItem {} {
              label 2048
              xywh {55 55 100 20} labelfont 1
            }
            MenuItem {} {
              label 4096
              xywh {55 55 100 20} labelfont 1
            }
            MenuItem {} {
              label 8192
              xywh {65 65 100 20} labelfont 1
            }
            MenuItem {} {
              label 16384
              xywh {75 75 100 20} labelfont 1
            }
          }
          Fl_Box {} {
            label {Most settings has effect only after ZynAddSubFX is restarted.}
            xywh {10 300 235 30} labelfont 1 labelsize 11 align 128
          }
          Fl_Box {} {
            label {Read the Readme.txt for other settings}
            xywh {10 280 240 15} labelfont 1 labelsize 11 align 128
          }
          Fl_Group {} {
            xywh {15 125 230 85} box ENGRAVED_BOX
          } {
            Fl_File_Input {} {
              label {Dump File}
              callback {config.cfg.DumpFile = o->value();}
              xywh {20 170 220 35} align 5
              code0 {o->insert(config.cfg.DumpFile.c_str());}
            }
            Fl_Check_Button {} {
              label {Dump notes}
              callback {config.cfg.DumpNotesToFile=(int) o->value();
dump.startnow();//this has effect only if this option was disabled}
              xywh {20 130 110 20} down_box DOWN_BOX
              code0 {o->value(config.cfg.DumpNotesToFile);}
            }
            Fl_Check_Button {} {
              label Append
              callback {config.cfg.DumpAppend=(int) o->value();}
              xywh {160 130 80 20} down_box DOWN_BOX
              code0 {o->value(config.cfg.DumpAppend);}
            }
          }
          Fl_Counter {} {
            label {XML compression level}
            callback {config.cfg.GzipCompression=(int) o->value();}
            tooltip {gzip compression level (0 - uncompressed)} xywh {20 215 65 15} type Simple labelsize 11 align 8 minimum 0 maximum 9 step 1
            code0 {o->value(config.cfg.GzipCompression);}
          }
          Fl_Choice {} {
            label {PADsynth Interpolation}
            callback {config.cfg.Interpolation=(int) o->value();}
            xywh {175 105 75 15} down_box BORDER_BOX labelsize 10 textsize 11
            code0 {o->value(config.cfg.Interpolation);}
          } {
            MenuItem {} {
              label {Linear(fast)}
              xywh {0 0 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label {Cubic(slow)}
              xywh {10 10 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Choice {} {
            label {Virtual Keyboard Layout}
            callback {config.cfg.VirKeybLayout=(int) o->value();;}
            xywh {155 235 85 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 11
            code0 {o->value(config.cfg.VirKeybLayout);}
          } {
            MenuItem {} {
              label { }
              xywh {5 5 100 20} labelfont 1 labelsize 11 deactivate
            }
            MenuItem {} {
              label QWERTY
              xywh {15 15 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Dvorak
              xywh {25 25 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label QWERTZ
              xywh {35 35 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label AZERTY
              xywh {45 45 100 20} labelfont 1 labelsize 11
            }
          }
          Fl_Check_Button {} {
            label {Ignore MIDI Program Change}
            callback {config.cfg.IgnoreProgramChange=(int) o->value();}
            xywh {10 255 220 20} down_box DOWN_BOX
            code0 {o->value(config.cfg.IgnoreProgramChange);}
          }
        }
        Fl_Group {} {
          label {Bank root dirs}
          xywh {5 25 500 285} hide
        } {
          Fl_Browser rootsbrowse {
            callback {activatebutton_rootdir(o->value()!=0);}
            xywh {15 35 485 220} type Hold
          }
          Fl_Button {} {
            label {Add root directory...}
            callback {const char *dirname;
dirname=fl_dir_chooser("Add a root directory for banks:",NULL,0);
if (dirname==NULL) return;

rootsbrowse->add(dirname);}
            xywh {15 265 80 35} box THIN_UP_BOX align 128
          }
          Fl_Button removerootdirbutton {
            label {Remove root dir...}
            callback {if (rootsbrowse->value()!=0) {
   rootsbrowse->remove(rootsbrowse->value());
};
activatebutton_rootdir(false);}
            xywh {105 265 80 35} box THIN_UP_BOX align 128
            code0 {o->deactivate();}
          }
          Fl_Button makedefaultrootdirbutton {
            label {Make default}
            callback {int n=rootsbrowse->value();

if (n!=0) {
   rootsbrowse->move(1,n);
   rootsbrowse->value(1);
   rootsbrowse->redraw();
};
activatebutton_rootdir(true);}
            xywh {190 265 80 35} box THIN_UP_BOX align 128
            code0 {o->deactivate();}
          }
        }
        Fl_Group {} {
          label {Presets dirs}
          xywh {5 25 500 285} hide
        } {
          Fl_Browser presetbrowse {
            callback {activatebutton_presetdir(o->value()!=0);}
            xywh {15 35 485 220} type Hold
          }
          Fl_Button {} {
            label {Add preset directory...}
            callback {const char *dirname;
dirname=fl_dir_chooser("Add a preset directory :",NULL,0);
if (dirname==NULL) return;

presetbrowse->add(dirname);}
            xywh {15 265 80 35} box THIN_UP_BOX align 128
          }
          Fl_Button removepresetbutton {
            label {Remove preset dir...}
            callback {if (presetbrowse->value()!=0) {
   presetbrowse->remove(presetbrowse->value());
};
activatebutton_presetdir(false);}
            xywh {105 265 80 35} box THIN_UP_BOX align 128
            code0 {o->deactivate();}
          }
          Fl_Button makedefaultpresetbutton {
            label {Make default}
            callback {int n=presetbrowse->value();

if (n!=0) {
   presetbrowse->move(1,n);
   presetbrowse->value(1);
   presetbrowse->redraw();
};
activatebutton_presetdir(true);}
            xywh {190 265 80 35} box THIN_UP_BOX align 128
            code0 {o->deactivate();}
          }
        }
      }
      Fl_Button {} {
        label Close
        callback {configwindow->hide();
writebankcfg();
writepresetcfg();}
        xywh {200 345 105 20} box THIN_UP_BOX
      }
    }
  }
  Function {ConfigUI()} {} {
    code {make_window();
readbankcfg();
readpresetcfg();} {}
  }
  Function {activatebutton_rootdir(bool active)} {} {
    code {if (active) {
	removerootdirbutton->activate();
	makedefaultrootdirbutton->activate();
}else{
	removerootdirbutton->deactivate();
	makedefaultrootdirbutton->deactivate();
};} {}
  }
  Function {activatebutton_presetdir(bool active)} {} {
    code {if (active) {
	removepresetbutton->activate();
	makedefaultpresetbutton->activate();
}else{
	removepresetbutton->deactivate();
	makedefaultpresetbutton->deactivate();
};} {}
  }
  Function {readbankcfg()} {} {
    code {rootsbrowse->clear();

for (int i=0;i<MAX_BANK_ROOT_DIRS;i++){
  if (!config.cfg.bankRootDirList[i].empty())
    rootsbrowse->add(config.cfg.bankRootDirList[i].c_str());
};} {}
  }
  Function {writebankcfg()} {} {
    code {config.clearbankrootdirlist();

for (int n=0;n<rootsbrowse->size();n++){ 
     config.cfg.bankRootDirList[n] = rootsbrowse->text(n+1);
};} {}
  }
  Function {readpresetcfg()} {} {
    code {presetbrowse->clear();

for(int i=0;i<MAX_BANK_ROOT_DIRS;i++){
  if(!config.cfg.presetsDirList[i].empty())
   presetbrowse->add(config.cfg.presetsDirList[i].c_str());
};} {}
  }
  Function {writepresetcfg()} {} {
    code {config.clearpresetsdirlist();

for (int n=0;n<presetbrowse->size();n++)
     config.cfg.presetsDirList[n] = presetbrowse->text(n+1);} {}
  }
  Function {getsamplerateorder()} {return_type int
  } {
    code {int smpr=config.cfg.SampleRate;
int order=0;
switch(smpr){
   case 16000:order=1;break;
   case 22050:order=2;break;
   case 32000:order=3;break;
   case 44100:order=4;break;
   case 48000:order=5;break;
   case 88200:order=6;break;
   case 96000:order=7;break;
   default:order=0;break;
};
return(order);} {}
  }
  Function {setsamplerateinput()} {return_type void
  } {
    code {char *tmpbuf=new char[100];
samplerateinput->cut(0,samplerateinput->maximum_size());
snprintf(tmpbuf,100,"%d",config.cfg.SampleRate);
samplerateinput->insert(tmpbuf);
delete []tmpbuf;} {}
  }
  Function {show()} {} {
    code {configwindow->show();} {}
  }
} 
