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.

119 lines
3.0KB

  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 "NoteSnapPluginGUI.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. NoteSnapPluginGUI::NoteSnapPluginGUI(int w, int h,NoteSnapPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  26. SpiralPluginGUI(w,h,o,ch)
  27. {
  28. int KeyWidth=10,Note,Pos=0,Count=0;
  29. for (int n=0; n<NUM_KEYS; n++)
  30. {
  31. m_Num[n]=n;
  32. Note = n%12;
  33. if (Note!=1 && Note!=3 && Note!=6 && Note!=8 && Note!=10)
  34. {
  35. Count++;
  36. Pos=Count*KeyWidth;
  37. m_Key[n] = new Fl_Button(Pos,20,KeyWidth,50,"");
  38. m_Key[n]->type(1);
  39. m_Key[n]->selection_color(FL_RED);
  40. m_Key[n]->box(FL_THIN_UP_BOX);
  41. m_Key[n]->labelsize(10);
  42. m_Key[n]->when(FL_WHEN_CHANGED);
  43. m_Key[n]->color(FL_WHITE);
  44. m_Key[n]->callback((Fl_Callback*)cb_Key, &m_Num[n]);
  45. add(m_Key[n]);
  46. }
  47. }
  48. Count=0;
  49. for (int n=0; n<NUM_KEYS; n++)
  50. {
  51. Note = n%12;
  52. if (Note==1 || Note==3 || Note==6 || Note==8 || Note==10)
  53. {
  54. m_Key[n] = new Fl_Button(Pos+5,20,KeyWidth,30,"");
  55. m_Key[n]->type(1);
  56. m_Key[n]->selection_color(FL_RED);
  57. m_Key[n]->box(FL_THIN_UP_BOX);
  58. m_Key[n]->labelsize(10);
  59. m_Key[n]->when(FL_WHEN_CHANGED);
  60. m_Key[n]->color(FL_BLACK);
  61. m_Key[n]->callback((Fl_Callback*)cb_Key, &m_Num[n]);
  62. add(m_Key[n]);
  63. }
  64. else
  65. {
  66. Count++;
  67. Pos=Count*KeyWidth;
  68. }
  69. }
  70. end();
  71. }
  72. void NoteSnapPluginGUI::UpdateValues(SpiralPlugin *o)
  73. {
  74. NoteSnapPlugin *Plugin = (NoteSnapPlugin *)o;
  75. for (int n=0; n<12; n++)
  76. {
  77. m_Key[n]->value(!Plugin->GetFilter(n));
  78. }
  79. }
  80. //// Callbacks ////
  81. inline void NoteSnapPluginGUI::cb_Key_i(Fl_Button* o, void* v)
  82. {
  83. int k=*(int*)(v);
  84. if (o->value())
  85. {
  86. m_GUICH->Set("Note",k);
  87. m_GUICH->SetCommand(NoteSnapPlugin::NOTE_OFF);
  88. }
  89. else
  90. {
  91. m_GUICH->Set("Note",k);
  92. m_GUICH->SetCommand(NoteSnapPlugin::NOTE_ON);
  93. }
  94. parent()->redraw();
  95. }
  96. void NoteSnapPluginGUI::cb_Key(Fl_Button* o, void* v)
  97. { ((NoteSnapPluginGUI*)(o->parent()))->cb_Key_i(o,v);}
  98. const string NoteSnapPluginGUI::GetHelpText(const string &loc){
  99. return string("")
  100. + "Quantises the input value into a note frequency\n"
  101. + "(using the midi note data).\n"
  102. + "Use the keyboard to select notes to be filtered out\n"
  103. + "for generating scales and chords";
  104. }