Fly my pretties!
[ardour.git] / gtk2_ardour / marker.h
1 /*
2     Copyright (C) 2001 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #ifndef __gtk_ardour_marker_h__
22 #define __gtk_ardour_marker_h__
23
24 #include <string>
25 #include <glib.h>
26 #include <ardour/ardour.h>
27 #include <gtk-canvas.h>
28 #include <sigc++/signal.h>
29
30 namespace ARDOUR {
31         class TempoSection;
32         class MeterSection;
33 }
34
35 class PublicEditor;
36
37 class Marker : public sigc::trackable
38 {
39   public:
40         enum Type {
41                 Mark,
42                 Tempo,
43                 Meter,
44                 Start,
45                 End,
46                 LoopStart,
47                 LoopEnd,
48                 PunchIn,
49                 PunchOut
50         };
51
52         Marker (PublicEditor& editor, GtkCanvasGroup *parent, guint32 rgba, const string& text, Type, 
53                 gint (*callback)(GtkCanvasItem *, GdkEvent *, gpointer), jack_nframes_t frame = 0);
54         virtual ~Marker ();
55
56         void set_position (jack_nframes_t);
57         void set_name (const string&);
58         void set_color_rgba (uint32_t rgba);
59
60         void hide ();
61         void show ();
62
63         Type type () { return _type; }
64         
65   protected:
66         PublicEditor& editor;
67
68         GtkCanvasItem *group;
69         GtkCanvasItem *mark;
70         GtkCanvasItem *text;
71         GtkCanvasPoints *points;
72
73         double    unit_position;
74         jack_nframes_t frame_position;
75         unsigned char      shift; /* should be double, but its always small and integral */
76         Type      _type;
77         
78         void reposition ();
79 };
80
81 class TempoMarker : public Marker
82 {
83   public:
84         TempoMarker (PublicEditor& editor, GtkCanvasGroup *parent, guint32 rgba, const string& text, ARDOUR::TempoSection&, 
85                      gint (*callback)(GtkCanvasItem *, GdkEvent *, gpointer));
86         ~TempoMarker ();
87
88         ARDOUR::TempoSection& tempo() const { return _tempo; }
89
90   private:
91         ARDOUR::TempoSection& _tempo;
92 };
93
94 class MeterMarker : public Marker
95 {
96   public:
97         MeterMarker (PublicEditor& editor, GtkCanvasGroup *parent, guint32 rgba, const string& text, ARDOUR::MeterSection&, 
98                      gint (*callback)(GtkCanvasItem *, GdkEvent *, gpointer));
99         ~MeterMarker ();
100
101         ARDOUR::MeterSection& meter() const { return _meter; }
102
103   private:
104         ARDOUR::MeterSection& _meter;
105 };
106
107 #endif /* __gtk_ardour_marker_h__ */