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.

154 lines
3.7KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2012 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 <FL/Fl_Tooltip.H>
  19. #include <FL/fl_ask.H>
  20. #include <FL/fl_draw.H>
  21. #include "Cursor_Region.H"
  22. #include "Cursor_Sequence.H"
  23. #include "Timeline.H"
  24. Fl_Color Cursor_Region::box_color ( void ) const
  25. {
  26. return ((Cursor_Sequence*)sequence())->cursor_color();
  27. }
  28. void Cursor_Region::box_color ( Fl_Color c )
  29. {
  30. ((Cursor_Sequence*)sequence())->cursor_color( c );
  31. }
  32. void
  33. Cursor_Region::get ( Log_Entry &e ) const
  34. {
  35. // Sequence_Region::get( e );
  36. e.add( ":start", start() );
  37. e.add( ":length", length() );
  38. e.add( ":label", label() );
  39. e.add( ":type", type() );
  40. }
  41. void
  42. Cursor_Region::set ( Log_Entry &e )
  43. {
  44. Sequence_Region::set( e );
  45. for ( int i = 0; i < e.size(); ++i )
  46. {
  47. const char *s, *v;
  48. e.get( i, &s, &v );
  49. if ( ! strcmp( s, ":label" ) )
  50. label( v );
  51. if ( ! strcmp( s, ":type" ) )
  52. {
  53. type( v );
  54. timeline->add_cursor( this );
  55. }
  56. }
  57. // timeline->redraw();
  58. }
  59. Cursor_Region::Cursor_Region ( nframes_t when, nframes_t length, const char *type, const char *label )
  60. {
  61. _label = NULL;
  62. _type = NULL;
  63. this->label( label );
  64. this->type( type );
  65. start( when );
  66. this->length( length );
  67. timeline->add_cursor( this );
  68. log_create();
  69. }
  70. Cursor_Region::Cursor_Region ( const Cursor_Region &rhs ) : Sequence_Region( rhs )
  71. {
  72. _label = rhs._label ? strdup( rhs._label ) : NULL;
  73. _type = rhs._type ? strdup( rhs._type ) : NULL;
  74. log_create();
  75. }
  76. Cursor_Region::~Cursor_Region ( )
  77. {
  78. // timeline->cursor_track->remove( this );
  79. log_destroy();
  80. label(NULL);
  81. type(NULL);
  82. }
  83. void
  84. Cursor_Region::draw_box ( void )
  85. {
  86. Sequence_Region::draw_box();
  87. }
  88. void
  89. Cursor_Region::draw ( void )
  90. {
  91. draw_label( _label, (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_TOP | FL_ALIGN_CLIP ) );
  92. }
  93. #include <FL/Fl_Text_Edit_Window.H>
  94. #include <FL/test_press.H>
  95. int
  96. Cursor_Region::handle ( int m )
  97. {
  98. Logger _log( this );
  99. if ( m == FL_PUSH )
  100. {
  101. if ( test_press( FL_BUTTON3 ) )
  102. {
  103. char *s = fl_text_edit( "Cursor text:", "&Save", label() );
  104. if ( s )
  105. label( s );
  106. free( s );
  107. return 0;
  108. }
  109. }
  110. int r = Sequence_Region::handle( m );
  111. if ( m == FL_RELEASE )
  112. {
  113. sequence()->sort();
  114. timeline->redraw();
  115. }
  116. return r;
  117. }