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.

143 lines
4.3KB

  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 <FL/Fl_Widget.H>
  20. #include <FL/Fl_Group.H>
  21. #include <FL/Fl.H>
  22. #include <stdio.h>
  23. #include "Loggable.H"
  24. #include <assert.h>
  25. #include <list>
  26. #include <queue>
  27. class Track;
  28. class Sequence_Widget;
  29. #include "types.h"
  30. /* This is the base class for all track types. */
  31. class Sequence : public Fl_Widget, public Loggable
  32. {
  33. /* not permitted */
  34. Sequence ( const Sequence &rhs );
  35. Sequence & operator= ( const Sequence &rhs );
  36. static std::queue <Sequence_Widget *> _delete_queue;
  37. void init ( void );
  38. protected:
  39. Track *_track; /* track this sequence belongs to */
  40. char *_name;
  41. friend class Timeline; // for draw_measure
  42. std::list <Sequence_Widget *> _widgets;
  43. Sequence_Widget *widget_at ( nframes_t ts, int Y );
  44. Sequence_Widget *event_widget ( void );
  45. public:
  46. virtual void log_children ( void ) const;
  47. /* child classes should implement this if they need to take
  48. special action when a widget is changed/moved/resized. /start/
  49. and /length/ define the affected region */
  50. virtual void handle_widget_change ( nframes_t start, nframes_t length );
  51. /* welcome to C++ */
  52. LOG_NAME_FUNC( Sequence );
  53. Sequence ( Track *track=0, const char *name = 0 );
  54. Sequence ( int X, int Y, int W, int H );
  55. virtual ~Sequence ( );
  56. /* override this to provide cursor */
  57. virtual Fl_Cursor cursor ( void ) const = 0;
  58. nframes_t x_to_offset ( int X );
  59. const char * name ( void ) const { return _name; }
  60. void name ( const char *s )
  61. {
  62. if ( _name ) free( _name );
  63. _name = s ? strdup( s ) : NULL;
  64. label( _name );
  65. }
  66. void sort ( void );
  67. void clear ( void );
  68. nframes_t next ( nframes_t from ) const;
  69. nframes_t prev ( nframes_t from ) const;
  70. Track *track ( void ) const { return _track; }
  71. void track ( Track *t ) { _track = t; }
  72. void remove ( Sequence_Widget *r );
  73. void add ( Sequence_Widget *r );
  74. void select_range ( int X, int W );
  75. void remove_selected ( void );
  76. Fl_Color color ( void ) const { return this == Fl::focus() ? fl_color_average( FL_FOREGROUND_COLOR, Fl_Widget::color(), 0.50f ) : Fl_Widget::color(); }
  77. void color ( Fl_Color v ) { Fl_Widget::color( v ); }
  78. const std::list <Sequence_Widget *> widgets ( void ) const { return _widgets; }
  79. void queue_delete ( Sequence_Widget *r )
  80. {
  81. _delete_queue.push( r );
  82. }
  83. Sequence_Widget * overlaps ( Sequence_Widget *r );
  84. nframes_t length ( void ) const;
  85. virtual Sequence * clone ( void )
  86. {
  87. assert( 0 );
  88. }
  89. virtual Sequence * clone_empty ( void )
  90. {
  91. return NULL;
  92. }
  93. virtual void snap ( Sequence_Widget *r );
  94. virtual int handle ( int m );
  95. virtual void draw ( void );
  96. virtual nframes_t process ( nframes_t ) { return 0; }
  97. };