summaryrefslogtreecommitdiffstats
path: root/src/context-fns.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2008-05-12 18:58:04 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2008-05-12 18:58:04 +0000
commitde27d953d1c13d2e7563b43c2d959b1b02aee9c3 (patch)
treeefc8ed7eaba9a2b0ed87eaf14b797103bd8fa33a /src/context-fns.cpp
parentfix typo (diff)
downloadinkscape-de27d953d1c13d2e7563b43c2d959b1b02aee9c3.tar.gz
inkscape-de27d953d1c13d2e7563b43c2d959b1b02aee9c3.zip
Add a centralized check (i.e. in the snapper mechanism) whether we've snapped or not, instead of leaving it up to the various tools. This should prevent these tools from moving to (0,0) if they bluntly use the value returned by the snapping mechanism without checking whether snapping has really occured.
(bzr r5659)
Diffstat (limited to '')
-rw-r--r--src/context-fns.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index 83048af40..61b6a2fc4 100644
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
@@ -86,7 +86,7 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
bool const control = state & GDK_CONTROL_MASK;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, item);
+ m.setup(NULL, item);
Inkscape::SnappedPoint snappoint;
if (control) {
@@ -141,23 +141,27 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
/* Choose the best snap and update points accordingly */
if (s[0].getDistance() < s[1].getDistance()) {
- p[0] = s[0].getPoint();
- p[1] = 2 * center - s[0].getPoint();
- snappoint = s[0];
+ if (s[0].getSnapped()) {
+ p[0] = s[0].getPoint();
+ p[1] = 2 * center - s[0].getPoint();
+ snappoint = s[0];
+ }
} else {
- p[0] = 2 * center - s[1].getPoint();
- p[1] = s[1].getPoint();
- snappoint = s[1];
+ if (s[1].getSnapped()) {
+ p[0] = 2 * center - s[1].getPoint();
+ p[1] = s[1].getPoint();
+ snappoint = s[1];
+ }
}
- desktop->snapindicator->set_new_snappoint(snappoint);
-
} else {
/* Our origin is the opposite corner. Snap the drag point along the constraint vector */
p[0] = center;
snappoint = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1],
Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
- p[1] = snappoint.getPoint();
+ if (snappoint.getSnapped()) {
+ p[1] = snappoint.getPoint();
+ }
}
} else if (shift) {
@@ -175,13 +179,17 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
s[1] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1]);
if (s[0].getDistance() < s[1].getDistance()) {
- p[0] = s[0].getPoint();
- p[1] = 2 * center - s[0].getPoint();
- snappoint = s[0];
+ if (s[0].getSnapped()) {
+ p[0] = s[0].getPoint();
+ p[1] = 2 * center - s[0].getPoint();
+ snappoint = s[0];
+ }
} else {
- p[0] = 2 * center - s[1].getPoint();
- p[1] = s[1].getPoint();
- snappoint = s[1];
+ if (s[1].getSnapped()) {
+ p[0] = 2 * center - s[1].getPoint();
+ p[1] = s[1].getPoint();
+ snappoint = s[1];
+ }
}
} else {
@@ -189,12 +197,13 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
/* There's no constraint on the corner point, so just snap it to anything */
p[0] = center;
snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt);
- p[1] = snappoint.getPoint();
+ if (snappoint.getSnapped()) {
+ p[1] = snappoint.getPoint();
+ }
}
if (snappoint.getSnapped()) {
- // this does not work well enough yet.
-// desktop->snapindicator->set_new_snappoint(snappoint);
+ desktop->snapindicator->set_new_snappoint(snappoint);
}
p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]);