Further fixes for #3529. Show marker lines the same colour as their marker; adjust...
[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                 Start, ///< session start
49                 End,   ///< session end
50                 LoopStart,
51                 LoopEnd,
52                 PunchIn,
53                 PunchOut
54         };
55
56
57         Marker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, Type,
58                 nframes_t frame = 0, bool handle_events = true);
59
60         virtual ~Marker ();
61
62         static PBD::Signal1<void,Marker*> CatchDeletion;
63
64         ArdourCanvas::Item& the_item() const;
65
66         void set_selected (bool);
67         void set_show_line (bool);
68         void canvas_height_set (double);
69
70         void set_position (framepos_t);
71         void set_name (const std::string&);
72         void set_color_rgba (uint32_t rgba);
73
74         framepos_t position() const { return frame_position; }
75
76         ArdourCanvas::Group * get_parent() { return _parent; }
77         void reparent (ArdourCanvas::Group & parent);
78
79         void hide ();
80         void show ();
81
82         Type type () { return _type; }
83
84   protected:
85         PublicEditor& editor;
86
87         Pango::FontDescription* name_font;
88
89         ArdourCanvas::Group* _parent;
90         ArdourCanvas::Group* _line_parent;
91         ArdourCanvas::Group *group;
92         ArdourCanvas::Polygon *mark;
93         ArdourCanvas::Pixbuf *name_pixbuf;
94         ArdourCanvas::Points *points;
95         ArdourCanvas::SimpleLine* _line;
96         ArdourCanvas::Points *line_points;
97
98         double        unit_position;
99         framepos_t    frame_position;
100         unsigned char shift; /* should be double, but its always small and integral */
101         Type         _type;
102         int           name_height;
103         bool         _selected;
104         bool         _shown;
105         double       _canvas_height;
106         uint32_t     _color;
107
108         void reposition ();
109         void setup_line ();
110 };
111
112 class TempoMarker : public Marker
113 {
114   public:
115         TempoMarker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&);
116         ~TempoMarker ();
117
118         ARDOUR::TempoSection& tempo() const { return _tempo; }
119
120   private:
121         ARDOUR::TempoSection& _tempo;
122 };
123
124 class MeterMarker : public Marker
125 {
126   public:
127         MeterMarker (PublicEditor& editor, ArdourCanvas::Group &, ArdourCanvas::Group &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&);
128         ~MeterMarker ();
129
130         ARDOUR::MeterSection& meter() const { return _meter; }
131
132   private:
133         ARDOUR::MeterSection& _meter;
134 };
135
136 #endif /* __gtk_ardour_marker_h__ */