# 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 "Fl_Osc_Dial.H"} {public local
} 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

class PointButton {open : {public Fl_Button, public Fl_Osc_Widget}}
{
  Function {PointButton(int x,int y, int w, int h, const char *label=0):Fl_Button(x,y,w,h,label),Fl_Osc_Widget(this)} {open
  } {
    code {} {}
  }
  Function {rebase(std::string new_base)} {open
  } {
    code {loc = new_base;} {}
  }
  Function {init(std::string path_)} {open
  } {
    code {ext = path_;} {}
  }
}
class EnvelopeUI {open : {public Fl_Osc_Group,PresetsUI_}
} {
  Function {EnvelopeUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h)} {} {
    code {freemodeeditwindow=NULL;
envADSR=NULL;
envASR=NULL;
envADSRfilter=NULL;
envASRbw=NULL;
envfree=NULL;} {}
  }
  Function {~EnvelopeUI()} {} {
    code {envwindow->hide();
hide();
freemodeeditwindow->hide();
delete (freemodeeditwindow);} {}
  }
  Function {make_freemode_edit_window()} {open
  } {
    Fl_Window freemodeeditwindow {
      label Envelope open
      xywh {702 801 575 180} type Double resizable
      class Fl_Osc_Window visible
    } {
      Fl_Button {} {
        label C
        callback {presetsui->copy(freemodeeditwindow->loc());}
        xywh {465 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        code0 {freemodeeditwindow->init(osc, loc());}
      }
      Fl_Button {} {
        label P
        callback {presetsui->paste(freemodeeditwindow->loc(),this);}
        xywh {482 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
      }
      Fl_Button addpoint {
        label {Add pt}
        callback {
if(freeedit->lastpoint >= MAX_ENVELOPE_POINTS - 1)
    return;
o->oscWrite("addPoint", "i", freeedit->lastpoint);
freeedit->lastpoint+=1;
freeedit->update();
envfree->redraw();
sustaincounter->update();

//sustaincounter->value(Penvsustain);
//sustaincounter->maximum(Penvpoints-2);}
        xywh {90 155 80 20} box THIN_UP_BOX labelsize 11
        code0 {(void)o->init("addPoint");}
        class PointButton
      }
      Fl_Box freeedit {
        label Envelope
        callback {sustaincounter->maximum(o->Penvpoints-2);}
        xywh {5 5 565 145} box FLAT_BOX color 0
        code0 {o->init();}
        class EnvelopeFreeEdit
      }
      Fl_Button deletepoint {
        label {Delete pt}
        callback {o->oscWrite("delPoint", "i", freeedit->lastpoint);
freeedit->lastpoint-=1;
freeedit->update();
envfree->redraw();
sustaincounter->update();
//sustaincounter->value(Penvsustain);
//sustaincounter->maximum(Penvpoints-2);}
        xywh {175 155 85 20} box THIN_UP_BOX labelsize 11
        code0 {(void)o->init("delPoint");}
        class PointButton
      }
      Fl_Check_Button forcedreleasecheck {
        label frcR
        tooltip {Forced Release} xywh {410 165 40 15} down_box DOWN_BOX labelsize 10
        code0 {o->init("Pforcedrelease");}
        class Fl_Osc_Check
      }
      Fl_Dial envstretchdial {
        label {Str.}
        tooltip {Envelope stretch (on lower notes make the envelope longer)} xywh {380 155 25 25} box ROUND_UP_BOX labelsize 10 align 4 maximum 127 step 1
        code0 {o->init("Penvstretch");}
        class Fl_Osc_Dial
      }
      Fl_Button {} {
        label Close
        callback {freemodeeditwindow->hide();}
        xywh {510 155 60 20} box THIN_UP_BOX
      }
      Fl_Check_Button linearenvelopecheck {
        label L
        tooltip {Linear Envelope} xywh {410 151 30 15} down_box DOWN_BOX labelsize 10
        code0 {o->init("Plinearenvelope");}
        class Fl_Osc_Check
      }
      Fl_Counter sustaincounter {
        label Sust
        callback {freeedit->redraw();
envfree->redraw();}
        tooltip {Sustain (0 is disabled)} xywh {305 155 40 15} type Simple labelsize 11 align 4 minimum 0 maximum 127 step 1
        code3 {o->init("Penvsustain");}
        class Fl_Osc_Counter
      }
      Fl_Check_Button freemodehack {
          xywh {0 0 0 0} down_box DOWN_BOX
          callback{refresh_display();}
          code0 {o->init("Pfreemode");o->hide();}
          class Fl_Osc_Check
      }
      Fl_Button {} {
        label {Cancel}
	tooltip {Cancel freemode editing}
        callback {disable_freemode();}
        xywh {5 155 80 20} box THIN_UP_BOX labelsize 11 labelcolor 1
        class Fl_Osc_Button
      }
    }
  }
  Function {make_ADSR_window()} {} {
    Fl_Window envADSR {open
      xywh {353 911 205 70} type Double color 50 labelfont 1
      class Fl_Osc_Group visible
    } {
      Fl_Group {} {
        label {Amplitude Envelope}
        xywh {0 0 205 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
        code0 {set_module_parameters(o);}
      } {
        Fl_Button {} {
          label C
          callback {presetsui->copy(envADSR->loc());}
          xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Button {} {
          label P
          callback {presetsui->paste(envADSR->loc(),this);}
          xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Dial e1adt {
          label {A.dt}
          callback {freeedit->redraw();}
          tooltip {Attack time} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e1ddt {
          label {D.dt}
          callback {freeedit->redraw();}
          tooltip {Decay time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PD_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e1rdt {
          label {R.dt}
          callback {freeedit->redraw();}
          tooltip {Release time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e1sval {
          label {S.val}
          callback {freeedit->redraw();}
          tooltip {Sustain value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PS_val");}
          class Fl_Osc_Dial
        }
        Fl_Check_Button e1forcedrelease {
          label frcR
          tooltip {Forced Release} xywh {180 35 20 15} down_box DOWN_BOX labelsize 10 align 6
          code0 {o->init("Pforcedrelease");}
          class Fl_Osc_Check
        }
        Fl_Dial e1envstretch {
          label Stretch
          tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Penvstretch");}
          class Fl_Osc_Dial
        }
        Fl_Button {} {
          label E
          callback {open_as_freemode();}
          tooltip {Envelope window} xywh {185 5 15 15} labelfont 1 labelsize 10
          class Fl_Osc_Button
        }
        Fl_Check_Button e1linearenvelope {
          label L
          tooltip {The evelope is linear} xywh {180 20 15 15} down_box DOWN_BOX labelsize 10 align 4
          code0 {o->init("Plinearenvelope");}
          class Fl_Osc_Check
        }
      }
    }
  }
  Function {make_ASR_window()} {} {
    Fl_Window envASR {open
      xywh {1067 911 210 70} type Double
      class Fl_Osc_Group visible
    } {
      Fl_Group {} {
        label {Frequency Envelope}
        xywh {0 0 210 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
        code0 {set_module_parameters(o);}
      } {
        Fl_Button {} {
          label C
          callback {presetsui->copy(envASR->loc());}
          xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Button {} {
          label P
          callback {presetsui->paste(envASR->loc(),this);}
          xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Dial e2aval {
          label {A.val}
          callback {freeedit->redraw();}
          tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e2adt {
          label {A.dt}
          callback {freeedit->redraw();}
          tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e2rval {
          label {R.val}
          callback {freeedit->redraw();}
          tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e2rdt {
          label {R.dt}
          callback {freeedit->redraw();}
          tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e2envstretch {
          label Stretch
          tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Penvstretch");}
          class Fl_Osc_Dial
        }
        Fl_Check_Button e2forcedrelease {
          label frcR
          tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
          code0 {o->init("Pforcedrelease");}
          class Fl_Osc_Check
        }
      }
      Fl_Button {} {
        label E
        callback {open_as_freemode();}
        tooltip {Envelope window} xywh {190 5 15 15} labelfont 1 labelsize 10
        class Fl_Osc_Button
      }
    }
  }
  Function {make_ADSRfilter_window()} {} {
    Fl_Window envADSRfilter {open
      xywh {1002 911 275 70} type Double color 50 labelfont 1
      class Fl_Osc_Group visible
    } {
      Fl_Group {} {
        label {Filter Envelope}
        xywh {0 0 275 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
        code0 {set_module_parameters(o);}
      } {
        Fl_Button {} {
          label C
          callback {presetsui->copy(envADSRfilter->loc());}
          xywh {220 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Button {} {
          label P
          callback {presetsui->paste(envADSRfilter->loc(),this);}
          xywh {237 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Dial e3aval {
          label {A.val}
          callback {freeedit->redraw();}
          tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e3adt {
          label {A.dt}
          callback {freeedit->redraw();}
          tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e3dval {
          label {D.val}
          callback {freeedit->redraw();}
          tooltip {decay value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PD_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e3ddt {
          label {D.dt}
          callback {freeedit->redraw();}
          tooltip {decay time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PD_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e3rdt {
          label {R.dt}
          callback {freeedit->redraw();}
          tooltip {Release time} xywh {145 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e3rval {
          label {R.val}
          callback {freeedit->redraw();}
          tooltip {Release value} xywh {180 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e3envstretch {
          label Stretch
          tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {215 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Penvstretch");}
          class Fl_Osc_Dial
        }
        Fl_Check_Button e3forcedrelease {
          label frcR
          tooltip {Forced Release} xywh {250 30 15 20} down_box DOWN_BOX labelsize 10 align 6
          code0 {o->init("Pforcedrelease");}
          class Fl_Osc_Check
        }
        Fl_Button {} {
          label E
          callback {open_as_freemode();}
          xywh {255 5 15 15} labelfont 1 labelsize 10
          class Fl_Osc_Button
        }
      }
    }
  }
  Function {make_ASRbw_window()} {} {
    Fl_Window envASRbw {open
      xywh {371 911 210 70} type Double
      code0 {set_module_parameters(o);}
      class Fl_Osc_Group visible
    } {
      Fl_Group {} {
        label {BandWidth Envelope}
        xywh {0 0 210 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
        code0 {set_module_parameters(o);}
      } {
        Fl_Button {} {
          label C
          callback {presetsui->copy(envASRbw->loc());}
          xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Button {} {
          label P
          callback {presetsui->paste(envASRbw->loc(),this);}
          xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Dial e4aval {
          label {A.val}
          callback {freeedit->redraw();}
          tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e4adt {
          label {A.dt}
          callback {freeedit->redraw();}
          tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PA_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e4rval {
          label {R.val}
          callback {freeedit->redraw();}
          tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_val");}
          class Fl_Osc_Dial
        }
        Fl_Dial e4rdt {
          label {R.dt}
          callback {freeedit->redraw();}
          tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("PR_dt");}
          class Fl_Osc_Dial
        }
        Fl_Dial e4envstretch {
          label Stretch
          tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Penvstretch");}
          class Fl_Osc_Dial
        }
        Fl_Check_Button e4forcedrelease {
          label frcR
          tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
          code0 {o->init("Pforcedrelease");}
          class Fl_Osc_Check
        }
      }
      Fl_Button {} {
        label E
        callback {open_as_freemode();}
        xywh {190 5 15 15} labelfont 1 labelsize 10
        class Fl_Osc_Button
      }
    }
  }
  Function {make_free_window()} {} {
    Fl_Window envfree {open
      xywh {385 911 205 70} type Double color 50 labelfont 1 resizable
      code0 {set_module_parameters(o);}
      class Fl_Osc_Group visible
    } {
      Fl_Group envfreegroup {
        label {Amplitude Envelope}
        xywh {0 0 205 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17 resizable
        code0 {set_module_parameters(o);}
      } {
        Fl_Button {} {
          label E
          callback {open_as_freemode();}
          xywh {185 5 15 15} labelfont 1 labelsize 10
          class Fl_Osc_Button
        }
        Fl_Box freeeditsmall {
          label Envelope
          callback {envfree->redraw();}
          xywh {5 20 195 45} box FLAT_BOX color 0 resizable
          code0 {o->init();}
          class EnvelopeFreeEdit
        }
        Fl_Button {} {
          label C
          callback {presetsui->copy(envfree->loc());}
          xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
        Fl_Button {} {
          label P
          callback {presetsui->paste(envfree->loc(),this);}
          xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
        }
      }
    }
  }
  Function {open_as_freemode()} {open
  } {
     code {
    if (!freemodehack->value() &&
        fl_choice("Convert envelope to free mode data?","No","Yes",NULL)==0)
        return;
    freemodehack->oscWrite("Pfreemode", "T");
    freeedit->update();
    freemodeeditwindow->show();
    freemodeeditwindow->position(Fl::event_x_root()-20, Fl::event_y_root()+20);
    freemodeeditwindow->size_range(400,160);
} {}
}
  Function {init(int env_type, Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {open
  } {
    code {osc  = osc_;
    base = base_;
    ext  = ext_;
    Envmode = env_type;
    Penvsustain = false;
    Penvpoints  = 3;
    Penvstretch = 0;
    Pforcedrelease = 0;
    Plinearenvelope = 0;
    assert(osc);
make_ADSR_window();
make_ASR_window();
make_ADSRfilter_window();
make_ASRbw_window();
make_free_window();

make_freemode_edit_window();

envwindow=NULL;
if(Envmode==3) envfreegroup->label("Frequency Envelope");
if(Envmode==4) envfreegroup->label("Filter Envelope");
if(Envmode==5) envfreegroup->label("Bandwidth Envelope");

freemodeeditwindow->label(this->label());


freeeditsmall->setpair(freeedit);
freeedit->setpair(freeeditsmall);


refresh_display();} {}
  }
  Function {rebase(std::string new_base)} {open
  } {
    code {Fl_Osc_Group::rebase(new_base);
    freemodeeditwindow->rebase(new_base+ext);} {}
  }
  Function {disable_freemode()} {open
  } {
    code {if (fl_choice("Discard free mode data?","No","Yes",NULL)==0)
        return;

    hide();
    int winx = Fl::event_x_root()-10;
    int winy = Fl::event_y_root()-155;
    winx = winx < 1 ? 1 : winx;
    winy = winy < 1 ? 1 : winy;
    freemodeeditwindow->hide();

    envwindow->hide();
    Fl_Group *par=envwindow->parent();
    par->hide();

    freemodehack->oscWrite("Pfreemode", "F");
    freeedit->update();
    envwindow->show();
    par->redraw();

    par->show();
    show();
    freemodeeditwindow->position(winx,winy);} {}
  }
  Function {refresh()} { open }
  { code {
    freemodehack->oscWrite("Pfreemode");
  } {}
  }
  Function {refresh_display()} {open
  } {
    code {

    sustaincounter->value(Penvsustain);
    sustaincounter->maximum(Penvpoints-2);

    envstretchdial->value(Penvstretch);

    if (Envmode > 2)
      linearenvelopecheck->hide();
    else {
      linearenvelopecheck->value(Plinearenvelope);
      linearenvelopecheck->show();
    }

    forcedreleasecheck->value(Pforcedrelease);

envADSR->hide();
envASR->hide();
envADSRfilter->hide();
envASRbw->hide();
envfree->hide();

if (freemodehack->value()) {
   envwindow=envfree;
   freeedit->update();
} else {
   freemodeeditwindow->hide();
   switch(Envmode){
         case 1:
         case 2:
           envwindow=envADSR;
         break;
         case 3:
           envwindow=envASR;
         break; 
         case 4:
           envwindow=envADSRfilter;
         break; 
         case 5:
          envwindow=envASRbw;
         break;
         default:
         break; 
   }
}

assert(envwindow);
envwindow->resize(this->x(),this->y(),this->w(),this->h());

envwindow->show();} {}
  }
  decl {int Envmode;} {private local
  }
  decl {int Penvsustain;} {private local
  }
  decl {int Penvpoints;} {private local
  }
  decl {int Penvstretch;} {private local
  }
  decl {int Pforcedrelease;} {private local
  }
  decl {int Plinearenvelope;} {private local
  }
  decl {Fl_Group *envwindow;} {private local
  }
} 
