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 "Tempo_Point.H"
21 #include "Tempo_Sequence.H"
22 #include "Timeline.H" // for timeline->tempo_track
26 Tempo_Point::Tempo_Point ( )
28 timeline->tempo_track->add( this );
31 Tempo_Point::Tempo_Point ( nframes_t when, float bpm )
37 timeline->tempo_track->add( this );
44 Tempo_Point::~Tempo_Point ( )
46 timeline->tempo_track->remove( this );
53 Tempo_Point::get ( Log_Entry &e ) const
55 // Sequence_Point::get( e );
57 e.add( ":start", start() );
58 e.add( ":tempo", _tempo );
62 Tempo_Point::set ( Log_Entry &e )
65 Sequence_Point::set( e );
67 for ( int i = 0; i < e.size(); ++i )
73 if ( ! strcmp( s, ":tempo" ) )
76 /* /\* FIXME: we need to add this to the time track on creation!!! *\/ */
77 /* timeline->tempo_track->add( this ); */
81 sequence()->handle_widget_change( start(), length() );
87 Tempo_Point::log_children ( void ) const
93 Tempo_Point::handle ( int m )
97 if ( m == FL_PUSH && Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) ) )
105 return Sequence_Point::handle( m );
109 #include <FL/Fl_Float_Input.H>
110 #include <FL/Fl_Menu_Window.H>
113 class Tempo_Point_Editor : public Fl_Menu_Window
117 Tempo_Point_Editor ( const Tempo_Point_Editor &rhs );
118 Tempo_Point_Editor & operator = ( const Tempo_Point_Editor &rhs );
127 Tempo_Point_Editor ( float *tempo ) : Fl_Menu_Window( 75, 58, "Edit Tempo" )
134 Fl_Float_Input *fi = _fi = new Fl_Float_Input( 12, 0 + 24, 50, 24, "Tempo:" );
135 fi->align( FL_ALIGN_TOP );
136 fi->when( FL_WHEN_NOT_CHANGED | FL_WHEN_ENTER_KEY );
137 fi->callback( &Tempo_Point_Editor::enter_cb, (void*)this );
140 snprintf( pat, sizeof( pat ), "%.1f", *tempo );
153 enter_cb ( Fl_Widget *, void *v )
155 ((Tempo_Point_Editor*)v)->enter_cb();
161 sscanf( _fi->value(), "%f", _tempo );
175 Tempo_Point::edit ( float *tempo )
177 Tempo_Point_Editor ti( tempo );