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"
28 #include "simpleline.h"
32 using namespace ARDOUR;
34 Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation,
35 Type type, nframes_t frame, bool handle_events)
37 : editor (ed), _parent(&parent), _type(type)
39 double label_offset = 0;
40 bool annotate_left = false;
134 points = new ArdourCanvas::Points ();
136 points->push_back (Gnome::Art::Point (0.0, 0.0));
137 points->push_back (Gnome::Art::Point (6.0, 0.0));
138 points->push_back (Gnome::Art::Point (6.0, 5.0));
139 points->push_back (Gnome::Art::Point (3.0, 10.0));
140 points->push_back (Gnome::Art::Point (0.0, 5.0));
141 points->push_back (Gnome::Art::Point (0.0, 0.0));
150 points = new ArdourCanvas::Points ();
151 points->push_back (Gnome::Art::Point (3.0, 0.0));
152 points->push_back (Gnome::Art::Point (6.0, 5.0));
153 points->push_back (Gnome::Art::Point (6.0, 10.0));
154 points->push_back (Gnome::Art::Point (0.0, 10.0));
155 points->push_back (Gnome::Art::Point (0.0, 5.0));
156 points->push_back (Gnome::Art::Point (3.0, 0.0));
163 points = new ArdourCanvas::Points ();
164 points->push_back (Gnome::Art::Point (0.0, 0.0));
165 points->push_back (Gnome::Art::Point (6.5, 6.5));
166 points->push_back (Gnome::Art::Point (0.0, 13.0));
167 points->push_back (Gnome::Art::Point (0.0, 0.0));
174 points = new ArdourCanvas::Points ();
175 points->push_back (Gnome::Art::Point (6.5, 6.5));
176 points->push_back (Gnome::Art::Point (13.0, 0.0));
177 points->push_back (Gnome::Art::Point (13.0, 13.0));
178 points->push_back (Gnome::Art::Point (6.5, 6.5));
182 annotate_left = true;
186 points = new ArdourCanvas::Points ();
187 points->push_back (Gnome::Art::Point (0.0, 0.0));
188 points->push_back (Gnome::Art::Point (13.0, 13.0));
189 points->push_back (Gnome::Art::Point (0.0, 13.0));
190 points->push_back (Gnome::Art::Point (0.0, 0.0));
197 points = new ArdourCanvas::Points ();
198 points->push_back (Gnome::Art::Point (13.0, 0.0));
199 points->push_back (Gnome::Art::Point (13.0, 13.0));
200 points->push_back (Gnome::Art::Point (0.0, 13.0));
201 points->push_back (Gnome::Art::Point (13.0, 0.0));
205 annotate_left = true;
209 points = new ArdourCanvas::Points ();
210 points->push_back (Gnome::Art::Point (0.0, 0.0));
211 points->push_back (Gnome::Art::Point (13.0, 0.0));
212 points->push_back (Gnome::Art::Point (0.0, 13.0));
213 points->push_back (Gnome::Art::Point (0.0, 0.0));
220 points = new ArdourCanvas::Points ();
221 points->push_back (Gnome::Art::Point (0.0, 0.0));
222 points->push_back (Gnome::Art::Point (12.0, 0.0));
223 points->push_back (Gnome::Art::Point (12.0, 12.0));
224 points->push_back (Gnome::Art::Point (0.0, 0.0));
228 annotate_left = true;
233 frame_position = frame;
234 unit_position = editor.frame_to_unit (frame);
236 /* adjust to properly locate the tip */
238 unit_position -= shift;
240 group = new Group (parent, unit_position, 1.0);
242 mark = new Polygon (*group);
243 mark->property_points() = *points;
244 mark->property_fill_color_rgba() = rgba;
245 mark->property_outline_color_rgba() = rgba;
246 mark->property_width_pixels() = 1;
247 Pango::FontDescription* font = get_font_for_style (N_("MarkerText"));
249 text = new Text (*group);
250 text->property_text() = annotation.c_str();
251 text->property_font_desc() = *font;
256 text->property_x() = -(text->property_text_width());
258 text->property_x() = label_offset;
260 text->property_y() = 0.0;
261 text->property_anchor() = Gtk::ANCHOR_NW;
262 text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerLabel.get();
264 editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
266 mark->set_data ("marker", this);
269 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);
300 Marker::set_line_vpos (double pos, double height)
303 line->property_y1() = pos;
304 line->property_y2() = pos + height;
309 Marker::add_line (ArdourCanvas::Group* group, double y_origin, double initial_height)
313 line = new ArdourCanvas::SimpleLine (*group);
314 line->property_color_rgba() = ARDOUR_UI::config()->canvasvar_EditPoint.get();
315 line->property_x1() = unit_position + shift;
316 line->property_y1() = y_origin;
317 line->property_x2() = unit_position + shift;
318 line->property_y2() = y_origin + initial_height;
320 line->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
330 line->raise_to_top();
344 Marker::the_item() const
350 Marker::set_name (const string& name)
352 text->property_text() = name.c_str();
354 text->property_x() = -(text->property_text_width());
359 Marker::set_position (nframes_t frame)
361 double new_unit_position = editor.frame_to_unit (frame);
362 new_unit_position -= shift;
363 group->move (new_unit_position - unit_position, 0.0);
364 frame_position = frame;
365 unit_position = new_unit_position;
368 line->property_x1() = unit_position + shift;
369 line->property_x2() = unit_position + shift;
374 Marker::reposition ()
376 set_position (frame_position);
392 Marker::set_color_rgba (uint32_t color)
394 mark->property_fill_color_rgba() = color;
395 mark->property_outline_color_rgba() = color;
398 /***********************************************************************/
400 TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
401 ARDOUR::TempoSection& temp)
402 : Marker (editor, parent, rgba, text, Tempo, 0, false),
405 set_position (_tempo.frame());
406 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_tempo_marker_event), mark, this));
409 TempoMarker::~TempoMarker ()
413 /***********************************************************************/
415 MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
416 ARDOUR::MeterSection& m)
417 : Marker (editor, parent, rgba, text, Meter, 0, false),
420 set_position (_meter.frame());
421 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_meter_marker_event), mark, this));
424 MeterMarker::~MeterMarker ()