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.

133 lines
3.8KB

  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 "Region.H"
  23. #include <stdio.h>
  24. #include "Loggable.H"
  25. #include <assert.h>
  26. #include <list>
  27. #include <queue>
  28. using namespace std;
  29. class Region;
  30. class Track_Widget;
  31. /* This is the base class for all track types. */
  32. class Track : public Fl_Widget, public Loggable
  33. {
  34. char *_name;
  35. static queue <Track_Widget *> _delete_queue;
  36. static Track_Widget *_pushed;
  37. static Track_Widget *_belowmouse;
  38. protected:
  39. list <Track_Widget *> _widgets;
  40. Track_Widget *event_widget ( void );
  41. virtual const char *class_name ( void ) { return "Track"; }
  42. void set ( char ** ) { return; }
  43. char ** get ( void )
  44. {
  45. // char *r;
  46. char **sa = (char**)malloc( sizeof( char* ) * 2);
  47. sa[0] = (char*)malloc( (_widgets.size() * ((sizeof( int ) * 2) + 3)) + 1 );
  48. sa[1] = NULL;
  49. sa[0][0] = '\0';
  50. /* char *s = sa[0]; */
  51. /* s += sprintf( s, ":items " ); */
  52. /* for ( list <Track_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ ) */
  53. /* { */
  54. /* s += sprintf( s, "0x%X", ((Loggable*)(*i))->id() ); */
  55. /* list <Track_Widget *>::const_iterator e = i; */
  56. /* if ( ++e != _widgets.end() ) */
  57. /* s += sprintf( s, "," ); */
  58. /* } */
  59. return sa;
  60. }
  61. public:
  62. Track ( int X, int Y, int W, int H );
  63. virtual ~Track ( );
  64. static Track_Widget *pushed ( void ) { return _pushed; };
  65. static Track_Widget *belowmouse ( void ) { return _belowmouse; };
  66. const char * name ( void ) const { return _name; }
  67. void name ( char *s ) { if ( _name ) free( _name ); _name = s; label( _name ); }
  68. void sort ( void );
  69. void remove ( Track_Widget *r );
  70. void add ( Track_Widget *r );
  71. void select_range ( int X, int W );
  72. void remove_selected ( void );
  73. const list <Track_Widget *> widgets ( void ) const { return _widgets; }
  74. void queue_delete ( Track_Widget *r )
  75. {
  76. _delete_queue.push( r );
  77. }
  78. Track_Widget * overlaps ( Track_Widget *r );
  79. virtual Track * clone ( void )
  80. {
  81. assert( 0 );
  82. }
  83. virtual Track * clone_empty ( void )
  84. {
  85. return NULL;
  86. }
  87. virtual void snap ( Track_Widget *r );
  88. virtual int handle ( int m );
  89. virtual void draw ( void );
  90. };