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.

172 lines
4.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 <stdio.h>
  19. #include "SeqPluginGUI.h"
  20. #include <FL/fl_draw.h>
  21. #include <FL/fl_draw.H>
  22. #include <FL/fl_file_chooser.h>
  23. static const int GUI_COLOUR = 179;
  24. static const int GUIBG_COLOUR = 144;
  25. static const int GUIBG2_COLOUR = 145;
  26. ////////////////////////////////////////////
  27. SeqPluginGUI::SeqPluginGUI(int w, int h,SeqPlugin *o,const HostInfo *Info) :
  28. SpiralPluginGUI(w,h,o)
  29. {
  30. m_Plugin=o;
  31. //size_range(10,10);
  32. m_Scroll = new Fl_Scroll(50, 20, w-57, h-26, "");
  33. add(m_Scroll);
  34. for (int n=0; n<NUM_PATTERNS; n++)
  35. {
  36. m_Plugin->SetEventMap(n,new Fl_EventMap(0, 0, 1000, 1000, ""));
  37. m_Plugin->GetEventMap(n)->SetType(Fl_EventMap::MELODY_MAP);
  38. m_Scroll->add(m_Plugin->GetEventMap(n));
  39. m_Plugin->GetEventMap(n)->CreateWindow();
  40. m_Plugin->GetEventMap(n)->SetUpdateLineClip(0, 18, w, h-38);
  41. m_Plugin->GetEventMap(n)->hide();
  42. }
  43. m_Plugin->GetEventMap(0)->show();
  44. m_Pattern = new Fl_Counter(5, 20, 40, 20, "Pattern");
  45. m_Pattern->labelsize(10);
  46. m_Pattern->type(FL_SIMPLE_COUNTER);
  47. m_Pattern->step(1);
  48. m_Pattern->value(0);
  49. m_Pattern->callback((Fl_Callback*)cb_Pattern);
  50. add(m_Pattern);
  51. m_Length = new Fl_Knob(5, 60, 40, 40, "Length");
  52. m_Length->color(GUI_COLOUR);
  53. m_Length->type(Fl_Knob::DOTLIN);
  54. m_Length->labelsize(10);
  55. m_Length->maximum(30);
  56. m_Length->step(0.01);
  57. m_Length->value(1.0);
  58. m_Length->callback((Fl_Callback*)cb_Length);
  59. add(m_Length);
  60. m_Speed = new Fl_Knob(5, 115, 40, 40, "Speed");
  61. m_Speed->color(GUI_COLOUR);
  62. m_Speed->type(Fl_Knob::DOTLIN);
  63. m_Speed->labelsize(10);
  64. m_Speed->maximum(4);
  65. m_Speed->step(0.01);
  66. m_Speed->value(2.0);
  67. m_Speed->callback((Fl_Callback*)cb_Speed);
  68. add(m_Speed);
  69. m_Zoom = new Fl_Knob(5,170,40,40,"Zoom");
  70. m_Zoom->color(GUI_COLOUR);
  71. m_Zoom->type(Fl_Knob::DOTLIN);
  72. m_Zoom->labelsize(10);
  73. m_Zoom->maximum(2);
  74. m_Zoom->step(0.01);
  75. m_Zoom->value(1.0);
  76. m_Zoom->callback((Fl_Callback*)cb_Zoom);
  77. add(m_Zoom);
  78. m_Update = new Fl_Button(2,225,45,20,"Update");
  79. m_Update->type(1);
  80. m_Update->labelsize(10);
  81. m_Update->value(1);
  82. m_Update->callback((Fl_Callback*)cb_Update,NULL);
  83. add(m_Update);
  84. m_NoteCut = new Fl_Button(2,245,45,20,"NoteCut");
  85. m_NoteCut->type(1);
  86. m_NoteCut->labelsize(10);
  87. m_NoteCut->value(0);
  88. m_NoteCut->callback((Fl_Callback*)cb_NoteCut);
  89. add(m_NoteCut);
  90. m_Clear = new Fl_Button(2,265,45,20,"Clear");
  91. m_Clear->type(0);
  92. m_Clear->labelsize(10);
  93. m_Clear->value(0);
  94. m_Clear->callback((Fl_Callback*)cb_Clear);
  95. add(m_Clear);
  96. end();
  97. }
  98. void SeqPluginGUI::UpdateValues()
  99. {
  100. }
  101. inline void SeqPluginGUI::cb_Update_i(Fl_Button* o, void* v)
  102. {
  103. m_Plugin->SetUpdate(o->value());
  104. }
  105. void SeqPluginGUI::cb_Update(Fl_Button* o, void* v)
  106. { ((SeqPluginGUI*)(o->parent()))->cb_Update_i(o,v);}
  107. inline void SeqPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v)
  108. {
  109. m_Plugin->SetNoteCut(o->value());
  110. }
  111. void SeqPluginGUI::cb_NoteCut(Fl_Button* o, void* v)
  112. { ((SeqPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);}
  113. inline void SeqPluginGUI::cb_Zoom_i(Fl_Knob* o, void* v)
  114. {
  115. m_Plugin->SetZoom(o->value());
  116. }
  117. void SeqPluginGUI::cb_Zoom(Fl_Knob* o, void* v)
  118. { ((SeqPluginGUI*)(o->parent()))->cb_Zoom_i(o,v);}
  119. inline void SeqPluginGUI::cb_Pattern_i(Fl_Counter* o, void* v)
  120. {
  121. if (o->value()<0) o->value(0);
  122. if (o->value()>NUM_PATTERNS-1) o->value(NUM_PATTERNS-1);
  123. m_Plugin->SetPattern((int)o->value());
  124. //UpdateValues();
  125. }
  126. void SeqPluginGUI::cb_Pattern(Fl_Counter* o, void* v)
  127. { ((SeqPluginGUI*)(o->parent()))->cb_Pattern_i(o,v);}
  128. inline void SeqPluginGUI::cb_Length_i(Fl_Knob* o, void* v)
  129. {
  130. m_Plugin->SetEndTime(o->value());
  131. }
  132. void SeqPluginGUI::cb_Length(Fl_Knob* o, void* v)
  133. { ((SeqPluginGUI*)(o->parent()))->cb_Length_i(o,v);}
  134. inline void SeqPluginGUI::cb_Speed_i(Fl_Knob* o, void* v)
  135. {
  136. m_Plugin->SetSpeed(o->value()-2.0f);
  137. }
  138. void SeqPluginGUI::cb_Speed(Fl_Knob* o, void* v)
  139. { ((SeqPluginGUI*)(o->parent()))->cb_Speed_i(o,v);}
  140. inline void SeqPluginGUI::cb_Clear_i(Fl_Button* o, void* v)
  141. {
  142. m_Plugin->ClearAll();
  143. }
  144. void SeqPluginGUI::cb_Clear(Fl_Button* o, void* v)
  145. { ((SeqPluginGUI*)(o->parent()))->cb_Clear_i(o,v);}