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.

115 lines
2.9KB

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