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.

161 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 "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. void
  33. get ( Log_Entry &e )
  34. {
  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. }
  50. Control_Point ( )
  51. {
  52. }
  53. public:
  54. /* Sequence_Widget * */
  55. /* clone ( const Sequence_Widget *r ) */
  56. /* { */
  57. /* return new Control_Point( *(Control_Point*)r ); */
  58. /* } */
  59. /* for loggable */
  60. LOG_CREATE_FUNC( Control_Point );
  61. Control_Point ( Sequence *t, nframes_t when, float y )
  62. {
  63. _track = t;
  64. _y = y;
  65. _r->offset = when;
  66. // _make_label();
  67. log_create();
  68. }
  69. Control_Point ( const Control_Point &rhs )
  70. {
  71. _r->offset = rhs._r->offset;
  72. _y = rhs._y;
  73. }
  74. Sequence_Widget *clone ( const Sequence_Widget *r )
  75. {
  76. return new Control_Point( *(Control_Point*)r );
  77. }
  78. ~Control_Point ( )
  79. {
  80. // if ( _label ) delete[] _label;
  81. log_destroy();
  82. }
  83. float control ( void ) const { return _y; }
  84. void control ( float v ) { _y = v; }
  85. int
  86. handle ( int m )
  87. {
  88. int r = Sequence_Widget::handle( m );
  89. switch ( m )
  90. {
  91. case FL_RELEASE:
  92. _track->sort();
  93. redraw();
  94. break;
  95. case FL_DRAG:
  96. {
  97. int Y = Fl::event_y() - parent()->y();
  98. if ( Y >= 0 && Y < parent()->h() )
  99. {
  100. _y = (float)Y / parent()->h();
  101. redraw();
  102. }
  103. track()->sort();
  104. break;
  105. }
  106. }
  107. return r;
  108. }
  109. int x ( void ) const { return line_x(); }
  110. int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
  111. int w ( void ) const { return 6; }
  112. int h ( void ) const { return 6; }
  113. /* void */
  114. /* draw_box ( int X, int Y, int W, int H ) */
  115. /* { */
  116. /* } */
  117. void
  118. draw ( int X, int Y, int W, int H )
  119. {
  120. // fl_draw_box( box(), x(), y(), w(), h(), box_color() );
  121. return;
  122. }
  123. };