From e1898194c0387d236157590f2d10917cb0137aac Mon Sep 17 00:00:00 2001 From: bulia byak Date: Wed, 22 Mar 2006 23:41:24 +0000 Subject: use rotation center in keyboard rotation and transform dialog (bzr r273) --- src/selection.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 763713c9d..473a7202e 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -339,6 +339,23 @@ NR::Rect Selection::boundsInDocument() const { 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(this)->itemList(); + NR::Point center; + if (items) { + SPItem *first = reinterpret_cast(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. */ -- cgit v1.2.3