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_Group.H>
  20. #include <FL/Fl.H>
  21. // #include "Region.H"
  22. #include <stdio.h>
  23. #include "Loggable.H"
  24. #include <assert.h>
  25. #include <list>
  26. #include <queue>
  27. using namespace std;
  28. class Region;
  29. class Track_Widget;
  30. class Track : public Fl_Group, public Loggable
  31. {
  32. Track *_next;
  33. Track *_prev;
  34. char *_name;
  35. static queue <Track_Widget *> _delete_queue;
  36. protected:
  37. list <Track_Widget *> _widgets;
  38. Track_Widget *event_widget ( void );
  39. const char *class_name ( void ) { return "Track"; }
  40. void set ( char ** ) { return; }
  41. char ** get ( void )
  42. {
  43. // char *r;
  44. char **sa = (char**)malloc( sizeof( char* ) * 2);
  45. sa[0] = (char*)malloc( (_widgets.size() * ((sizeof( int ) * 2) + 3)) + 1 );
  46. sa[1] = NULL;
  47. char *s = sa[0];
  48. s += sprintf( s, ":items " );
  49. for ( list <Track_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ )
  50. {
  51. s += sprintf( s, "0x%X", ((Loggable*)(*i))->id() );
  52. list <Track_Widget *>::const_iterator e = i;
  53. if ( ++e != _widgets.end() )
  54. s += sprintf( s, "," );
  55. }
  56. return sa;
  57. }
  58. public:
  59. Track ( int X, int Y, int W, int H ) : Fl_Group( X, Y, W, H )
  60. {
  61. _next = _prev = NULL;
  62. _name = NULL;
  63. box( FL_DOWN_BOX );
  64. color( fl_darker( FL_GRAY ) );
  65. end();
  66. log_create();
  67. }
  68. virtual ~Track ( )
  69. {
  70. /* FIXME: what to do with regions? */
  71. parent()->redraw();
  72. parent()->remove( this );
  73. log_destroy();
  74. }
  75. Track *next ( void ) const { return _next; }
  76. Track *prev ( void ) const { return _prev; }
  77. void prev ( Track *t ) { _prev = t; }
  78. void next ( Track *t ) { _next = t; }
  79. void sort ( void );
  80. void remove ( Track_Widget *r );
  81. void add ( Track_Widget *r );
  82. void select_range ( int X, int W );
  83. void remove_selected ( void );
  84. const list <Track_Widget *> widgets ( void ) const { return _widgets; }
  85. void queue_delete ( Track_Widget *r )
  86. {
  87. _delete_queue.push( r );
  88. }
  89. Track_Widget * overlaps ( Track_Widget *r );
  90. virtual void snap ( Track_Widget *r );
  91. virtual int handle ( int m );
  92. virtual void draw ( void );
  93. };