summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1b7827f)
raw | patch | inline | side by side (parent: 1b7827f)
author | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Wed, 17 Nov 2010 21:17:44 +0000 (22:17 +0100) | ||
committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Wed, 17 Nov 2010 21:17:44 +0000 (22:17 +0100) |
src/seltrans.cpp | patch | blob | history | |
src/snap.cpp | patch | blob | history | |
src/snap.h | patch | blob | history | |
src/ui/tool/node.cpp | patch | blob | history |
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 5a8e5d3dbabceb84a9acbdb9e10356e21fa212fe..cdfcee7420a3cf84017ca4708553bf43b96ff810 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
// 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 8b2d188e6975d8067c1f087645447dca0959293d..79f398cc54f77df6f4bea68633d4f4f17af384c5 100644 (file)
--- 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,
*
* 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 3c9af7d515ab84011a04af3ef0381087ca36547e..c79bd308a5e2bc1bc9f11337804d1cdad9fa416a 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
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 9ab4954883aad8dc4de16bc9eb5f5e15d6e7b907..6460d90622d9129ccd1c1377618633e7977abdc5 100644 (file)
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
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) {