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, nframes_t frame, bool handle_events)
34 : editor (ed), _type(type)
36 double label_offset = 0;
37 bool annotate_left = false;
131 points = new ArdourCanvas::Points ();
133 points->push_back (Gnome::Art::Point (0.0, 0.0));
134 points->push_back (Gnome::Art::Point (6.0, 0.0));
135 points->push_back (Gnome::Art::Point (6.0, 5.0));
136 points->push_back (Gnome::Art::Point (3.0, 10.0));
137 points->push_back (Gnome::Art::Point (0.0, 5.0));
138 points->push_back (Gnome::Art::Point (0.0, 0.0));
147 points = new ArdourCanvas::Points ();
148 points->push_back (Gnome::Art::Point (3.0, 0.0));
149 points->push_back (Gnome::Art::Point (6.0, 5.0));
150 points->push_back (Gnome::Art::Point (6.0, 10.0));
151 points->push_back (Gnome::Art::Point (0.0, 10.0));
152 points->push_back (Gnome::Art::Point (0.0, 5.0));
153 points->push_back (Gnome::Art::Point (3.0, 0.0));
160 points = new ArdourCanvas::Points ();
161 points->push_back (Gnome::Art::Point (0.0, 0.0));
162 points->push_back (Gnome::Art::Point (6.5, 6.5));
163 points->push_back (Gnome::Art::Point (0.0, 13.0));
164 points->push_back (Gnome::Art::Point (0.0, 0.0));
171 points = new ArdourCanvas::Points ();
172 points->push_back (Gnome::Art::Point (6.5, 6.5));
173 points->push_back (Gnome::Art::Point (13.0, 0.0));
174 points->push_back (Gnome::Art::Point (13.0, 13.0));
175 points->push_back (Gnome::Art::Point (6.5, 6.5));
179 annotate_left = true;
183 points = new ArdourCanvas::Points ();
184 points->push_back (Gnome::Art::Point (0.0, 0.0));
185 points->push_back (Gnome::Art::Point (13.0, 13.0));
186 points->push_back (Gnome::Art::Point (0.0, 13.0));
187 points->push_back (Gnome::Art::Point (0.0, 0.0));
194 points = new ArdourCanvas::Points ();
195 points->push_back (Gnome::Art::Point (13.0, 0.0));
196 points->push_back (Gnome::Art::Point (13.0, 13.0));
197 points->push_back (Gnome::Art::Point (0.0, 13.0));
198 points->push_back (Gnome::Art::Point (13.0, 0.0));
202 annotate_left = true;
206 points = new ArdourCanvas::Points ();
207 points->push_back (Gnome::Art::Point (0.0, 0.0));
208 points->push_back (Gnome::Art::Point (13.0, 0.0));
209 points->push_back (Gnome::Art::Point (0.0, 13.0));
210 points->push_back (Gnome::Art::Point (0.0, 0.0));
217 points = new ArdourCanvas::Points ();
218 points->push_back (Gnome::Art::Point (0.0, 0.0));
219 points->push_back (Gnome::Art::Point (12.0, 0.0));
220 points->push_back (Gnome::Art::Point (12.0, 12.0));
221 points->push_back (Gnome::Art::Point (0.0, 0.0));
225 annotate_left = true;
230 frame_position = frame;
231 unit_position = editor.frame_to_unit (frame);
233 /* adjust to properly locate the tip */
235 unit_position -= shift;
237 group = new Group (parent, unit_position, 1.0);
239 mark = new Polygon (*group);
240 mark->property_points() = *points;
241 mark->property_fill_color_rgba() = rgba;
242 mark->property_outline_color_rgba() = rgba;
243 mark->property_width_pixels() = 1;
244 Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
246 text = new Text (*group);
247 text->property_text() = annotation.c_str();
248 text->property_font_desc() = font;
250 text->property_x() = -(text->property_text_width());
252 text->property_x() = label_offset;
254 text->property_y() = 0.0;
255 text->property_anchor() = Gtk::ANCHOR_NW;
256 text->property_fill_color() = "black";
258 editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
260 mark->set_data ("marker", this);
263 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
270 /* destroying the parent group destroys its contents, namely any polygons etc. that we added */
277 Marker::the_item() const
283 Marker::set_name (const string& name)
285 text->property_text() = name.c_str();
287 text->property_x() = -(text->property_text_width());
292 Marker::set_position (nframes_t frame)
294 double new_unit_position = editor.frame_to_unit (frame);
295 new_unit_position -= shift;
296 group->move (new_unit_position - unit_position, 0.0);
297 frame_position = frame;
298 unit_position = new_unit_position;
302 Marker::reposition ()
304 set_position (frame_position);
320 Marker::set_color_rgba (uint32_t color)
322 mark->property_fill_color_rgba() = color;
325 /***********************************************************************/
327 TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
328 ARDOUR::TempoSection& temp)
329 : Marker (editor, parent, rgba, text, Tempo, 0, false),
332 set_position (_tempo.frame());
333 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_tempo_marker_event), mark, this));
336 TempoMarker::~TempoMarker ()
340 /***********************************************************************/
342 MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
343 ARDOUR::MeterSection& m)
344 : Marker (editor, parent, rgba, text, Meter, 0, false),
347 set_position (_meter.frame());
348 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_meter_marker_event), mark, this));
351 MeterMarker::~MeterMarker ()