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.

133 lines
3.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. #include <FL/fl_draw.H>
  19. #include "Control_Point.H"
  20. Control_Point::Control_Point ( Sequence *t, nframes_t when, float y )
  21. {
  22. _sequence = t;
  23. _y = y;
  24. _r->start = when;
  25. _box_color = FL_WHITE;
  26. log_create();
  27. }
  28. Control_Point::Control_Point ( const Control_Point &rhs ) : Sequence_Point( rhs )
  29. {
  30. _y = rhs._y;
  31. log_create();
  32. }
  33. void
  34. Control_Point::get ( Log_Entry &e ) const
  35. {
  36. Sequence_Point::get( e );
  37. e.add( ":y", _y );
  38. }
  39. void
  40. Control_Point::set ( Log_Entry &e )
  41. {
  42. for ( int i = 0; i < e.size(); ++i )
  43. {
  44. const char *s, *v;
  45. e.get( i, &s, &v );
  46. if ( ! strcmp( s, ":y" ) )
  47. _y = atof( v );
  48. timeline->redraw();
  49. // _make_label();
  50. }
  51. Sequence_Point::set( e );
  52. }
  53. void
  54. Control_Point::draw_box ( void )
  55. {
  56. if ( selected() )
  57. {
  58. fl_color( selection_color() );
  59. fl_pie( x(), y(), w(), h(), 0, 360 );
  60. }
  61. fl_color( box_color() );
  62. fl_arc( x(), y(), w(), h(), 0, 360 );
  63. if ( this == Sequence_Widget::belowmouse() ||
  64. this == Sequence_Widget::pushed() )
  65. {
  66. char val[10];
  67. snprintf( val, sizeof( val ), "%+.2f", 1.0 - _y * 2 );
  68. draw_label( val, (Fl_Align)( FL_ALIGN_TOP | FL_ALIGN_LEFT ), FL_FOREGROUND_COLOR );
  69. }
  70. }
  71. int
  72. Control_Point::handle ( int m )
  73. {
  74. int r = Sequence_Widget::handle( m );
  75. switch ( m )
  76. {
  77. case FL_RELEASE:
  78. sequence()->sort();
  79. redraw();
  80. break;
  81. case FL_ENTER:
  82. case FL_LEAVE:
  83. redraw();
  84. break;
  85. case FL_DRAG:
  86. {
  87. sequence()->sort();
  88. if ( nselected() > 1 )
  89. // only allow horizontal movement when part of a selection...
  90. break;
  91. int Y = Fl::event_y() - parent()->y();
  92. if ( Y >= 0 && Y < parent()->h() )
  93. {
  94. _y = (float)Y / parent()->h();
  95. redraw();
  96. }
  97. break;
  98. }
  99. }
  100. return r;
  101. }