From a6ba6ad5e29d23ba866e4d8bda61b4f18e053ba1 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Wed, 17 Nov 2010 22:17:44 +0100 Subject: Shift should disable snapping when dragging the rotation center of an object (bzr r9903) --- src/seltrans.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/seltrans.cpp') diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 5a8e5d3db..cdfcee742 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1323,26 +1323,30 @@ gboolean Inkscape::SelTrans::rotateRequest(Geom::Point &pt, guint state) // Move the item's transformation center gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) { - SnapManager &m = _desktop->namedview->snap_manager; - m.setup(_desktop); - // When dragging the transformation center while multiple items have been selected, then those // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center GSList *items = (GSList *) const_cast(_selection)->itemList(); + SnapManager &m = _desktop->namedview->snap_manager; + m.setup(_desktop); m.setRotationCenterSource(items); - m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER); - m.unSetup(); - if (state & GDK_CONTROL_MASK) { - if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) { - pt[Geom::Y] = _point[Geom::Y]; - } else { - pt[Geom::X] = _point[Geom::X]; + if (state & GDK_CONTROL_MASK) { // with Ctrl, constrain to axes + std::vector constraints; + constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(1, 0))); + constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(0, 1))); + Inkscape::SnappedPoint sp = m.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER), constraints, state & GDK_SHIFT_MASK); + pt = sp.getPoint(); + } + else { + if (!(state & GDK_SHIFT_MASK)) { // Shift disables snapping + m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER); } } + m.unSetup(); + // status text GString *xs = SP_PX_TO_METRIC_STRING(pt[Geom::X], _desktop->namedview->getDefaultMetric()); GString *ys = SP_PX_TO_METRIC_STRING(pt[Geom::Y], _desktop->namedview->getDefaultMetric()); -- cgit v1.2.3