summaryrefslogtreecommitdiffstats
path: root/src/sp-rect.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2009-01-11 12:31:10 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2009-01-11 12:31:10 +0000
commitf0fd80a9bab53449e2ac6a59038f8c2150997bd8 (patch)
treed39c90db51c0842e7a8f620a6f79049ea70a1546 /src/sp-rect.cpp
parentOptionally snap from/to midpoints of the edges of a bounding box (diff)
downloadinkscape-f0fd80a9bab53449e2ac6a59038f8c2150997bd8.tar.gz
inkscape-f0fd80a9bab53449e2ac6a59038f8c2150997bd8.zip
Snap from/to midpoints of a rectangle (SPRect)
(bzr r7109)
Diffstat (limited to 'src/sp-rect.cpp')
-rw-r--r--src/sp-rect.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 6030991e2..2f3fc1864 100644
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
@@ -544,11 +544,11 @@ sp_rect_get_visible_height(SPRect *rect)
/**
* Sets the snappoint p to the unrounded corners of the rectangle
*/
-static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const */*snapprefs*/)
+static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
{
/* This method overrides sp_shape_snappoints, which is the default for any shape. The default method
returns all eight points along the path of a rounded rectangle, but not the real corners. Snapping
- the startpoint and endpoint of each rounded corner is not very usefull and really confusing. Instead
+ the startpoint and endpoint of each rounded corner is not very useful and really confusing. Instead
we could snap either the real corners, or not snap at all. Bulia Byak opted to snap the real corners,
but it should be noted that this might be confusing in some cases with relatively large radii. With
small radii though the user will easily understand which point is snapping. */
@@ -560,10 +560,22 @@ static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::S
Geom::Matrix const i2d (sp_item_i2d_affine (item));
- *p = Geom::Point(rect->x.computed, rect->y.computed) * i2d;
- *p = Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d;
- *p = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d;
- *p = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d;
+ Geom::Point p0 = Geom::Point(rect->x.computed, rect->y.computed) * i2d;
+ Geom::Point p1 = Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d;
+ Geom::Point p2 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d;
+ Geom::Point p3 = Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d;
+
+ *p = p0;
+ *p = p1;
+ *p = p2;
+ *p = p3;
+
+ if (snapprefs->getSnapMidpoints()) {
+ *p = (p0 + p1)/2;
+ *p = (p1 + p2)/2;
+ *p = (p2 + p3)/2;
+ *p = (p3 + p0)/2;
+ }
}
void