# 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 or later} {} 

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

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

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

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

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

decl {\#include "Fl_Osc_Pane.H"} {public
}

decl {\#include "Fl_Osc_Value.H"} {public
}

decl {\#include "Fl_Osc_Check.H"} {public
}

decl {\#include "Fl_Osc_Counter.H"} {public
}

decl {\#include "Fl_Osc_Input.H"} {public
}

decl {\#include "Fl_Osc_Output.H"} {public
}

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

class MicrotonalUI {} {
  Function {make_window(Fl_Osc_Interface *osc, std::string base)} {} {
    Fl_Window microtonaluiwindow {
      label Scales
      xywh {99 164 405 450} type Double hide
      class Fl_Osc_Window
    } {
      Fl_Box {} {
        xywh {0 0 0 0}
        code0 {microtonaluiwindow->init(osc, base);}
      }
      Fl_Group {} {
        tooltip {Center where the note's freqs. are turned upside-down} xywh {249 2 155 45} box ENGRAVED_FRAME
      } {
        Fl_Check_Button {} {
          label {Invert keys}
          callback {if (o->value()==0) centerinvertcounter->deactivate();
   else centerinvertcounter->activate();}
          tooltip {Turn upside-down the note frequencies} xywh {254 13 55 30} down_box DOWN_BOX labelfont 1 labelsize 11 align 148
          code0 {o->init("Pinvertupdown");}
          class Fl_Osc_Check
        }
        Fl_Counter centerinvertcounter {
          label Center
          xywh {319 13 80 20} labelfont 1 labelsize 11 align 130 minimum 0 maximum 127 step 1 textfont 1
          code0 {o->lstep(12/*microtonal->getoctavesize()*/);}
          code1 {o->init("Pinvertupdowncenter");}
          class Fl_Osc_Counter
        }
      }
      Fl_Group microtonalgroup {selected
        xywh {3 49 402 398} box ENGRAVED_FRAME
      } {
        Fl_Button applybutton {
          label Retune
          callback {apply();}
          tooltip {Retune the synth accorging to the inputs from "Tunnings" and "Keyboard Mappings"} xywh {8 413 107 28} box THIN_UP_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13
        }
        Fl_Value_Output octavesizeoutput {
          label {nts./oct.}
          tooltip {Notes/Octave} xywh {150 423 35 17} labelsize 10 align 5 maximum 500 step 1 value 12 textfont 1
          code0 {o->init("octavesize");}
          class Fl_Osc_Output
        }
        Fl_Input nameinput {
          label {Name:}
          xywh {8 64 285 25} labelfont 1 labelsize 11 align 5
          code0 {o->maximum_size(MICROTONAL_MAX_NAME_LEN);}
          code1 {o->init("Pname");}
          class Fl_Osc_Input
        }
        Fl_Input tuningsinput {
          label {Tunings:}
          xywh {8 144 182 264} type Multiline labelfont 1 labelsize 11 align 5 when 2
          code0 {o->init("tunings");}
          class Fl_Osc_Input
        }
        Fl_Input commentinput {
          label {Comment:}
          xywh {8 104 391 25} labelfont 1 labelsize 11 align 5
          code0 {o->maximum_size(MICROTONAL_MAX_NAME_LEN);}
          code1 {o->init("Pcomment");}
          class Fl_Osc_Input
        }
        Fl_Counter {} {
          label Shift
          xywh {313 69 70 20} type Simple labelsize 11 align 1 minimum -64 maximum 63 step 1 textfont 1
          code0 {o->init("Pscaleshift");}
          class Fl_Osc_Counter
        }
        Fl_Button {} {
          label {Import .SCL file}
          callback {const char *filename;
filename=fl_file_chooser("Open:","(*.scl)",NULL,0);
if (filename==NULL) return;
osc->write("/load_scl", "s", filename);
if (true) {
       updateTuningsInput();
       nameinput->update();
       commentinput->update();
       tuningsinput->position(0);
       octavesizeoutput->update();
     }
     }
          tooltip {Inport Scala .scl file (tunnings)} xywh {243 411 84 15} box THIN_UP_BOX labelfont 1 labelsize 10
        }
        Fl_Group keymappinggroup {
          label {Keyboard Mapping} open
          xywh {193 144 206 264} box ENGRAVED_BOX labelfont 1 labelsize 11
        } {
          Fl_Input mappinginput {
            xywh {250 147 146 258} type Multiline labelfont 1 labelsize 11 align 5 when 2
            code0 {o->init("mapping");}
            class Fl_Osc_Input
          }
          Fl_Counter firstnotecounter {
            label {First note}
            tooltip {First MIDI note number} xywh {199 195 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 textfont 1 textsize 11
            code0 {o->init("Pfirstkey");}
            class Fl_Osc_Counter
          }
          Fl_Counter lastnotecounter {
            label {Last note}
            tooltip {Last MIDI note number} xywh {199 225 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 value 127 textfont 1 textsize 11
            code0 {o->init("Plastkey");}
            class Fl_Osc_Counter
          }
          Fl_Counter middlenotecounter {
            label {Midle note}
            tooltip {Midle note (where scale degree 0 is mapped to)} xywh {199 267 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 value 60 textfont 1 textsize 11
            code0 {o->init("Pmiddlenote");}
            class Fl_Osc_Counter
          }
          Fl_Value_Output mapsizeoutput {
            label {Map Size}
            xywh {201 382 44 20} labelsize 10 align 5 maximum 500 step 1 value 12 textfont 1
            code0 {o->init("Pmapsize");}
            class Fl_Osc_Output
          }
        }
        Fl_Check_Button mappingenabledbutton {
          label ON
          callback {if (o->value()==0) keymappinggroup->deactivate();
 else keymappinggroup->activate();
o->show();}
          tooltip {Enable the Mapping (otherwise the mapping is linear)} xywh {198 150 48 21} box FLAT_BOX down_box DOWN_BOX labelfont 1
          code0 {o->init("Pmappingenabled");}
          class Fl_Osc_Check
        }
        Fl_Button {} {
          label {Import .kbm file}
          callback {
          const char *filename;
filename=fl_file_chooser("Open:","(*.kbm)",NULL,0);
if (filename==NULL) return;
osc->write("/load_kbm", "s", filename);
if (true) {
       updateMappingInput();
       mappinginput->position(0);
       mapsizeoutput->update();
       firstnotecounter->update();
       lastnotecounter->update();
       middlenotecounter->update();
       mappingenabledbutton->update();
       afreqinput->update();
       anotecounter->update();
     }}
          tooltip {Inport Scala .kbm file (keyboard mapping)} xywh {243 428 84 16} box THIN_UP_BOX labelfont 1 labelsize 10
        }
      }
      Fl_Group {} {
        xywh {108 2 140 45} box ENGRAVED_FRAME
      } {
        Fl_Counter anotecounter {
          label {"A" Note}
          callback {
          /*if (microtonal->getnotefreq(o->value(),0)<0.0) o->textcolor(FL_RED);
 else o->textcolor(FL_BLACK);*/

o->redraw();}
          tooltip {The "A" note (the reference note for which freq. ("A" freq) is given)} xywh {173 17 65 20} labelfont 1 labelsize 10 align 129 minimum 0 maximum 127 step 1 value 69 textfont 1 textsize 10
          code0 {o->lstep(12);}
          code1 {o->init("PAnote");}
          class Fl_Osc_Counter
        }
        Fl_Value_Input afreqinput {
          label {"A" Freq.}
          tooltip {The freq. of "A" note (default=440.0)} xywh {118 17 45 20} labelfont 1 labelsize 10 align 1 minimum 1 maximum 20000 step 0.001 value 440 textfont 1 textsize 10
          code0 {o->init("PAfreq");}
          class Fl_Osc_Value
        }
      }
      Fl_Button {} {
        label Close
        callback {microtonaluiwindow->hide();}
        xywh {333 413 67 28} box THIN_UP_BOX
      }
      Fl_Check_Button {} {
        label {Enable Microtonal}
        callback {if (o->value()==0) microtonalgroup->deactivate();
   else microtonalgroup->activate();}
        xywh {3 3 102 45} box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 11 align 148
        code0 {o->init("Penabled");}
        class Fl_Osc_Check
      }
    }
  }
  Function {updateTuningsInput()} {} {
    code {tuningsinput->update();} {}
  }
  Function {updateMappingInput()} {} {
    code { mappinginput->update(); } {}
  }
  Function {MicrotonalUI(Fl_Osc_Interface *osc_, std::string base)} {} {
    code {osc=osc_;make_window(osc, base);} {}
  }
  Function {~MicrotonalUI()} {} {
    code {microtonaluiwindow->hide();
delete(microtonaluiwindow);} {}
  }
  Function {show()} {} {
    code {microtonaluiwindow->show();} {}
  }
  Function {apply()} {} {
    code {
    osc->write("/microtonal/tunings", "s", tuningsinput->value());
    osc->write("/microtonal/mapping", "s", mappinginput->value());
    octavesizeoutput->update();
    mapsizeoutput->update();
    anotecounter->update();
    } {}
  }
  decl {Fl_Osc_Interface *osc;} {private local
  }
} 
