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

decl {//License: GNU GPL version 2} {} 

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

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

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

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

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

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

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

decl {extern Dump dump;} {public
} 

class ConfigUI {} {
  Function {make_window()} {} {
    Fl_Window configwindow {
      label {ZynAddSubFX Settings}
      callback {writebankcfg();
o->hide();}
      xywh {88 313 510 340} type Double hide
    } {
      Fl_Tabs {} {
        xywh {5 5 500 305}
      } {
        Fl_Group {} {
          label {Main settings}
          xywh {5 25 500 285}
        } {
          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 12 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_Light_Button {} {
            label {Swap Stereo }
            callback {config.cfg.SwapStereo=(int) o->value();}
            xywh {20 80 85 20} box THIN_UP_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 12 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 {15 275 235 30} labelfont 1 labelsize 12 align 128
          }
          Fl_Box {} {
            label {Read the Readme.txt for other settings}
            xywh {10 255 240 20} labelfont 1 labelsize 12 align 128
          }
          Fl_Group {} {
            xywh {15 125 230 85} box ENGRAVED_BOX
          } {
            Fl_File_Input {} {
              label {Dump File}
              callback {snprintf(config.cfg.DumpFile,config.maxstringsize,"%s",o->value());}
              xywh {20 170 220 35} align 5
              code0 {o->insert(config.cfg.DumpFile);}
            }
            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 100 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_Group {} {
            xywh {255 45 245 260} box ENGRAVED_FRAME
          } {
            Fl_Box {} {
              label {Note: Not all the following settings are used (this depends on the operating system, etc..)}
              xywh {260 50 235 45} labelfont 1 labelsize 12 align 128
            }
            Fl_Group {} {
              label Linux
              xywh {260 110 235 115} box ENGRAVED_BOX labelfont 1 labelsize 16 align 5
            } {
              Fl_File_Input {} {
                label {OSS Sequencer Device (/dev/...)}
                callback {snprintf(config.cfg.LinuxOSSSeqInDev,config.maxstringsize,"%s",o->value());}
                xywh {265 180 225 35} align 5
                code0 {o->insert(config.cfg.LinuxOSSSeqInDev);}
              }
              Fl_File_Input {} {
                label {OSS Wave Out Device (/dev/...)}
                callback {snprintf(config.cfg.LinuxOSSWaveOutDev,config.maxstringsize,"%s",o->value());}
                xywh {265 130 225 35} align 5
                code0 {o->insert(config.cfg.LinuxOSSWaveOutDev);}
              }
            }
            Fl_Group {} {
              label Windows
              xywh {260 250 235 50} box ENGRAVED_BOX labelfont 1 labelsize 16 align 5
            } {
              Fl_Counter {} {
                label {Midi In Dev}
                callback {config.cfg.WindowsMidiInId=(int) o->value();
midiinputnamebox->label(config.winmididevices[config.cfg.WindowsMidiInId].name);}
                xywh {270 270 65 20} type Simple labelsize 12 align 1 minimum 0 maximum 100 step 1
                code0 {o->maximum(config.winmidimax-1);}
                code1 {o->value(config.cfg.WindowsMidiInId);}
              }
              Fl_Box midiinputnamebox {
                label {Midi input device name}
                xywh {340 260 150 35} labelfont 1 labelsize 12 align 212
                code0 {o->label(config.winmididevices[config.cfg.WindowsMidiInId].name);}
              }
            }
          }
          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 12 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 11 textsize 12
            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();;} open selected
            xywh {155 235 85 20} down_box BORDER_BOX labelsize 13 textfont 1 textsize 12
            code0 {o->value(config.cfg.VirKeybLayout);}
          } {
            menuitem {} {
              label { }
              xywh {5 5 100 20} labelfont 1 labelsize 13 deactivate
            }
            menuitem {} {
              label QWERTY
              xywh {15 15 100 20} labelfont 1 labelsize 13
            }
            menuitem {} {
              label Dvorak
              xywh {25 25 100 20} labelfont 1 labelsize 13
            }
          }
        }
        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 315 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]!=NULL) rootsbrowse->add(config.cfg.bankRootDirList[i]);
};} {}
  }
  Function {writebankcfg()} {} {
    code {config.clearbankrootdirlist();

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

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

for (int n=0;n<presetbrowse->size();n++){ 
     config.cfg.presetsDirList[n]=new char [MAX_STRING_SIZE];
     strncpy(config.cfg.presetsDirList[n],presetbrowse->text(n+1),MAX_STRING_SIZE);
};} {}
  }
  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();} {}
  }
}