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.

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