some C++-ification of GnomeCanvasBlah
[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 <libgnomecanvasmm/libgnomecanvasmm.h>
28 #include <libgnomecanvasmm/polygon.h>
29 #include <sigc++/signal.h>
30
31 namespace ARDOUR {
32         class TempoSection;
33         class MeterSection;
34 }
35
36 class PublicEditor;
37
38 class Marker : public sigc::trackable
39 {
40   public:
41         enum Type {
42                 Mark,
43                 Tempo,
44                 Meter,
45                 Start,
46                 End,
47                 LoopStart,
48                 LoopEnd,
49                 PunchIn,
50                 PunchOut
51         };
52
53         Marker (PublicEditor& editor, Gnome::Canvas::Group& parent, guint32 rgba, const string& text, Type, 
54                 gint (*callback)(Gnome::Canvas::Item *, GdkEvent *, gpointer), jack_nframes_t frame = 0);
55         virtual ~Marker ();
56
57         void set_position (jack_nframes_t);
58         void set_name (const string&);
59         void set_color_rgba (uint32_t rgba);
60
61         void hide ();
62         void show ();
63
64         Type type () { return _type; }
65         
66   protected:
67         PublicEditor& editor;
68
69         Gnome::Canvas::Group *group;
70         Gnome::Canvas::Item *mark;
71         Gnome::Canvas::Text *text;
72         Gnome::Canvas::Points *points;
73
74         double    unit_position;
75         jack_nframes_t frame_position;
76         unsigned char      shift; /* should be double, but its always small and integral */
77         Type      _type;
78         
79         void reposition ();
80 };
81
82 class TempoMarker : public Marker
83 {
84   public:
85         TempoMarker (PublicEditor& editor, Gnome::Canvas::Group& parent, guint32 rgba, const string& text, ARDOUR::TempoSection&, 
86                      gint (*callback)(Gnome::Canvas::Item *, GdkEvent *, gpointer));
87         ~TempoMarker ();
88
89         ARDOUR::TempoSection& tempo() const { return _tempo; }
90
91   private:
92         ARDOUR::TempoSection& _tempo;
93 };
94
95 class MeterMarker : public Marker
96 {
97   public:
98         MeterMarker (PublicEditor& editor, Gnome::Canvas::Group& parent, guint32 rgba, const string& text, ARDOUR::MeterSection&, 
99                      gint (*callback)(Gnome::Canvas::Item *, GdkEvent *, gpointer));
100         ~MeterMarker ();
101
102         ARDOUR::MeterSection& meter() const { return _meter; }
103
104   private:
105         ARDOUR::MeterSection& _meter;
106 };
107
108 #endif /* __gtk_ardour_marker_h__ */