apply font-scale to overall layout (rulers, track-header) - fixes #6088
[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 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::Container &, guint32 rgba, const std::string& text, Type,
60                 framepos_t frame = 0, bool handle_events = true);
61
62         virtual ~Marker ();
63
64         static PBD::Signal1<void,Marker*> CatchDeletion;
65
66         static void setup_sizes (const double timebar_height);
67
68         ArdourCanvas::Item& the_item() const;
69
70         void set_selected (bool);
71         void set_show_line (bool);
72         void canvas_height_set (double);
73
74         void set_position (framepos_t);
75         void set_name (const std::string&);
76         void set_color_rgba (uint32_t rgba);
77         void setup_line ();
78
79         framepos_t position() const { return frame_position; }
80
81         ArdourCanvas::Container * get_parent() { return _parent; }
82         void reparent (ArdourCanvas::Container & parent);
83
84         void hide ();
85         void show ();
86
87         Type type () { return _type; }
88
89         void set_left_label_limit (double);
90         void set_right_label_limit (double);
91
92         std::string name () const {
93                 return _name;
94         }
95
96         bool label_on_left () const;
97
98   protected:
99         PublicEditor& editor;
100
101         Pango::FontDescription name_font;
102
103         ArdourCanvas::Container* _parent;
104         ArdourCanvas::Container *group;
105         ArdourCanvas::Polygon *mark;
106         ArdourCanvas::Text *_name_item;
107         ArdourCanvas::Points *points;
108         ArdourCanvas::Line* _track_canvas_line;
109         ArdourCanvas::Rectangle* _name_background;
110
111         std::string  _name;
112         double        unit_position;
113         framepos_t    frame_position;
114         double       _shift;
115         Type         _type;
116         int           name_height;
117         bool         _selected;
118         bool         _shown;
119         bool         _line_shown;
120         double       _canvas_height;
121         uint32_t     _color;
122         double       _left_label_limit; ///< the number of pixels available to the left of this marker for a label
123         double       _right_label_limit; ///< the number of pixels available to the right of this marker for a label
124         double       _label_offset;
125
126         void reposition ();
127         void setup_line_x ();
128         void setup_name_display ();
129
130 private:
131         /* disallow copy construction */
132         Marker (Marker const &);
133         Marker & operator= (Marker const &);
134 };
135
136 class TempoMarker : public Marker
137 {
138   public:
139         TempoMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&);
140         ~TempoMarker ();
141
142         ARDOUR::TempoSection& tempo() const { return _tempo; }
143
144   private:
145         ARDOUR::TempoSection& _tempo;
146 };
147
148 class MeterMarker : public Marker
149 {
150   public:
151         MeterMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&);
152         ~MeterMarker ();
153
154         ARDOUR::MeterSection& meter() const { return _meter; }
155
156   private:
157         ARDOUR::MeterSection& _meter;
158 };
159
160 #endif /* __gtk_ardour_marker_h__ */