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.

140 lines
4.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. #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 *event_widget ( void );
  44. public:
  45. /* child classes should implement this if they need to take
  46. special action when a widget is changed/moved/resized. /start/
  47. and /length/ define the affected region */
  48. virtual void handle_widget_change ( nframes_t start, nframes_t length );
  49. /* welcome to C++ */
  50. LOG_NAME_FUNC( Sequence );
  51. Sequence ( Track *track=0 );
  52. Sequence ( int X, int Y, int W, int H );
  53. virtual ~Sequence ( );
  54. /* override this to provide cursor */
  55. virtual Fl_Cursor cursor ( void ) const = 0;
  56. nframes_t x_to_offset ( int X );
  57. const char * name ( void ) const { return _name; }
  58. void name ( const char *s )
  59. {
  60. if ( _name ) free( _name );
  61. _name = strdup( s );
  62. label( _name );
  63. }
  64. void sort ( void );
  65. nframes_t next ( nframes_t from ) const;
  66. nframes_t prev ( nframes_t from ) const;
  67. Track *track ( void ) const { return _track; }
  68. void track ( Track *t ) { _track = t; }
  69. void remove ( Sequence_Widget *r );
  70. void add ( Sequence_Widget *r );
  71. void select_range ( int X, int W );
  72. void remove_selected ( void );
  73. Fl_Color color ( void ) const { return this == Fl::focus() ? fl_color_average( FL_FOREGROUND_COLOR, Fl_Widget::color(), 0.50f ) : Fl_Widget::color(); }
  74. void color ( Fl_Color v ) { Fl_Widget::color( v ); }
  75. const std::list <Sequence_Widget *> widgets ( void ) const { return _widgets; }
  76. void queue_delete ( Sequence_Widget *r )
  77. {
  78. _delete_queue.push( r );
  79. }
  80. Sequence_Widget * overlaps ( Sequence_Widget *r );
  81. nframes_t length ( void ) const;
  82. virtual Sequence * clone ( void )
  83. {
  84. assert( 0 );
  85. }
  86. virtual Sequence * clone_empty ( void )
  87. {
  88. return NULL;
  89. }
  90. virtual void snap ( Sequence_Widget *r );
  91. virtual int handle ( int m );
  92. virtual void draw ( void );
  93. virtual nframes_t process ( nframes_t ) { return 0; }
  94. };