You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
6.6KB

  1. /* SpiralSynthModular
  2. * Copyleft (C) 2002 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <stdio.h>
  19. #include <FL/Fl_Box.H>
  20. #include <FL/Fl_Pixmap.H>
  21. #include "SettingsWindow.h"
  22. #include "SpiralSynthModularInfo.h"
  23. #include "GUI/options.xpm"
  24. SettingsWindow::SettingsWindow() :
  25. Fl_Double_Window(250,275,"SSM Options"),
  26. m_App(NULL)
  27. {
  28. color(SpiralSynthModularInfo::GUICOL_Tool);
  29. box(FL_FLAT_BOX);
  30. Fl_Pixmap *Icon = new Fl_Pixmap(options_xpm);
  31. Fl_Box *IconBox = new Fl_Box(25,30,50,50,"");
  32. IconBox->image(Icon);
  33. Fl_Box *TextBox = new Fl_Box(180,10,50,20,"SpiralSynth Modular");
  34. TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
  35. TextBox = new Fl_Box(180,30,50,20,"Constructed by Dave Griffiths");
  36. TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
  37. TextBox->labelsize(10);
  38. TextBox = new Fl_Box(192,40,50,20,"dave@@pawfal.org");
  39. TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
  40. TextBox->labelsize(10);
  41. TextBox = new Fl_Box(180,50,50,20,"www.pawfal.org");
  42. TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
  43. TextBox->labelsize(10);
  44. TextBox = new Fl_Box(180,63,50,20,"We are the music makers");
  45. TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
  46. TextBox->labelsize(10);
  47. TextBox = new Fl_Box(180,73,50,20,"We are the dreamers of dreams");
  48. TextBox->align(FL_ALIGN_RIGHT | FL_ALIGN_INSIDE);
  49. TextBox->labelsize(10);
  50. Fl_Group *OptionsGrp = new Fl_Group(5,95,240,150,"");
  51. OptionsGrp->box(FL_FLAT_BOX);
  52. OptionsGrp->color(SpiralSynthModularInfo::GUICOL_Button);
  53. m_Options = new Fl_Pack(5,115,230,100,"Settings");
  54. m_Options->color(SpiralSynthModularInfo::GUICOL_Button);
  55. OptionsGrp->add(m_Options);
  56. Fl_Box *Name;
  57. Fl_Pack *Line;
  58. char BufferSize[256];
  59. sprintf(BufferSize,"%d",SpiralSynthModularInfo::BUFSIZE);
  60. char FragmentSize[256];
  61. sprintf(FragmentSize,"%d",SpiralSynthModularInfo::FRAGSIZE);
  62. char FragmentCount[256];
  63. sprintf(FragmentCount,"%d",SpiralSynthModularInfo::FRAGCOUNT);
  64. char Samplerate[256];
  65. sprintf(Samplerate,"%d",SpiralSynthModularInfo::SAMPLERATE);
  66. char OutputDevice[256];
  67. sprintf(OutputDevice,"%s",SpiralSynthModularInfo::OUTPUTFILE.c_str());
  68. char MidiDevice[256];
  69. sprintf(MidiDevice,"%s",SpiralSynthModularInfo::MIDIFILE.c_str());
  70. Line = new Fl_Pack(0,0,100,20,"");
  71. Line->type(FL_HORIZONTAL);
  72. Name = new Fl_Box(55,0,150,20,"Buffer Size");
  73. Name->labelsize(10);
  74. Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
  75. Line->add(Name);
  76. m_BufferSize = new Fl_Int_Input(0,0,80,20,"");
  77. m_BufferSize->value(BufferSize);
  78. Line->add(m_BufferSize);
  79. Line->end();
  80. m_Options->add(Line);
  81. Line = new Fl_Pack(0,0,100,20,"");
  82. Line->type(FL_HORIZONTAL);
  83. Name = new Fl_Box(55,0,150,20,"Fragment Size");
  84. Name->labelsize(10);
  85. Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
  86. Line->add(Name);
  87. m_FragmentSize = new Fl_Int_Input(0,0,80,20,"");
  88. m_FragmentSize->value(FragmentSize);
  89. Line->add(m_FragmentSize);
  90. Line->end();
  91. m_Options->add(Line);
  92. Line = new Fl_Pack(0,0,100,20,"");
  93. Line->type(FL_HORIZONTAL);
  94. Name = new Fl_Box(55,0,150,20,"Fragment Count (-1 = auto)");
  95. Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
  96. Name->labelsize(10);
  97. Line->add(Name);
  98. m_FragmentCount = new Fl_Int_Input(0,0,80,20,"");
  99. m_FragmentCount->value(FragmentCount);
  100. Line->add(m_FragmentCount);
  101. Line->end();
  102. m_Options->add(Line);
  103. Line = new Fl_Pack(0,0,100,20,"");
  104. Line->type(FL_HORIZONTAL);
  105. Name = new Fl_Box(55,0,150,20,"SampleRate");
  106. Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
  107. Name->labelsize(10);
  108. Line->add(Name);
  109. m_Samplerate = new Fl_Int_Input(0,0,80,20,"");
  110. m_Samplerate->value(Samplerate);
  111. Line->add(m_Samplerate);
  112. Line->end();
  113. m_Options->add(Line);
  114. Line = new Fl_Pack(0,0,100,20,"");
  115. Line->type(FL_HORIZONTAL);
  116. Name = new Fl_Box(55,0,150,20,"Output Device");
  117. Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
  118. Name->labelsize(10);
  119. Line->add(Name);
  120. m_OutputDevice = new Fl_Input(0,0,80,20,"");
  121. m_OutputDevice->value(OutputDevice);
  122. Line->add(m_OutputDevice);
  123. Line->end();
  124. m_Options->add(Line);
  125. Line = new Fl_Pack(0,0,100,20,"");
  126. Line->type(FL_HORIZONTAL);
  127. Name = new Fl_Box(55,0,150,20,"Midi Device");
  128. Name->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
  129. Name->labelsize(10);
  130. Line->add(Name);
  131. m_MidiDevice = new Fl_Input(0,0,80,20,"");
  132. m_MidiDevice->value(MidiDevice);
  133. Line->add(m_MidiDevice);
  134. Line->end();
  135. m_Options->add(Line);
  136. m_Options->end();
  137. m_Save = new Fl_Button(140,250,50,20,"Save");
  138. m_Save->labelsize(10);
  139. m_Save->tooltip("Save these settings");
  140. m_Save->callback((Fl_Callback*)cb_Save);
  141. add(m_Save);
  142. m_Apply = new Fl_Button(195,250,50,20,"Apply");
  143. m_Apply->labelsize(10);
  144. m_Apply->tooltip("Some plugins may request to save data first");
  145. m_Apply->callback((Fl_Callback*)cb_Apply);
  146. add(m_Apply);
  147. end();
  148. }
  149. SettingsWindow::~SettingsWindow()
  150. {
  151. }
  152. inline void SettingsWindow::cb_Apply_i(Fl_Button* o, void* v)
  153. {
  154. SpiralSynthModularInfo::BUFSIZE=(int)atof(m_BufferSize->value());
  155. SpiralSynthModularInfo::FRAGSIZE=(int)atof(m_FragmentSize->value());
  156. SpiralSynthModularInfo::FRAGCOUNT=(int)atof(m_FragmentCount->value());
  157. SpiralSynthModularInfo::SAMPLERATE=(int)atof(m_Samplerate->value());
  158. SpiralSynthModularInfo::OUTPUTFILE=m_OutputDevice->value();
  159. SpiralSynthModularInfo::MIDIFILE=m_MidiDevice->value();
  160. assert(m_App);
  161. if (m_App)
  162. {
  163. m_App->UpdateHostInfo();
  164. }
  165. }
  166. void SettingsWindow::cb_Apply(Fl_Button* o, void* v)
  167. { ((SettingsWindow*)(o->parent()))->cb_Apply_i(o,v); }
  168. inline void SettingsWindow::cb_Save_i(Fl_Button* o, void* v)
  169. {
  170. SpiralSynthModularInfo::BUFSIZE=(int)atof(m_BufferSize->value());
  171. SpiralSynthModularInfo::FRAGSIZE=(int)atof(m_FragmentSize->value());
  172. SpiralSynthModularInfo::FRAGCOUNT=(int)atof(m_FragmentCount->value());
  173. SpiralSynthModularInfo::SAMPLERATE=(int)atof(m_Samplerate->value());
  174. SpiralSynthModularInfo::OUTPUTFILE=m_OutputDevice->value();
  175. SpiralSynthModularInfo::MIDIFILE=m_MidiDevice->value();
  176. SpiralSynthModularInfo::Get()->SavePrefs();
  177. }
  178. void SettingsWindow::cb_Save(Fl_Button* o, void* v)
  179. { ((SettingsWindow*)(o->parent()))->cb_Save_i(o,v); }