index edb9a8b459473939deaf365dc6eafc81e9733cf9..7343d6250c51a14e2a6049ef33c50df04307972a 100644 (file)
* an object involves going inside C but without entering S.)
* o Draw connectors to shape edges rather than bounding box.
* o Show a visual indicator for objects with the 'avoid' property set.
+ * o Allow user to change a object between a path and connector through
+ * the interface.
* o Create an interface for setting markers (arrow heads).
* o Better distinguish between paths and connectors to prevent problems
* in the node tool and paths accidently being turned into connectors
* in the connector tool. Perhaps have a way to convert between.
* o Only call libavoid's updateEndPoint as required. Currently we do it
* for both endpoints, even if only one is moving.
- * o Cleanup to remove unecessary borrowed DrawContext code.
* o Allow user-placeable connection points.
* o Deal sanely with connectors with both endpoints attached to the
* same connection point, and drawing of connectors attaching
#include "connector-context.h"
#include "pixmaps/cursor-connector.xpm"
+#include "pixmaps/cursor-connector.pixbuf"
#include "xml/node-event-vector.h"
#include "xml/repr.h"
#include "svg/svg.h"
#include "libavoid/vertices.h"
#include "context-fns.h"
#include "sp-namedview.h"
+#include "sp-text.h"
+#include "sp-flowtext.h"
+
static void sp_connector_context_class_init(SPConnectorContextClass *klass);
static void sp_connector_context_init(SPConnectorContext *conn_context);
SPEventContext *ec = SP_EVENT_CONTEXT(cc);
ec->cursor_shape = cursor_connector_xpm;
+ ec->cursor_pixbuf = gdk_pixbuf_new_from_inline(
+ -1,
+ cursor_connector_pixbuf,
+ FALSE,
+ NULL);
ec->hot_x = 1;
ec->hot_y = 1;
ec->xp = 0;
cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot)
{
g_assert (knot != NULL);
+
+ g_object_ref(knot);
SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(
knot->desktop->event_context);
switch (event->type) {
case GDK_ENTER_NOTIFY:
- gtk_object_set (GTK_OBJECT (knot->item), "fill_color",
- knot->fill [SP_KNOT_STATE_MOUSEOVER], NULL);
- gtk_object_set (GTK_OBJECT (knot->item), "stroke_color",
- knot->stroke [SP_KNOT_STATE_MOUSEOVER], NULL);
-
+ sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, TRUE);
+
cc->active_handle = knot;
if (knot->tip)
knot->desktop->event_context->defaultMessageContext()->set(
Inkscape::NORMAL_MESSAGE, knot->tip);
}
-
+
consumed = TRUE;
break;
case GDK_LEAVE_NOTIFY:
- gtk_object_set (GTK_OBJECT (knot->item), "fill_color",
- knot->fill [SP_KNOT_STATE_NORMAL], NULL);
- gtk_object_set (GTK_OBJECT (knot->item), "stroke_color",
- knot->stroke [SP_KNOT_STATE_NORMAL], NULL);
+ sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, FALSE);
cc->active_handle = NULL;
-
+
if (knot->tip) {
knot->desktop->event_context->defaultMessageContext()->clear();
}
-
+
consumed = TRUE;
break;
default:
break;
}
+
+ g_object_unref(knot);
return consumed;
}
// Set center connection point.
if ( cc->connpthandle == NULL ) {
- SPKnot * knot = (SPKnot*)g_object_new (SP_TYPE_KNOT, 0);
-
- knot->desktop = cc->desktop;
- knot->flags = SP_KNOT_VISIBLE;
+ SPKnot *knot = sp_knot_new(cc->desktop,
+ _("<b>Connection point</b>: click or drag to create a new connector"));
- knot->item = sp_canvas_item_new (sp_desktop_controls(cc->desktop),
- SP_TYPE_CTRL,
- "anchor", GTK_ANCHOR_CENTER,
- "filled", TRUE,
- "stroked", TRUE,
- "mode", SP_KNOT_MODE_XOR,
- NULL);
+ knot->setShape(SP_KNOT_SHAPE_SQUARE);
+ knot->setSize(8);
+ knot->setAnchor(GTK_ANCHOR_CENTER);
+ knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff);
+ sp_knot_update_ctrl(knot);
- gtk_signal_connect (GTK_OBJECT (knot->item), "event",
- GTK_SIGNAL_FUNC (cc_generic_knot_handler), knot);
+ // We don't want to use the standard knot handler,
+ //since we don't want this knot to be draggable.
+ g_signal_handler_disconnect(G_OBJECT(knot->item),
+ knot->_event_handler_id);
+ knot->_event_handler_id = 0;
- knot->fill [SP_KNOT_STATE_NORMAL] = 0xffffff00;
- knot->fill [SP_KNOT_STATE_MOUSEOVER] = 0xff0000ff;
- knot->stroke [SP_KNOT_STATE_NORMAL] = 0x01000000;
-
- g_object_set(G_OBJECT(knot),
- "shape", SP_KNOT_SHAPE_SQUARE,
- "size", 8,
- "anchor", GTK_ANCHOR_CENTER,
- "tip", _("<b>Connection point</b>: click or drag to create a new connector"),
- NULL);
+ gtk_signal_connect(GTK_OBJECT(knot->item), "event",
+ GTK_SIGNAL_FUNC(cc_generic_knot_handler), knot);
cc->connpthandle = knot;
}
// Create the handle if it doesn't exist
if ( cc->endpt_handle[i] == NULL ) {
- SPKnot * knot = (SPKnot*) g_object_new (SP_TYPE_KNOT, 0);
-
- knot->desktop = cc->desktop;
- knot->flags = SP_KNOT_VISIBLE;
-
- knot->item = sp_canvas_item_new (sp_desktop_controls (cc->desktop),
- SP_TYPE_CTRL,
- "anchor", GTK_ANCHOR_CENTER,
- "filled", TRUE,
- "stroked", TRUE,
- "mode", SP_KNOT_MODE_XOR,
- NULL);
+ SPKnot *knot = sp_knot_new(cc->desktop,
+ _("<b>Connector endpoint</b>: drag to reroute or connect to new shapes"));
- knot->fill [SP_KNOT_STATE_NORMAL] = 0xffffff00;
- knot->stroke [SP_KNOT_STATE_NORMAL] = 0x000000ff;
- knot->stroke [SP_KNOT_STATE_DRAGGING] = 0x000000ff;
- knot->stroke [SP_KNOT_STATE_MOUSEOVER] = 0x000000ff;
+ knot->setShape(SP_KNOT_SHAPE_SQUARE);
+ knot->setSize(7);
+ knot->setAnchor(GTK_ANCHOR_CENTER);
+ knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff);
+ knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
+ sp_knot_update_ctrl(knot);
- g_object_set(G_OBJECT(knot),
- "shape", SP_KNOT_SHAPE_DIAMOND,
- "size", 10,
- "tip", _("<b>Connector endpoint</b>: drag to reroute or connect to new shapes"),
- NULL);
+ // We don't want to use the standard knot handler,
+ //since we don't want this knot to be draggable.
+ g_signal_handler_disconnect(G_OBJECT(knot->item),
+ knot->_event_handler_id);
+ knot->_event_handler_id = 0;
- gtk_signal_connect (GTK_OBJECT (knot->item), "event",
- GTK_SIGNAL_FUNC (cc_generic_knot_handler), knot);
+ gtk_signal_connect(GTK_OBJECT(knot->item), "event",
+ GTK_SIGNAL_FUNC(cc_generic_knot_handler), knot);
cc->endpt_handle[i] = knot;
}
return false;
}
}
+ else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) {
+ if (prefs_get_int_attribute("tools.connector", "ignoretext", 1) == 1) {
+ // Don't count text as a shape we can connect connector to.
+ return false;
+ }
+ }
return true;
}