diff --git a/src/selection.cpp b/src/selection.cpp
index 763713c9d86923e0242f6399429fb41f01d77313..473a7202e594e1eecabcac3e1b9067774d7a64c9 100644 (file)
--- a/src/selection.cpp
+++ b/src/selection.cpp
return NR::Rect(*boundsInDocument(&r));
}
+/** Extract the position of the center from the first selected object */
+NR::Point Selection::center() const {
+ GSList *items = (GSList *) const_cast<Selection *>(this)->itemList();
+ NR::Point center;
+ if (items) {
+ SPItem *first = reinterpret_cast<SPItem*>(g_slist_last(items)->data); // from the first item in selection
+ if (first->isCenterSet()) { // only if set explicitly
+ center = first->getCenter();
+ } else {
+ center = bounds().midpoint();
+ }
+ } else {
+ center = bounds().midpoint();
+ }
+ return center;
+}
+
/**
* Compute the list of points in the selection that are to be considered for snapping.
*/