2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ardour/tempo.h>
|
|
|
|
|
|
|
|
#include "marker.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "canvas-simpleline.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
Marker::Marker (PublicEditor& ed, GnomeCanvasGroup *parent, guint32 rgba, const string& annotation,
|
|
|
|
Type type, gint (*callback)(GnomeCanvasItem *, GdkEvent *, gpointer), jack_nframes_t frame)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
: editor (ed), _type(type)
|
|
|
|
{
|
|
|
|
double label_offset = 0;
|
|
|
|
|
|
|
|
/* Shapes we use:
|
|
|
|
|
|
|
|
Mark:
|
|
|
|
|
|
|
|
(0,0) -> (6,0)
|
|
|
|
^ |
|
|
|
|
| V
|
|
|
|
(0,5) (6,5)
|
|
|
|
\ /
|
|
|
|
(3,10)
|
|
|
|
|
|
|
|
|
|
|
|
TempoMark:
|
|
|
|
MeterMark:
|
|
|
|
|
|
|
|
(3,0)
|
|
|
|
/ \
|
|
|
|
(0,5) -> (6,5)
|
|
|
|
^ |
|
|
|
|
| V
|
|
|
|
(0,10)<-(6,10)
|
|
|
|
|
|
|
|
|
|
|
|
Start:
|
|
|
|
|
|
|
|
0,0 -> 5,0
|
|
|
|
| \
|
|
|
|
| 10,5
|
|
|
|
| /
|
|
|
|
0,10 -> 5,10
|
|
|
|
|
|
|
|
End:
|
|
|
|
|
|
|
|
5,0 -> 10,0
|
|
|
|
/ |
|
|
|
|
0,5 |
|
|
|
|
\ |
|
|
|
|
5,10 <-10,10
|
|
|
|
|
|
|
|
|
|
|
|
TransportStart:
|
|
|
|
|
|
|
|
0,0->3,0
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| 3,8 -> 7,8
|
|
|
|
| |
|
|
|
|
0,11 ------ 7,11
|
|
|
|
|
|
|
|
TransportEnd:
|
|
|
|
|
|
|
|
4,0->7,0
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
0,8 ---- 4,8 |
|
|
|
|
| |
|
|
|
|
0,11 -------- 7,11
|
|
|
|
|
|
|
|
|
|
|
|
PunchIn:
|
|
|
|
|
|
|
|
0,0 ------> 8,0
|
|
|
|
| /
|
|
|
|
| /
|
|
|
|
| 4,5
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
0,11->4,11
|
|
|
|
|
|
|
|
PunchOut
|
|
|
|
|
|
|
|
0,0 -->-8,0
|
|
|
|
\ |
|
|
|
|
\ |
|
|
|
|
4,5 |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
4,11->8,11
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case Mark:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 0.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 6.0;
|
|
|
|
points->coords[3] = 0.0;
|
|
|
|
|
|
|
|
points->coords[4] = 6.0;
|
|
|
|
points->coords[5] = 5.0;
|
|
|
|
|
|
|
|
points->coords[6] = 3.0;
|
|
|
|
points->coords[7] = 10.0;
|
|
|
|
|
|
|
|
points->coords[8] = 0.0;
|
|
|
|
points->coords[9] = 5.0;
|
|
|
|
|
|
|
|
points->coords[10] = 0.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
shift = 3;
|
|
|
|
label_offset = 8.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Tempo:
|
|
|
|
case Meter:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 3.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 6.0;
|
|
|
|
points->coords[3] = 5.0;
|
|
|
|
|
|
|
|
points->coords[4] = 6.0;
|
|
|
|
points->coords[5] = 10.0;
|
|
|
|
|
|
|
|
points->coords[6] = 0.0;
|
|
|
|
points->coords[7] = 10.0;
|
|
|
|
|
|
|
|
points->coords[8] = 0.0;
|
|
|
|
points->coords[9] = 5.0;
|
|
|
|
|
|
|
|
points->coords[10] = 3.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
shift = 3;
|
|
|
|
label_offset = 8.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Start:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 0.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 5.0;
|
|
|
|
points->coords[3] = 0.0;
|
|
|
|
|
|
|
|
points->coords[4] = 10.0;
|
|
|
|
points->coords[5] = 5.0;
|
|
|
|
|
|
|
|
points->coords[6] = 5.0;
|
|
|
|
points->coords[7] = 10.0;
|
|
|
|
|
|
|
|
points->coords[8] = 0.0;
|
|
|
|
points->coords[9] = 10.0;
|
|
|
|
|
|
|
|
points->coords[10] = 0.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
shift = 10;
|
|
|
|
label_offset = 12.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case End:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 5.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 10.0;
|
|
|
|
points->coords[3] = 0.0;
|
|
|
|
|
|
|
|
points->coords[4] = 10.0;
|
|
|
|
points->coords[5] = 10.0;
|
|
|
|
|
|
|
|
points->coords[6] = 5.0;
|
|
|
|
points->coords[7] = 10.0;
|
|
|
|
|
|
|
|
points->coords[8] = 0.0;
|
|
|
|
points->coords[9] = 5.0;
|
|
|
|
|
|
|
|
points->coords[10] = 5.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
shift = 0;
|
|
|
|
label_offset = 12.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LoopStart:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (7);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 0.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 4.0;
|
|
|
|
points->coords[3] = 0.0;
|
|
|
|
|
|
|
|
points->coords[4] = 4.0;
|
|
|
|
points->coords[5] = 8.0;
|
|
|
|
|
|
|
|
points->coords[6] = 8.0;
|
|
|
|
points->coords[7] = 8.0;
|
|
|
|
|
|
|
|
points->coords[8] = 8.0;
|
|
|
|
points->coords[9] = 11.0;
|
|
|
|
|
|
|
|
points->coords[10] = 0.0;
|
|
|
|
points->coords[11] = 11.0;
|
|
|
|
|
|
|
|
points->coords[12] = 0.0;
|
|
|
|
points->coords[13] = 0.0;
|
|
|
|
|
|
|
|
shift = 0;
|
|
|
|
label_offset = 11.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LoopEnd:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (7);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 8.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 8.0;
|
|
|
|
points->coords[3] = 11.0;
|
|
|
|
|
|
|
|
points->coords[4] = 0.0;
|
|
|
|
points->coords[5] = 11.0;
|
|
|
|
|
|
|
|
points->coords[6] = 0.0;
|
|
|
|
points->coords[7] = 8.0;
|
|
|
|
|
|
|
|
points->coords[8] = 4.0;
|
|
|
|
points->coords[9] = 8.0;
|
|
|
|
|
|
|
|
points->coords[10] = 4.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
points->coords[12] = 8.0;
|
|
|
|
points->coords[13] = 0.0;
|
|
|
|
|
|
|
|
shift = 8;
|
|
|
|
label_offset = 11.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PunchIn:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 0.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 8.0;
|
|
|
|
points->coords[3] = 0.0;
|
|
|
|
|
|
|
|
points->coords[4] = 4.0;
|
|
|
|
points->coords[5] = 4.0;
|
|
|
|
|
|
|
|
points->coords[6] = 4.0;
|
|
|
|
points->coords[7] = 11.0;
|
|
|
|
|
|
|
|
points->coords[8] = 0.0;
|
|
|
|
points->coords[9] = 11.0;
|
|
|
|
|
|
|
|
points->coords[10] = 0.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
shift = 0;
|
|
|
|
label_offset = 10.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PunchOut:
|
2005-09-25 18:26:56 -04:00
|
|
|
points = gnome_canvas_points_new (6);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
points->coords[0] = 0.0;
|
|
|
|
points->coords[1] = 0.0;
|
|
|
|
|
|
|
|
points->coords[2] = 8.0;
|
|
|
|
points->coords[3] = 0.0;
|
|
|
|
|
|
|
|
points->coords[4] = 8.0;
|
|
|
|
points->coords[5] = 11.0;
|
|
|
|
|
|
|
|
points->coords[6] = 4.0;
|
|
|
|
points->coords[7] = 11.0;
|
|
|
|
|
|
|
|
points->coords[8] = 4.0;
|
|
|
|
points->coords[9] = 4.0;
|
|
|
|
|
|
|
|
points->coords[10] = 0.0;
|
|
|
|
points->coords[11] = 0.0;
|
|
|
|
|
|
|
|
shift = 8;
|
|
|
|
label_offset = 11.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_position = frame;
|
|
|
|
unit_position = editor.frame_to_unit (frame);
|
|
|
|
|
|
|
|
/* adjust to properly locate the tip */
|
|
|
|
|
|
|
|
unit_position -= shift;
|
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
group = gnome_canvas_item_new (parent,
|
|
|
|
gnome_canvas_group_get_type(),
|
2005-09-25 14:42:24 -04:00
|
|
|
"x", unit_position,
|
|
|
|
"y", 1.0,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
// cerr << "set mark al points, nc = " << points->num_points << endl;
|
2005-09-25 18:26:56 -04:00
|
|
|
mark = gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
|
|
|
|
gnome_canvas_polygon_get_type(),
|
2005-09-25 14:42:24 -04:00
|
|
|
"points", points,
|
|
|
|
"fill_color_rgba", rgba,
|
|
|
|
"outline_color", "black",
|
|
|
|
NULL);
|
|
|
|
|
2005-10-09 08:51:04 -04:00
|
|
|
Pango::FontDescription font = get_font_for_style (N_("MarkerText"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
text = gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
|
2005-10-09 08:51:04 -04:00
|
|
|
gnome_canvas_text_get_type (),
|
|
|
|
"text", annotation.c_str(),
|
|
|
|
"x", label_offset,
|
|
|
|
"y", 0.0,
|
|
|
|
"fontdesc", font,
|
|
|
|
"anchor", GTK_ANCHOR_NW,
|
|
|
|
"fill_color", "black",
|
|
|
|
NULL);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
gtk_object_set_data (GTK_OBJECT(group), "marker", this);
|
|
|
|
gtk_signal_connect (GTK_OBJECT(group), "event", (GtkSignalFunc) callback, &editor);
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
editor.ZoomChanged.connect (mem_fun(*this, &Marker::reposition));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Marker::~Marker ()
|
|
|
|
{
|
|
|
|
/* destroying the group destroys its contents */
|
|
|
|
gtk_object_destroy (GTK_OBJECT(group));
|
2005-09-25 18:26:56 -04:00
|
|
|
gnome_canvas_points_unref (points);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Marker::set_name (const string& name)
|
|
|
|
{
|
2005-09-25 18:26:56 -04:00
|
|
|
gnome_canvas_item_set (text, "text", name.c_str(), NULL);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Marker::set_position (jack_nframes_t frame)
|
|
|
|
{
|
|
|
|
double new_unit_position = editor.frame_to_unit (frame);
|
|
|
|
new_unit_position -= shift;
|
2005-09-25 18:26:56 -04:00
|
|
|
gnome_canvas_item_move (group, new_unit_position - unit_position, 0.0);
|
2005-09-25 14:42:24 -04:00
|
|
|
frame_position = frame;
|
|
|
|
unit_position = new_unit_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Marker::reposition ()
|
|
|
|
{
|
|
|
|
set_position (frame_position);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Marker::show ()
|
|
|
|
{
|
2005-09-25 18:26:56 -04:00
|
|
|
gnome_canvas_item_show (group);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Marker::hide ()
|
|
|
|
{
|
2005-09-25 18:26:56 -04:00
|
|
|
gnome_canvas_item_hide (group);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Marker::set_color_rgba (uint32_t color)
|
|
|
|
{
|
2005-09-25 18:26:56 -04:00
|
|
|
gnome_canvas_item_set (mark, "fill_color_rgba", color, NULL);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
TempoMarker::TempoMarker (PublicEditor& editor, GnomeCanvasGroup *parent, guint32 rgba, const string& text,
|
2005-09-25 14:42:24 -04:00
|
|
|
ARDOUR::TempoSection& temp,
|
2005-09-25 18:26:56 -04:00
|
|
|
gint (*callback)(GnomeCanvasItem *, GdkEvent *, gpointer))
|
2005-09-25 14:42:24 -04:00
|
|
|
: Marker (editor, parent, rgba, text, Tempo, callback, 0),
|
|
|
|
_tempo (temp)
|
|
|
|
{
|
|
|
|
set_position (_tempo.frame());
|
|
|
|
gtk_object_set_data (GTK_OBJECT(group), "tempo_marker", this);
|
|
|
|
}
|
|
|
|
|
|
|
|
TempoMarker::~TempoMarker ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
MeterMarker::MeterMarker (PublicEditor& editor, GnomeCanvasGroup *parent, guint32 rgba, const string& text,
|
2005-09-25 14:42:24 -04:00
|
|
|
ARDOUR::MeterSection& m,
|
2005-09-25 18:26:56 -04:00
|
|
|
gint (*callback)(GnomeCanvasItem *, GdkEvent *, gpointer))
|
2005-09-25 14:42:24 -04:00
|
|
|
: Marker (editor, parent, rgba, text, Meter, callback, 0),
|
|
|
|
_meter (m)
|
|
|
|
{
|
|
|
|
set_position (_meter.frame());
|
|
|
|
gtk_object_set_data (GTK_OBJECT(group), "meter_marker", this);
|
|
|
|
}
|
|
|
|
|
|
|
|
MeterMarker::~MeterMarker ()
|
|
|
|
{
|
|
|
|
}
|