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.

160 lines
4.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. #pragma once
  19. #include "Sequence.H"
  20. #include "Annotation_Point.H"
  21. #include "Annotation_Region.H"
  22. #include "Timeline.H"
  23. #include "Track.H"
  24. class Annotation_Sequence : public Sequence
  25. {
  26. protected:
  27. virtual void get ( Log_Entry &e ) const
  28. {
  29. e.add( ":track", _track );
  30. }
  31. void
  32. set ( Log_Entry &e )
  33. {
  34. for ( int i = 0; i < e.size(); ++i )
  35. {
  36. const char *s, *v;
  37. e.get( i, &s, &v );
  38. if ( ! strcmp( ":track", s ) )
  39. {
  40. int i;
  41. sscanf( v, "%X", &i );
  42. Track *t = (Track*)Loggable::find( i );
  43. assert( t );
  44. t->add( this );
  45. }
  46. }
  47. }
  48. Annotation_Sequence ( ) : Sequence ( 0 )
  49. {
  50. color( fl_darker( FL_GREEN ) );
  51. }
  52. public:
  53. LOG_CREATE_FUNC( Annotation_Sequence );
  54. Fl_Cursor cursor ( void ) const { return FL_CURSOR_INSERT; }
  55. Annotation_Sequence ( Track *track ) : Sequence( track )
  56. {
  57. color( fl_darker( FL_GREEN ) );
  58. log_create();
  59. }
  60. /* Annotation_Sequence ( int X, int Y, int W, int H ) : Sequence ( 0 ) */
  61. /* { */
  62. /* } */
  63. ~Annotation_Sequence ( )
  64. {
  65. Loggable::block_start();
  66. clear();
  67. log_destroy();
  68. track()->remove( this );
  69. Loggable::block_end();
  70. }
  71. int handle ( int m )
  72. {
  73. if ( Sequence::handle( m ) )
  74. return 1;
  75. switch ( m )
  76. {
  77. case FL_PUSH:
  78. {
  79. Logger log( this );
  80. if ( Fl::event_button1() )
  81. {
  82. add( new Annotation_Point( this, x_to_offset( Fl::event_x() ), "mark" ) );
  83. redraw();
  84. }
  85. if ( Fl::event_button3() && Fl::event_shift() )
  86. {
  87. Annotation_Region *r = new Annotation_Region( this, x_to_offset( Fl::event_x() ), "mark" );
  88. add( r );
  89. Sequence_Widget::pushed( r );
  90. r->handle( m );
  91. redraw();
  92. return 1;
  93. }
  94. else if ( Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_SHIFT | FL_CTRL ) ) )
  95. {
  96. Fl_Menu_Item menu[] =
  97. {
  98. { "Remove" },
  99. { 0 }
  100. };
  101. const Fl_Menu_Item *r = menu->popup( Fl::event_x(), Fl::event_y(), "Annotation Sequence" );
  102. if ( r )
  103. {
  104. if ( r == &menu[ 0 ] )
  105. {
  106. Fl::delete_widget( this );
  107. }
  108. }
  109. return 1;
  110. }
  111. break;
  112. }
  113. default:
  114. break;
  115. }
  116. return 0;
  117. }
  118. };