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.
20 #include <sigc++/bind.h>
21 #include <ardour/tempo.h>
24 #include "public_editor.h"
26 #include "canvas_impl.h"
30 Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation,
31 Type type, nframes_t frame, bool handle_events)
33 : editor (ed), _type(type)
35 double label_offset = 0;
36 bool annotate_left = false;
130 points = new ArdourCanvas::Points ();
132 points->push_back (Gnome::Art::Point (0.0, 0.0));
133 points->push_back (Gnome::Art::Point (6.0, 0.0));
134 points->push_back (Gnome::Art::Point (6.0, 5.0));
135 points->push_back (Gnome::Art::Point (3.0, 10.0));
136 points->push_back (Gnome::Art::Point (0.0, 5.0));
137 points->push_back (Gnome::Art::Point (0.0, 0.0));
146 points = new ArdourCanvas::Points ();
147 points->push_back (Gnome::Art::Point (3.0, 0.0));
148 points->push_back (Gnome::Art::Point (6.0, 5.0));
149 points->push_back (Gnome::Art::Point (6.0, 10.0));
150 points->push_back (Gnome::Art::Point (0.0, 10.0));
151 points->push_back (Gnome::Art::Point (0.0, 5.0));
152 points->push_back (Gnome::Art::Point (3.0, 0.0));
159 points = new ArdourCanvas::Points ();
160 points->push_back (Gnome::Art::Point (0.0, 0.0));
161 points->push_back (Gnome::Art::Point (6.5, 6.5));
162 points->push_back (Gnome::Art::Point (0.0, 13.0));
163 points->push_back (Gnome::Art::Point (0.0, 0.0));
170 points = new ArdourCanvas::Points ();
171 points->push_back (Gnome::Art::Point (6.5, 6.5));
172 points->push_back (Gnome::Art::Point (13.0, 0.0));
173 points->push_back (Gnome::Art::Point (13.0, 13.0));
174 points->push_back (Gnome::Art::Point (6.5, 6.5));
178 annotate_left = true;
182 points = new ArdourCanvas::Points ();
183 points->push_back (Gnome::Art::Point (0.0, 0.0));
184 points->push_back (Gnome::Art::Point (13.0, 13.0));
185 points->push_back (Gnome::Art::Point (0.0, 13.0));
186 points->push_back (Gnome::Art::Point (0.0, 0.0));
193 points = new ArdourCanvas::Points ();
194 points->push_back (Gnome::Art::Point (13.0, 0.0));
195 points->push_back (Gnome::Art::Point (13.0, 13.0));
196 points->push_back (Gnome::Art::Point (0.0, 13.0));
197 points->push_back (Gnome::Art::Point (13.0, 0.0));
201 annotate_left = true;
205 points = new ArdourCanvas::Points ();
206 points->push_back (Gnome::Art::Point (0.0, 0.0));
207 points->push_back (Gnome::Art::Point (13.0, 0.0));
208 points->push_back (Gnome::Art::Point (0.0, 13.0));
209 points->push_back (Gnome::Art::Point (0.0, 0.0));
216 points = new ArdourCanvas::Points ();
217 points->push_back (Gnome::Art::Point (0.0, 0.0));
218 points->push_back (Gnome::Art::Point (12.0, 0.0));
219 points->push_back (Gnome::Art::Point (12.0, 12.0));
220 points->push_back (Gnome::Art::Point (0.0, 0.0));
224 annotate_left = true;
229 frame_position = frame;
230 unit_position = editor.frame_to_unit (frame);
232 /* adjust to properly locate the tip */
234 unit_position -= shift;
236 group = new Group (parent, unit_position, 1.0);
238 mark = new Polygon (*group);
239 mark->property_points() = *points;
240 mark->property_fill_color_rgba() = rgba;
241 mark->property_outline_color_rgba() = rgba;
242 mark->property_width_pixels() = 1;
243 Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
245 text = new Text (*group);
246 text->property_text() = annotation.c_str();
247 text->property_font_desc() = font;
249 text->property_x() = -(text->property_text_width());
251 text->property_x() = label_offset;
253 text->property_y() = 0.0;
254 text->property_anchor() = Gtk::ANCHOR_NW;
255 text->property_fill_color() = "black";
257 editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
259 mark->set_data ("marker", this);
262 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
269 /* destroying the parent group destroys its contents, namely any polygons etc. that we added */
276 Marker::the_item() const
282 Marker::set_name (const string& name)
284 text->property_text() = name.c_str();
286 text->property_x() = -(text->property_text_width());
291 Marker::set_position (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 ()