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.

157 lines
4.1KB

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