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.

279 lines
7.1KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 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 "Track_Header.H"
  19. void
  20. Track_Header::cb_input_field ( Fl_Widget *w, void *v )
  21. {
  22. ((Track_Header*)v)->cb_input_field();
  23. }
  24. void
  25. Track_Header::cb_button ( Fl_Widget *w, void *v )
  26. {
  27. ((Track_Header*)v)->cb_button( w );
  28. }
  29. void
  30. Track_Header::cb_input_field ( void )
  31. {
  32. log_start();
  33. if ( _name )
  34. free( _name );
  35. _name = strdup( name_field->value() );
  36. log_end();
  37. }
  38. void
  39. Track_Header::cb_button ( Fl_Widget *w )
  40. {
  41. printf( "FIXME: inform mixer here\n" );
  42. if ( w == record_button )
  43. {
  44. }
  45. else
  46. if ( w == take_menu )
  47. {
  48. int v = take_menu->value();
  49. switch ( v )
  50. {
  51. case 0: /* show all takes */
  52. show_all_takes( take_menu->menu()[ v ].value() );
  53. return;
  54. case 1: /* new */
  55. track( track()->clone_empty() );
  56. return;
  57. }
  58. const char *s = take_menu->menu()[ v ].text;
  59. for ( int i = takes->children(); i--; )
  60. {
  61. Track *t = (Track*)takes->child( i );
  62. if ( ! strcmp( s, t->name() ) )
  63. {
  64. track( t );
  65. redraw();
  66. break;
  67. }
  68. }
  69. }
  70. }
  71. Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) :
  72. Fl_Group ( X, Y, W, H, L )
  73. {
  74. _track = NULL;
  75. _name = NULL;
  76. _selected = false;
  77. _show_all_takes = false;
  78. _size = 1;
  79. Fl_Group::size( w(), height() );
  80. Track_Header *o = this;
  81. o->box( FL_THIN_UP_BOX );
  82. {
  83. Fl_Group *o = new Fl_Group( 2, 2, 149, 70 );
  84. o->color( ( Fl_Color ) 53 );
  85. {
  86. Fl_Input *o = name_field = new Fl_Input( 2, 2, 144, 24 );
  87. o->color( ( Fl_Color ) 33 );
  88. o->labeltype( FL_NO_LABEL );
  89. o->labelcolor( FL_GRAY0 );
  90. o->textcolor( 32 );
  91. o->callback( cb_input_field, (void*)this );
  92. }
  93. {
  94. Fl_Group *o = controls = new Fl_Group( 2, 28, 149, 24 );
  95. {
  96. Fl_Button *o = record_button =
  97. new Fl_Button( 6, 28, 26, 24, "@circle" );
  98. o->type( 1 );
  99. o->box( FL_THIN_UP_BOX );
  100. o->color( FL_LIGHT1 );
  101. o->selection_color( FL_RED );
  102. o->labelsize( 8 );
  103. o->callback( cb_button, this );
  104. }
  105. {
  106. Fl_Button *o = mute_button =
  107. new Fl_Button( 35, 28, 26, 24, "m" );
  108. o->type( 1 );
  109. o->box( FL_THIN_UP_BOX );
  110. o->color( FL_LIGHT1 );
  111. o->labelsize( 11 );
  112. o->callback( cb_button, this );
  113. }
  114. {
  115. Fl_Button *o = solo_button =
  116. new Fl_Button( 66, 28, 26, 24, "s" );
  117. o->type( 1 );
  118. o->box( FL_THIN_UP_BOX );
  119. o->color( FL_LIGHT1 );
  120. o->labelsize( 11 );
  121. o->callback( cb_button, this );
  122. }
  123. {
  124. Fl_Menu_Button *o = take_menu =
  125. new Fl_Menu_Button( 97, 28, 47, 24, "T" );
  126. o->box( FL_THIN_UP_BOX );
  127. o->color( FL_LIGHT1 );
  128. o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
  129. o->callback( cb_button, this );
  130. o->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE );
  131. o->add( "New", 0, 0, 0, FL_MENU_DIVIDER );
  132. }
  133. o->end();
  134. }
  135. {
  136. Fl_Box *o = new Fl_Box( 0, 76, 149, 38 );
  137. o->box( FL_FLAT_BOX );
  138. Fl_Group::current()->resizable( o );
  139. }
  140. o->size( Track_Header::width(), h() );
  141. o->end();
  142. }
  143. {
  144. Fl_Pack *o = pack = new Fl_Pack( width(), 0, 1006, 115 );
  145. o->labeltype( FL_NO_LABEL );
  146. o->resize( x() + width(), y(), w() - width(), h() );
  147. Fl_Group::current()->resizable( o );
  148. {
  149. Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 115 );
  150. o->end();
  151. }
  152. {
  153. Fl_Pack *o = takes = new Fl_Pack( width(), 0, pack->w(), 115 );
  154. o->end();
  155. o->hide();
  156. }
  157. o->end();
  158. }
  159. end();
  160. log_create();
  161. }
  162. Track_Header::~Track_Header ( )
  163. {
  164. log_destroy();
  165. }
  166. static int pack_visible( Fl_Pack *p )
  167. {
  168. int v = 0;
  169. for ( int i = p->children(); i--; )
  170. if ( p->child( i )->visible() )
  171. v++;
  172. return v;
  173. }
  174. /* adjust size of widget and children */
  175. void
  176. Track_Header::resize ( void )
  177. {
  178. for ( int i = takes->children(); i--; )
  179. takes->child( i )->size( w(), height() );
  180. for ( int i = control->children(); i--; )
  181. control->child( i )->size( w(), height() );
  182. if ( _show_all_takes )
  183. {
  184. takes->show();
  185. Fl_Group::size( w(), height() * ( 1 + takes->children() + pack_visible( control ) ) );
  186. }
  187. else
  188. {
  189. takes->hide();
  190. Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) );
  191. }
  192. if ( track() )
  193. track()->size( w(), height() );
  194. if ( controls->y() + controls->h() > y() + h() )
  195. controls->hide();
  196. else
  197. controls->show();
  198. parent()->redraw();
  199. }
  200. void
  201. Track_Header::size ( int v )
  202. {
  203. if ( v < 0 || v > 3 )
  204. return;
  205. _size = v;
  206. resize();
  207. }
  208. void
  209. Track_Header::track( Track * t )
  210. {
  211. // t->size( 1, h() );
  212. if ( track() )
  213. add( track() );
  214. // takes->insert( *track(), 0 );
  215. _track = t;
  216. pack->insert( *t, 0 );
  217. resize();
  218. }
  219. void
  220. Track_Header::add_control( Track *t )
  221. {
  222. control->add( t );
  223. resize();
  224. }