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.

126 lines
3.1KB

  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 <FL/fl_draw.H>
  21. #include "Annotation_Region.H"
  22. void
  23. Annotation_Region::get ( Log_Entry &e ) const
  24. {
  25. Sequence_Region::get( e );
  26. e.add( ":label", _label );
  27. }
  28. void
  29. Annotation_Region::set ( Log_Entry &e )
  30. {
  31. Sequence_Region::set( e );
  32. for ( int i = 0; i < e.size(); ++i )
  33. {
  34. const char *s, *v;
  35. e.get( i, &s, &v );
  36. if ( ! strcmp( s, ":label" ) )
  37. label( v );
  38. }
  39. // timeline->redraw();
  40. }
  41. Annotation_Region::Annotation_Region ( Sequence *sequence, nframes_t when, const char *label )
  42. {
  43. _sequence = NULL;
  44. _r->start = when;
  45. /* FIXME: hack */
  46. _r->length = 400;
  47. _label = strdup( label );
  48. sequence->add( this );
  49. log_create();
  50. }
  51. Annotation_Region::Annotation_Region ( const Annotation_Region &rhs ) : Sequence_Region( rhs )
  52. {
  53. log_create();
  54. }
  55. Annotation_Region::~Annotation_Region ( )
  56. {
  57. log_destroy();
  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. #include <FL/test_press.H>
  71. int
  72. Annotation_Region::handle ( int m )
  73. {
  74. Logger _log( this );
  75. if ( m == FL_PUSH )
  76. {
  77. if ( test_press( FL_BUTTON3 ) )
  78. {
  79. char *s = fl_text_edit( "Annotation text:", "&Save", label() );
  80. if ( s )
  81. label( s );
  82. free( s );
  83. return 0;
  84. }
  85. }
  86. int r = Sequence_Region::handle( m );
  87. if ( m == FL_RELEASE )
  88. {
  89. sequence()->sort();
  90. timeline->redraw();
  91. }
  92. return r;
  93. }