-ControlPoint::ControlPoint (AutomationLine& al, gint (*event_handler)(GnomeCanvasItem*, GdkEvent*, gpointer))
- : line (al)
-{
- model = al.the_list().end();
- view_index = 0;
- can_slide = true;
- _x = 0;
- _y = 0;
- _shape = Full;
- _size = 4.0;
- selected = false;
-
- item = gnome_canvas_item_new (line.canvas_group(),
- gnome_canvas_simplerect_get_type(),
- "draw", (gboolean) TRUE,
- "fill", (gboolean) FALSE,
- "fill_color_rgba", color_map[cControlPointFill],
- "outline_color_rgba", color_map[cControlPointOutline],
- "outline_pixels", (gint) 1,
- NULL);
-
- gtk_object_set_data (GTK_OBJECT(item), "control_point", this);
- gtk_signal_connect (GTK_OBJECT(item), "event", (GtkSignalFunc) event_handler, this);
-
- hide ();
- set_visible (false);
-}
-
-ControlPoint::ControlPoint (const ControlPoint& other, bool dummy_arg_to_force_special_copy_constructor)
- : line (other.line)
-{
- if (&other == this) {
- return;
- }
-
- model = other.model;
- view_index = other.view_index;
- can_slide = other.can_slide;
- _x = other._x;
- _y = other._y;
- _shape = other._shape;
- _size = other._size;
- selected = false;
-
- item = gnome_canvas_item_new (line.canvas_group(),
- gnome_canvas_simplerect_get_type(),
- "fill", (gboolean) FALSE,
- "outline_color_rgba", color_map[cEnteredControlPointOutline],
- "outline_pixels", (gint) 1,
- NULL);
-
- /* NOTE: no event handling in copied ControlPoints */
-
- hide ();
- set_visible (false);
-}
-
-ControlPoint::~ControlPoint ()
-{
- gtk_object_destroy (GTK_OBJECT(item));
-}
-
-void
-ControlPoint::hide ()
-{
- gnome_canvas_item_hide (item);
-}
-
-void
-ControlPoint::show()
-{
- gnome_canvas_item_show (item);
-}
-
-void
-ControlPoint::set_visible (bool yn)
-{
- gnome_canvas_item_set (item, "draw", (gboolean) yn, NULL);
-}
-
-void
-ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t vi, ShapeType shape)
-{
- model = mi;
- view_index = vi;
- move_to (x, y, shape);
-}
-
-void
-ControlPoint::show_color (bool entered, bool hide_too)
-{
- if (entered) {
- if (selected) {
- gnome_canvas_item_set (item, "outline_color_rgba", color_map[cEnteredControlPointSelected], NULL);
- set_visible(true);
- } else {
- gnome_canvas_item_set (item, "outline_color_rgba", color_map[cEnteredControlPoint], NULL);
- if (hide_too) {
- set_visible(false);
- }
- }
-
- } else {
- if (selected) {
- gnome_canvas_item_set (item, "outline_color_rgba", color_map[cControlPointSelected], NULL);
- set_visible(true);
- } else {
- gnome_canvas_item_set (item, "outline_color_rgba", color_map[cControlPoint], NULL);
- if (hide_too) {
- set_visible(false);
- }
- }
- }
-}
-
-void
-ControlPoint::set_size (double sz)
-{
- _size = sz;
-
-#if 0
- if (_size > 6.0) {
- gnome_canvas_item_set (item,
- "fill", (gboolean) TRUE,
- NULL);
- } else {
- gnome_canvas_item_set (item,
- "fill", (gboolean) FALSE,
- NULL);
- }
-#endif
-
- move_to (_x, _y, _shape);
-}
-
-void
-ControlPoint::move_to (double x, double y, ShapeType shape)
-{
- double x1 = 0;
- double x2 = 0;
- double half_size = rint(_size/2.0);
-
- switch (shape) {
- case Full:
- x1 = x - half_size;
- x2 = x + half_size;
- break;
- case Start:
- x1 = x;
- x2 = x + half_size;
- break;
- case End:
- x1 = x - half_size;
- x2 = x;
- break;
- }
-
- gnome_canvas_item_set (item,
- "x1", x1,
- "x2", x2,
- "y1", y - half_size,
- "y2", y + half_size,
- NULL);
-
- _x = x;
- _y = y;
- _shape = shape;
-}
-
-/*****/
-
-AutomationLine::AutomationLine (string name, TimeAxisView& tv, GnomeCanvasItem* parent, AutomationList& al,
- gint (*point_handler)(GnomeCanvasItem*, GdkEvent*, gpointer),
- gint (*line_handler)(GnomeCanvasItem*, GdkEvent*, gpointer))