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.

166 lines
4.3KB

  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 ( nframes_t when, float y )
  83. {
  84. _y = y;
  85. _offset = when;
  86. // _make_label();
  87. log_create();
  88. }
  89. ~Control_Point ( )
  90. {
  91. // if ( _label ) delete[] _label;
  92. log_destroy();
  93. }
  94. float control ( void ) const { return _y; }
  95. void control ( float v ) { _y = v; }
  96. int
  97. handle ( int m )
  98. {
  99. int r = Track_Widget::handle( m );
  100. if ( m == FL_RELEASE )
  101. {
  102. _track->sort();
  103. timeline->redraw();
  104. }
  105. return r;
  106. }
  107. int
  108. y ( void ) const
  109. {
  110. return _track->y() + ((float)h() * _y);
  111. }
  112. void
  113. draw_box ( int X, int Y, int W, int H )
  114. {
  115. // Track_Widget::draw_box( x(), y(), w(), h() );
  116. }
  117. void
  118. draw ( int X, int Y, int W, int H )
  119. {
  120. fl_color( FL_RED );
  121. fl_draw_box( FL_UP_BOX, x(), y(), 6, 6, FL_RED );
  122. // fl_rectf( x(), y() + ry, 6, 6 );
  123. }
  124. };