Fix update of range marker names. Fixes #3533.
[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 <libgnomecanvasmm/pixbuf.h>
27 #include <sigc++/signal.h>
28
29 #include "ardour/ardour.h"
30 #include "pbd/signals.h"
31
32 #include "canvas.h"
33
34 namespace ARDOUR {
35         class TempoSection;
36         class MeterSection;
37 }
38
39 class PublicEditor;
40
41 class Marker : public sigc::trackable
42 {
43   public:
44         enum Type {
45                 Mark,
46                 Tempo,
47                 Meter,
48                 SessionStart, ///< session start
49                 SessionEnd,   ///< session end
50                 RangeStart,
51                 RangeEnd,
52                 LoopStart,
53                 LoopEnd,
54                 PunchIn,
55                 PunchOut
56         };
57
58
59         Marker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, Type,
60                 nframes_t frame = 0, bool handle_events = true);
61
62         virtual ~Marker ();
63
64         static PBD::Signal1<void,Marker*> CatchDeletion;
65
66         ArdourCanvas::Item& the_item() const;
67
68         void set_selected (bool);
69         void set_show_line (bool);
70         void canvas_height_set (double);
71
72         void set_position (framepos_t);
73         void set_name (const std::string&);
74         void set_color_rgba (uint32_t rgba);
75         void setup_line ();
76
77         framepos_t position() const { return frame_position; }
78
79         ArdourCanvas::Group * get_parent() { return _parent; }
80         void reparent (ArdourCanvas::Group & parent);
81
82         void hide ();
83         void show ();
84
85         Type type () { return _type; }
86
87   protected:
88         PublicEditor& editor;
89
90         Pango::FontDescription* name_font;
91
92         ArdourCanvas::Group* _parent;
93         ArdourCanvas::Group* _line_parent;
94         ArdourCanvas::Group *group;
95         ArdourCanvas::Polygon *mark;
96         ArdourCanvas::Pixbuf *name_pixbuf;
97         ArdourCanvas::Points *points;
98         ArdourCanvas::SimpleLine* _line;
99         ArdourCanvas::Points *line_points;
100
101         double        unit_position;
102         framepos_t    frame_position;
103         double       _shift;
104         Type         _type;
105         int           name_height;
106         bool         _selected;
107         bool         _shown;
108         bool         _line_shown;
109         double       _canvas_height;
110         uint32_t     _color;
111
112         void reposition ();
113         void setup_line_x ();
114 };
115
116 class TempoMarker : public Marker
117 {
118   public:
119         TempoMarker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&);
120         ~TempoMarker ();
121
122         ARDOUR::TempoSection& tempo() const { return _tempo; }
123
124   private:
125         ARDOUR::TempoSection& _tempo;
126 };
127
128 class MeterMarker : public Marker
129 {
130   public:
131         MeterMarker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&);
132         ~MeterMarker ();
133
134         ARDOUR::MeterSection& meter() const { return _meter; }
135
136   private:
137         ARDOUR::MeterSection& _meter;
138 };
139
140 #endif /* __gtk_ardour_marker_h__ */