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.

162 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. int
  88. handle ( int m )
  89. {
  90. int r = Sequence_Widget::handle( m );
  91. switch ( m )
  92. {
  93. case FL_RELEASE:
  94. _track->sort();
  95. redraw();
  96. break;
  97. case FL_DRAG:
  98. {
  99. int Y = Fl::event_y() - parent()->y();
  100. if ( Y >= 0 && Y < parent()->h() )
  101. {
  102. _y = (float)Y / parent()->h();
  103. redraw();
  104. }
  105. track()->sort();
  106. break;
  107. }
  108. }
  109. return r;
  110. }
  111. int x ( void ) const { return line_x(); }
  112. int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
  113. int w ( void ) const { return 6; }
  114. int h ( void ) const { return 6; }
  115. /* void */
  116. /* draw_box ( int X, int Y, int W, int H ) */
  117. /* { */
  118. /* } */
  119. void
  120. draw ( int X, int Y, int W, int H )
  121. {
  122. // fl_draw_box( box(), x(), y(), w(), h(), box_color() );
  123. return;
  124. }
  125. };