initial commit of hand merging, plus getting "ancient" waf script to work correctly
[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
26 #include <sigc++/signal.h>
27
28 #include "ardour/ardour.h"
29 #include "pbd/signals.h"
30 #include "canvas/types.h"
31
32 namespace ARDOUR {
33         class TempoSection;
34         class MeterSection;
35 }
36
37 namespace ArdourCanvas {
38         class Polygon;
39         class Line;
40         class Rectangle;
41         class Group;
42         class Pixbuf;
43         class Item;
44 }
45
46 class PublicEditor;
47
48 class Marker : public sigc::trackable
49 {
50   public:
51         enum Type {
52                 Mark,
53                 Tempo,
54                 Meter,
55                 SessionStart, ///< session start
56                 SessionEnd,   ///< session end
57                 RangeStart,
58                 RangeEnd,
59                 LoopStart,
60                 LoopEnd,
61                 PunchIn,
62                 PunchOut
63         };
64
65
66         Marker (PublicEditor& editor, ArdourCanvas::Group &, guint32 rgba, const std::string& text, Type,
67                 framepos_t frame = 0, bool handle_events = true);
68
69         virtual ~Marker ();
70
71         static PBD::Signal1<void,Marker*> CatchDeletion;
72
73         ArdourCanvas::Item& the_item() const;
74
75         void set_selected (bool);
76         void set_show_line (bool);
77         void canvas_height_set (double);
78
79         void set_position (framepos_t);
80         void set_name (const std::string&);
81         void set_color_rgba (uint32_t rgba);
82         void setup_line ();
83
84         framepos_t position() const { return frame_position; }
85
86         ArdourCanvas::Group * get_parent() { return _parent; }
87         void reparent (ArdourCanvas::Group & parent);
88
89         void hide ();
90         void show ();
91
92         Type type () { return _type; }
93
94         void set_left_label_limit (double);
95         void set_right_label_limit (double);
96
97         std::string name () const {
98                 return _name;
99         }
100
101         bool label_on_left () const;
102
103   protected:
104         PublicEditor& editor;
105
106         Pango::FontDescription name_font;
107
108         ArdourCanvas::Group* _parent;
109         ArdourCanvas::Group *group;
110         ArdourCanvas::Polygon *mark;
111         ArdourCanvas::Pixbuf *name_pixbuf;
112         ArdourCanvas::Points *points;
113         ArdourCanvas::Line* _line;
114         ArdourCanvas::Points *line_points;
115         ArdourCanvas::Rectangle* _name_background;
116
117         std::string  _name;
118         double        unit_position;
119         framepos_t    frame_position;
120         double       _shift;
121         Type         _type;
122         int           name_height;
123         bool         _selected;
124         bool         _shown;
125         bool         _line_shown;
126         double       _canvas_height;
127         uint32_t     _color;
128         double       _left_label_limit; ///< the number of pixels available to the left of this marker for a label
129         double       _right_label_limit; ///< the number of pixels available to the right of this marker for a label
130         double       _label_offset;
131
132         void reposition ();
133         void setup_line_x ();
134         void setup_name_display ();
135
136 private:
137         /* disallow copy construction */
138         Marker (Marker const &);
139         Marker & operator= (Marker const &);
140 };
141
142 class TempoMarker : public Marker
143 {
144   public:
145         TempoMarker (PublicEditor& editor, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&);
146         ~TempoMarker ();
147
148         ARDOUR::TempoSection& tempo() const { return _tempo; }
149
150   private:
151         ARDOUR::TempoSection& _tempo;
152 };
153
154 class MeterMarker : public Marker
155 {
156   public:
157         MeterMarker (PublicEditor& editor, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&);
158         ~MeterMarker ();
159
160         ARDOUR::MeterSection& meter() const { return _meter; }
161
162   private:
163         ARDOUR::MeterSection& _meter;
164 };
165
166 #endif /* __gtk_ardour_marker_h__ */