Code

While drawing and constraining to specific angles (using CTRL): don't try a freeSnap...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Mon, 4 Aug 2008 21:09:10 +0000 (21:09 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Mon, 4 Aug 2008 21:09:10 +0000 (21:09 +0000)
src/draw-context.cpp
src/pen-context.cpp
src/pencil-context.cpp

index a127df87752c1f26bfb92d745f72634426162db5..2d02677577a7a7d91c17173800d007ed75d6e6dc 100644 (file)
@@ -445,11 +445,6 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/)
 void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, NR::Point const o,
                                  guint state)
 {
-    /* Control must be down for this snap to work */
-    if ((state & GDK_CONTROL_MASK) == 0) {
-        return;
-    }
-
     unsigned const snaps = abs(prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12));
     /* 0 means no snapping. */
 
@@ -480,21 +475,20 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
     if (fabs(bdot) > 0) {
         p = o + bdot * best;
 
-        /* Snap it along best vector */
-        SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
-        m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
-        m.constrainedSnapReturnByRef( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best));
+        if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
+                                         //After all, the user explicitely asked for angular snapping by
+                                         //pressing CTRL
+            /* Snap it along best vector */
+            SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
+            m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
+            m.constrainedSnapReturnByRef( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best));
+        }
     }
 }
 
 
-void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guint const state)
+void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guint const /*state*/)
 {
-    /* Shift disables this snap */
-    if (state & GDK_SHIFT_MASK) {
-        return;
-    }
-
     SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
     m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
     m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
index 1c9b30dc3b1877b10c88166cf9aa394b9356c38b..4fb7fbc99a2c4f31e9472688dd01e3926769c499 100644 (file)
@@ -276,11 +276,18 @@ sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
 static void
 spdc_endpoint_snap(SPPenContext const *const pc, NR::Point &p, guint const state)
 {
-    if (pc->npoints > 0) {
-        spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
+    
+    if ((state & GDK_CONTROL_MASK)) { //CTRL enables angular snapping
+        if (pc->npoints > 0) {
+            spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
+        }
+    } else {
+        if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
+                                         //After all, the user explicitely asked for angular snapping by
+                                         //pressing CTRL
+            spdc_endpoint_snap_free(pc, p, state);
+        }
     }
-
-    spdc_endpoint_snap_free(pc, p, state);
 }
 
 /**
@@ -292,8 +299,13 @@ spdc_endpoint_snap_handle(SPPenContext const *const pc, NR::Point &p, guint cons
     g_return_if_fail(( pc->npoints == 2 ||
                        pc->npoints == 5   ));
 
-    spdc_endpoint_snap_rotation(pc, p, pc->p[pc->npoints - 2], state);
-    spdc_endpoint_snap_free(pc, p, state);
+    if ((state & GDK_CONTROL_MASK)) { //CTRL enables angular snapping
+        spdc_endpoint_snap_rotation(pc, p, pc->p[pc->npoints - 2], state);
+    } else {
+        if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
+            spdc_endpoint_snap_free(pc, p, state);
+        }
+    }
 }
 
 static gint 
index 0a5bc74443e6a46ea533f7022589ff087b745248..894b5cd71878f986f131359ed36c02f76e571540 100644 (file)
@@ -154,8 +154,15 @@ sp_pencil_context_dispose(GObject *object)
 static void
 spdc_endpoint_snap(SPPencilContext const *pc, NR::Point &p, guint const state)
 {
-    spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
-    spdc_endpoint_snap_free(pc, p, state);
+    if ((state & GDK_CONTROL_MASK)) { //CTRL enables constrained snapping
+        spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
+    } else {
+        if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
+                                         //After all, the user explicitely asked for angular snapping by
+                                         //pressing CTRL
+            spdc_endpoint_snap_free(pc, p, state);
+        }
+    }
 }
 
 /**