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.

105 lines
3.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 "SplitSwitchPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. using namespace std;
  22. ////////////////////////////////////////////
  23. SplitSwitchPluginGUI::SplitSwitchPluginGUI (int w, int h, SplitSwitchPlugin *o, ChannelHandler *ch, const HostInfo *Info) :
  24. SpiralPluginGUI (w, h, o, ch)
  25. {
  26. m_Switch = new Fl_Counter (15, 14, 50, 20, "Select");
  27. m_Switch->labelsize (10);
  28. m_Switch->type (FL_SIMPLE_COUNTER);
  29. m_Switch->box (FL_PLASTIC_UP_BOX);
  30. m_Switch->color (Info->GUI_COLOUR);
  31. m_Switch->selection_color (Info->GUI_COLOUR);
  32. m_Switch->step (1);
  33. m_Switch->value (1);
  34. m_Switch->callback ((Fl_Callback*) cb_Switch);
  35. add (m_Switch);
  36. m_Chans = new Fl_Counter (15, 50, 50, 15, "Channels");
  37. m_Chans->labelsize (8);
  38. m_Chans->textsize (8);
  39. m_Chans->type (FL_SIMPLE_COUNTER);
  40. m_Chans->box (FL_PLASTIC_UP_BOX);
  41. m_Chans->color (Info->GUI_COLOUR);
  42. m_Chans->selection_color (Info->GUI_COLOUR);
  43. m_Chans->step (1);
  44. m_Chans->value (2);
  45. m_Chans->callback ((Fl_Callback*) cb_Chans);
  46. add (m_Chans);
  47. end();
  48. }
  49. inline void SplitSwitchPluginGUI::cb_Chans_i (Fl_Counter* o, void* v) {
  50. if (o->value() < 2) o->value(2);
  51. else {
  52. m_GUICH->Set ("Chans", int (o->value ()));
  53. m_GUICH->SetCommand (SplitSwitchPlugin::SETCHANS);
  54. m_GUICH->Wait ();
  55. needs_resize (true);
  56. }
  57. }
  58. void SplitSwitchPluginGUI::cb_Chans (Fl_Counter* o, void* v) {
  59. ((SplitSwitchPluginGUI*) (o->parent ())) -> cb_Chans_i (o, v);
  60. }
  61. inline void SplitSwitchPluginGUI::cb_Switch_i (Fl_Counter* o, void* v) {
  62. if (o->value()<1 || o->value() > m_Chans->value ())
  63. o->value (1);
  64. m_GUICH->Set ("Switch", int (o->value ()));
  65. }
  66. void SplitSwitchPluginGUI::cb_Switch (Fl_Counter* o, void* v) {
  67. ((SplitSwitchPluginGUI*) (o->parent ())) -> cb_Switch_i (o, v);
  68. }
  69. void SplitSwitchPluginGUI::Update () {
  70. if (m_GUICH->GetBool ("Auto")) {
  71. int e = m_GUICH->GetInt ("Echo");
  72. if (m_Switch->value () != e) m_Switch->value (e);
  73. }
  74. }
  75. void SplitSwitchPluginGUI::UpdateValues (SpiralPlugin *o) {
  76. SplitSwitchPlugin* Plugin = (SplitSwitchPlugin*)o;
  77. m_Chans->value (Plugin->GetChans ());
  78. m_Switch->value (Plugin->GetSwitch ());
  79. }
  80. const string SplitSwitchPluginGUI::GetHelpText(const string &loc){
  81. return string("")
  82. + "It's a simple 1-input n-output rotary switch.\n\n"
  83. + "The 'Channels' parameter controls the number of outputs.\n\n"
  84. + "The 'Select' parameter selects which output echos the input.\n\n"
  85. + "The 'CV' input also selects which output echos the input.\n\n"
  86. + "The 'Clock' input is a trigger to select the next output chanel.\n\n"
  87. + "The 'CV' output enables you to gang several switches together, by\n"
  88. + "connecting it to the other switches' 'CV' input.\n";
  89. }