From: dvlierop2 Date: Mon, 4 Aug 2008 21:09:10 +0000 (+0000) Subject: While drawing and constraining to specific angles (using CTRL): don't try a freeSnap... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1d0b394330fa71e860830f533fc62a8b9aa5a72b;p=inkscape.git While drawing and constraining to specific angles (using CTRL): don't try a freeSnap() after we've already tried a constrainedSnap() --- diff --git a/src/draw-context.cpp b/src/draw-context.cpp index a127df877..2d0267757 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -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); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 1c9b30dc3..4fb7fbc99 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -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 diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 0a5bc7444..894b5cd71 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -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); + } + } } /**