diff --git a/src/knot.cpp b/src/knot.cpp
index dd773ca75e3f01ed8d25f2b9140fd336e6538156..dc5b78b1754c54f0fe4ff9cee1d3fcfa54f75123 100644 (file)
--- a/src/knot.cpp
+++ b/src/knot.cpp
#include "message-stack.h"
#include "message-context.h"
#include "event-context.h"
+#include "sp-namedview.h"
+#include "snap.h"
+#include "selection.h"
#define KNOT_EVENT_MASK (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | \
g_assert(knot != NULL);
g_assert(SP_IS_KNOT(knot));
- g_object_ref(knot);
- tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
-
- bool consumed = FALSE;
-
/* Run client universal event handler, if present */
+ gboolean consumed = FALSE;
+
g_signal_emit(knot, knot_signals[EVENT], 0, event, &consumed);
if (consumed) {
return TRUE;
}
+ g_object_ref(knot);
+ tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+
switch (event->type) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
TRUE);
}
NR::Point const motion_w(event->motion.x, event->motion.y);
- NR::Point const motion_dt = knot->desktop->w2d(motion_w);
- NR::Point p = motion_dt - knot->grabbed_rel_pos;
- sp_knot_request_position (knot, &p, event->motion.state);
+ NR::Point motion_dt = knot->desktop->w2d(motion_w) - knot->grabbed_rel_pos;
+
+ // Only snap path nodes, for which the anchor is set to GTK_ANCHOR_CENTER
+ // (according to default value as set in sp_knot_init())
+ // If we have one of the transform handles at hand, then the anchor will be
+ // set to e.g. GTK_ANCHOR_SW (see seltrans-handles.cpp). The transform handles
+ // will be snapped in seltrans.cpp, not here
+ if (knot->anchor == GTK_ANCHOR_CENTER) {
+ SnapManager const &m = knot->desktop->namedview->snap_manager;
+ SPItem *curr = knot->desktop->selection->singleItem(); //Is this really the only way to get to the item to which this knot belongs?
+ motion_dt = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, motion_dt, curr).getPoint();
+ }
+
+ sp_knot_request_position (knot, &motion_dt, event->motion.state);
knot->desktop->scroll_to_point (&motion_dt);
+ knot->desktop->set_coordinate_status(knot->pos); // display the coordinate of knot, not cursor - they may be different!
moved = TRUE;
}
break;
g_return_if_fail(knot != NULL);
g_return_if_fail(SP_IS_KNOT(knot));
- bool done = FALSE;
+ gboolean done = FALSE;
g_signal_emit(knot,
knot_signals[REQUEST], 0,