Extend LV2UI-Request-Parameter File/Path GUI
[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
31 #include "canvas/fwd.h"
32 #include "canvas/types.h"
33
34 namespace ARDOUR {
35         class TempoSection;
36         class MeterSection;
37 }
38
39 class PublicEditor;
40
41 /** Location Marker
42  *
43  * Editor ruler representation of a location marker or range on the timeline.
44  */
45 class ArdourMarker : public sigc::trackable
46 {
47 public:
48         enum Type {
49                 Mark,
50                 Tempo,
51                 Meter,
52                 SessionStart, ///< session start
53                 SessionEnd,   ///< session end
54                 RangeStart,
55                 RangeEnd,
56                 LoopStart,
57                 LoopEnd,
58                 PunchIn,
59                 PunchOut
60         };
61
62
63         ArdourMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, Type,
64                       samplepos_t sample = 0, bool handle_events = true);
65
66         virtual ~ArdourMarker ();
67
68         static PBD::Signal1<void,ArdourMarker*> CatchDeletion;
69
70         static void setup_sizes (const double timebar_height);
71
72         ArdourCanvas::Item& the_item() const;
73
74         void set_selected (bool);
75         void set_show_line (bool);
76         void canvas_height_set (double);
77
78         void set_position (samplepos_t);
79         void set_name (const std::string&);
80         void set_points_color (uint32_t rgba);
81         void set_color_rgba (uint32_t rgba);
82         void setup_line ();
83
84         samplepos_t position() const { return sample_position; }
85
86         ArdourCanvas::Container * get_parent() { return _parent; }
87         void reparent (ArdourCanvas::Container & 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::Container* _parent;
109         ArdourCanvas::Container *group;
110         ArdourCanvas::Polygon *mark;
111         ArdourCanvas::Text *_name_item;
112         ArdourCanvas::Points *points;
113         ArdourCanvas::Line* _track_canvas_line;
114         ArdourCanvas::Rectangle* _name_background;
115
116         std::string  _name;
117         double        unit_position;
118         samplepos_t    sample_position;
119         double       _shift;
120         Type         _type;
121         int           name_height;
122         bool         _selected;
123         bool         _shown;
124         bool         _line_shown;
125         double       _canvas_height;
126         uint32_t     _color;
127         uint32_t     _points_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         ArdourMarker (ArdourMarker const &);
139         ArdourMarker & operator= (ArdourMarker const &);
140 };
141
142 class TempoMarker : public ArdourMarker
143 {
144   public:
145         TempoMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&);
146         ~TempoMarker ();
147
148         ARDOUR::TempoSection& tempo() const { return _tempo; }
149
150         void update_height_mark (const double ratio);
151   private:
152         ARDOUR::TempoSection& _tempo;
153 };
154
155 class MeterMarker : public ArdourMarker
156 {
157   public:
158         MeterMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&);
159         ~MeterMarker ();
160
161         ARDOUR::MeterSection& meter() const { return _meter; }
162
163   private:
164         ARDOUR::MeterSection& _meter;
165 };
166
167 #endif /* __gtk_ardour_marker_h__ */