summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2015-04-29 21:14:01 +0000
committerMarc Jeanmougin <mc@M0nst3r.bouyguesbox.fr>2015-04-29 21:14:01 +0000
commit9b7af8caac08ad42a48214518bc004e258eb5873 (patch)
treedcaaac56217eb5da334ab420f5e791cf7eb70f23 /src/document.cpp
parentBetter solution picking (diff)
parentcorrected test file (diff)
downloadinkscape-9b7af8caac08ad42a48214518bc004e258eb5873.tar.gz
inkscape-9b7af8caac08ad42a48214518bc004e258eb5873.zip
bzr merge lp:~mc.../inkscape/SelContainer
The main change of this branch is that the container for selections is now a std::vector and not a GSList. This change propagates in most of the codebase. Normally, there are no changes of semantics, except the following: -> childList is now in the intuitive order (childList()[0] is now firstChild) -> sp_selection_paste_impl is now in the opposite order (change is local to selection-chemistry.cpp, and simplify a few things there) -> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it) -> a few comparison functions now work "the c++ way": the C way was to return -1 if a<b, 0 if a==b and 1 if a>b, now they return (bool)(a<b) so they can be used with std::sort (bzr r14074)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 1c6bb76de..f06953e34 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -1266,7 +1266,7 @@ static bool overlaps(Geom::Rect const &area, Geom::Rect const &box)
return area.intersects(box);
}
-static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,
+static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,
bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false)
{
g_return_val_if_fail(SP_IS_GROUP(group), s);
@@ -1279,7 +1279,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey,
SPItem *child = SP_ITEM(o);
Geom::OptRect box = child->desktopVisualBounds();
if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
- s = g_slist_append(s, child);
+ s.push_back(child);
}
}
}
@@ -1306,7 +1306,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group)
return inGroup;
}
-SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive)
+SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive)
{
g_return_val_if_fail(group, NULL);
SPItem *bottomMost = 0;
@@ -1320,7 +1320,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro
Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey);
if (arenaitem && arenaitem->pick(p, delta, 1) != NULL
&& (take_insensitive || item->isVisibleAndUnlocked(dkey))) {
- if (g_slist_find((GSList *) list, item) != NULL) {
+ if (find(list.begin(),list.end(),item)!=list.end() ) {
bottomMost = item;
}
}
@@ -1422,11 +1422,11 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin
* Assumes box is normalized (and g_asserts it!)
*
*/
-GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const
+std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const
{
- g_return_val_if_fail(this->priv != NULL, NULL);
-
- return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within);
+ std::vector<SPItem*> x;
+ g_return_val_if_fail(this->priv != NULL, x);
+ return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within);
}
/*
@@ -1436,16 +1436,16 @@ GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) cons
*
*/
-GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const
+std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const
{
- g_return_val_if_fail(this->priv != NULL, NULL);
-
- return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps);
+ std::vector<SPItem*> x;
+ g_return_val_if_fail(this->priv != NULL, x);
+ return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps);
}
-GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
+std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
{
- GSList *items = NULL;
+ std::vector<SPItem*> items;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// When picking along the path, we don't want small objects close together
@@ -1454,11 +1454,11 @@ GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point
gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
prefs->setDouble("/options/cursortolerance/value", 0.25);
- for(unsigned int i = 0; i < points.size(); i++) {
+ for(int i = points.size()-1;i>=0; i--) {
SPItem *item = getItemAtPoint(key, points[i],
false, NULL);
- if (item && !g_slist_find(items, item))
- items = g_slist_prepend (items, item);
+ if (item && items.end()==find(items.begin(),items.end(), item))
+ items.push_back(item);
}
// and now we restore it back