Strip trailing whitespace and fix other whitespace errors (e.g. space/tab mixing...
[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
28 #include "ardour/ardour.h"
29 #include "pbd/destructible.h"
30
31 #include "canvas.h"
32
33 namespace ARDOUR {
34         class TempoSection;
35         class MeterSection;
36 }
37
38 class PublicEditor;
39
40 class Marker : public PBD::Destructible
41 {
42   public:
43         enum Type {
44                 Mark,
45                 Tempo,
46                 Meter,
47                 Start,
48                 End,
49                 LoopStart,
50                 LoopEnd,
51                 PunchIn,
52                 PunchOut
53         };
54
55
56         Marker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const std::string& text, Type,
57                 nframes_t frame = 0, bool handle_events = true);
58
59         virtual ~Marker ();
60
61         ArdourCanvas::Item& the_item() const;
62
63         void add_line (ArdourCanvas::Group*, double y_origin, double initial_height);
64         void show_line ();
65         void hide_line ();
66         void set_line_vpos (double y_origin, double height);
67
68         void set_position (nframes64_t);
69         void set_name (const std::string&);
70         void set_color_rgba (uint32_t rgba);
71
72         nframes64_t position() const { return frame_position; }
73
74         ArdourCanvas::Group * get_parent() { return _parent; }
75         void reparent (ArdourCanvas::Group & parent);
76
77         void hide ();
78         void show ();
79
80         Type type () { return _type; }
81
82   protected:
83         PublicEditor& editor;
84
85         Pango::FontDescription* name_font;
86
87         ArdourCanvas::Group * _parent;
88         ArdourCanvas::Group *group;
89         ArdourCanvas::Polygon *mark;
90         ArdourCanvas::Pixbuf *name_pixbuf;
91         ArdourCanvas::Points *points;
92         ArdourCanvas::SimpleLine *line;
93         ArdourCanvas::Points *line_points;
94
95         double        unit_position;
96         nframes64_t   frame_position;
97         unsigned char shift; /* should be double, but its always small and integral */
98         Type          _type;
99         int           name_height;
100
101         void reposition ();
102 };
103
104 class TempoMarker : public Marker
105 {
106   public:
107         TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const std::string& text, ARDOUR::TempoSection&);
108         ~TempoMarker ();
109
110         ARDOUR::TempoSection& tempo() const { return _tempo; }
111
112   private:
113         ARDOUR::TempoSection& _tempo;
114 };
115
116 class MeterMarker : public Marker
117 {
118   public:
119         MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const std::string& text, ARDOUR::MeterSection&);
120         ~MeterMarker ();
121
122         ARDOUR::MeterSection& meter() const { return _meter; }
123
124   private:
125         ARDOUR::MeterSection& _meter;
126 };
127
128 #endif /* __gtk_ardour_marker_h__ */