fixes for destructive track offsets of various kinds; move from jack_nframes_t -...
[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     $Id$
19 */
20
21 #ifndef __gtk_ardour_marker_h__
22 #define __gtk_ardour_marker_h__
23
24 #include <string>
25 #include <glib.h>
26 #include <ardour/ardour.h>
27 #include <sigc++/signal.h>
28
29 #include "canvas.h"
30
31 namespace ARDOUR {
32         class TempoSection;
33         class MeterSection;
34 }
35
36 class PublicEditor;
37
38 class Marker : public sigc::trackable
39 {
40   public:
41         enum Type {
42                 Mark,
43                 Tempo,
44                 Meter,
45                 Start,
46                 End,
47                 LoopStart,
48                 LoopEnd,
49                 PunchIn,
50                 PunchOut
51         };
52
53
54         Marker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, Type, 
55                 nframes_t frame = 0, bool handle_events = true);
56
57         virtual ~Marker ();
58
59         ArdourCanvas::Item& the_item() const;
60
61         void set_position (nframes_t);
62         void set_name (const string&);
63         void set_color_rgba (uint32_t rgba);
64
65         void hide ();
66         void show ();
67
68         Type type () { return _type; }
69         
70   protected:
71         PublicEditor& editor;
72
73         ArdourCanvas::Group *group;
74         ArdourCanvas::Polygon *mark;
75         ArdourCanvas::Text *text;
76         ArdourCanvas::Points *points;
77
78         double    unit_position;
79         nframes_t frame_position;
80         unsigned char      shift; /* should be double, but its always small and integral */
81         Type      _type;
82         
83         void reposition ();
84 };
85
86 class TempoMarker : public Marker
87 {
88   public:
89         TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, ARDOUR::TempoSection&);
90         ~TempoMarker ();
91
92         ARDOUR::TempoSection& tempo() const { return _tempo; }
93
94   private:
95         ARDOUR::TempoSection& _tempo;
96 };
97
98 class MeterMarker : public Marker
99 {
100   public:
101         MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, ARDOUR::MeterSection&);
102         ~MeterMarker ();
103
104         ARDOUR::MeterSection& meter() const { return _meter; }
105
106   private:
107         ARDOUR::MeterSection& _meter;
108 };
109
110 #endif /* __gtk_ardour_marker_h__ */