summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-11-17 21:17:44 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-11-17 21:17:44 +0000
commita6ba6ad5e29d23ba866e4d8bda61b4f18e053ba1 (patch)
tree036cc9271c4e6ecafe6ffcf75318eb13df63bb4b /src
parentExtensions. Removing tooltips from color>randomize (see Bug #676419). (diff)
downloadinkscape-a6ba6ad5e29d23ba866e4d8bda61b4f18e053ba1.tar.gz
inkscape-a6ba6ad5e29d23ba866e4d8bda61b4f18e053ba1.zip
Shift should disable snapping when dragging the rotation center of an object
(bzr r9903)
Diffstat (limited to '')
-rw-r--r--src/seltrans.cpp24
-rw-r--r--src/snap.cpp13
-rw-r--r--src/snap.h5
-rw-r--r--src/ui/tool/node.cpp4
4 files changed, 28 insertions, 18 deletions
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 *>(_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<Inkscape::Snapper::SnapConstraint> 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());
diff --git a/src/snap.cpp b/src/snap.cpp
index 8b2d188e6..79f398cc5 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -319,11 +319,12 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c
* constrainedSnapReturnByRef() is equal in snapping behavior to
* constrainedSnap(), but the former returns the snapped point trough the referenced
* parameter p. This parameter p initially contains the position of the snap
- * source and will we overwritten by the target position if snapping has occurred.
+ * source and will be overwritten by the target position if snapping has occurred.
* This makes snapping transparent to the calling code. If this is not desired
* because either the calling code must know whether snapping has occurred, or
* because the original position should not be touched, then constrainedSnap() should
- * be called instead.
+ * be called instead. If there's nothing to snap to or if snapping has been disabled,
+ * then this method will still apply the constraint (but without snapping)
*
* PS:
* 1) SnapManager::setup() must have been called before calling this method,
@@ -357,6 +358,8 @@ void SnapManager::constrainedSnapReturnByRef(Geom::Point &p,
*
* PS: SnapManager::setup() must have been called before calling this method,
* but only once for a set of points
+ * PS: If there's nothing to snap to or if snapping has been disabled, then this
+ * method will still apply the constraint (but without snapping)
*
* \param p Source point to be snapped
* \param constraint The direction or line along which snapping must occur
@@ -421,12 +424,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint
* and will try to snap the SnapCandidatePoint to all of the provided constraints and see which one fits best
* \param p Source point to be snapped
* \param constraints List of directions or lines along which snapping must occur
+ * \param dont_snap If true then we will only apply the constraint, without snapping
* \param bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation
*/
Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandidatePoint const &p,
std::vector<Inkscape::Snapper::SnapConstraint> const &constraints,
+ bool dont_snap,
Geom::OptRect const &bbox_to_snap) const
{
@@ -438,7 +443,7 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi
SnappedConstraints sc;
SnapperList const snappers = getSnappers();
std::vector<Geom::Point> projections;
- bool snapping_is_futile = !someSnapperMightSnap();
+ bool snapping_is_futile = !someSnapperMightSnap() || dont_snap;
Inkscape::SnappedPoint result = no_snap;
@@ -452,7 +457,7 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi
projections.push_back(pp);
}
- if (snap_mouse && p.isSingleHandle()) {
+ if (snap_mouse && p.isSingleHandle() && !dont_snap) {
// Snapping the mouse pointer instead of the constrained position of the knot allows
// to snap to things which don't intersect with the constraint line; this is basically
// then just a freesnap with the constraint applied afterwards
diff --git a/src/snap.h b/src/snap.h
index 3c9af7d51..c79bd308a 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -135,8 +135,9 @@ public:
Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
Inkscape::SnappedPoint multipleConstrainedSnaps(Inkscape::SnapCandidatePoint const &p,
- std::vector<Inkscape::Snapper::SnapConstraint> const &constraints,
- Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
+ std::vector<Inkscape::Snapper::SnapConstraint> const &constraints,
+ bool dont_snap = false,
+ Geom::OptRect const &bbox_to_snap = Geom::OptRect()) const;
Inkscape::SnappedPoint constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p,
boost::optional<Geom::Point> const &p_ref,
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 9ab495488..6460d9062 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -1020,12 +1020,12 @@ void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event)
constraints.push_back(Inkscape::Snapper::SnapConstraint(origin, *bperp_point));
}
- sp = sm.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(new_pos, _snapSourceType()), constraints);
+ sp = sm.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(new_pos, _snapSourceType()), constraints, held_shift(*event));
} else {
// with Ctrl, constrain to axes
constraints.push_back(Inkscape::Snapper::SnapConstraint(origin, Geom::Point(1, 0)));
constraints.push_back(Inkscape::Snapper::SnapConstraint(origin, Geom::Point(0, 1)));
- sp = sm.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(new_pos, _snapSourceType()), constraints);
+ sp = sm.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(new_pos, _snapSourceType()), constraints, held_shift(*event));
}
new_pos = sp.getPoint();
} else if (snap) {