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.

136 lines
3.8KB

  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 "EchoPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. static const int GUI_COLOUR = 179;
  22. static const int GUIBG_COLOUR = 144;
  23. static const int GUIBG2_COLOUR = 145;
  24. ////////////////////////////////////////////
  25. EchoPluginGUI::EchoPluginGUI(int w, int h,EchoPlugin *o,const HostInfo *Info) :
  26. SpiralPluginGUI(w,h,o)
  27. {
  28. m_Plugin=o;
  29. m_Delay = new Fl_Slider(15, 20, 20, 70, "Delay");
  30. m_Delay->type(4);
  31. m_Delay->selection_color(GUI_COLOUR);
  32. m_Delay->labelsize(10);
  33. m_Delay->maximum(1);
  34. m_Delay->step(0.001);
  35. m_Delay->value(0.5);
  36. m_Delay->callback((Fl_Callback*)cb_Delay);
  37. m_Feedback = new Fl_Slider(75, 20, 20, 70, "Feedback");
  38. m_Feedback->type(4);
  39. m_Feedback->selection_color(GUI_COLOUR);
  40. m_Feedback->labelsize(10);
  41. m_Feedback->maximum(1.1);
  42. m_Feedback->step(0.01);
  43. m_Feedback->value(0.4);
  44. m_Feedback->callback((Fl_Callback*)cb_Feedback);
  45. m_pop = new Fl_Button(1,h-14, 13, 13, "@>");
  46. m_pop->type(1);
  47. m_pop->box(FL_FLAT_BOX);
  48. m_pop->down_box(FL_FLAT_BOX);
  49. m_pop->labeltype(FL_SYMBOL_LABEL);
  50. m_pop->labelsize(10);
  51. m_pop->labelcolor(25);
  52. m_pop->callback((Fl_Callback*)cb_pop);
  53. m_out_delay = new Fl_Output(50, h+5, 55, 15, "Delay");
  54. m_out_delay->box(FL_ENGRAVED_BOX);
  55. m_out_delay->color(16);
  56. m_out_delay->labelsize(10);
  57. m_out_delay->textsize(10);
  58. m_out_delay->hide();
  59. m_out_delay->set_output();
  60. m_out_feedback = new Fl_Output(50, h+22, 55, 15, "Feedback");
  61. m_out_feedback->box(FL_ENGRAVED_BOX);
  62. m_out_feedback->color(16);
  63. m_out_feedback->labelsize(10);
  64. m_out_feedback->textsize(10);
  65. m_out_feedback->hide();
  66. m_out_feedback->set_output();
  67. end();
  68. }
  69. extern "C" int sprintf(char *,const char *,...);
  70. void EchoPluginGUI::UpdateValues()
  71. {
  72. m_Delay->value(1.0f-m_Plugin->GetDelay());
  73. m_Feedback->value(1.1f-m_Plugin->GetFeedback());
  74. char str[10];
  75. sprintf(str,"%5.3f s", m_Plugin->GetDelay());
  76. m_out_delay->value(str);
  77. sprintf(str,"%5.1f %%", 100*m_Plugin->GetFeedback());
  78. m_out_feedback->value(str);
  79. }
  80. inline void EchoPluginGUI::cb_Delay_i(Fl_Slider* o, void* v)
  81. {
  82. char str[10];
  83. float value=1.0f-o->value();
  84. m_Plugin->SetDelay(value);
  85. sprintf(str,"%5.3f s", value);
  86. m_out_delay->value(str);
  87. }
  88. void EchoPluginGUI::cb_Delay(Fl_Slider* o, void* v)
  89. { ((EchoPluginGUI*)(o->parent()))->cb_Delay_i(o,v); }
  90. inline void EchoPluginGUI::cb_Feedback_i(Fl_Slider* o, void* v)
  91. {
  92. char str[10];
  93. m_Plugin->SetFeedback(1.1f-o->value());
  94. sprintf(str,"%5.1f %%", 100*(1.1f-o->value()));
  95. m_out_feedback->value(str);
  96. }
  97. void EchoPluginGUI::cb_Feedback(Fl_Slider* o, void* v)
  98. { ((EchoPluginGUI*)(o->parent()))->cb_Feedback_i(o,v); }
  99. inline void EchoPluginGUI::cb_pop_i(Fl_Button *o, void*) {
  100. if (o->value())
  101. {
  102. o->label("@2>");
  103. m_out_delay->show();
  104. m_out_feedback->show();
  105. redraw();
  106. }
  107. else
  108. {
  109. o->label("@>");
  110. m_out_delay->hide();
  111. m_out_feedback->hide();
  112. redraw();
  113. parent()->redraw();
  114. }
  115. }
  116. void EchoPluginGUI::cb_pop(Fl_Button* o, void* v) {
  117. ((EchoPluginGUI*)(o->parent()))->cb_pop_i(o,v);
  118. }