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.

302 lines
7.5KB

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