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.

164 lines
4.0KB

  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 "Control_Sequence.H"
  19. #include "Track.H"
  20. Control_Sequence::Control_Sequence ( Track *track ) : Sequence( 0, 0, 0, 0 )
  21. {
  22. init();
  23. _track = track;
  24. if ( track )
  25. track->add( this );
  26. log_create();
  27. }
  28. Control_Sequence::~Control_Sequence ( )
  29. {
  30. log_destroy();
  31. }
  32. void
  33. Control_Sequence::init ( void )
  34. {
  35. _track = NULL;
  36. color( fl_darker( FL_GREEN ) );
  37. }
  38. void
  39. Control_Sequence::get ( Log_Entry &e )
  40. {
  41. Sequence::get( e );
  42. e.add( ":t", _track );
  43. }
  44. void
  45. Control_Sequence::set ( Log_Entry &e )
  46. {
  47. Sequence::set( e );
  48. for ( int i = 0; i < e.size(); ++i )
  49. {
  50. const char *s, *v;
  51. e.get( i, &s, &v );
  52. if ( ! strcmp( ":t", s ) )
  53. {
  54. int i;
  55. sscanf( v, "%X", &i );
  56. Track *t = (Track*)Loggable::find( i );
  57. assert( t );
  58. t->add( this );
  59. }
  60. }
  61. }
  62. void
  63. Control_Sequence::draw ( void )
  64. {
  65. if ( ! fl_not_clipped( x(), y(), w(), h() ) )
  66. return;
  67. fl_push_clip( x(), y(), w(), h() );
  68. draw_box();
  69. int X, Y, W, H;
  70. fl_clip_box( x(), y(), w(), h(), X, Y, W, H );
  71. fl_line_style( FL_SOLID, 4 );
  72. fl_color( fl_color_average( selection_color(), color(), 0.90f ) );
  73. fl_begin_complex_polygon();
  74. list <Sequence_Widget *>::const_iterator e = _widgets.end();
  75. e--;
  76. if ( _widgets.size() )
  77. for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); ; r++ )
  78. {
  79. if ( r == _widgets.begin() )
  80. {
  81. fl_vertex( x(), y() + h() );
  82. fl_vertex( x(), (*r)->y() );
  83. }
  84. fl_vertex( (*r)->x(), (*r)->y() );
  85. if ( r == e )
  86. {
  87. fl_vertex( x() + w(), (*r)->y() );
  88. fl_vertex( x() + w(), y() + h() );
  89. break;
  90. }
  91. }
  92. fl_end_complex_polygon();
  93. fl_line_style( FL_SOLID, 0 );
  94. timeline->draw_measure_lines( x(), y(), w(), h(), color() );
  95. for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
  96. (*r)->draw_box();
  97. fl_pop_clip();
  98. }
  99. int
  100. Control_Sequence::handle ( int m )
  101. {
  102. int r = Sequence::handle( m );
  103. if ( r )
  104. return r;
  105. switch ( m )
  106. {
  107. case FL_PUSH:
  108. {
  109. if ( Fl::event_button1() )
  110. {
  111. Control_Point *r = new Control_Point( this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ), (float)(Fl::event_y() - y()) / h() );
  112. add( r );
  113. }
  114. return 1;
  115. }
  116. default:
  117. return 0;
  118. }
  119. }