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.4KB

  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 "Sequence_Point.H"
  20. class Control_Point : public Sequence_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. virtual void get ( Log_Entry &e ) const
  33. {
  34. Sequence_Point::get( e );
  35. e.add( ":y", _y );
  36. }
  37. void
  38. set ( Log_Entry &e )
  39. {
  40. for ( int i = 0; i < e.size(); ++i )
  41. {
  42. const char *s, *v;
  43. e.get( i, &s, &v );
  44. if ( ! strcmp( s, ":y" ) )
  45. _y = atof( v );
  46. timeline->redraw();
  47. // _make_label();
  48. }
  49. Sequence_Point::set( e );
  50. }
  51. Control_Point ( )
  52. {
  53. _box_color = FL_WHITE;
  54. }
  55. public:
  56. /* Sequence_Widget * */
  57. /* clone ( const Sequence_Widget *r ) */
  58. /* { */
  59. /* return new Control_Point( *(Control_Point*)r ); */
  60. /* } */
  61. /* for loggable */
  62. LOG_CREATE_FUNC( Control_Point );
  63. Control_Point ( Sequence *t, nframes_t when, float y )
  64. {
  65. _track = t;
  66. _y = y;
  67. _r->offset = when;
  68. _box_color = FL_WHITE;
  69. log_create();
  70. }
  71. Control_Point ( const Control_Point &rhs )
  72. {
  73. _r->offset = rhs._r->offset;
  74. _y = rhs._y;
  75. }
  76. Sequence_Widget *clone ( const Sequence_Widget *r )
  77. {
  78. return new Control_Point( *(Control_Point*)r );
  79. }
  80. ~Control_Point ( )
  81. {
  82. // if ( _label ) delete[] _label;
  83. log_destroy();
  84. }
  85. float control ( void ) const { return _y; }
  86. void control ( float v ) { _y = v; }
  87. /* only for playback thread */
  88. nframes_t when ( void ) const { return _range.offset; }
  89. int
  90. handle ( int m )
  91. {
  92. int r = Sequence_Widget::handle( m );
  93. switch ( m )
  94. {
  95. case FL_RELEASE:
  96. _track->sort();
  97. redraw();
  98. break;
  99. case FL_DRAG:
  100. {
  101. track()->sort();
  102. if ( selected() )
  103. break;
  104. int Y = Fl::event_y() - parent()->y();
  105. if ( Y >= 0 && Y < parent()->h() )
  106. {
  107. _y = (float)Y / parent()->h();
  108. redraw();
  109. }
  110. break;
  111. }
  112. }
  113. return r;
  114. }
  115. /* int x ( void ) const { return line_x(); } */
  116. int abs_w ( void ) const { return 6; }
  117. // int w ( void ) const { return 6; }
  118. int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
  119. int h ( void ) const { return 6; }
  120. void
  121. draw ( int X, int Y, int W, int H )
  122. {
  123. }
  124. };