2 Copyright (C) 2001 Paul Davis
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.
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.
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.
21 #include <sigc++/bind.h>
22 #include <ardour/tempo.h>
25 #include "public_editor.h"
27 #include "canvas_impl.h"
31 Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation,
32 Type type, jack_nframes_t frame, bool handle_events)
34 : editor (ed), _type(type)
36 double label_offset = 0;
126 points = new ArdourCanvas::Points ();
128 points->push_back (Gnome::Art::Point (0.0, 0.0));
129 points->push_back (Gnome::Art::Point (6.0, 0.0));
130 points->push_back (Gnome::Art::Point (6.0, 5.0));
131 points->push_back (Gnome::Art::Point (3.0, 10.0));
132 points->push_back (Gnome::Art::Point (0.0, 5.0));
133 points->push_back (Gnome::Art::Point (0.0, 0.0));
142 points = new ArdourCanvas::Points ();
143 points->push_back (Gnome::Art::Point (3.0, 0.0));
144 points->push_back (Gnome::Art::Point (6.0, 5.0));
145 points->push_back (Gnome::Art::Point (6.0, 10.0));
146 points->push_back (Gnome::Art::Point (0.0, 10.0));
147 points->push_back (Gnome::Art::Point (0.0, 5.0));
148 points->push_back (Gnome::Art::Point (3.0, 0.0));
155 points = new ArdourCanvas::Points ();
156 points->push_back (Gnome::Art::Point (0.0, 0.0));
157 points->push_back (Gnome::Art::Point (5.0, 0.0));
158 points->push_back (Gnome::Art::Point (10.0, 5.0));
159 points->push_back (Gnome::Art::Point (5.0, 10.0));
160 points->push_back (Gnome::Art::Point (0.0, 10.0));
161 points->push_back (Gnome::Art::Point (0.0, 0.0));
168 points = new ArdourCanvas::Points ();
169 points->push_back (Gnome::Art::Point (5.0, 0.0));
170 points->push_back (Gnome::Art::Point (10.0, 0.0));
171 points->push_back (Gnome::Art::Point (10.0, 10.0));
172 points->push_back (Gnome::Art::Point (5.0, 10.0));
173 points->push_back (Gnome::Art::Point (0.0, 5.0));
174 points->push_back (Gnome::Art::Point (5.0, 0.0));
181 points = new ArdourCanvas::Points ();
182 points->push_back (Gnome::Art::Point (0.0, 0.0));
183 points->push_back (Gnome::Art::Point (4.0, 0.0));
184 points->push_back (Gnome::Art::Point (4.0, 8.0));
185 points->push_back (Gnome::Art::Point (8.0, 8.0));
186 points->push_back (Gnome::Art::Point (8.0, 11.0));
187 points->push_back (Gnome::Art::Point (0.0, 11.0));
188 points->push_back (Gnome::Art::Point (0.0, 0.0));
195 points = new ArdourCanvas::Points ();
196 points->push_back (Gnome::Art::Point (8.0, 0.0));
197 points->push_back (Gnome::Art::Point (8.0, 11.0));
198 points->push_back (Gnome::Art::Point (0.0, 11.0));
199 points->push_back (Gnome::Art::Point (0.0, 8.0));
200 points->push_back (Gnome::Art::Point (4.0, 8.0));
201 points->push_back (Gnome::Art::Point (4.0, 0.0));
202 points->push_back (Gnome::Art::Point (8.0, 0.0));
209 points = new ArdourCanvas::Points ();
210 points->push_back (Gnome::Art::Point (0.0, 0.0));
211 points->push_back (Gnome::Art::Point (8.0, 0.0));
212 points->push_back (Gnome::Art::Point (4.0, 4.0));
213 points->push_back (Gnome::Art::Point (4.0, 11.0));
214 points->push_back (Gnome::Art::Point (0.0, 11.0));
215 points->push_back (Gnome::Art::Point (0.0, 0.0));
222 points = new ArdourCanvas::Points ();
223 points->push_back (Gnome::Art::Point (0.0, 0.0));
224 points->push_back (Gnome::Art::Point (8.0, 0.0));
225 points->push_back (Gnome::Art::Point (8.0, 11.0));
226 points->push_back (Gnome::Art::Point (4.0, 11.0));
227 points->push_back (Gnome::Art::Point (4.0, 4.0));
228 points->push_back (Gnome::Art::Point (0.0, 0.0));
236 frame_position = frame;
237 unit_position = editor.frame_to_unit (frame);
239 /* adjust to properly locate the tip */
241 unit_position -= shift;
243 group = new Group (parent, unit_position, 1.0);
245 mark = new Polygon (*group);
246 mark->property_points() = *points;
247 mark->property_fill_color_rgba() = rgba;
248 mark->property_outline_color() = "black";
250 Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
252 text = new Text (*group);
253 text->property_text() = annotation.c_str();
254 text->property_x() = label_offset;
255 text->property_y() = 0.0;
256 text->property_font_desc() = font;
257 text->property_anchor() = Gtk::ANCHOR_NW;
258 text->property_fill_color() = "black";
260 editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
262 mark->set_data ("marker", this);
265 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
272 /* destroying the parent group destroys its contents, namely any polygons etc. that we added */
279 Marker::the_item() const
285 Marker::set_name (const string& name)
287 text->property_text() = name.c_str();
291 Marker::set_position (jack_nframes_t frame)
293 double new_unit_position = editor.frame_to_unit (frame);
294 new_unit_position -= shift;
295 group->move (new_unit_position - unit_position, 0.0);
296 frame_position = frame;
297 unit_position = new_unit_position;
301 Marker::reposition ()
303 set_position (frame_position);
319 Marker::set_color_rgba (uint32_t color)
321 mark->property_fill_color_rgba() = color;
324 /***********************************************************************/
326 TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
327 ARDOUR::TempoSection& temp)
328 : Marker (editor, parent, rgba, text, Tempo, 0, false),
331 set_position (_tempo.frame());
332 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_tempo_marker_event), mark, this));
335 TempoMarker::~TempoMarker ()
339 /***********************************************************************/
341 MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
342 ARDOUR::MeterSection& m)
343 : Marker (editor, parent, rgba, text, Meter, 0, false),
346 set_position (_meter.frame());
347 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_meter_marker_event), mark, this));
350 MeterMarker::~MeterMarker ()