Code

- do not use shift to disable snapping while holding shift to rotate a guide
authorDiederik van Lierop <mailat-signdiedenrezidotnl>
Mon, 19 Jul 2010 06:51:04 +0000 (08:51 +0200)
committerDiederik van Lierop <mailat-signdiedenrezidotnl>
Mon, 19 Jul 2010 06:51:04 +0000 (08:51 +0200)
- snap guides to paths too
- always show the same snap indicator

src/desktop-events.cpp
src/display/snap-indicator.cpp
src/object-snapper.cpp
src/object-snapper.h
src/snap.cpp

index 810f501d7fe1bbf024161db08f6fa31b54d9e314..bb22b0faa4f65ff2b1cb01f90caf538dce2c7eb2 100644 (file)
@@ -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)) {
index fe5bd0371927471d2d068a39ea66fe4b18caf769..838d51f055dc1992486df81daca52ae6aeff146f 100644 (file)
@@ -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?
 
index 983a6fedee8eda2423f46ab49833148d6eebdab4..ed8dfe5b995123f8e35a5c9e42c4af9d32878280 100644 (file)
@@ -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);
 
 }
 
index caf643f730e867b89f498b701f03c2eff56daa8a..66db0ecaa1db453965303ee8d5d42a7d14e60c62 100644 (file)
@@ -84,7 +84,7 @@ private:
                       Inkscape::SnapCandidatePoint const &p,
                       std::vector<SnapCandidatePoint> *unselected_nodes) const; // in desktop coordinates
 
-    void _snapTranslatingGuideToNodes(SnappedConstraints &sc,
+    void _snapTranslatingGuide(SnappedConstraints &sc,
                      Geom::Point const &p,
                      Geom::Point const &guide_normal) const;
 
index c47f93ff11c37a77dfcc685ae00f8ce37c458d13..a4e0567274bd581fd5e5aa57ccf59576805102be 100644 (file)
@@ -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);
 }