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.

136 lines
3.6KB

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