summaryrefslogtreecommitdiffstats
path: root/src/object-snapper.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2009-01-11 12:10:19 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2009-01-11 12:10:19 +0000
commitbae59caa568c5dbf0c96d7d4d9e8a7870119d492 (patch)
tree79cfd591ab43da7bc4b093260f6bbc572b87f823 /src/object-snapper.cpp
parentAdded a new toolbar with snapping controls (diff)
downloadinkscape-bae59caa568c5dbf0c96d7d4d9e8a7870119d492.tar.gz
inkscape-bae59caa568c5dbf0c96d7d4d9e8a7870119d492.zip
Optionally snap from/to midpoints of the edges of a bounding box
(bzr r7108)
Diffstat (limited to 'src/object-snapper.cpp')
-rw-r--r--src/object-snapper.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index c03a7c288..35841891f 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -238,11 +238,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapPreferences::PointType
// of the item AND the bbox of the clipping path at the same time
if (!(*i).clip_or_mask) {
Geom::OptRect b = sp_item_bbox_desktop(root_item, bbox_type);
- if (b) {
- for ( unsigned k = 0 ; k < 4 ; k++ ) {
- _points_to_snap_to->push_back(b->corner(k));
- }
- }
+ getBBoxPoints(b, _points_to_snap_to, _snapmanager->snapprefs.getSnapMidpoints());
}
}
}
@@ -736,6 +732,20 @@ void Inkscape::ObjectSnapper::_getBorderNodes(std::vector<Geom::Point> *points)
points->push_back(Geom::Point(w,0));
}
+void Inkscape::getBBoxPoints(Geom::OptRect const bbox, std::vector<Geom::Point> *points, bool const includeMidpoints)
+{
+ if (bbox) {
+ // collect the corners of the bounding box
+ for ( unsigned k = 0 ; k < 4 ; k++ ) {
+ points->push_back(bbox->corner(k));
+ // optionally, collect the midpoints of the bounding box's edges too
+ if (includeMidpoints) {
+ points->push_back((bbox->corner(k) + bbox->corner((k+1) % 4))/2);
+ }
+ }
+ }
+}
+
/*
Local Variables:
mode:c++