Update NTK.
[nondaw.git] / timeline / src / Time_Point.H
blob5d513373b0ccd5c37278fa4ff7a46399630b1a73
2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles                                     */
4 /*                                                                             */
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.                                                  */
9 /*                                                                             */
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   */
13 /* more details.                                                               */
14 /*                                                                             */
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 /*******************************************************************************/
21 #pragma once
23 #include "Sequence_Point.H"
24 #include "Loggable.H"
26 struct time_sig
28     int beats_per_bar;
29     int beat_type;
31     time_sig ( ) : beats_per_bar( 0 ), beat_type( 0 )
32         {
33         }
35     time_sig ( int bpb, int note ) : beats_per_bar( bpb ), beat_type( note )
36         {
37         }
40 class Time_Point : public Sequence_Point
42     time_sig _time;
44     void
45     _make_label ( void )
46         {
47             if ( ! _label )
48                 _label = (char*)malloc( 40 );
50             snprintf( _label, 40, "%d/%d", _time.beats_per_bar, _time.beat_type );
51         }
54 protected:
56 //    const char *class_name ( void ) { return "Time_Point"; }
58     virtual void get ( Log_Entry &e ) const;
59     void set ( Log_Entry &e );
60     void log_children ( void ) const;
62     Time_Point ( );
64 public:
66     LOG_CREATE_FUNC( Time_Point );
67     SEQUENCE_WIDGET_CLONE_FUNC( Time_Point );
69     static bool edit ( time_sig *sig );
71     Time_Point ( nframes_t when, int bpb, int note );
72     Time_Point ( const Time_Point &rhs );
74     ~Time_Point ( );
76     void
77     time ( int bpb, int note )
78         {
79             _time.beats_per_bar = bpb; _time.beat_type = note;
80             _make_label();
81             redraw();
82         }
83     time_sig time ( void ) const { return _time; }
85     int handle ( int m );