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.

192 lines
5.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 "SequencerPluginGUI.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. SequencerPluginGUI::PatternWin::PatternWin(int w,int h,const char* n) :
  28. Fl_Double_Window(w,h,n)
  29. {
  30. m_Scroll = new Fl_Scroll(0, 0, w, h, "");
  31. resizable(m_Scroll);
  32. add(m_Scroll);
  33. m_Melody = new Fl_EventMap(0, 0, 1000, 1000, "");
  34. m_Melody->SetType(Fl_EventMap::MELODY_MAP);
  35. m_Scroll->add(m_Melody);
  36. m_Melody->CreateWindow();
  37. m_Melody->SetUpdateLineClip(0, 18, w, h-38);
  38. m_Melody->show();
  39. end();
  40. }
  41. ////////////////////////////////////////////
  42. SequencerPluginGUI::SequencerPluginGUI(int w, int h,SequencerPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  43. SpiralPluginGUI(w,h,o,ch)
  44. {
  45. m_Scroll = new Fl_Scroll(50, 20, w-57, h-26, "");
  46. add(m_Scroll);
  47. m_ArrangementMap = new Fl_EventMap(0, 0, 1000, 1000, "");
  48. m_ArrangementMap->user_data((void*)this);
  49. m_ArrangementMap->SetType(Fl_EventMap::ARRANGE_MAP);
  50. m_Scroll->add(m_ArrangementMap);
  51. m_ArrangementMap->CreateWindow();
  52. m_ArrangementMap->SetUpdateLineClip(0, 18, w, h-38);
  53. m_ArrangementMap->show();
  54. m_Length = new Fl_Knob(5, 60, 40, 40, "Length");
  55. m_Length->color(GUI_COLOUR);
  56. m_Length->type(Fl_Knob::DOTLIN);
  57. m_Length->labelsize(10);
  58. m_Length->maximum(30);
  59. m_Length->step(0.01);
  60. m_Length->value(1.0);
  61. m_Length->callback((Fl_Callback*)cb_Length);
  62. add(m_Length);
  63. m_Speed = new Fl_Knob(5, 115, 40, 40, "Speed");
  64. m_Speed->color(GUI_COLOUR);
  65. m_Speed->type(Fl_Knob::DOTLIN);
  66. m_Speed->labelsize(10);
  67. m_Speed->maximum(4);
  68. m_Speed->step(0.01);
  69. m_Speed->value(2.0);
  70. m_Speed->callback((Fl_Callback*)cb_Speed);
  71. add(m_Speed);
  72. m_Zoom = new Fl_Knob(5,170,40,40,"Zoom");
  73. m_Zoom->color(GUI_COLOUR);
  74. m_Zoom->type(Fl_Knob::DOTLIN);
  75. m_Zoom->labelsize(10);
  76. m_Zoom->maximum(2);
  77. m_Zoom->step(0.01);
  78. m_Zoom->value(1.0);
  79. m_Zoom->callback((Fl_Callback*)cb_Zoom);
  80. add(m_Zoom);
  81. m_NewPattern = new Fl_Button(2,225,45,20,"New Pat");
  82. m_NewPattern->type(0);
  83. m_NewPattern->labelsize(10);
  84. m_NewPattern->callback((Fl_Callback*)cb_NewPattern,NULL);
  85. add(m_NewPattern);
  86. m_NoteCut = new Fl_Button(2,245,45,20,"NoteCut");
  87. m_NoteCut->type(1);
  88. m_NoteCut->labelsize(10);
  89. m_NoteCut->value(0);
  90. m_NoteCut->callback((Fl_Callback*)cb_NoteCut);
  91. add(m_NoteCut);
  92. m_Clear = new Fl_Button(2,265,45,20,"Clear");
  93. m_Clear->type(0);
  94. m_Clear->labelsize(10);
  95. m_Clear->value(0);
  96. m_Clear->callback((Fl_Callback*)cb_Clear);
  97. add(m_Clear);
  98. end();
  99. }
  100. void SequencerPluginGUI::UpdateValues(SpiralPlugin *o)
  101. {
  102. }
  103. inline void SequencerPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v)
  104. {
  105. //m_Plugin->SetNoteCut(o->value());
  106. }
  107. void SequencerPluginGUI::cb_NoteCut(Fl_Button* o, void* v)
  108. { ((SequencerPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);}
  109. inline void SequencerPluginGUI::cb_Zoom_i(Fl_Knob* o, void* v)
  110. {
  111. //m_Plugin->SetZoom(o->value());
  112. }
  113. void SequencerPluginGUI::cb_Zoom(Fl_Knob* o, void* v)
  114. { ((SequencerPluginGUI*)(o->parent()))->cb_Zoom_i(o,v);}
  115. inline void SequencerPluginGUI::cb_Pattern_i(Fl_Counter* o, void* v)
  116. {
  117. if (o->value()<0) o->value(0);
  118. if (o->value()>NUM_PATTERNS-1) o->value(NUM_PATTERNS-1);
  119. //m_Plugin->SetPattern((int)o->value());
  120. //UpdateValues();
  121. }
  122. void SequencerPluginGUI::cb_Pattern(Fl_Counter* o, void* v)
  123. { ((SequencerPluginGUI*)(o->parent()))->cb_Pattern_i(o,v);}
  124. inline void SequencerPluginGUI::cb_Length_i(Fl_Knob* o, void* v)
  125. {
  126. //m_Plugin->SetEndTime(o->value());
  127. }
  128. void SequencerPluginGUI::cb_Length(Fl_Knob* o, void* v)
  129. { ((SequencerPluginGUI*)(o->parent()))->cb_Length_i(o,v);}
  130. inline void SequencerPluginGUI::cb_Speed_i(Fl_Knob* o, void* v)
  131. {
  132. //m_Plugin->SetSpeed(o->value()-2.0f);
  133. }
  134. void SequencerPluginGUI::cb_Speed(Fl_Knob* o, void* v)
  135. { ((SequencerPluginGUI*)(o->parent()))->cb_Speed_i(o,v);}
  136. inline void SequencerPluginGUI::cb_Clear_i(Fl_Button* o, void* v)
  137. {
  138. //m_Plugin->ClearAll();
  139. }
  140. void SequencerPluginGUI::cb_Clear(Fl_Button* o, void* v)
  141. { ((SequencerPluginGUI*)(o->parent()))->cb_Clear_i(o,v);}
  142. inline void SequencerPluginGUI::cb_NewPattern_i(Fl_Button* o, void* v)
  143. {
  144. int eid = m_ArrangementMap->AddEvent(300,100,100,Fl_SEvent::NO_TYPE);
  145. m_ArrangementMap->GetEvent(eid)->SetName("My Pattern");
  146. const char *name = fl_input("Name the new pattern:", "My Pattern");
  147. if (name) m_ArrangementMap->GetEvent(eid)->SetName(name);
  148. m_PatternWinMap[eid] = new PatternWin(400,200,m_ArrangementMap->GetEvent(eid)->GetName().c_str());
  149. m_ArrangementMap->SetEventCallback((Fl_Callback*)cb_ArrangeRM);
  150. redraw();
  151. }
  152. void SequencerPluginGUI::cb_NewPattern(Fl_Button* o, void* v)
  153. { ((SequencerPluginGUI*)(o->parent()))->cb_NewPattern_i(o,v);}
  154. inline void SequencerPluginGUI::cb_ArrangeRM_i(Fl_Button* o, void* v)
  155. {
  156. int ID=((Fl_SEvent*)o)->GetID();
  157. if (m_PatternWinMap[ID]->shown()) m_PatternWinMap[ID]->hide();
  158. else m_PatternWinMap[ID]->show();
  159. }
  160. void SequencerPluginGUI::cb_ArrangeRM(Fl_Button* o, void* v)
  161. { ((SequencerPluginGUI*)(o->parent()->user_data()))->cb_ArrangeRM_i(o,v);}