Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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.

170 lines
4.6KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "Module.H"
  19. #include <FL/fl_draw.H>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include "Module_Parameter_Editor.H"
  23. Module::~Module ( )
  24. {
  25. for ( unsigned int i = 0; i < audio_input.size(); ++i )
  26. audio_input[i].disconnect();
  27. for ( unsigned int i = 0; i < audio_output.size(); ++i )
  28. audio_output[i].disconnect();
  29. for ( unsigned int i = 0; i < control_input.size(); ++i )
  30. control_input[i].disconnect();
  31. for ( unsigned int i = 0; i < control_output.size(); ++i )
  32. control_output[i].disconnect();
  33. audio_input.clear();
  34. audio_output.clear();
  35. control_input.clear();
  36. control_output.clear();
  37. }
  38. void
  39. Module::draw_box ( void )
  40. {
  41. fl_color( FL_WHITE );
  42. int tw, th, tx, ty;
  43. tw = w();
  44. th = h();
  45. ty = y();
  46. tx = x();
  47. // bbox( tx, ty, tw, th );
  48. fl_push_clip( tx, ty, tw, th );
  49. int spacing = w() / instances();
  50. for ( int i = instances(); i--; )
  51. {
  52. fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, Fl::belowmouse() == this ? fl_lighter( color() ) : color() );
  53. }
  54. if ( audio_input.size() && audio_output.size() )
  55. {
  56. /* maybe draw control indicators */
  57. if ( control_input.size() )
  58. fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  59. if ( control_output.size() )
  60. fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  61. }
  62. fl_pop_clip();
  63. // box( FL_NO_BOX );
  64. Fl_Group::draw_children();
  65. }
  66. void
  67. Module::draw_label ( void )
  68. {
  69. int tw, th, tx, ty;
  70. bbox( tx, ty, tw, th );
  71. const char *lp = label();
  72. int l = strlen( label() );
  73. fl_color( FL_FOREGROUND_COLOR );
  74. char *s = NULL;
  75. if ( l > 10 )
  76. {
  77. s = new char[l];
  78. char *sp = s;
  79. for ( ; *lp; ++lp )
  80. switch ( *lp )
  81. {
  82. case 'i': case 'e': case 'o': case 'u': case 'a':
  83. break;
  84. default:
  85. *(sp++) = *lp;
  86. }
  87. *sp = '\0';
  88. }
  89. if ( l > 20 )
  90. fl_font( FL_HELVETICA, 10 );
  91. else
  92. fl_font( FL_HELVETICA, 14 );
  93. fl_draw( s ? s : lp, tx, ty, tw, th, (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE) );
  94. if ( s )
  95. delete[] s;
  96. }
  97. #include "FL/test_press.H"
  98. int
  99. Module::handle ( int m )
  100. {
  101. switch ( m )
  102. {
  103. case FL_PUSH:
  104. {
  105. if ( test_press( FL_BUTTON1 ) )
  106. {
  107. if ( _editor )
  108. {
  109. _editor->show();
  110. }
  111. else if ( ncontrol_inputs() )
  112. {
  113. DMESSAGE( "Opening module parameters for \"%s\"", label() );
  114. _editor = new Module_Parameter_Editor( this );
  115. _editor->show();
  116. do { Fl::wait(); }
  117. while ( _editor->shown() );
  118. DMESSAGE( "Module parameters for \"%s\" closed",label() );
  119. delete _editor;
  120. _editor = NULL;
  121. }
  122. return 1;
  123. }
  124. break;
  125. }
  126. }
  127. return Fl_Group::handle( m );
  128. }