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.

181 lines
4.7KB

  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++], ":track 0x%X", _track ? _track->id() : 0 );
  37. asprintf( &sa[i++], ":x %lu", _offset );
  38. asprintf( &sa[i++], ":y %.2f", _y );
  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, ":control" ) )
  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. }
  64. free( s );
  65. }
  66. free( sa );
  67. timeline->redraw();
  68. // _make_label();
  69. }
  70. Control_Point ( )
  71. {
  72. }
  73. public:
  74. /* for loggable */
  75. static Loggable *
  76. create ( char **sa )
  77. {
  78. Control_Point *r = new Control_Point;
  79. r->set( sa );
  80. return (Loggable *)r;
  81. }
  82. Control_Point ( Track *t, nframes_t when, float y )
  83. {
  84. _track = t;
  85. _y = y;
  86. _offset = when;
  87. // _make_label();
  88. log_create();
  89. }
  90. ~Control_Point ( )
  91. {
  92. // if ( _label ) delete[] _label;
  93. log_destroy();
  94. }
  95. float control ( void ) const { return _y; }
  96. void control ( float v ) { _y = v; }
  97. int
  98. handle ( int m )
  99. {
  100. int r = Track_Widget::handle( m );
  101. switch ( m )
  102. {
  103. case FL_RELEASE:
  104. _track->sort();
  105. redraw();
  106. break;
  107. case FL_DRAG:
  108. {
  109. int Y = Fl::event_y() - parent()->y();
  110. if ( Y >= 0 && Y < parent()->h() )
  111. {
  112. _y = (float)Y / parent()->h();
  113. redraw();
  114. }
  115. break;
  116. }
  117. }
  118. return r;
  119. }
  120. int x ( void ) const { return line_x(); }
  121. int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
  122. int w ( void ) const { return 6; }
  123. int h ( void ) const { return 6; }
  124. /* void */
  125. /* draw_box ( int X, int Y, int W, int H ) */
  126. /* { */
  127. /* } */
  128. void
  129. draw ( int X, int Y, int W, int H )
  130. {
  131. // fl_draw_box( box(), x(), y(), w(), h(), box_color() );
  132. return;
  133. }
  134. };