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.

164 lines
4.4KB

  1. /* SpiralPlugin
  2. * Copyleft (C) 2000 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 "OutputPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_file_chooser.H>
  21. static const int GUI_COLOUR = 179;
  22. static const int GUIBG_COLOUR = 144;
  23. static const int GUIBG2_COLOUR = 145;
  24. OutputPluginGUI::OutputPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch,const HostInfo *Info) :
  25. SpiralPluginGUI(w,h,o,ch)
  26. {
  27. Volume = new Fl_Knob(30, 22, 40, 40, "Volume");
  28. Volume->color(GUI_COLOUR);
  29. Volume->type(Fl_Knob::DOTLIN);
  30. Volume->labelsize(10);
  31. Volume->maximum(1);
  32. Volume->step(0.001);
  33. Volume->value(0.5);
  34. Volume->callback((Fl_Callback*)cb_Volume);
  35. Record = new Fl_Button(30, 80, 40, 25, "Record");
  36. Record->type(1);
  37. Record->down_box(FL_DOWN_BOX);
  38. Record->labelsize(10);
  39. Record->callback((Fl_Callback*)cb_Record);
  40. OpenRead = new Fl_Button(2, 110, 30, 15, "Read");
  41. OpenRead->type(1);
  42. OpenRead->down_box(FL_DOWN_BOX);
  43. OpenRead->labelsize(10);
  44. OpenRead->callback((Fl_Callback*)cb_OpenRead);
  45. OpenDuplex = new Fl_Button(34, 110, 31, 15, "Dplx");
  46. OpenDuplex->type(1);
  47. OpenDuplex->down_box(FL_DOWN_BOX);
  48. OpenDuplex->labelsize(10);
  49. OpenDuplex->callback((Fl_Callback*)cb_OpenDuplex);
  50. OpenWrite = new Fl_Button(68, 110, 30, 15, "Write");
  51. OpenWrite->type(1);
  52. OpenWrite->down_box(FL_DOWN_BOX);
  53. OpenWrite->labelsize(10);
  54. OpenWrite->callback((Fl_Callback*)cb_OpenWrite);
  55. end();
  56. }
  57. void OutputPluginGUI::UpdateValues(SpiralPlugin *o)
  58. {
  59. Volume->value(OSSOutput::Get()->GetVolume());
  60. }
  61. //// Callbacks ////
  62. inline void OutputPluginGUI::cb_Volume_i(Fl_Knob* o, void* v)
  63. {
  64. m_GUICH->Set("Volume",(float)o->value());
  65. m_GUICH->SetCommand(OutputPlugin::SET_VOLUME);
  66. }
  67. void OutputPluginGUI::cb_Volume(Fl_Knob* o, void* v)
  68. { ((OutputPluginGUI*)(o->parent()))->cb_Volume_i(o,v); }
  69. inline void OutputPluginGUI::cb_Record_i(Fl_Button* o, void* v)
  70. {
  71. if (o->value())
  72. {
  73. char *fn=fl_file_chooser("Pick a Wav file to save to", "*.wav", NULL);
  74. if (fn && fn!="")
  75. {
  76. OSSOutput::Get()->WavOpen(fn);
  77. }
  78. else
  79. {
  80. OSSOutput::Get()->WavClose();
  81. o->value(false);
  82. }
  83. }
  84. else
  85. {
  86. OSSOutput::Get()->WavClose();
  87. }
  88. }
  89. void OutputPluginGUI::cb_Record(Fl_Button* o, void* v)
  90. { ((OutputPluginGUI*)(o->parent()))->cb_Record_i(o,v); }
  91. inline void OutputPluginGUI::cb_OpenRead_i(Fl_Button* o, void* v)
  92. {
  93. if (o->value())
  94. {
  95. OpenWrite->value(0);
  96. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  97. m_GUICH->Wait();
  98. m_GUICH->SetCommand(OutputPlugin::OPENREAD);
  99. m_GUICH->Wait();
  100. }
  101. else
  102. {
  103. OpenWrite->value(0);
  104. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  105. m_GUICH->Wait();
  106. }
  107. }
  108. void OutputPluginGUI::cb_OpenRead(Fl_Button* o, void* v)
  109. { ((OutputPluginGUI*)(o->parent()))->cb_OpenRead_i(o,v); }
  110. inline void OutputPluginGUI::cb_OpenDuplex_i(Fl_Button* o, void* v)
  111. {
  112. if (o->value())
  113. {
  114. OpenRead->value(0);
  115. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  116. m_GUICH->Wait();
  117. m_GUICH->SetCommand(OutputPlugin::OPENDUPLEX);
  118. m_GUICH->Wait();
  119. }
  120. else
  121. {
  122. OpenRead->value(0);
  123. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  124. m_GUICH->Wait();
  125. }
  126. }
  127. void OutputPluginGUI::cb_OpenDuplex(Fl_Button* o, void* v)
  128. { ((OutputPluginGUI*)(o->parent()))->cb_OpenDuplex_i(o,v); }
  129. inline void OutputPluginGUI::cb_OpenWrite_i(Fl_Button* o, void* v)
  130. {
  131. if (o->value())
  132. {
  133. OpenRead->value(0);
  134. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  135. m_GUICH->Wait();
  136. m_GUICH->SetCommand(OutputPlugin::OPENWRITE);
  137. m_GUICH->Wait();
  138. }
  139. else
  140. {
  141. OpenRead->value(0);
  142. m_GUICH->SetCommand(OutputPlugin::CLOSE);
  143. m_GUICH->Wait();
  144. }
  145. }
  146. void OutputPluginGUI::cb_OpenWrite(Fl_Button* o, void* v)
  147. { ((OutputPluginGUI*)(o->parent()))->cb_OpenWrite_i(o,v); }