2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
20 #include <FL/fl_draw.H>
22 #include "Control_Point.H"
26 Control_Point::Control_Point ( Sequence *t, nframes_t when, float y )
31 _box_color = FL_WHITE;
36 Control_Point::Control_Point ( const Control_Point &rhs ) : Sequence_Point( rhs )
44 Control_Point::get ( Log_Entry &e ) const
46 Sequence_Point::get( e );
52 Control_Point::set ( Log_Entry &e )
54 for ( int i = 0; i < e.size(); ++i )
60 if ( ! strcmp( s, ":y" ) )
68 Sequence_Point::set( e );
72 Control_Point::draw_box ( void )
76 fl_color( selection_color() );
77 fl_pie( x(), y(), w(), h(), 0, 360 );
80 fl_color( box_color() );
82 fl_arc( x(), y(), w(), h(), 0, 360 );
84 if ( this == Sequence_Widget::belowmouse() ||
85 this == Sequence_Widget::pushed() )
88 snprintf( val, sizeof( val ), "%+.2f", 1.0 - _y * 2 );
92 if ( x() < _sequence->x() + ( _sequence->w() / 2 ) )
97 if ( y() < _sequence->y() + ( _sequence->h() / 2 ) )
102 draw_label( val, a, FL_FOREGROUND_COLOR );
108 Control_Point::handle ( int m )
110 int r = Sequence_Widget::handle( m );
127 if ( nselected() > 1 )
128 // only allow horizontal movement when part of a selection...
131 int Y = Fl::event_y() - parent()->y();
133 if ( Y >= 0 && Y < parent()->h() )
135 _y = (float)Y / parent()->h();