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.

117 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. #include <FL/fl_draw.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. }
  64. int
  65. Control_Point::handle ( int m )
  66. {
  67. int r = Sequence_Widget::handle( m );
  68. switch ( m )
  69. {
  70. case FL_RELEASE:
  71. sequence()->sort();
  72. redraw();
  73. break;
  74. case FL_DRAG:
  75. {
  76. sequence()->sort();
  77. if ( selected() )
  78. break;
  79. int Y = Fl::event_y() - parent()->y();
  80. if ( Y >= 0 && Y < parent()->h() )
  81. {
  82. _y = (float)Y / parent()->h();
  83. redraw();
  84. }
  85. break;
  86. }
  87. }
  88. return r;
  89. }