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, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation,
31 Type type, gint (*callback)(ArdourCanvas::Item *, GdkEvent *, gpointer), jack_nframes_t frame)
33 : editor (ed), _type(type)
35 double label_offset = 0;
125 points = new ArdourCanvas::Points ();
127 points->push_back (Gnome::Art::Point (0.0, 0.0));
128 points->push_back (Gnome::Art::Point (6.0, 0.0));
129 points->push_back (Gnome::Art::Point (6.0, 5.0));
130 points->push_back (Gnome::Art::Point (3.0, 10.0));
131 points->push_back (Gnome::Art::Point (0.0, 5.0));
132 points->push_back (Gnome::Art::Point (0.0, 0.0));
141 points = new ArdourCanvas::Points ();
142 points->push_back (Gnome::Art::Point (3.0, 0.0));
143 points->push_back (Gnome::Art::Point (6.0, 5.0));
144 points->push_back (Gnome::Art::Point (6.0, 10.0));
145 points->push_back (Gnome::Art::Point (0.0, 10.0));
146 points->push_back (Gnome::Art::Point (0.0, 5.0));
147 points->push_back (Gnome::Art::Point (3.0, 0.0));
154 points = new ArdourCanvas::Points ();
155 points->push_back (Gnome::Art::Point (0.0, 0.0));
156 points->push_back (Gnome::Art::Point (5.0, 0.0));
157 points->push_back (Gnome::Art::Point (10.0, 5.0));
158 points->push_back (Gnome::Art::Point (5.0, 10.0));
159 points->push_back (Gnome::Art::Point (0.0, 10.0));
160 points->push_back (Gnome::Art::Point (0.0, 0.0));
167 points = new ArdourCanvas::Points ();
168 points->push_back (Gnome::Art::Point (5.0, 0.0));
169 points->push_back (Gnome::Art::Point (10.0, 0.0));
170 points->push_back (Gnome::Art::Point (10.0, 10.0));
171 points->push_back (Gnome::Art::Point (5.0, 10.0));
172 points->push_back (Gnome::Art::Point (0.0, 5.0));
173 points->push_back (Gnome::Art::Point (5.0, 0.0));
180 points = new ArdourCanvas::Points ();
181 points->push_back (Gnome::Art::Point (0.0, 0.0));
182 points->push_back (Gnome::Art::Point (4.0, 0.0));
183 points->push_back (Gnome::Art::Point (4.0, 8.0));
184 points->push_back (Gnome::Art::Point (8.0, 8.0));
185 points->push_back (Gnome::Art::Point (8.0, 11.0));
186 points->push_back (Gnome::Art::Point (0.0, 11.0));
187 points->push_back (Gnome::Art::Point (0.0, 0.0));
194 points = new ArdourCanvas::Points ();
195 points->push_back (Gnome::Art::Point (8.0, 0.0));
196 points->push_back (Gnome::Art::Point (8.0, 11.0));
197 points->push_back (Gnome::Art::Point (0.0, 11.0));
198 points->push_back (Gnome::Art::Point (0.0, 8.0));
199 points->push_back (Gnome::Art::Point (4.0, 8.0));
200 points->push_back (Gnome::Art::Point (4.0, 0.0));
201 points->push_back (Gnome::Art::Point (8.0, 0.0));
208 points = new ArdourCanvas::Points ();
209 points->push_back (Gnome::Art::Point (0.0, 0.0));
210 points->push_back (Gnome::Art::Point (8.0, 0.0));
211 points->push_back (Gnome::Art::Point (4.0, 4.0));
212 points->push_back (Gnome::Art::Point (4.0, 11.0));
213 points->push_back (Gnome::Art::Point (0.0, 11.0));
214 points->push_back (Gnome::Art::Point (0.0, 0.0));
221 points = new ArdourCanvas::Points ();
222 points->push_back (Gnome::Art::Point (0.0, 0.0));
223 points->push_back (Gnome::Art::Point (8.0, 0.0));
224 points->push_back (Gnome::Art::Point (8.0, 11.0));
225 points->push_back (Gnome::Art::Point (4.0, 11.0));
226 points->push_back (Gnome::Art::Point (4.0, 4.0));
227 points->push_back (Gnome::Art::Point (0.0, 0.0));
235 frame_position = frame;
236 unit_position = editor.frame_to_unit (frame);
238 /* adjust to properly locate the tip */
240 unit_position -= shift;
243 group->set_property ("x", unit_position);
244 group->set_property ("y", 1.0);
245 // cerr << "set mark al points, nc = " << points->num_points << endl;
246 mark = new ArdourCanvas::Polygon (*group);
247 mark->set_property ("points", points);
248 mark->set_property ("fill_color_rgba", rgba);
249 mark->set_property ("outline_color", Gdk::Color ("black"));
251 Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
253 text = new ArdourCanvas::Text (*group);
254 text->set_property ("text", annotation.c_str());
255 text->set_property ("x", label_offset);
256 text->set_property ("y", 0.0);
257 text->set_property ("fontdesc", font);
258 text->set_property ("anchor", Gtk::ANCHOR_NW);
259 text->set_property ("fill_color", Gdk::Color ("black"));
261 group->signal_event().connect() (bind (mem_fun (editor, &PublicEditor::reposition), group, this));
266 /* destroying the group destroys its contents */
273 Marker::set_name (const string& name)
275 text->set_property ("text", name.c_str());
279 Marker::set_position (jack_nframes_t frame)
281 double new_unit_position = editor.frame_to_unit (frame);
282 new_unit_position -= shift;
283 group->move (new_unit_position - unit_position, 0.0);
284 frame_position = frame;
285 unit_position = new_unit_position;
289 Marker::reposition ()
291 set_position (frame_position);
307 Marker::set_color_rgba (uint32_t color)
309 mark->set_property ("fill_color_rgba", color);
312 /***********************************************************************/
314 TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
315 ARDOUR::TempoSection& temp,
316 gint (*callback)(ArdourCanvas::Item *, GdkEvent *, gpointer))
317 : Marker (editor, parent, rgba, text, Tempo, callback, 0),
320 set_position (_tempo.frame());
321 group->set_data ("tempo_marker", this);
324 TempoMarker::~TempoMarker ()
328 /***********************************************************************/
330 MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text,
331 ARDOUR::MeterSection& m,
332 gint (*callback)(ArdourCanvas::Item *, GdkEvent *, gpointer))
333 : Marker (editor, parent, rgba, text, Meter, callback, 0),
336 set_position (_meter.frame());
337 gtk_object_set_data (GTK_OBJECT(group), "meter_marker", this);
340 MeterMarker::~MeterMarker ()