From c4aa590bedcf358acf15bdf0d8134ae99e3be167 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 23 Jan 2010 14:36:56 +0100 Subject: Remove redundancy from snapping API (type of snapsource no longer has to be specified explicitly) (bzr r9014) --- src/connector-context.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 0fc9de9d0..bfdef1032 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -774,7 +774,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const if (!cc->sid) { // This is the first point, so just snap it to the grid // as there's no other points to go off. - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); } spcc_connector_set_initial_point(cc, p); @@ -786,7 +786,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const case SP_CONNECTOR_CONTEXT_DRAGGING: { // This is the second click of a connector creation. - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); spcc_connector_set_subsequent_point(cc, p); spcc_connector_finish_segment(cc, p); @@ -934,8 +934,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons gobble_motion_events(mevent.state); // This is movement during a connector creation. if ( cc->npoints > 0 ) { - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, - Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); cc->selection->clear(); spcc_connector_set_subsequent_point(cc, p); ret = TRUE; @@ -947,8 +946,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons gobble_motion_events(GDK_BUTTON1_MASK); g_assert( SP_IS_PATH(cc->clickeditem)); - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, - Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); // Update the hidden path Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); @@ -1023,7 +1021,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con //case SP_CONNECTOR_CONTEXT_POINT: case SP_CONNECTOR_CONTEXT_DRAGGING: { - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); if (cc->within_tolerance) { @@ -1044,7 +1042,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con } case SP_CONNECTOR_CONTEXT_REROUTING: { - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); cc_connector_rerouting_finish(cc, &p); sp_document_ensure_up_to_date(doc); @@ -1068,7 +1066,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con if (!cc->within_tolerance) { - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; cp.pos = p * sp_item_dt2i_affine(cc->active_shape); @@ -1081,7 +1079,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); @@ -1184,7 +1182,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) if (!cc->within_tolerance) { - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; cp.pos = p * sp_item_dt2i_affine(cc->active_shape); @@ -1212,7 +1210,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) m.setup(desktop); Geom::Point p = cc->selected_handle->pos; - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); -- cgit v1.2.3 From e52fb9fac3f1bbd924c0ca3b6b5e214a095d44af Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 30 Jan 2010 23:04:33 +0100 Subject: Finally introducing the pre-snap indicator (bzr r9034) --- src/connector-context.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index bfdef1032..294e129b3 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -976,6 +976,9 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons /* This is perfectly valid */ break; default: + if (sp_event_context_knot_mouseover(cc)) { + m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); + } break; } } -- cgit v1.2.3 From 195208c56145d9b9673aff0bb2f8795f5bc6fe22 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 6 Feb 2010 15:59:28 +0100 Subject: Tiny bit of refactoring (inverting some logic) (bzr r9059) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 294e129b3..b61c00df6 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -976,7 +976,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons /* This is perfectly valid */ break; default: - if (sp_event_context_knot_mouseover(cc)) { + if (!sp_event_context_knot_mouseover(cc)) { m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); } break; -- cgit v1.2.3 From a78a295c3c2df3ee1ff480302a2c2bbb4d39c4b4 Mon Sep 17 00:00:00 2001 From: "Arcadie M. Cracan" Date: Sun, 21 Feb 2010 12:40:13 +0200 Subject: Disabled unfinished connection point edit mode. Added inkscape:connection-start-point, inkscape:connection-end-point attributes for connector endpoints. This corrects the previous approach making drawings created in 0.48 version compatible with earlier versions (new attributes are silently ignored). (bzr r9103.1.1) --- src/connector-context.cpp | 76 +++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 26 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index b61c00df6..eed03385c 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -218,7 +218,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item); static void cc_clear_active_shape(SPConnectorContext *cc); static void cc_set_active_conn(SPConnectorContext *cc, SPItem *item); static void cc_clear_active_conn(SPConnectorContext *cc); -static gchar *conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& w); +static bool conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href, gchar **cpid); static void cc_select_handle(SPKnot* knot); static void cc_deselect_handle(SPKnot* knot); static bool cc_item_is_shape(SPItem *item); @@ -338,8 +338,10 @@ sp_connector_context_init(SPConnectorContext *cc) cc->endpt_handle[i] = NULL; cc->endpt_handler_id[i] = 0; } - cc->sid = NULL; - cc->eid = NULL; + cc->shref = NULL; + cc->scpid = NULL; + cc->ehref = NULL; + cc->ecpid = NULL; cc->npoints = 0; cc->state = SP_CONNECTOR_CONTEXT_IDLE; } @@ -366,13 +368,21 @@ sp_connector_context_dispose(GObject *object) cc->endpt_handle[i] = NULL; } } - if (cc->sid) { - g_free(cc->sid); - cc->sid = NULL; + if (cc->shref) { + g_free(cc->shref); + cc->shref = NULL; } - if (cc->eid) { - g_free(cc->eid); - cc->eid = NULL; + if (cc->scpid) { + g_free(cc->scpid); + cc->scpid = NULL; + } + if (cc->ehref) { + g_free(cc->shref); + cc->shref = NULL; + } + if (cc->ecpid) { + g_free(cc->scpid); + cc->scpid = NULL; } g_assert( cc->newConnRef == NULL ); @@ -570,8 +580,8 @@ cc_clear_active_conn(SPConnectorContext *cc) } -static gchar * -conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p) +static bool +conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href, gchar **cpid) { // TODO: this will need to change when there are more connection // points available for each shape. @@ -580,10 +590,13 @@ conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p) { p = cc->active_handle->pos; const ConnectionPoint& cp = cc->connpthandles[cc->active_handle]; - return g_strdup_printf("#%s_%c_%d", SP_OBJECT_ID(cc->active_shape), - cp.type == ConnPointDefault ? 'd' : 'u' , cp.id); + *href = g_strdup_printf("#%s", SP_OBJECT_ID(cc->active_shape)); + *cpid = g_strdup_printf("%c%d", cp.type == ConnPointDefault ? 'd' : 'u' , cp.id); + return true; } - return NULL; + *href = NULL; + *cpid = NULL; + return false; } static void @@ -769,9 +782,9 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const Geom::Point p = event_dt; // Test whether we clicked on a connection point - cc->sid = conn_pt_handle_test(cc, p); + bool found = conn_pt_handle_test(cc, p, &cc->shref, &cc->scpid); - if (!cc->sid) { + if (!found) { // This is the first point, so just snap it to the grid // as there's no other points to go off. m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); @@ -791,7 +804,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const spcc_connector_set_subsequent_point(cc, p); spcc_connector_finish_segment(cc, p); // Test whether we clicked on a connection point - cc->eid = conn_pt_handle_test(cc, p); + /*bool found = */conn_pt_handle_test(cc, p, &cc->ehref, &cc->ecpid); if (cc->npoints != 0) { spcc_connector_finish(cc); } @@ -1035,7 +1048,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con spcc_connector_set_subsequent_point(cc, p); spcc_connector_finish_segment(cc, p); // Test whether we clicked on a connection point - cc->eid = conn_pt_handle_test(cc, p); + /*bool found = */conn_pt_handle_test(cc, p, &cc->ehref, &cc->ecpid); if (cc->npoints != 0) { spcc_connector_finish(cc); } @@ -1265,16 +1278,21 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p if (p != NULL) { // Test whether we clicked on a connection point - gchar *shape_label = conn_pt_handle_test(cc, *p); + gchar *shape_label, *cpid; + bool found = conn_pt_handle_test(cc, *p, &shape_label, &cpid); - if (shape_label) { + if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { sp_object_setAttribute(cc->clickeditem, - "inkscape:connection-start",shape_label, false); + "inkscape:connection-start", shape_label, false); + sp_object_setAttribute(cc->clickeditem, + "inkscape:connection-start-point", cpid, false); } else { sp_object_setAttribute(cc->clickeditem, - "inkscape:connection-end",shape_label, false); + "inkscape:connection-end", shape_label, false); + sp_object_setAttribute(cc->clickeditem, + "inkscape:connection-end-point", cpid, false); } g_free(shape_label); } @@ -1417,17 +1435,23 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) cc->isOrthogonal ? "orthogonal" : "polyline", false); sp_object_setAttribute(cc->newconn, "inkscape:connector-curvature", Glib::Ascii::dtostr(cc->curvature).c_str(), false); - if (cc->sid) + if (cc->shref) { sp_object_setAttribute(cc->newconn, "inkscape:connection-start", - cc->sid, false); + cc->shref, false); + if (cc->scpid) + sp_object_setAttribute(cc->newconn, "inkscape:connection-start-point", + cc->scpid, false); connection = true; } - if (cc->eid) + if (cc->ehref) { sp_object_setAttribute(cc->newconn, "inkscape:connection-end", - cc->eid, false); + cc->ehref, false); + if (cc->ecpid) + sp_object_setAttribute(cc->newconn, "inkscape:connection-end-point", + cc->ecpid, false); connection = true; } // Process pending updates. -- cgit v1.2.3 From fd703018ee505f643f866aa4e0cc3f1bebf7aa7d Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 1 Mar 2010 22:10:16 -0800 Subject: Cleanup on id access. (bzr r9127) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index eed03385c..ba6c067c0 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -590,7 +590,7 @@ conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href, gchar { p = cc->active_handle->pos; const ConnectionPoint& cp = cc->connpthandles[cc->active_handle]; - *href = g_strdup_printf("#%s", SP_OBJECT_ID(cc->active_shape)); + *href = g_strdup_printf("#%s", cc->active_shape->getId()); *cpid = g_strdup_printf("%c%d", cp.type == ConnPointDefault ? 'd' : 'u' , cp.id); return true; } -- cgit v1.2.3 From 847b4f57816ba691e471cf891beca6d263438f03 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 18 Mar 2010 23:21:16 -0700 Subject: Cleanup of SP_ACTIVE_DESKTOP to prepare clipboard code for reuse. (bzr r9209) --- src/connector-context.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index ba6c067c0..b0e192190 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -233,6 +233,9 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam gpointer data); +static char* cc_knot_tips[] = { _("Connection point: click or drag to create a new connector"), + _("Connection point: click to select, drag to move") }; + /*static Geom::Point connector_drag_origin_w(0, 0); static bool connector_within_tolerance = false;*/ static SPEventContextClass *parent_class; -- cgit v1.2.3