Code

- do not use shift to disable snapping while holding shift to rotate a guide
authorDiederik van Lierop <mailat-signdiedenrezidotnl>
Sun, 18 Jul 2010 10:12:38 +0000 (12:12 +0200)
committerDiederik van Lierop <mailat-signdiedenrezidotnl>
Sun, 18 Jul 2010 10:12:38 +0000 (12:12 +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 0409e64b11ad9bd644abc44b8c722f53c6f0d2c4..776c56c15a64de7f3870db616876bac935fddd25 100644 (file)
@@ -228,27 +228,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 22d5f35aa8f122f8aeb0fac28c9ccbc5450bfecf..57d5b0fc5cbfb3487265a79442bd30842edb4024 100644 (file)
@@ -281,18 +281,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;
@@ -682,7 +680,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);
 
 }
 
@@ -706,7 +704,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 454a18545d54e2ea06b5d00947514057700760fe..b0084c2d77fc0478238a7c73e34563781b1c7dfa 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 1127ccba186408b174304400dde4a576b32c1ebe..ccaf3dee3b8bb652ca835b8421467f9e8b4adf61 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);
 }