summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2010-04-22 20:42:03 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2010-04-22 20:42:03 +0000
commitf5fe904a389f1ea866c783a03fdf70df466e055f (patch)
tree0bc6303563cea29214cb9a1726c695a81d029544 /src
parentTranslations. en_GB translation update by Tim Sheridan. fr translation update... (diff)
downloadinkscape-f5fe904a389f1ea866c783a03fdf70df466e055f.tar.gz
inkscape-f5fe904a389f1ea866c783a03fdf70df466e055f.zip
Fix snapping regression introduced by rev. #9118
Fixed bugs: - https://launchpad.net/bugs/562205 (bzr r9364)
Diffstat (limited to 'src')
-rw-r--r--src/display/curve.cpp13
-rw-r--r--src/display/curve.h2
-rw-r--r--src/object-snapper.cpp2
-rw-r--r--src/sp-image.cpp2
4 files changed, 14 insertions, 5 deletions
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1b54c981c..73b8dc36d 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -44,7 +44,7 @@ SPCurve::SPCurve(Geom::PathVector const& pathv)
}
SPCurve *
-SPCurve::new_from_rect(Geom::Rect const &rect)
+SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides)
{
SPCurve *c = new SPCurve();
@@ -54,7 +54,16 @@ SPCurve::new_from_rect(Geom::Rect const &rect)
for (int i=3; i>=1; i--) {
c->lineto(rect.corner(i));
}
- c->closepath();
+
+ if (all_four_sides) {
+ // When _constrained_ snapping to a path, the 2geom::SimpleCrosser will be invoked which doesn't consider the closing segment.
+ // of a path. Consequently, in case we want to snap to for example the page border, we must provide all four sides of the
+ // rectangle explicitly
+ c->lineto(rect.corner(0));
+ } else {
+ // ... instead of just three plus a closing segment
+ c->closepath();
+ }
return c;
}
diff --git a/src/display/curve.h b/src/display/curve.h
index 79a385b09..fe0720195 100644
--- a/src/display/curve.h
+++ b/src/display/curve.h
@@ -27,7 +27,7 @@ public:
/* Constructors */
explicit SPCurve();
explicit SPCurve(Geom::PathVector const& pathv);
- static SPCurve * new_from_rect(Geom::Rect const &rect);
+ static SPCurve * new_from_rect(Geom::Rect const &rect, bool all_four_sides = false);
virtual ~SPCurve();
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index a3285b406..77449ddc3 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -733,7 +733,7 @@ Geom::PathVector* Inkscape::ObjectSnapper::_getBorderPathv() const
Geom::PathVector* Inkscape::ObjectSnapper::_getPathvFromRect(Geom::Rect const rect) const
{
- SPCurve const *border_curve = SPCurve::new_from_rect(rect);
+ SPCurve const *border_curve = SPCurve::new_from_rect(rect, true);
if (border_curve) {
Geom::PathVector *dummy = new Geom::PathVector(border_curve->get_pathvector());
return dummy;
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index bb867e969..68bafdeab 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -1552,7 +1552,7 @@ sp_image_set_curve(SPImage *image)
NRRect rect;
sp_image_bbox(image, &rect, Geom::identity(), 0);
Geom::Rect rect2 = to_2geom(*rect.upgrade());
- SPCurve *c = SPCurve::new_from_rect(rect2);
+ SPCurve *c = SPCurve::new_from_rect(rect2, true);
if (image->curve) {
image->curve = image->curve->unref();