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"
27 #include "ardour_ui.h"
31 using namespace ARDOUR;
33 Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation,
34 Type type, nframes_t frame, bool handle_events)
36 : editor (ed), _parent(&parent), _type(type)
38 double label_offset = 0;
39 bool annotate_left = false;
133 points = new ArdourCanvas::Points ();
135 points->push_back (Gnome::Art::Point (0.0, 0.0));
136 points->push_back (Gnome::Art::Point (6.0, 0.0));
137 points->push_back (Gnome::Art::Point (6.0, 5.0));
138 points->push_back (Gnome::Art::Point (3.0, 10.0));
139 points->push_back (Gnome::Art::Point (0.0, 5.0));
140 points->push_back (Gnome::Art::Point (0.0, 0.0));
149 points = new ArdourCanvas::Points ();
150 points->push_back (Gnome::Art::Point (3.0, 0.0));
151 points->push_back (Gnome::Art::Point (6.0, 5.0));
152 points->push_back (Gnome::Art::Point (6.0, 10.0));
153 points->push_back (Gnome::Art::Point (0.0, 10.0));
154 points->push_back (Gnome::Art::Point (0.0, 5.0));
155 points->push_back (Gnome::Art::Point (3.0, 0.0));
162 points = new ArdourCanvas::Points ();
163 points->push_back (Gnome::Art::Point (0.0, 0.0));
164 points->push_back (Gnome::Art::Point (6.5, 6.5));
165 points->push_back (Gnome::Art::Point (0.0, 13.0));
166 points->push_back (Gnome::Art::Point (0.0, 0.0));
173 points = new ArdourCanvas::Points ();
174 points->push_back (Gnome::Art::Point (6.5, 6.5));
175 points->push_back (Gnome::Art::Point (13.0, 0.0));
176 points->push_back (Gnome::Art::Point (13.0, 13.0));
177 points->push_back (Gnome::Art::Point (6.5, 6.5));
181 annotate_left = true;
185 points = new ArdourCanvas::Points ();
186 points->push_back (Gnome::Art::Point (0.0, 0.0));
187 points->push_back (Gnome::Art::Point (13.0, 13.0));
188 points->push_back (Gnome::Art::Point (0.0, 13.0));
189 points->push_back (Gnome::Art::Point (0.0, 0.0));
196 points = new ArdourCanvas::Points ();
197 points->push_back (Gnome::Art::Point (13.0, 0.0));
198 points->push_back (Gnome::Art::Point (13.0, 13.0));
199 points->push_back (Gnome::Art::Point (0.0, 13.0));
200 points->push_back (Gnome::Art::Point (13.0, 0.0));
204 annotate_left = true;
208 points = new ArdourCanvas::Points ();
209 points->push_back (Gnome::Art::Point (0.0, 0.0));
210 points->push_back (Gnome::Art::Point (13.0, 0.0));
211 points->push_back (Gnome::Art::Point (0.0, 13.0));
212 points->push_back (Gnome::Art::Point (0.0, 0.0));
219 points = new ArdourCanvas::Points ();
220 points->push_back (Gnome::Art::Point (0.0, 0.0));
221 points->push_back (Gnome::Art::Point (12.0, 0.0));
222 points->push_back (Gnome::Art::Point (12.0, 12.0));
223 points->push_back (Gnome::Art::Point (0.0, 0.0));
227 annotate_left = true;
232 frame_position = frame;
233 unit_position = editor.frame_to_unit (frame);
235 /* adjust to properly locate the tip */
237 unit_position -= shift;
239 group = new Group (parent, unit_position, 1.0);
241 mark = new Polygon (*group);
242 mark->property_points() = *points;
243 mark->property_fill_color_rgba() = rgba;
244 mark->property_outline_color_rgba() = rgba;
245 mark->property_width_pixels() = 1;
246 Pango::FontDescription* font = get_font_for_style (N_("MarkerText"));
248 text = new Text (*group);
249 text->property_text() = annotation.c_str();
250 text->property_font_desc() = *font;
255 text->property_x() = -(text->property_text_width());
257 text->property_x() = label_offset;
259 text->property_y() = 0.0;
260 text->property_anchor() = Gtk::ANCHOR_NW;
261 text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerLabel.get();
263 editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
265 mark->set_data ("marker", this);
268 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
281 /* destroying the parent group destroys its contents, namely any polygons etc. that we added */
292 void Marker::reparent(ArdourCanvas::Group & parent)
294 group->reparent(parent);
299 Marker::set_line_length (double len)
302 line_points->back().set_y (len);
303 line->property_points() = *line_points;
308 Marker::add_line (ArdourCanvas::Group* group, double initial_height)
312 line_points = new ArdourCanvas::Points ();
313 line_points->push_back (Gnome::Art::Point (unit_position + shift, 0.0));
314 line_points->push_back (Gnome::Art::Point (unit_position + shift, initial_height));
316 line = new ArdourCanvas::Line (*group);
317 line->property_width_pixels() = 1;
318 line->property_points() = *line_points;
319 line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EditPoint.get();
321 line->property_first_arrowhead() = TRUE;
322 line->property_last_arrowhead() = TRUE;
323 line->property_arrow_shape_a() = 11.0;
324 line->property_arrow_shape_b() = 0.0;
325 line->property_arrow_shape_c() = 9.0;
327 line->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
337 line->raise_to_top();
351 Marker::the_item() const
357 Marker::set_name (const string& name)
359 text->property_text() = name.c_str();
361 text->property_x() = -(text->property_text_width());
366 Marker::set_position (nframes_t frame)
368 double new_unit_position = editor.frame_to_unit (frame);
369 new_unit_position -= shift;
370 group->move (new_unit_position - unit_position, 0.0);
371 frame_position = frame;
372 unit_position = new_unit_position;
375 (*line_points)[0].set_x (unit_position + shift);
376 (*line_points)[1].set_x (unit_position + shift);
377 line->property_points() = *line_points;
382 Marker::reposition ()
384 set_position (frame_position);
400 Marker::set_color_rgba (uint32_t color)
402 mark->property_fill_color_rgba() = color;
403 mark->property_outline_color_rgba() = color;
406 /***********************************************************************/
408 TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
409 ARDOUR::TempoSection& temp)
410 : Marker (editor, parent, rgba, text, Tempo, 0, false),
413 set_position (_tempo.frame());
414 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_tempo_marker_event), mark, this));
417 TempoMarker::~TempoMarker ()
421 /***********************************************************************/
423 MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
424 ARDOUR::MeterSection& m)
425 : Marker (editor, parent, rgba, text, Meter, 0, false),
428 set_position (_meter.frame());
429 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_meter_marker_event), mark, this));
432 MeterMarker::~MeterMarker ()