Non reinvents the DAW. Powerful enough to form a complete studio, fast and light enough to run on low-end hardware like the eeePC or Raspberry Pi, and so reliable that it can be used live https://non.tuxfamily.org/
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.

127 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 = sequence;
  44. _r->start = when;
  45. /* FIXME: hack */
  46. _r->length = 400;
  47. _label = strdup( label );
  48. log_create();
  49. }
  50. Annotation_Region::Annotation_Region ( const Annotation_Region &rhs ) : Sequence_Region( rhs )
  51. {
  52. _label = strdup( rhs._label );
  53. log_create();
  54. }
  55. Annotation_Region::~Annotation_Region ( )
  56. {
  57. log_destroy();
  58. if ( _label ) free( _label );
  59. }
  60. void
  61. Annotation_Region::draw_box ( void )
  62. {
  63. Sequence_Region::draw_box();
  64. }
  65. void
  66. Annotation_Region::draw ( void )
  67. {
  68. draw_label( _label, (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_TOP | FL_ALIGN_CLIP ) );
  69. }
  70. #include <Fl_Text_Edit_Window.H>
  71. #include <test_press.H>
  72. int
  73. Annotation_Region::handle ( int m )
  74. {
  75. Logger _log( this );
  76. if ( m == FL_PUSH )
  77. {
  78. if ( test_press( FL_BUTTON3 ) )
  79. {
  80. char *s = fl_text_edit( "Annotation text:", "&Save", label() );
  81. if ( s )
  82. label( s );
  83. free( s );
  84. return 0;
  85. }
  86. }
  87. int r = Sequence_Region::handle( m );
  88. if ( m == FL_RELEASE )
  89. {
  90. sequence()->sort();
  91. timeline->redraw();
  92. }
  93. return r;
  94. }