From 3b9b25de18b8fef19ad5ff06ae6e73f8cf30d914 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 19 Jul 2010 08:51:04 +0200 Subject: [PATCH] - do not use shift to disable snapping while holding shift to rotate a guide - snap guides to paths too - always show the same snap indicator --- src/desktop-events.cpp | 14 ++++++-------- src/display/snap-indicator.cpp | 30 +++++++++--------------------- src/object-snapper.cpp | 8 +++----- src/object-snapper.h | 2 +- src/snap.cpp | 3 +-- 5 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 810f501d7..bb22b0faa 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -296,10 +296,9 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) if (!(event->motion.state & GDK_SHIFT_MASK)) { m.guideConstrainedSnap(motion_dt, *guide); } - } else if (!(event->motion.state & GDK_SHIFT_MASK)) { - if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) { - m.guideFreeSnap(motion_dt, guide->normal_to_line, drag_type); - } + } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) { + // cannot use shift here to disable snapping, because we already use it for rotating the guide + m.guideFreeSnap(motion_dt, guide->normal_to_line, drag_type); } switch (drag_type) { @@ -361,10 +360,9 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) if (!(event->button.state & GDK_SHIFT_MASK)) { m.guideConstrainedSnap(event_dt, *guide); } - } else if (!(event->button.state & GDK_SHIFT_MASK)) { - if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) { - m.guideFreeSnap(event_dt, guide->normal_to_line, drag_type); - } + } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) { + // cannot use shift here to disable snapping, because we already use it for rotating the guide + m.guideFreeSnap(event_dt, guide->normal_to_line, drag_type); } if (sp_canvas_world_pt_inside_window(item->canvas, event_w)) { diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index fe5bd0371..838d51f05 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -229,27 +229,15 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap // Display the snap indicator (i.e. the cross) SPCanvasItem * canvasitem = NULL; - if (p.getTarget() == SNAPTARGET_NODE_SMOOTH || p.getTarget() == SNAPTARGET_NODE_CUSP) { - canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), - SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, - "size", 10.0, - "stroked", TRUE, - "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff, - "mode", SP_KNOT_MODE_XOR, - "shape", SP_KNOT_SHAPE_DIAMOND, - NULL ); - } else { - canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), - SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, - "size", 10.0, - "stroked", TRUE, - "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff, - "mode", SP_KNOT_MODE_XOR, - "shape", SP_KNOT_SHAPE_CROSS, - NULL ); - } + canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), + SP_TYPE_CTRL, + "anchor", GTK_ANCHOR_CENTER, + "size", 10.0, + "stroked", TRUE, + "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff, + "mode", SP_KNOT_MODE_XOR, + "shape", SP_KNOT_SHAPE_CROSS, + NULL ); const int timeout_val = 1200; // TODO add preference for snap indicator timeout? diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 983a6fede..ed8dfe5b9 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -280,18 +280,16 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, } } -void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &sc, +void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc, Geom::Point const &p, Geom::Point const &guide_normal) const { // Iterate through all nodes, find out which one is the closest to this guide, and snap to it! _collectNodes(SNAPSOURCE_GUIDE, true); - // Although we won't snap to paths here (which would give us under constrained snaps) we can still snap to intersections of paths. if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) { _collectPaths(Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), true); _snapPaths(sc, Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL); - // The paths themselves should be discarded in findBestSnap(), as we should only snap to their intersections } SnappedPoint s; @@ -669,7 +667,7 @@ void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc, } _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity()); - _snapTranslatingGuideToNodes(sc, p, guide_normal); + _snapTranslatingGuide(sc, p, guide_normal); } @@ -693,7 +691,7 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc, } _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity()); - _snapTranslatingGuideToNodes(sc, p, guide_normal); + _snapTranslatingGuide(sc, p, guide_normal); } diff --git a/src/object-snapper.h b/src/object-snapper.h index caf643f73..66db0ecaa 100644 --- a/src/object-snapper.h +++ b/src/object-snapper.h @@ -84,7 +84,7 @@ private: Inkscape::SnapCandidatePoint const &p, std::vector *unselected_nodes) const; // in desktop coordinates - void _snapTranslatingGuideToNodes(SnappedConstraints &sc, + void _snapTranslatingGuide(SnappedConstraints &sc, Geom::Point const &p, Geom::Point const &guide_normal) const; diff --git a/src/snap.cpp b/src/snap.cpp index c47f93ff1..a4e056727 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -430,8 +430,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, (*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL); } - // Snap to intersections of curves, but not to the curves themselves! (see _snapTranslatingGuideToNodes in object-snapper.cpp) - Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, true); + Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, false); s.getPoint(p); } -- 2.30.2