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.

316 lines
7.7KB

  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. {
  83. char pname[40];
  84. static int n = 0;
  85. snprintf( pname, sizeof( pname ), "out-%d", n++ );
  86. output.push_back( Port( strdup( pname ) ) );
  87. }
  88. diskstream = new Disk_Stream( this, engine->frame_rate(), engine->nframes(), 1 );
  89. Fl_Group::size( w(), height() );
  90. Track_Header *o = this;
  91. o->box( FL_THIN_UP_BOX );
  92. {
  93. Fl_Group *o = new Fl_Group( 2, 2, 149, 70 );
  94. o->color( ( Fl_Color ) 53 );
  95. {
  96. Fl_Input *o = name_field = new Fl_Input( 2, 2, 144, 24 );
  97. o->color( ( Fl_Color ) 33 );
  98. o->labeltype( FL_NO_LABEL );
  99. o->labelcolor( FL_GRAY0 );
  100. o->textcolor( 32 );
  101. o->callback( cb_input_field, (void*)this );
  102. }
  103. {
  104. Fl_Group *o = controls = new Fl_Group( 2, 28, 149, 24 );
  105. {
  106. Fl_Button *o = record_button =
  107. new Fl_Button( 6, 28, 26, 24, "@circle" );
  108. o->type( 1 );
  109. o->box( FL_THIN_UP_BOX );
  110. o->color( FL_LIGHT1 );
  111. o->selection_color( FL_RED );
  112. o->labelsize( 8 );
  113. o->callback( cb_button, this );
  114. }
  115. {
  116. Fl_Button *o = mute_button =
  117. new Fl_Button( 35, 28, 26, 24, "m" );
  118. o->type( 1 );
  119. o->box( FL_THIN_UP_BOX );
  120. o->color( FL_LIGHT1 );
  121. o->labelsize( 11 );
  122. o->callback( cb_button, this );
  123. }
  124. {
  125. Fl_Button *o = solo_button =
  126. new Fl_Button( 66, 28, 26, 24, "s" );
  127. o->type( 1 );
  128. o->box( FL_THIN_UP_BOX );
  129. o->color( FL_LIGHT1 );
  130. o->labelsize( 11 );
  131. o->callback( cb_button, this );
  132. }
  133. {
  134. Fl_Menu_Button *o = take_menu =
  135. new Fl_Menu_Button( 97, 28, 47, 24, "T" );
  136. o->box( FL_THIN_UP_BOX );
  137. o->color( FL_LIGHT1 );
  138. o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
  139. o->callback( cb_button, this );
  140. o->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE );
  141. o->add( "New", 0, 0, 0, FL_MENU_DIVIDER );
  142. }
  143. o->end();
  144. }
  145. {
  146. Fl_Box *o = new Fl_Box( 0, 76, 149, 38 );
  147. o->box( FL_FLAT_BOX );
  148. Fl_Group::current()->resizable( o );
  149. }
  150. o->size( Track_Header::width(), h() );
  151. o->end();
  152. }
  153. {
  154. Fl_Pack *o = pack = new Fl_Pack( width(), 0, 1006, 115 );
  155. o->labeltype( FL_NO_LABEL );
  156. o->resize( x() + width(), y(), w() - width(), h() );
  157. Fl_Group::current()->resizable( o );
  158. {
  159. Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 115 );
  160. o->end();
  161. }
  162. {
  163. Fl_Pack *o = takes = new Fl_Pack( width(), 0, pack->w(), 115 );
  164. o->end();
  165. o->hide();
  166. }
  167. o->end();
  168. }
  169. end();
  170. log_create();
  171. }
  172. Track_Header::~Track_Header ( )
  173. {
  174. log_destroy();
  175. }
  176. static int pack_visible( Fl_Pack *p )
  177. {
  178. int v = 0;
  179. for ( int i = p->children(); i--; )
  180. if ( p->child( i )->visible() )
  181. v++;
  182. return v;
  183. }
  184. /* adjust size of widget and children */
  185. void
  186. Track_Header::resize ( void )
  187. {
  188. for ( int i = takes->children(); i--; )
  189. takes->child( i )->size( w(), height() );
  190. for ( int i = control->children(); i--; )
  191. control->child( i )->size( w(), height() );
  192. if ( _show_all_takes )
  193. {
  194. takes->show();
  195. Fl_Group::size( w(), height() * ( 1 + takes->children() + pack_visible( control ) ) );
  196. }
  197. else
  198. {
  199. takes->hide();
  200. Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) );
  201. }
  202. if ( track() )
  203. track()->size( w(), height() );
  204. if ( controls->y() + controls->h() > y() + h() )
  205. controls->hide();
  206. else
  207. controls->show();
  208. parent()->redraw();
  209. }
  210. void
  211. Track_Header::size ( int v )
  212. {
  213. if ( v < 0 || v > 3 )
  214. return;
  215. _size = v;
  216. resize();
  217. }
  218. void
  219. Track_Header::track( Track * t )
  220. {
  221. // t->size( 1, h() );
  222. if ( track() )
  223. add( track() );
  224. // takes->insert( *track(), 0 );
  225. _track = t;
  226. pack->insert( *t, 0 );
  227. resize();
  228. }
  229. void
  230. Track_Header::add_control( Track *t )
  231. {
  232. control->add( t );
  233. resize();
  234. }
  235. /**********/
  236. /* Engine */
  237. /**********/
  238. /* THREAD: RT */
  239. nframes_t
  240. Track_Header::process ( nframes_t nframes )
  241. {
  242. if ( diskstream )
  243. return diskstream->process( nframes );
  244. else
  245. return 0;
  246. }
  247. /* THREAD: RT */
  248. void
  249. Track_Header::seek ( nframes_t frame )
  250. {
  251. if ( diskstream )
  252. return diskstream->seek( frame );
  253. }