diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-07-16 21:52:53 +0000 |
|---|---|---|
| committer | Javiertxo <jtx@jtx.marker.es> | 2013-07-16 21:52:53 +0000 |
| commit | 488bfe58fe622fbd7b0d93039d5dd014c69e7884 (patch) | |
| tree | fd4bf21c1ec55f4d8ca2f2b25a2087b057005cd1 /src/selection.cpp | |
| parent | Update to trunk (diff) | |
| parent | Shape calculations. re-introduce grid of a smaller size. (http://article.gman... (diff) | |
| download | inkscape-488bfe58fe622fbd7b0d93039d5dd014c69e7884.tar.gz inkscape-488bfe58fe622fbd7b0d93039d5dd014c69e7884.zip | |
Update to trunk
(bzr r11950.1.125)
Diffstat (limited to 'src/selection.cpp')
| -rw-r--r-- | src/selection.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/selection.cpp b/src/selection.cpp index d018aba0c..784219c88 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -358,6 +358,35 @@ SPItem *Selection::singleItem() { } } +SPItem *Selection::smallestItem(Selection::CompareSize compare) { + return _sizeistItem(true, compare); +} + +SPItem *Selection::largestItem(Selection::CompareSize compare) { + return _sizeistItem(false, compare); +} + +SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { + GSList const *items = const_cast<Selection *>(this)->itemList(); + gdouble max = sml ? 1e18 : 0; + SPItem *ist = NULL; + + for ( GSList const *i = items; i != NULL ; i = i->next ) { + Geom::OptRect obox = SP_ITEM(i->data)->desktopPreferredBounds(); + if (!obox || obox.isEmpty()) continue; + Geom::Rect bbox = *obox; + + gdouble size = compare == 2 ? bbox.area() : + (compare == 1 ? bbox.width() : bbox.height()); + size = sml ? size : size * -1; + if (size < max) { + max = size; + ist = SP_ITEM(i->data); + } + } + return ist; +} + Inkscape::XML::Node *Selection::singleRepr() { SPObject *obj=single(); return obj ? obj->getRepr() : NULL; |
