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;
244 group->set_property ("x", unit_position);
245 group->set_property ("y", 1.0);
246 // cerr << "set mark al points, nc = " << points->num_points << endl;
247 mark = new Polygon (*group);
248 mark->set_property ("points", points);
249 mark->set_property ("fill_color_rgba", rgba);
250 mark->set_property ("outline_color", Gdk::Color ("black"));
252 Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
254 text = new Text (*group);
255 text->set_property ("text", annotation.c_str());
256 text->set_property ("x", label_offset);
257 text->set_property ("y", 0.0);
258 text->set_property ("fontdesc", font);
259 text->set_property ("anchor", Gtk::ANCHOR_NW);
260 text->set_property ("fill_color", Gdk::Color ("black"));
262 editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
264 mark->set_data ("marker", this);
267 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
274 /* destroying the parent group destroys its contents, namely any polygons etc. that we added */
281 Marker::the_item() const
287 Marker::set_name (const string& name)
289 text->set_property ("text", name.c_str());
293 Marker::set_position (jack_nframes_t frame)
295 double new_unit_position = editor.frame_to_unit (frame);
296 new_unit_position -= shift;
297 group->move (new_unit_position - unit_position, 0.0);
298 frame_position = frame;
299 unit_position = new_unit_position;
303 Marker::reposition ()
305 set_position (frame_position);
321 Marker::set_color_rgba (uint32_t color)
323 mark->set_property ("fill_color_rgba", color);
326 /***********************************************************************/
328 TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
329 ARDOUR::TempoSection& temp)
330 : Marker (editor, parent, rgba, text, Tempo, 0, false),
333 set_position (_tempo.frame());
334 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_tempo_marker_event), mark, this));
337 TempoMarker::~TempoMarker ()
341 /***********************************************************************/
343 MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
344 ARDOUR::MeterSection& m)
345 : Marker (editor, parent, rgba, text, Meter, 0, false),
348 set_position (_meter.frame());
349 group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_meter_marker_event), mark, this));
352 MeterMarker::~MeterMarker ()