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.

115 lines
2.9KB

  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 "Control_Point.H"
  19. Control_Point::Control_Point ( Sequence *t, nframes_t when, float y )
  20. {
  21. _sequence = t;
  22. _y = y;
  23. _r->start = when;
  24. _box_color = FL_WHITE;
  25. log_create();
  26. }
  27. Control_Point::Control_Point ( const Control_Point &rhs ) : Sequence_Point( rhs )
  28. {
  29. _y = rhs._y;
  30. log_create();
  31. }
  32. void
  33. Control_Point::get ( Log_Entry &e ) const
  34. {
  35. Sequence_Point::get( e );
  36. e.add( ":y", _y );
  37. }
  38. void
  39. Control_Point::set ( Log_Entry &e )
  40. {
  41. for ( int i = 0; i < e.size(); ++i )
  42. {
  43. const char *s, *v;
  44. e.get( i, &s, &v );
  45. if ( ! strcmp( s, ":y" ) )
  46. _y = atof( v );
  47. timeline->redraw();
  48. // _make_label();
  49. }
  50. Sequence_Point::set( e );
  51. }
  52. void
  53. Control_Point::draw_box ( void )
  54. {
  55. if ( selected() )
  56. {
  57. fl_color( selection_color() );
  58. fl_pie( x(), y(), w(), h(), 0, 360 );
  59. }
  60. fl_color( box_color() );
  61. fl_arc( x(), y(), w(), h(), 0, 360 );
  62. }
  63. int
  64. Control_Point::handle ( int m )
  65. {
  66. int r = Sequence_Widget::handle( m );
  67. switch ( m )
  68. {
  69. case FL_RELEASE:
  70. sequence()->sort();
  71. redraw();
  72. break;
  73. case FL_DRAG:
  74. {
  75. sequence()->sort();
  76. if ( selected() )
  77. break;
  78. int Y = Fl::event_y() - parent()->y();
  79. if ( Y >= 0 && Y < parent()->h() )
  80. {
  81. _y = (float)Y / parent()->h();
  82. redraw();
  83. }
  84. break;
  85. }
  86. }
  87. return r;
  88. }