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 <ardour/tempo.h>
24 #include "public_editor.h"
25 #include "canvas-simpleline.h"
30 Marker::Marker (PublicEditor& ed, Gnome::Canvas::Group& parent, guint32 rgba, const string& annotation,
31 Type type, gint (*callback)(Gnome::Canvas::Item *, GdkEvent *, gpointer), jack_nframes_t frame)
33 : editor (ed), _type(type)
35 double label_offset = 0;
125 points = new Gnome::Canvas::Points ();
127 points->push_back (Gnome::Art::Point (0.0, 0.0));
128 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));
133 points->push_back (Gnome::Art::Point (0.0, 5.0));
134 points->push_back (Gnome::Art::Point (0.0, 0.0));
143 points = new Gnome::Canvas::Points ();
144 points->push_back (Gnome::Art::Point (3.0, 0.0));
145 points->push_back (Gnome::Art::Point (6.0, 5.0));
147 points->push_back (Gnome::Art::Point (6.0, 10.0));
148 points->push_back (Gnome::Art::Point (0.0, 10.0));
149 points->push_back (Gnome::Art::Point (0.0, 5.0));
150 points->push_back (Gnome::Art::Point (3.0, 0.0));
157 points = new Gnome::Canvas::Points ();
158 points->push_back (Gnome::Art::Point (0.0, 0.0));
159 points->push_back (Gnome::Art::Point (5.0, 0.0));
160 points->push_back (Gnome::Art::Point (10.0, 5.0));
161 points->push_back (Gnome::Art::Point (5.0, 10.0));
162 points->push_back (Gnome::Art::Point (0.0, 10.0));
163 points->push_back (Gnome::Art::Point (0.0, 0.0));
170 points = new Gnome::Canvas::Points ();
171 points->push_back (Gnome::Art::Point (5.0, 0.0));
172 points->push_back (Gnome::Art::Point (10.0, 0.0));
173 points->push_back (Gnome::Art::Point (10.0, 10.0));
174 points->push_back (Gnome::Art::Point (5.0, 10.0));
175 points->push_back (Gnome::Art::Point (0.0, 5.0));
176 points->push_back (Gnome::Art::Point (5.0, 0.0));
183 points = new Gnome::Canvas::Points ();
184 points->push_back (Gnome::Art::Point (0.0, 0.0));
185 points->push_back (Gnome::Art::Point (4.0, 0.0));
186 points->push_back (Gnome::Art::Point (4.0, 8.0));
187 points->push_back (Gnome::Art::Point (8.0, 8.0));
188 points->push_back (Gnome::Art::Point (8.0, 11.0));
189 points->push_back (Gnome::Art::Point (0.0, 11.0));
190 points->push_back (Gnome::Art::Point (0.0, 0.0));
197 points = new Gnome::Canvas::Points ();
198 points->push_back (Gnome::Art::Point (8.0, 0.0));
199 points->push_back (Gnome::Art::Point (8.0, 11.0));
200 points->push_back (Gnome::Art::Point (0.0, 11.0));
201 points->push_back (Gnome::Art::Point (0.0, 8.0));
202 points->push_back (Gnome::Art::Point (4.0, 8.0));
203 points->push_back (Gnome::Art::Point (4.0, 0.0));
204 points->push_back (Gnome::Art::Point (8.0, 0.0));
211 points = new Gnome::Canvas::Points ();
212 points->push_back (Gnome::Art::Point (0.0, 0.0));
213 points->push_back (Gnome::Art::Point (8.0, 0.0));
214 points->push_back (Gnome::Art::Point (4.0, 4.0));
215 points->push_back (Gnome::Art::Point (4.0, 11.0));
216 points->push_back (Gnome::Art::Point (0.0, 11.0));
217 points->push_back (Gnome::Art::Point (0.0, 0.0));
224 points = new Gnome::Canvas::Points ();
225 points->push_back (Gnome::Art::Point (0.0, 0.0));
226 points->push_back (Gnome::Art::Point (8.0, 0.0));
227 points->push_back (Gnome::Art::Point (8.0, 11.0));
228 points->push_back (Gnome::Art::Point (4.0, 11.0));
229 points->push_back (Gnome::Art::Point (4.0, 4.0));
230 points->push_back (Gnome::Art::Point (0.0, 0.0));
238 frame_position = frame;
239 unit_position = editor.frame_to_unit (frame);
241 /* adjust to properly locate the tip */
243 unit_position -= shift;
246 group->set_property ("x", unit_position);
247 group->set_property ("y", 1.0);
248 // cerr << "set mark al points, nc = " << points->num_points << endl;
249 mark = new Gnome::Canvas::Polygon (*group);
250 mark->set_property ("points", points);
251 mark->set_property ("fill_color_rgba", rgba);
252 mark->set_property ("outline_color", Gdk::Color ("black"));
254 Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
256 text = new Gnome::Canvas::Text (*group);
257 text->set_property ("text", annotation.c_str());
258 text->set_property ("x", label_offset);
259 text->set_property ("y", 0.0);
260 text->set_property ("fontdesc", font);
261 text->set_property ("anchor", Gtk::ANCHOR_NW);
262 text->set_property ("fill_color", Gdk::Color ("black"));
264 group->set_data ("marker", this);
265 gtk_signal_connect (GTK_OBJECT(group), "event", (GtkSignalFunc) callback, &editor);
267 editor.ZoomChanged.connect (mem_fun(*this, &Marker::reposition));
272 /* destroying the group destroys its contents */
273 gtk_object_destroy (GTK_OBJECT(group));
274 gnome_canvas_points_unref (points->gobj());
278 Marker::set_name (const string& name)
280 text->set_property ("text", name.c_str());
284 Marker::set_position (jack_nframes_t frame)
286 double new_unit_position = editor.frame_to_unit (frame);
287 new_unit_position -= shift;
288 group->move (new_unit_position - unit_position, 0.0);
289 frame_position = frame;
290 unit_position = new_unit_position;
294 Marker::reposition ()
296 set_position (frame_position);
312 Marker::set_color_rgba (uint32_t color)
314 mark->set_property ("fill_color_rgba", color);
317 /***********************************************************************/
319 TempoMarker::TempoMarker (PublicEditor& editor, Gnome::Canvas::Group& parent, guint32 rgba, const string& text,
320 ARDOUR::TempoSection& temp,
321 gint (*callback)(Gnome::Canvas::Item *, GdkEvent *, gpointer))
322 : Marker (editor, parent, rgba, text, Tempo, callback, 0),
325 set_position (_tempo.frame());
326 group->set_data ("tempo_marker", this);
329 TempoMarker::~TempoMarker ()
333 /***********************************************************************/
335 MeterMarker::MeterMarker (PublicEditor& editor, Gnome::Canvas::Group& parent, guint32 rgba, const string& text,
336 ARDOUR::MeterSection& m,
337 gint (*callback)(Gnome::Canvas::Item *, GdkEvent *, gpointer))
338 : Marker (editor, parent, rgba, text, Meter, callback, 0),
341 set_position (_meter.frame());
342 gtk_object_set_data (GTK_OBJECT(group), "meter_marker", this);
345 MeterMarker::~MeterMarker ()