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.

916 lines
22KB

  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. /* A Track is a container for various sequences; the sequence, the
  19. * takes (inactive sequences), annotation sequences, control
  20. * sequences */
  21. /* TODO: split into Track and Audio_Track (and maybe later Video_Track
  22. * and MIDI_Track */
  23. #include <sys/time.h>
  24. #include "Track.H"
  25. #include "Transport.H"
  26. #include "../FL/Fl_Sometimes_Input.H"
  27. #include <FL/fl_ask.H>
  28. #include <FL/Fl_Color_Chooser.H>
  29. #include <FL/Fl.H>
  30. #include "Engine/Engine.H" // for lock()
  31. #include "Control_Sequence.H"
  32. #include "Annotation_Sequence.H"
  33. #include "const.h"
  34. #include "debug.h"
  35. int Track::_soloing = 0;
  36. const char *Track::capture_format = "Wav 24";
  37. Track::Track ( const char *L, int channels ) :
  38. Fl_Group ( 0, 0, 0, 0, 0 )
  39. {
  40. init();
  41. if ( L )
  42. name( L );
  43. color( (Fl_Color)rand() );
  44. configure_inputs( channels );
  45. configure_outputs( channels );
  46. log_create();
  47. }
  48. Track::Track ( ) : Fl_Group( 0, 0, 1, 1 )
  49. {
  50. init();
  51. timeline->add_track( this );
  52. }
  53. Track::~Track ( )
  54. {
  55. Loggable::block_start();
  56. /* must destroy sequences first to preserve proper log order */
  57. takes->clear();
  58. control->clear();
  59. annotation->clear();
  60. delete sequence();
  61. takes = NULL;
  62. control = NULL;
  63. annotation = NULL;
  64. log_destroy();
  65. /* ensure that soloing accounting is performed */
  66. solo( false );
  67. timeline->remove_track( this );
  68. /* give up our ports */
  69. configure_inputs( 0 );
  70. configure_outputs( 0 );
  71. _sequence = NULL;
  72. if ( _name )
  73. free( _name );
  74. Loggable::block_end();
  75. }
  76. void
  77. Track::init ( void )
  78. {
  79. _sequence = NULL;
  80. _name = NULL;
  81. _selected = false;
  82. _show_all_takes = false;
  83. _size = 1;
  84. record_ds = NULL;
  85. playback_ds = NULL;
  86. labeltype( FL_NO_LABEL );
  87. // clear_visible_focus();
  88. Fl_Group::size( timeline->w(), height() );
  89. Track *o = this;
  90. o->box( FL_FLAT_BOX );
  91. {
  92. Fl_Group *o = new Fl_Group( 0, 0, 149, 70 );
  93. o->color( ( Fl_Color ) 53 );
  94. o->box( FL_THIN_UP_BOX );
  95. {
  96. Fl_Input *o = name_field = new Fl_Sometimes_Input( 2, 2, 144, 24 );
  97. o->color( FL_BACKGROUND_COLOR );
  98. o->labeltype( FL_NO_LABEL );
  99. o->labelcolor( FL_GRAY0 );
  100. o->textcolor( FL_FOREGROUND_COLOR );
  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_ASYM_BOX );
  110. o->down_box( FL_ASYM_BOX );
  111. o->selection_color( FL_RED );
  112. o->color( fl_color_average( FL_GRAY, o->selection_color(), 0.80 ) );
  113. o->labelsize( 9 );
  114. o->callback( cb_button, this );
  115. }
  116. {
  117. Fl_Button *o = mute_button =
  118. new Fl_Button( 35, 28, 26, 24, "m" );
  119. o->selection_color( fl_color_average( FL_YELLOW, FL_GREEN, 0.50 ) );
  120. o->color( fl_color_average( FL_GRAY, o->selection_color(), 0.80 ) );
  121. o->type( 1 );
  122. o->box( FL_ASYM_BOX );
  123. o->down_box( FL_ASYM_BOX );
  124. o->labelsize( 15 );
  125. o->callback( cb_button, this );
  126. }
  127. {
  128. Fl_Button *o = solo_button =
  129. new Fl_Button( 66, 28, 26, 24, "s" );
  130. o->selection_color( fl_color_average( FL_YELLOW, FL_RED, 0.50 ) );
  131. o->color( fl_color_average( FL_GRAY, o->selection_color(), 0.80 ) );
  132. o->type( 1 );
  133. o->box( FL_ASYM_BOX );
  134. o->down_box( FL_ASYM_BOX );
  135. o->labelsize( 15 );
  136. o->callback( cb_button, this );
  137. }
  138. {
  139. Fl_Menu_Button *o = take_menu =
  140. new Fl_Menu_Button( 97, 28, 47, 24, "T" );
  141. o->box( FL_UP_BOX );
  142. o->color( FL_LIGHT1 );
  143. o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
  144. o->callback( cb_button, this );
  145. o->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE );
  146. o->add( "New", 0, 0, 0, FL_MENU_DIVIDER );
  147. }
  148. o->end();
  149. }
  150. {
  151. Fl_Box *o = new Fl_Box( 0, 72, 149, 38 );
  152. o->box( FL_NO_BOX );
  153. Fl_Group::current()->resizable( o );
  154. }
  155. o->size( Track::width(), h() );
  156. o->end();
  157. }
  158. {
  159. Fl_Pack *o = pack = new Fl_Pack( width(), 0, 1006, 115 );
  160. o->type( Fl_Pack::VERTICAL );
  161. o->labeltype( FL_NO_LABEL );
  162. o->resize( x() + width(), y(), w() - width(), h() );
  163. resizable( o );
  164. {
  165. Fl_Pack *o = annotation = new Fl_Pack( width(), 0, pack->w(), 1 );
  166. o->type( Fl_Pack::VERTICAL );
  167. o->end();
  168. }
  169. {
  170. Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 1 );
  171. o->type( Fl_Pack::VERTICAL );
  172. o->end();
  173. }
  174. {
  175. Fl_Pack *o = takes = new Fl_Pack( width(), 0, pack->w(), 1 );
  176. o->type( Fl_Pack::VERTICAL );
  177. o->end();
  178. o->hide();
  179. }
  180. o->end();
  181. }
  182. end();
  183. }
  184. void
  185. Track::set ( Log_Entry &e )
  186. {
  187. for ( int i = 0; i < e.size(); ++i )
  188. {
  189. const char *s, *v;
  190. e.get( i, &s, &v );
  191. if ( ! strcmp( s, ":height" ) )
  192. {
  193. size( atoi( v ) );
  194. adjust_size();
  195. }
  196. else if ( ! strcmp( s, ":selected" ) )
  197. _selected = atoi( v );
  198. // else if ( ! strcmp( s, ":armed"
  199. else if ( ! strcmp( s, ":name" ) )
  200. name( v );
  201. else if ( ! strcmp( s, ":inputs" ) )
  202. configure_inputs( atoi( v ) );
  203. else if ( ! strcmp( s, ":outputs" ) )
  204. configure_outputs( atoi( v ) );
  205. else if ( ! strcmp( s, ":color" ) )
  206. {
  207. color( (Fl_Color)atoll( v ) );
  208. redraw();
  209. }
  210. else if ( ! strcmp( s, ":show-all-takes" ) )
  211. show_all_takes( atoi( v ) );
  212. else if ( ! strcmp( s, ":solo" ) )
  213. solo( atoi( v ) );
  214. else if ( ! strcmp( s, ":mute" ) )
  215. mute( atoi( v ) );
  216. else if ( ! strcmp( s, ":arm" ) )
  217. armed( atoi( v ) );
  218. else if ( ! strcmp( s, ":sequence" ) )
  219. {
  220. int i;
  221. sscanf( v, "%X", &i );
  222. if ( i )
  223. {
  224. Audio_Sequence *t = (Audio_Sequence*)Loggable::find( i );
  225. /* FIXME: our track might not have been
  226. * defined yet... what should we do about this
  227. * chicken/egg problem? */
  228. if ( t )
  229. {
  230. // assert( t );
  231. sequence( t );
  232. }
  233. }
  234. }
  235. }
  236. }
  237. void
  238. Track::get ( Log_Entry &e ) const
  239. {
  240. e.add( ":name", _name );
  241. e.add( ":sequence", sequence() );
  242. e.add( ":selected", _selected );
  243. e.add( ":color", (unsigned long)color());
  244. }
  245. void
  246. Track::get_unjournaled ( Log_Entry &e ) const
  247. {
  248. e.add( ":height", size() );
  249. e.add( ":inputs", input.size() );
  250. e.add( ":outputs", output.size() );
  251. e.add( ":show-all-takes", _show_all_takes );
  252. e.add( ":armed", armed() );
  253. e.add( ":mute", mute() );
  254. e.add( ":solo", solo() );
  255. }
  256. void
  257. Track::log_children ( void ) const
  258. {
  259. log_create();
  260. for ( int i = control->children(); i--; )
  261. ((Sequence*)control->child( i ))->log_children();
  262. for ( int i = annotation->children(); i--; )
  263. ((Sequence*)annotation->child( i ))->log_children();
  264. for ( int i = takes->children(); i--; )
  265. ((Sequence*)takes->child( i ))->log_children();
  266. sequence()->log_children();
  267. }
  268. void
  269. Track::solo ( bool b )
  270. {
  271. if ( b && ! solo_button->value() )
  272. ++_soloing;
  273. else if ( ! b && solo_button->value() )
  274. --_soloing;
  275. solo_button->value( b );
  276. }
  277. void
  278. Track::cb_input_field ( Fl_Widget *, void *v )
  279. {
  280. ((Track*)v)->cb_input_field();
  281. }
  282. void
  283. Track::cb_button ( Fl_Widget *w, void *v )
  284. {
  285. ((Track*)v)->cb_button( w );
  286. }
  287. void
  288. Track::cb_input_field ( void )
  289. {
  290. log_start();
  291. name( name_field->value() );
  292. log_end();
  293. }
  294. void
  295. Track::cb_button ( Fl_Widget *w )
  296. {
  297. if ( w == record_button )
  298. {
  299. }
  300. if ( w == mute_button )
  301. {
  302. }
  303. if ( w == solo_button )
  304. {
  305. if ( solo_button->value() )
  306. ++_soloing;
  307. else
  308. --_soloing;
  309. }
  310. else
  311. if ( w == take_menu )
  312. {
  313. int v = take_menu->value();
  314. switch ( v )
  315. {
  316. case 0: /* show all takes */
  317. show_all_takes( take_menu->menu()[ v ].value() );
  318. break;
  319. case 1: /* new */
  320. sequence( (Audio_Sequence*)sequence()->clone_empty() );
  321. break;
  322. case 2: /* remove */
  323. if ( takes->children() )
  324. {
  325. Loggable::block_start();
  326. Audio_Sequence *s = sequence();
  327. sequence( (Audio_Sequence*)takes->child( 0 ) );
  328. delete s;
  329. Loggable::block_end();
  330. }
  331. break;
  332. case 3:
  333. if ( takes->children() )
  334. {
  335. Loggable::block_start();
  336. takes->clear();
  337. Loggable::block_end();
  338. }
  339. break;
  340. default:
  341. sequence( (Audio_Sequence*)take_menu->menu()[ v ].user_data() );
  342. }
  343. }
  344. }
  345. static int pack_visible( Fl_Pack *p )
  346. {
  347. int v = 0;
  348. for ( int i = p->children(); i--; )
  349. if ( p->child( i )->visible() )
  350. v++;
  351. return v;
  352. }
  353. /* adjust size of widget and children */
  354. void
  355. Track::adjust_size ( void )
  356. {
  357. for ( int i = takes->children(); i--; )
  358. takes->child( i )->size( w(), height() );
  359. for ( int i = annotation->children(); i--; )
  360. annotation->child( i )->size( w(), 24 );
  361. for ( int i = control->children(); i--; )
  362. control->child( i )->size( w(), height() );
  363. /* FIXME: hack! */
  364. if ( annotation->children() )
  365. annotation->show();
  366. else
  367. annotation->hide();
  368. if ( _show_all_takes )
  369. {
  370. takes->show();
  371. Fl_Group::size( w(), height() * ( 1 + takes->children() + pack_visible( control ) ) );
  372. }
  373. else
  374. {
  375. takes->hide();
  376. Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) );
  377. }
  378. Fl_Group::size( w(), h() + ( ( 24 ) * pack_visible( annotation ) ) );
  379. if ( sequence() )
  380. sequence()->size( w(), height() );
  381. if ( controls->y() + controls->h() > y() + h() )
  382. controls->hide();
  383. else
  384. controls->show();
  385. /* FIXME: why is this necessary? */
  386. if ( parent() )
  387. parent()->parent()->redraw();
  388. }
  389. void
  390. Track::size ( int v )
  391. {
  392. if ( v < 0 || v > 3 )
  393. return;
  394. _size = v;
  395. adjust_size();
  396. }
  397. void
  398. Track::update_take_menu ( void )
  399. {
  400. take_menu->clear();
  401. take_menu->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE | ( _show_all_takes ? FL_MENU_VALUE : 0 ) );
  402. take_menu->add( "New", 0, 0, 0 );
  403. if ( takes->children() )
  404. {
  405. take_menu->add( "Remove", 0, 0, 0 );
  406. take_menu->add( "Remove others", 0, 0, 0, FL_MENU_DIVIDER );
  407. for ( int i = 0; i < takes->children(); ++i )
  408. {
  409. Sequence *s = (Sequence *)takes->child( i );
  410. take_menu->add( s->name(), 0, 0, s );
  411. }
  412. }
  413. }
  414. void
  415. Track::add ( Audio_Sequence * t )
  416. {
  417. takes->insert( *t, 0 );
  418. t->color( fl_color_average( FL_BLACK, FL_GRAY, 0.25f ) );
  419. t->labeltype( FL_ENGRAVED_LABEL );
  420. update_take_menu();
  421. }
  422. void
  423. Track::remove ( Audio_Sequence *t )
  424. {
  425. if ( ! takes )
  426. return;
  427. timeline->wrlock();
  428. if ( sequence() == t )
  429. {
  430. pack->remove( t );
  431. if ( takes->children() )
  432. sequence( (Audio_Sequence*)takes->child( 0 ) );
  433. else
  434. /* FIXME: should this ever happen? */
  435. _sequence = NULL;
  436. }
  437. else
  438. takes->remove( t );
  439. /* delete t; */
  440. timeline->unlock();
  441. adjust_size();
  442. update_take_menu();
  443. }
  444. void
  445. Track::remove ( Annotation_Sequence *t )
  446. {
  447. if ( ! annotation )
  448. return;
  449. annotation->remove( t );
  450. adjust_size();
  451. }
  452. void
  453. Track::remove ( Control_Sequence *t )
  454. {
  455. if ( ! control )
  456. return;
  457. timeline->wrlock();
  458. engine->lock();
  459. control->remove( t );
  460. engine->unlock();
  461. timeline->unlock();
  462. adjust_size();
  463. }
  464. void
  465. Track::sequence ( Audio_Sequence * t )
  466. {
  467. t->track( this );
  468. if ( sequence() )
  469. add( sequence() );
  470. _sequence = t;
  471. pack->insert( *t, 1 );
  472. t->color( FL_GRAY );
  473. t->labeltype( FL_NO_LABEL );
  474. update_take_menu();
  475. adjust_size();
  476. }
  477. void
  478. Track::add ( Control_Sequence *t )
  479. {
  480. DMESSAGE( "adding control sequence" );
  481. engine->lock();
  482. t->track( this );
  483. control->add( t );
  484. t->color( color() );
  485. engine->unlock();
  486. adjust_size();
  487. }
  488. void
  489. Track::add ( Annotation_Sequence *t )
  490. {
  491. DMESSAGE( "adding annotation sequence" );
  492. t->track( this );
  493. annotation->add( t );
  494. adjust_size();
  495. }
  496. /** add all widget on this track falling within the given rectangle to
  497. the selection. */
  498. void
  499. Track::select ( int X, int Y, int W, int H,
  500. bool include_control, bool merge_control )
  501. {
  502. Sequence *t = sequence();
  503. if ( ! ( t->y() > Y + H || t->y() + t->h() < Y ) )
  504. t->select_range( X, W );
  505. else
  506. include_control = true;
  507. if ( include_control )
  508. for ( int i = control->children(); i--; )
  509. {
  510. Control_Sequence *c = (Control_Sequence*)control->child( i );
  511. if ( merge_control ||
  512. ( c->y() >= Y && c->y() + c->h() <= Y + H ) )
  513. c->select_range( X, W );
  514. }
  515. }
  516. #include <FL/Fl_Menu_Button.H>
  517. void
  518. Track::menu_cb ( Fl_Widget *w, void *v )
  519. {
  520. ((Track*)v)->menu_cb( (Fl_Menu_*) w );
  521. }
  522. void
  523. Track::menu_cb ( const Fl_Menu_ *m )
  524. {
  525. char picked[256];
  526. m->item_pathname( picked, sizeof( picked ) );
  527. Logger log( this );
  528. if ( ! strcmp( picked, "Type/Mono" ) )
  529. {
  530. configure_inputs( 1 );
  531. configure_outputs( 1 );
  532. }
  533. else if ( ! strcmp( picked, "Type/Stereo" ) )
  534. {
  535. configure_inputs( 2 );
  536. configure_outputs( 2 );
  537. }
  538. else if ( ! strcmp( picked, "Type/Quad" ) )
  539. {
  540. configure_inputs( 4 );
  541. configure_outputs( 4 );
  542. }
  543. else if ( ! strcmp( picked, "Type/..." ) )
  544. {
  545. const char *s = fl_input( "How many channels?", "3" );
  546. if ( s )
  547. {
  548. int c = atoi( s );
  549. if ( c <= 0 || c > 10 )
  550. fl_alert( "Invalid number of channels." );
  551. else
  552. {
  553. configure_inputs( c );
  554. configure_outputs( c );
  555. }
  556. }
  557. }
  558. else if ( ! strcmp( picked, "/Add Control" ) )
  559. {
  560. new Control_Sequence( this );
  561. }
  562. else if ( ! strcmp( picked, "/Add Annotation" ) )
  563. {
  564. add( new Annotation_Sequence( this ) );
  565. }
  566. else if ( ! strcmp( picked, "/Color" ) )
  567. {
  568. unsigned char r, g, b;
  569. Fl::get_color( color(), r, g, b );
  570. if ( fl_color_chooser( "Track Color", r, g, b ) )
  571. {
  572. color( fl_rgb_color( r, g, b ) );
  573. }
  574. redraw();
  575. }
  576. else if ( ! strcmp( picked, "Flags/Record" ) )
  577. {
  578. armed( m->mvalue()->flags & FL_MENU_VALUE );
  579. }
  580. else if ( ! strcmp( picked, "Flags/Mute" ) )
  581. {
  582. mute( m->mvalue()->flags & FL_MENU_VALUE );
  583. }
  584. else if ( ! strcmp( picked, "Flags/Solo" ) )
  585. {
  586. solo( m->mvalue()->flags & FL_MENU_VALUE );
  587. }
  588. else if ( ! strcmp( picked, "Size/Small" ) )
  589. {
  590. size( 0 );
  591. }
  592. else if ( ! strcmp( picked, "Size/Medium" ) )
  593. {
  594. size( 1 );
  595. }
  596. else if ( ! strcmp( picked, "Size/Large" ) )
  597. {
  598. size( 2 );
  599. }
  600. else if ( ! strcmp( picked, "Size/Huge" ) )
  601. {
  602. size( 3 );
  603. }
  604. else if ( ! strcmp( picked, "/Remove" ) )
  605. {
  606. int r = fl_choice( "Are you certain you want to remove track \"%s\"?", "Cancel", NULL, "Remove", name() );
  607. if ( r == 2 )
  608. {
  609. timeline->remove_track( this );
  610. Fl::delete_widget( this );
  611. }
  612. }
  613. else if ( ! strcmp( picked, "/Rename" ) )
  614. {
  615. ((Fl_Sometimes_Input*)name_field)->take_focus();
  616. }
  617. }
  618. #include "FL/menu_popup.H"
  619. /** build the context menu */
  620. Fl_Menu_Button &
  621. Track::menu ( void ) const
  622. {
  623. static Fl_Menu_Button m( 0, 0, 0, 0, "Track" );
  624. int c = output.size();
  625. int s = size();
  626. Fl_Menu_Item menu[] =
  627. {
  628. { "Type", 0, 0, 0, FL_SUBMENU },
  629. { "Mono", 0, 0, 0, FL_MENU_RADIO | ( c == 1 ? FL_MENU_VALUE : 0 ) },
  630. { "Stereo", 0, 0, 0, FL_MENU_RADIO | ( c == 2 ? FL_MENU_VALUE : 0 ) },
  631. { "Quad", 0, 0, 0, FL_MENU_RADIO | ( c == 4 ? FL_MENU_VALUE : 0 ) },
  632. { "...", 0, 0, 0, FL_MENU_RADIO | ( c == 3 || c > 4 ? FL_MENU_VALUE : 0 ) },
  633. { 0 },
  634. { "Add Control", 0, 0, 0 },
  635. { "Add Annotation", 0, 0, 0 },
  636. { "Color", 0, 0, 0 },
  637. { "Rename", FL_CTRL + 'n', 0, 0 },
  638. { "Size", 0, 0, 0, FL_SUBMENU },
  639. { "Small", FL_ALT + '1', 0, 0, FL_MENU_RADIO | ( s == 0 ? FL_MENU_VALUE : 0 ) },
  640. { "Medium", FL_ALT + '2', 0, 0, FL_MENU_RADIO | ( s == 1 ? FL_MENU_VALUE : 0 ) },
  641. { "Large", FL_ALT + '3', 0, 0, FL_MENU_RADIO | ( s == 2 ? FL_MENU_VALUE : 0 ) },
  642. { "Huge", FL_ALT + '4', 0, 0, FL_MENU_RADIO | ( s == 3 ? FL_MENU_VALUE : 0 ) },
  643. { 0 },
  644. { "Flags", 0, 0, 0, FL_SUBMENU },
  645. { "Record", FL_CTRL + 'r', 0, 0, FL_MENU_TOGGLE | ( armed() ? FL_MENU_VALUE : 0 ) },
  646. { "Mute", FL_CTRL + 'm', 0, 0, FL_MENU_TOGGLE | ( mute() ? FL_MENU_VALUE : 0 ) },
  647. { "Solo", FL_CTRL + 's', 0, 0, FL_MENU_TOGGLE | ( solo() ? FL_MENU_VALUE : 0 ) },
  648. { 0 },
  649. { "Remove", 0, 0, 0 }, // transport->rolling ? FL_MENU_INACTIVE : 0 },
  650. { 0 },
  651. };
  652. menu_set_callback( menu, &Track::menu_cb, (void*)this );
  653. m.copy( menu, (void*)this );
  654. return m;
  655. }
  656. #include "FL/event_name.H"
  657. #include "FL/test_press.H"
  658. void
  659. Track::draw ( void )
  660. {
  661. int X, Y, W, H;
  662. fl_push_clip( x(), y(), w(), h() );
  663. fl_clip_box( x(), y(), w(), h(), X, Y, W, H );
  664. if ( _selected )
  665. {
  666. Fl_Color c = color();
  667. color( FL_RED );
  668. Fl_Group::draw();
  669. color( c );
  670. }
  671. else
  672. Fl_Group::draw();
  673. fl_pop_clip();
  674. }
  675. int
  676. Track::handle ( int m )
  677. {
  678. /* if ( m != FL_NO_EVENT ) */
  679. /* DMESSAGE( "%s", event_name( m ) ); */
  680. switch ( m )
  681. {
  682. case FL_KEYBOARD:
  683. {
  684. Fl_Menu_Button * men = &menu();
  685. if ( Fl::event_key() == FL_Menu )
  686. {
  687. menu_popup( men );
  688. return 1;
  689. }
  690. else
  691. return men->test_shortcut() || Fl_Group::handle( m );
  692. }
  693. case FL_MOUSEWHEEL:
  694. {
  695. Logger log( this );
  696. if ( ! Fl::event_shift() )
  697. return Fl_Group::handle( m );
  698. int d = Fl::event_dy();
  699. if ( d < 0 )
  700. size( size() - 1 );
  701. else
  702. size( size() + 1 );
  703. return 1;
  704. }
  705. case FL_PUSH:
  706. {
  707. Logger log( this );
  708. if ( Fl_Group::handle( m ) )
  709. return 1;
  710. if ( test_press( FL_BUTTON3 ) && Fl::event_x() < Track::width() )
  711. {
  712. menu_popup( &menu() );
  713. return 1;
  714. }
  715. return 0;
  716. }
  717. default:
  718. return Fl_Group::handle( m );
  719. }
  720. return 0;
  721. }