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.

120 lines
3.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 <FL/Fl_Tooltip.H>
  19. #include <FL/fl_ask.H>
  20. #include "Annotation_Region.H"
  21. void
  22. Annotation_Region::get ( Log_Entry &e ) const
  23. {
  24. Sequence_Region::get( e );
  25. e.add( ":label", _label );
  26. }
  27. void
  28. Annotation_Region::set ( Log_Entry &e )
  29. {
  30. Sequence_Region::set( e );
  31. for ( int i = 0; i < e.size(); ++i )
  32. {
  33. const char *s, *v;
  34. e.get( i, &s, &v );
  35. if ( ! strcmp( s, ":label" ) )
  36. name( v );
  37. }
  38. // timeline->redraw();
  39. }
  40. Annotation_Region::Annotation_Region ( Sequence *sequence, nframes_t when, const char *name )
  41. {
  42. _sequence = sequence;
  43. _r->start = when;
  44. /* FIXME: hack */
  45. _r->length = 400;
  46. _label = strdup( name );
  47. log_create();
  48. }
  49. Annotation_Region::Annotation_Region ( const Annotation_Region &rhs ) : Sequence_Region( rhs )
  50. {
  51. _label = strdup( rhs._label );
  52. log_create();
  53. }
  54. Annotation_Region::~Annotation_Region ( )
  55. {
  56. log_destroy();
  57. if ( _label ) free( _label );
  58. }
  59. void
  60. Annotation_Region::draw_box ( void )
  61. {
  62. Sequence_Region::draw_box();
  63. }
  64. void
  65. Annotation_Region::draw ( void )
  66. {
  67. draw_label( _label, (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_TOP | FL_ALIGN_CLIP ) );
  68. }
  69. #include "FL/Fl_Text_Edit_Window.H"
  70. int
  71. Annotation_Region::handle ( int m )
  72. {
  73. Logger _log( this );
  74. if ( m == FL_PUSH && Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() )
  75. {
  76. char *s = fl_text_edit( "Annotation text:", "&Save", name() );
  77. if ( s )
  78. name( s );
  79. free( s );
  80. return 0;
  81. }
  82. int r = Sequence_Region::handle( m );
  83. if ( m == FL_RELEASE )
  84. {
  85. sequence()->sort();
  86. timeline->redraw();
  87. }
  88. return r;
  89. }