8a82a902711ad2f95d7a5a8d1baeb8fcd28a1839
[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 */
19
20 #ifndef __gtk_ardour_marker_h__
21 #define __gtk_ardour_marker_h__
22
23 #include <string>
24 #include <glib.h>
25 #include "ardour/ardour.h"
26 #include "pbd/destructible.h"
27
28 #include "canvas.h"
29
30 namespace ARDOUR {
31         class TempoSection;
32         class MeterSection;
33 }
34
35 class PublicEditor;
36
37 class Marker : public PBD::Destructible
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
53         Marker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, Type, 
54                 nframes_t frame = 0, bool handle_events = true);
55
56         virtual ~Marker ();
57
58         ArdourCanvas::Item& the_item() const;
59
60         void add_line (ArdourCanvas::Group*, double y_origin, double initial_height);
61         void show_line ();
62         void hide_line ();
63         void set_line_vpos (double y_origin, double height);
64
65         void set_position (nframes_t);
66         void set_name (const string&);
67         void set_color_rgba (uint32_t rgba);
68         
69         nframes64_t position() const { return frame_position; }
70
71         ArdourCanvas::Group * get_parent() { return _parent; }
72         void reparent (ArdourCanvas::Group & parent);
73         
74         void hide ();
75         void show ();
76
77         Type type () { return _type; }
78
79   protected:
80         PublicEditor& editor;
81
82         ArdourCanvas::Group * _parent;
83         ArdourCanvas::Group *group;
84         ArdourCanvas::Polygon *mark;
85         ArdourCanvas::Text *text;
86         ArdourCanvas::Points *points;
87         ArdourCanvas::SimpleLine *line;
88         ArdourCanvas::Points *line_points;
89
90         double        unit_position;
91         nframes64_t   frame_position;
92         unsigned char shift; /* should be double, but its always small and integral */
93         Type         _type;
94         
95         void reposition ();
96 };
97
98 class TempoMarker : public Marker
99 {
100   public:
101         TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, ARDOUR::TempoSection&);
102         ~TempoMarker ();
103
104         ARDOUR::TempoSection& tempo() const { return _tempo; }
105
106   private:
107         ARDOUR::TempoSection& _tempo;
108 };
109
110 class MeterMarker : public Marker
111 {
112   public:
113         MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, ARDOUR::MeterSection&);
114         ~MeterMarker ();
115
116         ARDOUR::MeterSection& meter() const { return _meter; }
117
118   private:
119         ARDOUR::MeterSection& _meter;
120 };
121
122 #endif /* __gtk_ardour_marker_h__ */