summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-08-09 09:58:51 +0000
committerAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-08-09 09:58:51 +0000
commite5143d65bb57d4ce623e6220585b099e6d2ee453 (patch)
tree4ff78f6fa8f0c1b740fd43b0ade2b91dbf9226d0 /src/ui
parentRemove deprecated Autotools and btool files. Please use CMake instead (diff)
parentMerged trunk (diff)
downloadinkscape-e5143d65bb57d4ce623e6220585b099e6d2ee453.tar.gz
inkscape-e5143d65bb57d4ce623e6220585b099e6d2ee453.zip
Merged gsoc work. Created better data structure for selections, replaced SPObject children list, improved spray tool, split tests to separate executables
(bzr r15047)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/clipboard.cpp30
-rw-r--r--src/ui/dialog/align-and-distribute.cpp22
-rw-r--r--src/ui/dialog/clonetiler.cpp32
-rw-r--r--src/ui/dialog/document-properties.cpp14
-rw-r--r--src/ui/dialog/export.cpp25
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp87
-rw-r--r--src/ui/dialog/find.cpp14
-rw-r--r--src/ui/dialog/font-substitution.cpp2
-rw-r--r--src/ui/dialog/glyphs.cpp8
-rw-r--r--src/ui/dialog/grid-arrange-tab.cpp20
-rw-r--r--src/ui/dialog/icon-preview.cpp4
-rw-r--r--src/ui/dialog/objects.cpp93
-rw-r--r--src/ui/dialog/pixelartdialog.cpp4
-rw-r--r--src/ui/dialog/polar-arrange-tab.cpp2
-rw-r--r--src/ui/dialog/spellcheck.cpp12
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp88
-rw-r--r--src/ui/dialog/swatches.cpp2
-rw-r--r--src/ui/dialog/symbols.cpp13
-rw-r--r--src/ui/dialog/tags.cpp53
-rw-r--r--src/ui/dialog/text-edit.cpp12
-rw-r--r--src/ui/dialog/transformation.cpp44
-rw-r--r--src/ui/interface.cpp6
-rw-r--r--src/ui/tools/box3d-tool.cpp4
-rw-r--r--src/ui/tools/calligraphic-tool.cpp4
-rw-r--r--src/ui/tools/connector-tool.cpp10
-rw-r--r--src/ui/tools/eraser-tool.cpp11
-rw-r--r--src/ui/tools/flood-tool.cpp2
-rw-r--r--src/ui/tools/gradient-tool.cpp18
-rw-r--r--src/ui/tools/lpe-tool.cpp4
-rw-r--r--src/ui/tools/mesh-tool.cpp16
-rw-r--r--src/ui/tools/node-tool.cpp11
-rw-r--r--src/ui/tools/select-tool.cpp2
-rw-r--r--src/ui/tools/spray-tool.cpp58
-rw-r--r--src/ui/tools/spray-tool.h9
-rw-r--r--src/ui/tools/tool-base.cpp10
-rw-r--r--src/ui/tools/tweak-tool.cpp30
-rw-r--r--src/ui/widget/layer-selector.cpp20
-rw-r--r--src/ui/widget/object-composite-settings.cpp2
-rw-r--r--src/ui/widget/style-subject.cpp10
39 files changed, 405 insertions, 403 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 14e9fdf32..66b13ed9d 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -510,8 +510,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
// resize each object in the selection
if (separately) {
- std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ auto itemlist= selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (item) {
Geom::OptRect obj_size = item->desktopVisualBounds();
@@ -527,8 +527,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
else {
Geom::OptRect sel_size = selection->visualBounds();
if ( sel_size ) {
- sp_selection_scale_relative(selection, sel_size->midpoint(),
- _getScale(desktop, min, max, *sel_size, apply_x, apply_y));
+ sp_object_set_scale_relative(selection, sel_size->midpoint(),
+ _getScale(desktop, min, max, *sel_size, apply_x, apply_y));
}
}
pasted = true;
@@ -566,8 +566,8 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
desktop->doc()->importDefs(tempdoc);
// make sure all selected items are converted to paths first (i.e. rectangles)
sp_selected_to_lpeitems(desktop);
- std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ auto itemlist= selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
_applyPathEffect(item, effectstack);
}
@@ -649,9 +649,9 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
{
// copy the defs used by all items
- std::vector<SPItem*> itemlist=selection->itemList();
+ auto itemlist= selection->items();
cloned_elements.clear();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (item) {
_copyUsedDefs(item);
@@ -662,7 +662,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
// copy the representation of the items
std::vector<SPObject*> sorted_items;
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i)
+ for(auto i=itemlist.begin();i!=itemlist.end();++i)
sorted_items.push_back(*i);
sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position_bool);
@@ -827,8 +827,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
SPObject *mask = item->mask_ref->getObject();
_copyNode(mask->getRepr(), _doc, _defs);
// recurse into the mask for its gradients etc.
- for (SPObject *o = mask->children ; o != NULL ; o = o->next) {
- SPItem *childItem = dynamic_cast<SPItem *>(o);
+ for(auto& o: mask->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&o);
if (childItem) {
_copyUsedDefs(childItem);
}
@@ -845,8 +845,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
// recurse
- for (SPObject *o = item->children ; o != NULL ; o = o->next) {
- SPItem *childItem = dynamic_cast<SPItem *>(o);
+ for(auto& o: item->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&o);
if (childItem) {
_copyUsedDefs(childItem);
}
@@ -882,8 +882,8 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
_copyNode(pattern->getRepr(), _doc, _defs);
// items in the pattern may also use gradients and other patterns, so recurse
- for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: pattern->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
_copyUsedDefs(childItem);
}
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 6006093ed..ed9ec3b0a 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -122,7 +122,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups");
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
const Coeffs &a = _allCoeffs[index];
@@ -282,7 +282,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -477,7 +477,9 @@ private :
// xGap and yGap are the minimum space required between bounding rectangles.
double const xGap = removeOverlapXGap.get_value();
double const yGap = removeOverlapYGap.get_value();
- removeoverlap(_dialog.getDesktop()->getSelection()->itemList(), xGap, yGap);
+ auto tmp = _dialog.getDesktop()->getSelection()->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ removeoverlap(vec, xGap, yGap);
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
@@ -508,8 +510,9 @@ private :
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- graphlayout(_dialog.getDesktop()->getSelection()->itemList());
-
+ auto tmp = _dialog.getDesktop()->getSelection()->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ graphlayout(vec);
// restore compensation setting
prefs->setInt("/options/clonecompensation/value", saved_compensation);
@@ -568,7 +571,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -634,7 +637,8 @@ private :
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- std::vector<SPItem*> x(_dialog.getDesktop()->getSelection()->itemList());
+ auto tmp = _dialog.getDesktop()->getSelection()->items();
+ std::vector<SPItem*> x(tmp.begin(), tmp.end());
unclump (x);
// restore compensation setting
@@ -665,7 +669,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
//Check 2 or more selected objects
@@ -759,7 +763,7 @@ private :
Inkscape::Selection *selection = desktop->getSelection();
if (!selection) return;
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
//Check 2 or more selected objects
if (selected.size() < 2) return;
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp
index 97767e604..1fa7a6c71 100644
--- a/src/ui/dialog/clonetiler.cpp
+++ b/src/ui/dialog/clonetiler.cpp
@@ -1256,7 +1256,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk
return;
}
- if (selection->itemList().size() > 1) {
+ if (boost::distance(selection->items()) > 1) {
gtk_widget_set_sensitive (buttons, FALSE);
gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>"));
return;
@@ -1922,12 +1922,12 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from)
if (!trace_drawing)
return;
- for (SPObject *o = from->firstChild(); o != NULL; o = o->next) {
- SPItem *item = dynamic_cast<SPItem *>(o);
- if (item && clonetiler_is_a_clone_of(o, NULL)) {
+ for (auto& o: from->children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
+ if (item && clonetiler_is_a_clone_of(&o, NULL)) {
item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too!
}
- clonetiler_trace_hide_tiled_clones_recursively (o);
+ clonetiler_trace_hide_tiled_clones_recursively (&o);
}
}
@@ -1993,7 +1993,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() || selection->itemList().size() > 1) {
+ if (selection->isEmpty() || boost::distance(selection->items()) > 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
return;
}
@@ -2003,9 +2003,9 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *)
std::vector<SPItem*> to_unclump; // not including the original
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
- to_unclump.push_back((SPItem*)child);
+ for (auto& child: parent->children) {
+ if (clonetiler_is_a_clone_of (&child, obj)) {
+ to_unclump.push_back((SPItem*)&child);
}
}
@@ -2023,8 +2023,8 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj)
guint n = 0;
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
+ for (auto& child: parent->children) {
+ if (clonetiler_is_a_clone_of (&child, obj)) {
n ++;
}
}
@@ -2042,7 +2042,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() || selection->itemList().size() > 1) {
+ if (selection->isEmpty() || boost::distance(selection->items()) > 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
return;
}
@@ -2052,9 +2052,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d
// remove old tiling
GSList *to_delete = NULL;
- for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) {
- if (clonetiler_is_a_clone_of (child, obj)) {
- to_delete = g_slist_prepend (to_delete, child);
+ for (auto& child: parent->children) {
+ if (clonetiler_is_a_clone_of (&child, obj)) {
+ to_delete = g_slist_prepend (to_delete, &child);
}
}
for (GSList *i = to_delete; i; i = i->next) {
@@ -2120,7 +2120,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg)
}
// Check if more than one object is selected.
- if (selection->itemList().size() > 1) {
+ if (boost::distance(selection->items()) > 1) {
desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
return;
}
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index 88fefe4f2..053549b73 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -1176,12 +1176,7 @@ void DocumentProperties::changeEmbeddedScript(){
for (std::vector<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) {
SPObject* obj = *it;
if (id == obj->getId()){
-
- int count=0;
- for ( SPObject *child = obj->children ; child; child = child->next )
- {
- count++;
- }
+ int count = (int) obj->children.size();
if (count>1)
g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count);
@@ -1225,8 +1220,11 @@ void DocumentProperties::editEmbeddedScript(){
//XML Tree being used directly here while it shouldn't be.
Inkscape::XML::Node *repr = obj->getRepr();
if (repr){
- SPObject *child;
- while (NULL != (child = obj->firstChild())) child->deleteObject();
+ auto tmp = obj->children | boost::adaptors::transformed([](SPObject& o) { return &o; });
+ std::vector<SPObject*> vec(tmp.begin(), tmp.end());
+ for (auto &child: vec) {
+ child->deleteObject();
+ }
obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str()));
//TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text());
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index effbfc74d..670e4c8b5 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -543,7 +543,7 @@ void Export::onBatchClicked ()
void Export::updateCheckbuttons ()
{
- gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size();
+ gint num = (gint) boost::distance(SP_ACTIVE_DESKTOP->getSelection()->items());
if (num >= 2) {
batch_export.set_sensitive(true);
batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
@@ -749,14 +749,14 @@ void Export::onAreaToggled ()
case SELECTION_SELECTION:
if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) {
- sp_selection_get_export_hints (SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi);
+ sp_object_set_get_export_hints(SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi);
/* If we still don't have a filename -- let's build
one that's nice */
if (filename.empty()) {
const gchar * id = "object";
- const std::vector<XML::Node*> reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList();
- for(std::vector<XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) {
+ auto reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes();
+ for(auto i=reprlst.begin(); reprlst.end() != i; ++i) {
Inkscape::XML::Node * repr = *i;
if (repr->attribute("id")) {
id = repr->attribute("id");
@@ -946,7 +946,7 @@ void Export::onExport ()
if (batch_export.get_active ()) {
// Batch export of selected objects
- gint num = (desktop->getSelection()->itemList()).size();
+ gint num = (gint) boost::distance(desktop->getSelection()->items());
gint n = 0;
if (num < 1) {
@@ -960,8 +960,8 @@ void Export::onExport ()
gint export_count = 0;
- std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){
+ auto itemlist= desktop->getSelection()->items();
+ for(auto i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){
SPItem *item = *i;
prog_dlg->set_data("current", GINT_TO_POINTER(n));
@@ -1001,12 +1001,13 @@ void Export::onExport ()
MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE,
_("Exporting file <b>%s</b>..."), safeFile), desktop);
std::vector<SPItem*> x;
+ std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end());
if (!sp_export_png_file (doc, path.c_str(),
*area, width, height, dpi, dpi,
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
TRUE, // overwrite without asking
- hide ? (desktop->getSelection()->itemList()) : x
+ hide ? selected : x
)) {
gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
@@ -1091,12 +1092,13 @@ void Export::onExport ()
/* Do export */
std::vector<SPItem*> x;
+ std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end());
ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(),
Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
nv->pagecolor,
onProgressCallback, (void*)prog_dlg,
FALSE,
- hide ? (desktop->getSelection()->itemList()) : x
+ hide ? selected : x
);
if (status == EXPORT_ERROR) {
gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str());
@@ -1162,15 +1164,14 @@ void Export::onExport ()
break;
}
case SELECTION_SELECTION: {
- std::vector<XML::Node*> reprlst;
SPDocument * doc = SP_ACTIVE_DOCUMENT;
bool modified = false;
bool saved = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, false);
- reprlst = desktop->getSelection()->reprList();
+ auto reprlst = desktop->getSelection()->xmlNodes();
- for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) {
+ for(auto i=reprlst.begin(); reprlst.end() != i; ++i) {
Inkscape::XML::Node * repr = *i;
const gchar * temp_string;
Glib::ustring dir = Glib::path_get_dirname(filename.c_str());
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 97fa47f2f..8dbc90cc5 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -84,9 +84,7 @@ static int input_count(const SPFilterPrimitive* prim)
return 2;
else if(SP_IS_FEMERGE(prim)) {
// Return the number of feMergeNode connections plus an extra
- int count = 1;
- for(const SPObject* o = prim->firstChild(); o; o = o->next, ++count){};
- return count;
+ return (int) (prim->children.size() + 1);
}
else
return 1;
@@ -655,7 +653,7 @@ private:
void select_svg_element(){
Inkscape::Selection* sel = _desktop->getSelection();
if (sel->isEmpty()) return;
- Inkscape::XML::Node* node = sel->reprList()[0];
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node || !node->matchAttributeName("id")) return;
std::ostringstream xlikhref;
@@ -1024,11 +1022,10 @@ public:
// FuncNode can be in any order so we must search to find correct one.
SPFeFuncNode* find_node(SPFeComponentTransfer* ct)
{
- SPObject* node = ct->children;
SPFeFuncNode* funcNode = NULL;
bool found = false;
- for(;node;node=node->next){
- funcNode = SP_FEFUNCNODE(node);
+ for(auto& node: ct->children) {
+ funcNode = SP_FEFUNCNODE(&node);
if( funcNode->channel == _channel ) {
found = true;
break;
@@ -1192,7 +1189,7 @@ protected:
_locked = true;
- SPObject* child = o->children;
+ SPObject* child = o->firstChild();
if(SP_IS_FEDISTANTLIGHT(child))
_light_source.set_active(0);
@@ -1217,7 +1214,7 @@ private:
if(prim) {
_locked = true;
- SPObject* child = prim->children;
+ SPObject* child = prim->firstChild();
const int ls = _light_source.get_active_row_number();
// Check if the light source type has changed
if(!(ls == -1 && !child) &&
@@ -1251,8 +1248,8 @@ private:
_light_box.show_all();
SPFilterPrimitive* prim = _dialog._primitive_list.get_selected();
- if(prim && prim->children)
- _settings.show_and_update(_light_source.get_active_data()->id, prim->children);
+ if(prim && prim->firstChild())
+ _settings.show_and_update(_light_source.get_active_data()->id, prim->firstChild());
}
FilterEffectsDialog& _dialog;
@@ -1438,8 +1435,8 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel)
}
std::set<SPObject*> used;
- std::vector<SPItem*> itemlist=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= sel->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
SPObject *obj = *i;
SPStyle *style = obj->style;
if (!style || !SP_IS_ITEM(obj)) {
@@ -1519,8 +1516,8 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri
if((*iter)[_columns.sel] == 1)
filter = 0;
- std::vector<SPItem*> itemlist=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= sel->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
SPItem * item = *i;
SPStyle *style = item->style;
g_assert(style != NULL);
@@ -1808,26 +1805,25 @@ void FilterEffectsDialog::PrimitiveList::update()
bool active_found = false;
_dialog._primitive_box->set_sensitive(true);
_dialog.update_filter_general_settings_view();
- for(SPObject *prim_obj = f->children;
- prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj);
- prim_obj = prim_obj->next) {
- SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(prim_obj);
- if(prim) {
- Gtk::TreeModel::Row row = *_model->append();
- row[_columns.primitive] = prim;
-
- //XML Tree being used directly here while it shouldn't be.
- row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name());
- row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str());
-
- if (prim->getId()) {
- row[_columns.id] = Glib::ustring(prim->getId());
- }
-
- if(prim == active_prim) {
- get_selection()->select(row);
- active_found = true;
- }
+ for(auto& prim_obj: f->children) {
+ SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj);
+ if(!prim) {
+ break;
+ }
+ Gtk::TreeModel::Row row = *_model->append();
+ row[_columns.primitive] = prim;
+
+ //XML Tree being used directly here while it shouldn't be.
+ row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name());
+ row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str());
+
+ if (prim->getId()) {
+ row[_columns.id] = Glib::ustring(prim->getId());
+ }
+
+ if(prim == active_prim) {
+ get_selection()->select(row);
+ active_found = true;
}
}
@@ -2214,11 +2210,12 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T
if(SP_IS_FEMERGE(prim)) {
int c = 0;
bool found = false;
- for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) {
- if(c == attr && SP_IS_FEMERGENODE(o)) {
- image = SP_FEMERGENODE(o)->input;
+ for (auto& o: prim->children) {
+ if(c == attr && SP_IS_FEMERGENODE(&o)) {
+ image = SP_FEMERGENODE(&o)->input;
found = true;
}
+ ++c;
}
if(!found)
return target;
@@ -2405,21 +2402,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
if(SP_IS_FEMERGE(prim)) {
int c = 1;
bool handled = false;
- for(SPObject* o = prim->firstChild(); o && !handled; o = o->next, ++c) {
- if(c == _in_drag && SP_IS_FEMERGENODE(o)) {
+ for (auto& o: prim->children) {
+ if(c == _in_drag && SP_IS_FEMERGENODE(&o)) {
// If input is null, delete it
if(!in_val) {
//XML Tree being used directly here while it shouldn't be.
- sp_repr_unparent(o->getRepr());
+ sp_repr_unparent(o.getRepr());
DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS,
_("Remove merge node"));
(*get_selection()->get_selected())[_columns.primitive] = prim;
+ } else {
+ _dialog.set_attr(&o, SP_ATTR_IN, in_val);
}
- else
- _dialog.set_attr(o, SP_ATTR_IN, in_val);
handled = true;
+ break;
}
+ ++c;
}
// Add new input?
if(!handled && c == _in_drag && in_val) {
@@ -2938,7 +2937,7 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input)
void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input)
{
- set_attr(_primitive_list.get_selected()->children, input->get_attribute(), input->get_as_attribute().c_str());
+ set_attr(_primitive_list.get_selected()->firstChild(), input->get_attribute(), input->get_as_attribute().c_str());
}
void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val)
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 8b6067e82..b4f7902f5 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -740,22 +740,22 @@ std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, boo
return l; // we're not interested in metadata
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- SPItem *item = dynamic_cast<SPItem *>(child);
- if (item && !child->cloned && !desktop->isLayer(item)) {
+ for (auto& child: r->children) {
+ SPItem *item = dynamic_cast<SPItem *>(&child);
+ if (item && !child.cloned && !desktop->isLayer(item)) {
if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) {
- l.insert(l.begin(),(SPItem*)child);
+ l.insert(l.begin(),(SPItem*)&child);
}
}
- l = all_items (child, l, hidden, locked);
+ l = all_items (&child, l, hidden, locked);
}
return l;
}
std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked)
{
- std::vector<SPItem*> itemlist=s->itemList();
- for(std::vector<SPItem*>::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; ++i) {
+ auto itemlist= s->items();
+ for(auto i=boost::rbegin(itemlist); boost::rend(itemlist) != i; ++i) {
SPObject *obj = *i;
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp
index 76af412ca..abae8ea70 100644
--- a/src/ui/dialog/font-substitution.cpp
+++ b/src/ui/dialog/font-substitution.cpp
@@ -173,7 +173,7 @@ std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli
family = SP_TEXT(parent_text)->layout.getFontFamily(0);
// Add all the spans fonts to the set
gint ii = 0;
- for (SPObject *child = parent_text->firstChild() ; child ; child = child->getNext() ) {
+ for (auto& child: parent_text->children) {
family = SP_TEXT(parent_text)->layout.getFontFamily(ii);
setFontSpans.insert(family);
ii++;
diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp
index 3b9a13bdb..9c1236ca9 100644
--- a/src/ui/dialog/glyphs.cpp
+++ b/src/ui/dialog/glyphs.cpp
@@ -516,8 +516,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop)
void GlyphsPanel::insertText()
{
SPItem *textItem = 0;
- std::vector<SPItem*> itemlist=targetDesktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= targetDesktop->selection->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) {
textItem = *i;
break;
@@ -617,8 +617,8 @@ void GlyphsPanel::selectionModifiedCB(guint flags)
void GlyphsPanel::calcCanInsert()
{
int items = 0;
- std::vector<SPItem*> itemlist=targetDesktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) {
+ auto itemlist= targetDesktop->selection->items();
+ for(auto i=itemlist.begin(); itemlist.end() != i; ++i) {
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) {
++items;
}
diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp
index de84abd12..5872393ae 100644
--- a/src/ui/dialog/grid-arrange-tab.cpp
+++ b/src/ui/dialog/grid-arrange-tab.cpp
@@ -156,7 +156,11 @@ void GridArrangeTab::arrange()
desktop->getDocument()->ensureUpToDate();
Inkscape::Selection *selection = desktop->getSelection();
- const std::vector<SPItem*> items = selection ? selection->itemList() : std::vector<SPItem*>();
+ std::vector<SPItem*> items;
+ if (selection) {
+ items.insert(items.end(), selection->items().begin(), selection->items().end());
+ }
+
for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end(); ++i){
SPItem *item = *i;
Geom::OptRect b = item->documentVisualBounds();
@@ -185,7 +189,7 @@ void GridArrangeTab::arrange()
// require the sorting done before we can calculate row heights etc.
g_return_if_fail(selection);
- std::vector<SPItem*> sorted(selection->itemList());
+ std::vector<SPItem*> sorted(selection->items().begin(), selection->items().end());
sort(sorted.begin(),sorted.end(),sp_compare_y_position);
sort(sorted.begin(),sorted.end(),sp_compare_x_position);
@@ -361,8 +365,7 @@ void GridArrangeTab::on_row_spinbutton_changed()
Inkscape::Selection *selection = desktop ? desktop->selection : 0;
g_return_if_fail( selection );
- std::vector<SPItem*> const items = selection->itemList();
- int selcount = items.size();
+ int selcount = (int) boost::distance(selection->items());
double PerCol = ceil(selcount / NoOfColsSpinner.get_value());
NoOfRowsSpinner.set_value(PerCol);
@@ -387,7 +390,7 @@ void GridArrangeTab::on_col_spinbutton_changed()
Inkscape::Selection *selection = desktop ? desktop->selection : 0;
g_return_if_fail(selection);
- int selcount = selection->itemList().size();
+ int selcount = (int) boost::distance(selection->items());
double PerRow = ceil(selcount / NoOfRowsSpinner.get_value());
NoOfColsSpinner.set_value(PerRow);
@@ -524,7 +527,10 @@ void GridArrangeTab::updateSelection()
updating = true;
SPDesktop *desktop = Parent->getDesktop();
Inkscape::Selection *selection = desktop ? desktop->selection : 0;
- std::vector<SPItem*> const items = selection ? selection->itemList() : std::vector<SPItem*>();
+ std::vector<SPItem*> items;
+ if (selection) {
+ items.insert(items.end(), selection->items().begin(), selection->items().end());
+ }
if (!items.empty()) {
int selcount = items.size();
@@ -591,7 +597,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent)
g_return_if_fail( selection );
int selcount = 1;
if (!selection->isEmpty()) {
- selcount = selection->itemList().size();
+ selcount = (int) boost::distance(selection->items());
}
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index 8dd0ae489..a4fcc9947 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -359,8 +359,8 @@ void IconPreviewPanel::refreshPreview()
if ( sel ) {
//g_message("found a selection to play with");
- std::vector<SPItem*> const items = sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();!target && i!=items.end();++i){
+ auto items = sel->items();
+ for(auto i=items.begin();!target && i!=items.end();++i){
SPItem* item = *i;
gchar const *id = item->getId();
if ( id ) {
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index 471097797..09ffc9c4c 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -330,12 +330,11 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/)
void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow)
{
if ( _desktop && obj ) {
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
-
- if (SP_IS_ITEM(child))
+ for(auto& child: obj->children) {
+ if (SP_IS_ITEM(&child))
{
- SPItem * item = SP_ITEM(child);
- SPGroup * group = SP_IS_GROUP(child) ? SP_GROUP(child) : 0;
+ SPItem * item = SP_ITEM(&child);
+ SPGroup * group = SP_IS_GROUP(&child) ? SP_GROUP(&child) : 0;
//Add the item to the tree and set the column information
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
@@ -362,14 +361,14 @@ void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow)
}
//Add an object watcher to the item
- ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, child);
- child->getRepr()->addObserver(*w);
+ ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, &child);
+ child.getRepr()->addObserver(*w);
_objectWatchers.push_back(w);
//If the item is a group, recursively add its children
if (group)
{
- _addObject( child, &row );
+ _addObject( &child, &row );
}
}
}
@@ -389,9 +388,8 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) {
//end mark
if (recurse)
{
- for (SPObject * iter = obj->children; iter != NULL; iter = iter->next)
- {
- _updateObject(iter, recurse);
+ for (auto& iter: obj->children) {
+ _updateObject(&iter, recurse);
}
}
}
@@ -468,8 +466,8 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) {
_selectedConnection.block();
_tree.get_selection()->unselect_all();
SPItem *item = NULL;
- std::vector<SPItem*> const items = sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); ++i){
+ auto items = sel->items();
+ for(auto i=items.begin(); i!=items.end(); ++i){
item = *i;
if (setOpacity)
{
@@ -506,19 +504,22 @@ void ObjectsPanel::_setCompositingValues(SPItem *item)
SPGaussianBlur *spblur = NULL;
if (item->style->getFilter())
{
- for(SPObject *primitive_obj = item->style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) {
- if(SP_IS_FEBLEND(primitive_obj) && !spblend) {
- //Get the blend mode
- spblend = SP_FEBLEND(primitive_obj);
- }
-
- if(SP_IS_GAUSSIANBLUR(primitive_obj) && !spblur) {
- //Get the blur value
- spblur = SP_GAUSSIANBLUR(primitive_obj);
- }
+ for (auto& primitive_obj: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) {
+ break;
}
+ if(SP_IS_FEBLEND(&primitive_obj) && !spblend) {
+ //Get the blend mode
+ spblend = SP_FEBLEND(&primitive_obj);
+ }
+
+ if(SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) {
+ //Get the blur value
+ spblur = SP_GAUSSIANBLUR(&primitive_obj);
+ }
+ }
}
-
+
//Set the blend mode
_fe_cb.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL);
@@ -1278,9 +1279,9 @@ bool ObjectsPanel::_executeAction()
break;
case BUTTON_COLLAPSE_ALL:
{
- for (SPObject* obj = _document->getRoot()->firstChild(); obj != NULL; obj = obj->next) {
- if (SP_IS_GROUP(obj)) {
- _setCollapsed(SP_GROUP(obj));
+ for (auto& obj: _document->getRoot()->children) {
+ if (SP_IS_GROUP(&obj)) {
+ _setCollapsed(SP_GROUP(&obj));
}
}
_objectsChanged(_document->getRoot());
@@ -1390,9 +1391,10 @@ void ObjectsPanel::_setCollapsed(SPGroup * group)
{
group->setExpanded(false);
group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
- for (SPObject *iter = group->children; iter != NULL; iter = iter->next)
- {
- if (SP_IS_GROUP(iter)) _setCollapsed(SP_GROUP(iter));
+ for (auto& iter: group->children) {
+ if (SP_IS_GROUP(&iter)) {
+ _setCollapsed(SP_GROUP(&iter));
+ }
}
}
@@ -1503,11 +1505,14 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl
if (blendmode != "normal") {
gdouble radius = 0;
if (item->style->getFilter()) {
- for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) {
- if (SP_IS_GAUSSIANBLUR(primitive)) {
+ for (auto& primitive: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
+ break;
+ }
+ if (SP_IS_GAUSSIANBLUR(&primitive)) {
Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX);
if (bbox) {
- radius = SP_GAUSSIANBLUR(primitive)->stdDeviation.getNumber();
+ radius = SP_GAUSSIANBLUR(&primitive)->stdDeviation.getNumber();
}
}
}
@@ -1515,13 +1520,16 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl
SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius);
sp_style_set_property_url(item, "filter", filter, false);
} else {
- for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) {
- if (SP_IS_FEBLEND(primitive)) {
- primitive->deleteObject();
+ for (auto& primitive: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
+ break;
+ }
+ if (SP_IS_FEBLEND(&primitive)) {
+ primitive.deleteObject();
break;
}
}
- if (!item->style->getFilter()->children) {
+ if (!item->style->getFilter()->firstChild()) {
remove_filter(item, false);
}
}
@@ -1572,13 +1580,16 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur)
SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius);
sp_style_set_property_url(item, "filter", filter, false);
} else if (item->style->filter.set && item->style->getFilter()) {
- for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) {
- if (SP_IS_GAUSSIANBLUR(primitive)) {
- primitive->deleteObject();
+ for (auto& primitive: item->style->getFilter()->children) {
+ if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
+ break;
+ }
+ if (SP_IS_GAUSSIANBLUR(&primitive)) {
+ primitive.deleteObject();
break;
}
}
- if (!item->style->getFilter()->children) {
+ if (!item->style->getFilter()->firstChild()) {
remove_filter(item, false);
}
}
diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp
index 62e6bf591..b838b0842 100644
--- a/src/ui/dialog/pixelartdialog.cpp
+++ b/src/ui/dialog/pixelartdialog.cpp
@@ -366,8 +366,8 @@ void PixelArtDialogImpl::vectorize()
return;
}
- std::vector<SPItem*> const items = desktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();++i){
+ auto items = desktop->selection->items();
+ for(auto i=items.begin(); i!=items.end();++i){
if ( !SP_IS_IMAGE(*i) )
continue;
diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp
index 6324ec57f..c51881a96 100644
--- a/src/ui/dialog/polar-arrange-tab.cpp
+++ b/src/ui/dialog/polar-arrange-tab.cpp
@@ -264,7 +264,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p)
void PolarArrangeTab::arrange()
{
Inkscape::Selection *selection = parent->getDesktop()->getSelection();
- const std::vector<SPItem*> tmp(selection->itemList());
+ const std::vector<SPItem*> tmp(selection->items().begin(), selection->items().end());
SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection
bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active();
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 61fa4c22b..045ce3459 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -227,14 +227,14 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock
return l; // we're not interested in metadata
}
- for (SPObject *child = r->firstChild(); child; child = child->next) {
- if (SP_IS_ITEM (child) && !child->cloned && !desktop->isLayer(SP_ITEM(child))) {
- if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) {
- if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child))
- l = g_slist_prepend (l, child);
+ for (auto& child: r->children) {
+ if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) {
+ if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) {
+ if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child))
+ l = g_slist_prepend (l, &child);
}
}
- l = allTextItems (child, l, hidden, locked);
+ l = allTextItems (&child, l, hidden, locked);
}
return l;
}
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index 87bab72e9..6a87f3714 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -113,11 +113,11 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){
void SvgFontsDialog::AttrEntry::on_attr_changed(){
SPObject* o = NULL;
- for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){
+ for (auto& node: dialog->get_selected_spfont()->children) {
switch(this->attr){
case SP_PROP_FONT_FAMILY:
- if (SP_IS_FONTFACE(node)){
- o = node;
+ if (SP_IS_FONTFACE(&node)){
+ o = &node;
continue;
}
break;
@@ -168,9 +168,9 @@ void GlyphComboBox::update(SPFont* spfont){
this->append(""); //Gtk is refusing to clear the combobox when I comment out this line
this->remove_all();
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
- this->append((static_cast<SPGlyph*>(node))->unicode);
+ for (auto& node: spfont->children) {
+ if (SP_IS_GLYPH(&node)){
+ this->append((static_cast<SPGlyph*>(&node))->unicode);
}
}
}
@@ -306,10 +306,9 @@ void SvgFontsDialog::update_global_settings_tab(){
SPFont* font = get_selected_spfont();
if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
- _familyname_entry->set_text((SP_FONTFACE(obj))->font_family);
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
+ _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family);
}
}
}
@@ -412,12 +411,12 @@ SvgFontsDialog::populate_glyphs_box()
SPFont* spfont = this->get_selected_spfont();
_glyphs_observer.set(spfont);
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
+ for (auto& node: spfont->children) {
+ if (SP_IS_GLYPH(&node)){
Gtk::TreeModel::Row row = *(_GlyphsListStore->append());
- row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(node);
- row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(node))->glyph_name;
- row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(node))->unicode;
+ row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(&node);
+ row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(&node))->glyph_name;
+ row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(&node))->unicode;
}
}
}
@@ -430,13 +429,13 @@ SvgFontsDialog::populate_kerning_pairs_box()
SPFont* spfont = this->get_selected_spfont();
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_HKERN(node)){
+ for (auto& node: spfont->children) {
+ if (SP_IS_HKERN(&node)){
Gtk::TreeModel::Row row = *(_KerningPairsListStore->append());
- row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(node))->u1->attribute_string().c_str();
- row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(node))->u2->attribute_string().c_str();
- row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(node))->k;
- row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(node);
+ row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(&node))->u1->attribute_string().c_str();
+ row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(&node))->u2->attribute_string().c_str();
+ row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(&node))->k;
+ row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(&node);
}
}
}
@@ -491,11 +490,10 @@ void SvgFontsDialog::add_glyph(){
Geom::PathVector
SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){
double units_per_em = 1000;
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- sp_repr_get_double(obj->getRepr(), "units-per-em", &units_per_em);
+ sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em);
}
}
@@ -522,7 +520,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){
return;
}
- Inkscape::XML::Node* node = sel->reprList().front();
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node) return;//TODO: should this be an assert?
if (!node->matchAttributeName("d") || !node->attribute("d")){
char *msg = _("The selected object does not have a <b>path</b> description.");
@@ -564,7 +562,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
return;
}
- Inkscape::XML::Node* node = sel->reprList().front();
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node) return;//TODO: should this be an assert?
if (!node->matchAttributeName("d") || !node->attribute("d")){
char *msg = _("The selected object does not have a <b>path</b> description.");
@@ -574,13 +572,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
gchar *str = sp_svg_write_path (flip_coordinate_system(pathv));
- obj->getRepr()->setAttribute("d", str);
+ obj.getRepr()->setAttribute("d", str);
g_free(str);
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
}
@@ -597,11 +594,10 @@ void SvgFontsDialog::reset_missing_glyph_description(){
}
SPDocument* doc = desktop->getDocument();
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
+ obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph"));
}
}
@@ -736,12 +732,12 @@ void SvgFontsDialog::add_kerning_pair(){
//look for this kerning pair on the currently selected font
this->kerning_pair = NULL;
- for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){
+ for (auto& node: get_selected_spfont()->children) {
//TODO: It is not really correct to get only the first byte of each string.
//TODO: We should also support vertical kerning
- if (SP_IS_HKERN(node) && (static_cast<SPGlyphKerning*>(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
- && (static_cast<SPGlyphKerning*>(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
- this->kerning_pair = static_cast<SPGlyphKerning*>(node);
+ if (SP_IS_HKERN(&node) && (static_cast<SPGlyphKerning*>(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
+ && (static_cast<SPGlyphKerning*>(&node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
+ this->kerning_pair = static_cast<SPGlyphKerning*>(&node);
continue;
}
}
@@ -850,11 +846,10 @@ SPFont *new_font(SPDocument *document)
void set_font_family(SPFont* font, char* str){
if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("font-family", str);
+ obj.getRepr()->setAttribute("font-family", str);
}
}
@@ -871,11 +866,10 @@ void SvgFontsDialog::add_font(){
font->setLabel(os.str().c_str());
os2 << "SVGFont " << count;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("font-family", os2.str().c_str());
+ obj.getRepr()->setAttribute("font-family", os2.str().c_str());
}
}
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index b3767f584..3012c5c26 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -114,7 +114,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr )
bool shown = false;
if ( desktop && desktop->doc() ) {
Inkscape::Selection *selection = desktop->getSelection();
- std::vector<SPItem*> const items = selection->itemList();
+ std::vector<SPItem*> const items(selection->items().begin(), selection->items().end());
if (!items.empty()) {
SPStyle query( desktop->doc() );
int result = objects_query_fillstroke((items), &query, true);
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index de4e127bd..4840b897b 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -432,11 +432,6 @@ void SymbolsDialog::iconChanged() {
SPObject* symbol = symbolDocument->getObjectById(symbol_id);
if( symbol ) {
- if( symbolDocument == currentDocument ) {
- // Select the symbol on the canvas so it can be manipulated
- currentDesktop->selection->set( symbol, false );
- }
-
// Find style for use in <use>
// First look for default style stored in <symbol>
gchar const* style = symbol->getAttribute("inkscape:symbol-style");
@@ -619,8 +614,8 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l)
l = g_slist_prepend (l, r);
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- l = symbols_in_doc_recursive( child, l );
+ for (auto& child: r->children) {
+ l = symbols_in_doc_recursive( &child, l );
}
return l;
@@ -641,8 +636,8 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l)
l = g_slist_prepend (l, r);
}
- for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
- l = use_in_doc_recursive( child, l );
+ for (auto& child: r->children) {
+ l = use_in_doc_recursive( &child, l );
}
return l;
diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp
index 768e13d43..dfe71bddb 100644
--- a/src/ui/dialog/tags.cpp
+++ b/src/ui/dialog/tags.cpp
@@ -335,8 +335,8 @@ void TagsPanel::_objectsSelected( Selection *sel ) {
_selectedConnection.block();
_tree.get_selection()->unselect_all();
- std::vector<SPObject*> tmp=sel->list();
- for(std::vector<SPObject*>::const_iterator i=tmp.begin();i!=tmp.end();++i)
+ auto tmp = sel->objects();
+ for(auto i = tmp.begin(); i != tmp.end(); ++i)
{
SPObject *obj = *i;
_store->foreach(sigc::bind<SPObject *>( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj));
@@ -386,26 +386,26 @@ void TagsPanel::_objectsChanged(SPObject* root)
void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow )
{
if ( _desktop && obj ) {
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
- if (SP_IS_TAG(child))
+ for (auto& child: obj->children) {
+ if (SP_IS_TAG(&child))
{
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
Gtk::TreeModel::Row row = *iter;
- row[_model->_colObject] = child;
+ row[_model->_colObject] = &child;
row[_model->_colParentObject] = NULL;
- row[_model->_colLabel] = child->label() ? child->label() : child->getId();
+ row[_model->_colLabel] = child.label() ? child.label() : child.getId();
row[_model->_colAddRemove] = true;
row[_model->_colAllowAddRemove] = true;
_tree.expand_to_path( _store->get_path(iter) );
- TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child);
- child->getRepr()->addObserver(*w);
+ TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child);
+ child.getRepr()->addObserver(*w);
_objectWatchers.push_back(w);
- _addObject( doc, child, &row );
+ _addObject( doc, &child, &row );
}
}
- if (SP_IS_TAG(obj) && obj->children)
+ if (SP_IS_TAG(obj) && obj->firstChild())
{
Gtk::TreeModel::iterator iteritems = parentRow ? _store->append(parentRow->children()) : _store->prepend();
Gtk::TreeModel::Row rowitems = *iteritems;
@@ -416,16 +416,16 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row*
rowitems[_model->_colAllowAddRemove] = false;
_tree.expand_to_path( _store->get_path(iteritems) );
-
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
- if (SP_IS_TAG_USE(child))
+
+ for (auto& child: obj->children) {
+ if (SP_IS_TAG_USE(&child))
{
- SPItem *item = SP_TAG_USE(child)->ref->getObject();
+ SPItem *item = SP_TAG_USE(&child)->ref->getObject();
Gtk::TreeModel::iterator iter = _store->prepend(rowitems->children());
Gtk::TreeModel::Row row = *iter;
- row[_model->_colObject] = child;
+ row[_model->_colObject] = &child;
row[_model->_colParentObject] = NULL;
- row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(child)->href;
+ row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(&child)->href;
row[_model->_colAddRemove] = false;
row[_model->_colAllowAddRemove] = true;
@@ -434,7 +434,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row*
}
if (item) {
- TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child, item->getRepr());
+ TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child, item->getRepr());
item->getRepr()->addObserver(*w);
_objectWatchers.push_back(w);
}
@@ -446,12 +446,11 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row*
void TagsPanel::_select_tag( SPTag * tag )
{
- for (SPObject * child = tag->children; child != NULL; child = child->next)
- {
- if (SP_IS_TAG(child)) {
- _select_tag(SP_TAG(child));
- } else if (SP_IS_TAG_USE(child)) {
- SPObject * obj = SP_TAG_USE(child)->ref->getObject();
+ for (auto& child: tag->children) {
+ if (SP_IS_TAG(&child)) {
+ _select_tag(SP_TAG(&child));
+ } else if (SP_IS_TAG_USE(&child)) {
+ SPObject * obj = SP_TAG_USE(&child)->ref->getObject();
if (obj) {
if (_desktop->selection->isEmpty()) _desktop->setCurrentLayer(obj->parent);
_desktop->selection->add(obj);
@@ -633,12 +632,12 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event)
if (col == _tree.get_column(COL_ADD - 1) && down_at_add) {
if (SP_IS_TAG(obj)) {
bool wasadded = false;
- std::vector<SPItem*> items=_desktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= _desktop->selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *newobj = *i;
bool addchild = true;
- for ( SPObject *child = obj->children; child != NULL; child = child->next) {
- if (SP_IS_TAG_USE(child) && SP_TAG_USE(child)->ref->getObject() == newobj) {
+ for (auto& child: obj->children) {
+ if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) {
addchild = false;
}
}
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 5d50a6c30..50c6c1553 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -413,8 +413,8 @@ SPItem *TextEdit::getSelectedTextItem (void)
if (!SP_ACTIVE_DESKTOP)
return NULL;
- std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i)
+ auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i)
{
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
return *i;
@@ -431,8 +431,8 @@ unsigned TextEdit::getSelectedTextCount (void)
unsigned int items = 0;
- std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i)
+ auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i)
{
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
++items;
@@ -538,11 +538,11 @@ void TextEdit::onApply()
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
unsigned items = 0;
- const std::vector<SPItem*> item_list = desktop->getSelection()->itemList();
+ auto item_list = desktop->getSelection()->items();
SPCSSAttr *css = fillTextStyle ();
sp_desktop_set_style(desktop, css, true);
- for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();++i){
+ for(auto i=item_list.begin();i!=item_list.end();++i){
// apply style to the reprs of all text objects in the selection
if (SP_IS_TEXT (*i)) {
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 5fb5bdfc4..7f1492cd7 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -544,7 +544,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection)
{
if (selection && !selection->isEmpty()) {
if (_check_replace_matrix.get_active()) {
- Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection
+ Geom::Affine current (selection->items().front()->transform); // take from the first item in selection
Geom::Affine new_displayed = current;
@@ -617,19 +617,19 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
if (!prefs->getBool("/dialogs/transformation/applyseparately")) {
// move selection as a whole
if (_check_move_relative.get_active()) {
- sp_selection_move_relative(selection, x, y);
+ sp_object_set_move_relative(selection, x, y);
} else {
Geom::OptRect bbox = selection->preferredBounds();
if (bbox) {
- sp_selection_move_relative(selection,
- x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
+ sp_object_set_move_relative(selection,
+ x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
}
}
} else {
if (_check_move_relative.get_active()) {
// shift each object relatively to the previous one
- std::vector<SPItem*> selected(selection->itemList());
+ std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
if (selected.empty()) return;
if (fabs(x) > 1e-6) {
@@ -685,8 +685,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
} else {
Geom::OptRect bbox = selection->preferredBounds();
if (bbox) {
- sp_selection_move_relative(selection,
- x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
+ sp_object_set_move_relative(selection,
+ x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
}
}
}
@@ -704,8 +704,8 @@ void Transformation::applyPageScale(Inkscape::Selection *selection)
bool transform_stroke = prefs->getBool("/options/transform/stroke", true);
bool preserve = prefs->getBool("/options/preservetransform/value", false);
if (prefs->getBool("/dialogs/transformation/applyseparately")) {
- std::vector<SPItem*> tmp=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){
+ auto tmp= selection->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
Geom::OptRect bbox_pref = item->desktopPreferredBounds();
Geom::OptRect bbox_geom = item->desktopGeometricBounds();
@@ -750,7 +750,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection)
double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2;
Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1);
- sp_selection_apply_affine(selection, scaler);
+ sp_object_set_apply_affine(selection, scaler);
}
}
@@ -768,15 +768,15 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection)
}
if (prefs->getBool("/dialogs/transformation/applyseparately")) {
- std::vector<SPItem*> tmp=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){
+ auto tmp= selection->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0));
}
} else {
boost::optional<Geom::Point> center = selection->center();
if (center) {
- sp_selection_rotate_relative(selection, *center, angle);
+ sp_object_set_rotate_relative(selection, *center, angle);
}
}
@@ -788,8 +788,8 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/dialogs/transformation/applyseparately")) {
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i = items.begin();i!=items.end();++i){
SPItem *item = *i;
if (!_units_skew.isAbsolute()) { // percentage
@@ -843,7 +843,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
- sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY);
+ sp_object_set_skew_relative(selection, *center, 0.01 * skewX, 0.01 * skewY);
} else if (_units_skew.isRadial()) { //deg or rad
double angleX = _scalar_skew_horizontal.getValue("rad");
double angleY = _scalar_skew_vertical.getValue("rad");
@@ -856,7 +856,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
}
double skewX = tan(-angleX);
double skewY = tan(angleY);
- sp_selection_skew_relative(selection, *center, skewX, skewY);
+ sp_object_set_skew_relative(selection, *center, skewX, skewY);
} else { // absolute displacement
double skewX = _scalar_skew_horizontal.getValue("px");
double skewY = _scalar_skew_vertical.getValue("px");
@@ -864,7 +864,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
- sp_selection_skew_relative(selection, *center, skewX/height, skewY/width);
+ sp_object_set_skew_relative(selection, *center, skewX / height, skewY / width);
}
}
}
@@ -890,14 +890,14 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection)
}
if (_check_replace_matrix.get_active()) {
- std::vector<SPItem*> tmp=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){
+ auto tmp = selection->items();
+ for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
item->set_item_transform(displayed);
item->updateRepr();
}
} else {
- sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform
+ sp_object_set_apply_affine(selection, displayed); // post-multiply each object's transform
}
DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
@@ -1043,7 +1043,7 @@ void Transformation::onReplaceMatrixToggled()
double f = _scalar_transform_f.getValue();
Geom::Affine displayed (a, b, c, d, e, f);
- Geom::Affine current = selection->itemList()[0]->transform; // take from the first item in selection
+ Geom::Affine current = selection->items().front()->transform; // take from the first item in selection
Geom::Affine new_displayed;
if (_check_replace_matrix.get_active()) {
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 3c754be29..b47e66451 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -1210,7 +1210,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
- sp_selection_move_relative(selection, m, false);
+ sp_object_set_move_relative(selection, m, false);
}
}
@@ -2056,8 +2056,8 @@ void ContextMenu::ImageEdit(void)
}
#endif
- std::vector<SPItem*> itemlist=_desktop->selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
+ auto itemlist= _desktop->selection->items();
+ for(auto i=itemlist.begin();i!=itemlist.end();++i){
Inkscape::XML::Node *ir = (*i)->getRepr();
const gchar *href = ir->attribute("xlink:href");
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 9b5b264bc..94488a700 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -109,8 +109,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
SPDefs *defs = document->getDefs();
bool has_persp = false;
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child)) {
+ for (auto& child: defs->children) {
+ if (SP_IS_PERSP3D(&child)) {
has_persp = true;
break;
}
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 84c4adc89..d623035d9 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -921,10 +921,10 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
if (unionize) {
desktop->getSelection()->add(this->repr);
- sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
+ sp_selected_path_union_skip_undo(desktop->getSelection());
} else if (subtract) {
desktop->getSelection()->add(this->repr);
- sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop);
+ sp_selected_path_diff_skip_undo(desktop->getSelection());
} else {
if (this->keep_selected) {
desktop->getSelection()->set(this->repr);
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 605b573d7..84f7f318c 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -1107,9 +1107,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) {
// The idea here is to try and add a group's children to solidify
// connection handling. We react to path objects with only one node.
- for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) {
- if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) {
- this->_activeShapeAddKnot((SPItem *) child);
+ for (auto& child: item->children) {
+ if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) {
+ this->_activeShapeAddKnot((SPItem *) &child);
}
}
this->_activeShapeAddKnot(item);
@@ -1299,8 +1299,8 @@ void cc_selection_set_avoid(bool const set_avoid)
int changes = 0;
- std::vector<SPItem*> l = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end(); ++i) {
+ auto l = selection->items();
+ for(auto i=l.begin();i!=l.end(); ++i) {
SPItem *item = *i;
char const *value = (set_avoid) ? "true" : NULL;
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 838522b34..d18db8266 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -681,7 +681,7 @@ void EraserTool::set_to_accumulated() {
}
}
} else {
- toWorkOn = selection->itemList();
+ toWorkOn.insert(toWorkOn.end(), selection->items().begin(), selection->items().end());
}
wasSelection = true;
}
@@ -697,7 +697,6 @@ void EraserTool::set_to_accumulated() {
item->deleteObject(true);
sp_object_unref(item);
workDone = true;
- workDone = true;
} else if (SP_IS_GROUP(item) || use ) {
/*Do nothing*/
} else {
@@ -708,7 +707,7 @@ void EraserTool::set_to_accumulated() {
Inkscape::GC::release(dup); // parent takes over
selection->set(dup);
if (!this->nowidth) {
- sp_selected_path_union_skip_undo(selection, desktop);
+ sp_selected_path_union_skip_undo(selection);
}
selection->add(item);
if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){
@@ -719,9 +718,9 @@ void EraserTool::set_to_accumulated() {
css = 0;
}
if (this->nowidth) {
- sp_selected_path_cut_skip_undo(selection, desktop);
+ sp_selected_path_cut_skip_undo(selection);
} else {
- sp_selected_path_diff_skip_undo(selection, desktop);
+ sp_selected_path_diff_skip_undo(selection);
}
workDone = true; // TODO set this only if something was cut.
bool break_apart = prefs->getBool("/tools/eraser/break_apart", false);
@@ -734,7 +733,7 @@ void EraserTool::set_to_accumulated() {
}
if ( !selection->isEmpty() ) {
// If the item was not completely erased, track the new remainder.
- std::vector<SPItem*> nowSel(selection->itemList());
+ std::vector<SPItem*> nowSel(selection->items().begin(), selection->items().end());
for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) {
remainingItems.push_back(*i2);
}
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 2f125e6ed..0b893a7ba 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -446,7 +446,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.",
SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() );
selection->add(reprobj);
- sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
+ sp_selected_path_union_skip_undo(desktop->getSelection());
} else {
desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE,
ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.",
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index e4814c3de..a084a8fd9 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -99,7 +99,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) {
if (selection == NULL) {
return;
}
- guint n_obj = selection->itemList().size();
+ guint n_obj = (guint) boost::distance(selection->items());
if (!drag->isNonEmpty() || selection->isEmpty())
return;
@@ -485,10 +485,10 @@ bool GradientTool::root_handler(GdkEvent* event) {
if (over_line) {
// we take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time);
+ sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time);
} else {
- std::vector<SPItem*> items=selection->itemList();
- for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i) {
+ auto items= selection->items();
+ for (auto i = items.begin();i!=items.end();++i) {
SPItem *item = *i;
SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -890,7 +890,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- std::vector<SPItem*> items(selection->itemList());
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
@@ -900,8 +900,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- std::vector<SPItem*> itemlist = selection->itemList();
- for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();++i) {
+ auto itemlist = selection->items();
+ for (auto i = itemlist.begin();i!=itemlist.end();++i) {
//FIXME: see above
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -924,7 +924,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
ec->_grdrag->local_change = true;
// give the grab out-of-bounds values of xp/yp because we're already dragging
// and therefore are already out of tolerance
- ec->_grdrag->grabKnot (selection->itemList()[0],
+ ec->_grdrag->grabKnot (selection->items().front(),
type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1,
-1, // ignore number (though it is always 1)
fill_or_stroke, 99999, 99999, etime);
@@ -933,7 +933,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = selection->itemList().size();
+ int n_objects = (int) boost::distance(selection->items());
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index ee85dd28c..29e4c9e74 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -393,8 +393,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup();
gchar *arc_length;
double lengthval;
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (SP_IS_PATH(*i)) {
path = SP_PATH(*i);
curve = path->getCurve();
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index 32e70bc19..f2cf8c4a2 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -102,7 +102,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
return;
}
- guint n_obj = selection->itemList().size();
+ guint n_obj = (guint) boost::distance(selection->items());
if (!drag->isNonEmpty() || selection->isEmpty()) {
return;
@@ -466,11 +466,11 @@ bool MeshTool::root_handler(GdkEvent* event) {
if (over_line) {
// We take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time);
+ sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time);
} else {
// Create a new gradient with default coordinates.
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPItem *item = *i;
SPGradientType new_type = SP_GRADIENT_TYPE_MESH;
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -944,7 +944,7 @@ static void sp_mesh_end_drag(MeshTool &rc) {
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- std::vector<SPItem*> items(selection->itemList());
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
@@ -954,8 +954,8 @@ static void sp_mesh_end_drag(MeshTool &rc) {
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
//FIXME: see above
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -971,7 +971,7 @@ static void sp_mesh_end_drag(MeshTool &rc) {
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = selection->itemList().size();
+ int n_objects = (int) boost::distance(selection->items());
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index bf18d4a2e..f7f09610c 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -372,8 +372,8 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape
r.role = role;
s.insert(r);
} else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) {
- for (SPObject *c = obj->children; c; c = c->next) {
- gather_items(nt, base, c, role, s);
+ for (auto& c: obj->children) {
+ gather_items(nt, base, &c, role, s);
}
} else if (SP_IS_ITEM(obj)) {
SPItem *item = static_cast<SPItem*>(obj);
@@ -401,8 +401,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
std::set<ShapeRecord> shapes;
- std::vector<SPItem*> items=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= sel->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *obj = *i;
if (SP_IS_ITEM(obj)) {
@@ -437,8 +437,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
}
}
+ std::vector<SPItem *> vec(sel->items().begin(), sel->items().end());
_previous_selection = _current_selection;
- _current_selection = sel->itemList();
+ _current_selection = vec;
this->_multipath->setItems(shapes);
this->update_tip(NULL);
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 34ca2926d..86a2dbed3 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -467,7 +467,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
if (!selection->isEmpty()) {
- SPItem *clicked_item = selection->itemList()[0];
+ SPItem *clicked_item = selection->items().front();
if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box
desktop->setCurrentLayer(clicked_item);
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 3fafac2a7..3649008ff 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -13,6 +13,7 @@
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
* Jabiertxo Arraiza <jabier.arraiza@marker.es>
+ * Adrian Boguszewski
*
* Copyright (C) 2009 authors
*
@@ -182,6 +183,7 @@ SprayTool::SprayTool()
}
SprayTool::~SprayTool() {
+ object_set.clear();
this->enableGrDrag(false);
this->style_set_connection.disconnect();
@@ -196,7 +198,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -577,7 +579,7 @@ static bool fit_item(SPDesktop *desktop,
if (selection->isEmpty()) {
return false;
}
- std::vector<SPItem*> const items_selected(selection->itemList());
+ std::vector<SPItem*> const items_selected(selection->items().begin(), selection->items().end());
std::vector<SPItem*> items_down_erased;
for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) {
SPItem *item_down = *i;
@@ -848,7 +850,7 @@ static bool fit_item(SPDesktop *desktop,
}
static bool sp_spray_recursive(SPDesktop *desktop,
- Inkscape::Selection *selection,
+ Inkscape::ObjectSet *set,
SPItem *item,
Geom::Point p,
Geom::Point /*vector*/,
@@ -893,7 +895,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
if (box) {
// convert 3D boxes to ordinary groups before spraying their shapes
item = box3d_convert_to_group(box);
- selection->add(item);
+ set->add(item);
}
}
@@ -982,23 +984,11 @@ static bool sp_spray_recursive(SPDesktop *desktop,
}
#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
} else if (mode == SPRAY_MODE_SINGLE_PATH) {
+ long setSize = boost::distance(set->items());
+ SPItem *parent_item = setSize > 0 ? set->items().front() : nullptr; // Initial object
+ SPItem *unionResult = setSize > 1 ? *(++set->items().begin()) : nullptr; // Previous union
+ SPItem *item_copied = nullptr; // Projected object
- SPItem *parent_item = NULL; // Initial object
- SPItem *item_copied = NULL; // Projected object
- SPItem *unionResult = NULL; // Previous union
-
- int i=1;
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end(); ++it){
- SPItem *item1 = *it;
- if (i == 1) {
- parent_item = item1;
- }
- if (i == 2) {
- unionResult = item1;
- }
- i++;
- }
if (parent_item) {
SPDocument *doc = parent_item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
@@ -1031,13 +1021,13 @@ static bool sp_spray_recursive(SPDesktop *desktop,
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
// Union and duplication
- selection->clear();
- selection->add(item_copied);
+ set->clear();
+ set->add(item_copied);
if (unionResult) { // No need to add the very first item (initialized with NULL).
- selection->add(unionResult);
+ set->add(unionResult);
}
- sp_selected_path_union_skip_undo(selection, selection->desktop());
- selection->add(parent_item);
+ sp_selected_path_union_skip_undo(set);
+ set->add(parent_item);
Inkscape::GC::release(copy);
did = true;
}
@@ -1132,9 +1122,8 @@ static bool sp_spray_recursive(SPDesktop *desktop,
static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
SPDesktop *desktop = tc->desktop;
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty()) {
+ Inkscape::ObjectSet *set = tc->objectSet();
+ if (set->isEmpty()) {
return false;
}
@@ -1156,7 +1145,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
double move_standard_deviation = get_move_standard_deviation(tc);
{
- std::vector<SPItem*> const items(selection->itemList());
+ std::vector<SPItem*> const items(set->items().begin(), set->items().end());
for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
SPItem *item = *i;
@@ -1168,7 +1157,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
SPItem *item = *i;
g_assert(item != NULL);
if (sp_spray_recursive(desktop
- , selection
+ , set
, item
, p, vector
, tc->mode
@@ -1262,6 +1251,11 @@ bool SprayTool::root_handler(GdkEvent* event) {
this->is_dilating = true;
this->has_dilated = false;
+ object_set = *desktop->getSelection();
+ if (mode == SPRAY_MODE_SINGLE_PATH) {
+ desktop->getSelection()->clear();
+ }
+
if(this->is_dilating && event->button.button == 1 && !this->space_panning) {
sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event));
}
@@ -1285,7 +1279,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray."));
@@ -1370,6 +1364,8 @@ bool SprayTool::root_handler(GdkEvent* event) {
SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
break;
case SPRAY_MODE_SINGLE_PATH:
+ sp_selected_path_union_skip_undo(objectSet());
+ desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end());
DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
break;
diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h
index c81110b37..d5504d565 100644
--- a/src/ui/tools/spray-tool.h
+++ b/src/ui/tools/spray-tool.h
@@ -13,6 +13,7 @@
* Vincent MONTAGNE
* Pierre BARBRY-BLOT
* Jabiertxo ARRAIZA
+ * Adrian Boguszewski
*
* Copyright (C) 2009 authors
*
@@ -120,8 +121,14 @@ public:
virtual const std::string& getPrefsPath();
-
void update_cursor(bool /*with_shift*/);
+
+ ObjectSet* objectSet() {
+ return &object_set;
+ }
+
+private:
+ ObjectSet object_set;
};
}
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index f85744744..8a35882b9 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -1051,9 +1051,8 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
item = sp_event_context_find_item (desktop,
Geom::Point(event->button.x, event->button.y), FALSE, FALSE);
- /* fixme: This is not what I want but works for now (Lauris) */
- if (event->type == GDK_KEY_PRESS) {
- item = desktop->getSelection()->itemList().front();
+ if (event->type == GDK_KEY_PRESS && !desktop->getSelection()->isEmpty()) {
+ item = desktop->getSelection()->items().front();
}
ContextMenu* CM = new ContextMenu(desktop, item);
@@ -1127,8 +1126,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p,
SPItem *item = 0;
if (select_under) {
- SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(
- desktop->selection->itemList(), p);
+ auto tmp = desktop->selection->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(vec, p);
item = desktop->getItemAtPoint(p, into_groups, selected_at_point);
if (item == NULL) { // we may have reached bottom, flip over to the top
item = desktop->getItemAtPoint(p, into_groups, NULL);
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index fbf1b2a0b..a0394ecd4 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -141,7 +141,7 @@ void TweakTool::update_cursor (bool with_shift) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -373,9 +373,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) {
GSList *children = NULL;
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- if (dynamic_cast<SPItem *>(static_cast<SPObject *>(child))) {
- children = g_slist_prepend(children, child);
+ for (auto& child: item->children) {
+ if (dynamic_cast<SPItem *>(static_cast<SPObject *>(&child))) {
+ children = g_slist_prepend(children, &child);
}
}
@@ -820,8 +820,8 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
double offset_l = 0;
double offset_h = 0;
SPObject *child_prev = NULL;
- for (SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- SPStop *stop = dynamic_cast<SPStop *>(child);
+ for (auto& child: vector->children) {
+ SPStop *stop = dynamic_cast<SPStop *>(&child);
if (!stop) {
continue;
}
@@ -866,7 +866,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
}
offset_l = offset_h;
- child_prev = child;
+ child_prev = &child;
}
}
@@ -882,8 +882,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
bool did = false;
if (dynamic_cast<SPGroup *>(item)) {
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: item->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
if (sp_tweak_color_recursive (mode, childItem, item_at_point,
fill_goal, do_fill,
@@ -939,9 +939,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
Geom::Affine i2dt = item->i2dt_affine ();
if (style->filter.set && style->getFilter()) {
//cycle through filter primitives
- SPObject *primitive_obj = style->getFilter()->children;
- while (primitive_obj) {
- SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj);
+ for (auto& primitive_obj: style->getFilter()->children) {
+ SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj);
if (primitive) {
//if primitive is gaussianblur
SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive);
@@ -950,7 +949,6 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
blur_now += num * i2dt.descrim(); // sum all blurs in the filter
}
}
- primitive_obj = primitive_obj->next;
}
}
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y];
@@ -1064,8 +1062,8 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point
double move_force = get_move_force(tc);
double color_force = MIN(sqrt(path_force)/20.0, 1);
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end(); ++i){
SPItem *item = *i;
if (is_color_mode (tc->mode)) {
@@ -1173,7 +1171,7 @@ bool TweakTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak."));
diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index 7ee34f3b3..4432a6e09 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -19,6 +19,8 @@
#include "ui/dialog/layer-properties.h"
#include <glibmm/i18n.h>
+#include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include "desktop.h"
@@ -346,27 +348,17 @@ void LayerSelector::_buildSiblingEntries(
unsigned depth, SPObject &parent,
Inkscape::Util::List<SPObject &> hierarchy
) {
- using Inkscape::Util::List;
using Inkscape::Util::rest;
- using Inkscape::Util::reverse_list_in_place;
- using Inkscape::Util::filter_list;
- Inkscape::Util::List<SPObject &> siblings(
- reverse_list_in_place(
- filter_list<SPObject::SiblingIterator>(
- is_layer(_desktop), parent.firstChild(), NULL
- )
- )
- );
+ auto siblings = parent.children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed;
SPObject *layer( hierarchy ? &*hierarchy : NULL );
- while (siblings) {
- _buildEntry(depth, *siblings);
- if ( &*siblings == layer ) {
+ for (auto& sib: siblings) {
+ _buildEntry(depth, sib);
+ if ( &sib == layer ) {
_buildSiblingEntries(depth+1, *layer, rest(hierarchy));
}
- ++siblings;
}
}
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index c8ac20c54..1727660c8 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -118,7 +118,7 @@ ObjectCompositeSettings::_blendBlurValueChanged()
const Glib::ustring blendmode = _fe_cb.get_blend_mode();
//apply created filter to every selected item
- std::vector<SPObject*> sel=_subject->list();
+ std::vector<SPObject*> sel = _subject->list();
for (std::vector<SPObject*>::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) {
if (!SP_IS_ITEM(*i)) {
continue;
diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp
index 811ed2221..a779e6feb 100644
--- a/src/ui/widget/style-subject.cpp
+++ b/src/ui/widget/style-subject.cpp
@@ -54,11 +54,13 @@ Inkscape::Selection *StyleSubject::Selection::_getSelection() const {
}
}
-std::vector<SPObject*> StyleSubject::Selection::list(){
+std::vector<SPObject*> StyleSubject::Selection::list() {
Inkscape::Selection *selection = _getSelection();
- if(selection)
- return selection->list();
- else return std::vector<SPObject*>();
+ if(selection) {
+ return std::vector<SPObject *>(selection->objects().begin(), selection->objects().end());
+ }
+
+ return std::vector<SPObject*>();
}
Geom::OptRect StyleSubject::Selection::getBounds(SPItem::BBoxType type) {