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.

184 lines
4.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 "Track_Point.H"
  20. class Control_Point : public Track_Point
  21. {
  22. float _y;
  23. /* void */
  24. /* _make_label ( void ) */
  25. /* { */
  26. /* if ( ! _label ) */
  27. /* _label = new char[40]; */
  28. /* snprintf( _label, 40, "%.1f", _y ); */
  29. /* } */
  30. protected:
  31. const char *class_name ( void ) { return "Control_Point"; }
  32. char ** get ( void )
  33. {
  34. char **sa = (char**)malloc( sizeof( char* ) * 4 );
  35. int i = 0;
  36. asprintf( &sa[i++], ":x %lu", _offset );
  37. asprintf( &sa[i++], ":y %.2f", _y );
  38. asprintf( &sa[i++], ":track 0x%X", _track ? _track->id() : 0 );
  39. sa[i] = NULL;
  40. return sa;
  41. }
  42. void
  43. set ( char **sa )
  44. {
  45. for ( int i = 0; sa[i]; ++i )
  46. {
  47. char *s = sa[i];
  48. strtok( s, " " );
  49. char *v = s + strlen( s ) + 1;
  50. if ( ! strcmp( s, ":x" ) )
  51. _offset = atol( v );
  52. else
  53. if ( ! strcmp( s, ":y" ) )
  54. _y = atof( v );
  55. else
  56. if ( ! strcmp( s, ":track" ) )
  57. {
  58. int i;
  59. sscanf( v, "%X", &i );
  60. Track *t = (Track*)Loggable::find( i );
  61. assert( t );
  62. t->add( this );
  63. t->sort();
  64. }
  65. free( s );
  66. }
  67. free( sa );
  68. timeline->redraw();
  69. // _make_label();
  70. }
  71. Control_Point ( )
  72. {
  73. }
  74. public:
  75. /* for loggable */
  76. static Loggable *
  77. create ( char **sa )
  78. {
  79. Control_Point *r = new Control_Point;
  80. r->set( sa );
  81. return (Loggable *)r;
  82. }
  83. Control_Point ( Track *t, nframes_t when, float y )
  84. {
  85. _track = t;
  86. _y = y;
  87. _offset = when;
  88. // _make_label();
  89. log_create();
  90. }
  91. ~Control_Point ( )
  92. {
  93. // if ( _label ) delete[] _label;
  94. log_destroy();
  95. }
  96. float control ( void ) const { return _y; }
  97. void control ( float v ) { _y = v; }
  98. int
  99. handle ( int m )
  100. {
  101. int r = Track_Widget::handle( m );
  102. switch ( m )
  103. {
  104. case FL_RELEASE:
  105. _track->sort();
  106. redraw();
  107. break;
  108. case FL_DRAG:
  109. {
  110. int Y = Fl::event_y() - parent()->y();
  111. if ( Y >= 0 && Y < parent()->h() )
  112. {
  113. _y = (float)Y / parent()->h();
  114. redraw();
  115. }
  116. track()->sort();
  117. break;
  118. }
  119. }
  120. return r;
  121. }
  122. int x ( void ) const { return line_x(); }
  123. int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
  124. int w ( void ) const { return 6; }
  125. int h ( void ) const { return 6; }
  126. /* void */
  127. /* draw_box ( int X, int Y, int W, int H ) */
  128. /* { */
  129. /* } */
  130. void
  131. draw ( int X, int Y, int W, int H )
  132. {
  133. // fl_draw_box( box(), x(), y(), w(), h(), box_color() );
  134. return;
  135. }
  136. };