From cc2006747c97d56815cf1111ee4e3d511ed61ea8 Mon Sep 17 00:00:00 2001 From: samuel Date: Thu, 8 Nov 2018 19:40:39 +0100 Subject: [PATCH 1/4] Fix Bug #1796261 --- src/widgets/stroke-style.cpp | 85 ++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 29 deletions(-) mode change 100644 => 100755 src/widgets/stroke-style.cpp diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp old mode 100644 new mode 100755 index bfa21a9eae..db01a7e2cd --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -1209,6 +1209,22 @@ StrokeStyle::setPaintOrderButtons(Gtk::ToggleButton *active) } +/** + * Recursively builds a simple list from an arbitrarily complex selection + * of items and grouped items + */ +static void buildGroupedItemList(SPObject *element, std::vector &simple_list) +{ + if (SP_IS_GROUP(element)) { + for (SPObject *i = element->firstChild(); i; i = i->getNext()) { + buildGroupedItemList(i, simple_list); + } + } else { + simple_list.push_back(element); + } +} + + /** * Updates the marker combobox to highlight the appropriate marker and scroll to * that marker. @@ -1230,53 +1246,64 @@ StrokeStyle::updateAllMarkers(std::vector const &objects, bool skip_und } } + auto simplified_list = std::vector(); + for (SPItem *item : objects) { + SPObject *o = SP_OBJECT (item); + if (SP_IS_GROUP(o)) { + buildGroupedItemList(o, simplified_list); + } else { + simplified_list.push_back(o); + } + } + for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { MarkerComboBox *combo = static_cast(keyloc[i].key); // Per SVG spec, text objects cannot have markers; disable combobox if only texts are selected combo->set_sensitive(!all_texts); } - // We show markers of the first object in the list only + // We show markers of the last object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = objects[0]; - for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { - // For all three marker types, + for (SPObject *object : simplified_list) { + for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { + // For all three marker types, - // find the corresponding combobox item - MarkerComboBox *combo = static_cast(keyloc[i].key); + // find the corresponding combobox item + MarkerComboBox *combo = static_cast(keyloc[i].key); - // Quit if we're in update state - if (combo->update()) { - return; - } + // Quit if we're in update state + if (combo->update()) { + return; + } - combo->setDesktop(desktop); + combo->setDesktop(desktop); - if (object->style->marker_ptrs[keyloc[i].loc]->value != nullptr && !all_texts) { - // If the object has this type of markers, + if (object->style->marker_ptrs[keyloc[i].loc]->value != nullptr && !all_texts) { + // If the object has this type of markers, - // Extract the name of the marker that the object uses - SPObject *marker = getMarkerObj(object->style->marker_ptrs[keyloc[i].loc]->value, object->document); - // Scroll the combobox to that marker - combo->set_current(marker); + // Extract the name of the marker that the object uses + SPObject *marker = getMarkerObj(object->style->marker_ptrs[keyloc[i].loc]->value, object->document); + // Scroll the combobox to that marker + combo->set_current(marker); - // Set the marker color - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gboolean update = prefs->getBool("/options/markers/colorUpdateMarkers", true); + // Set the marker color + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gboolean update = prefs->getBool("/options/markers/colorUpdateMarkers", true); - if (update) { - setMarkerColor(marker, combo->get_loc(), SP_ITEM(object)); + if (update) { + setMarkerColor(marker, combo->get_loc(), SP_ITEM(object)); - if (!skip_undo) { - SPDocument *document = desktop->getDocument(); - DocumentUndo::maybeDone(document, "UaM", SP_VERB_DIALOG_FILL_STROKE, - _("Set marker color")); + if (!skip_undo) { + SPDocument *document = desktop->getDocument(); + DocumentUndo::maybeDone(document, "UaM", SP_VERB_DIALOG_FILL_STROKE, + _("Set marker color")); + } } - } - } else { - combo->set_current(nullptr); + } else { + combo->set_current(nullptr); + } } } -- GitLab From 916b185c3044ddb4e31f5a3af9782bde56a7d703 Mon Sep 17 00:00:00 2001 From: Samuel Buttigieg Date: Thu, 8 Nov 2018 18:50:21 +0000 Subject: [PATCH 2/4] Update stroke-style.cpp --- src/widgets/stroke-style.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index db01a7e2cd..9d61d42421 100755 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -494,8 +494,6 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, Inkscape::XML::Node *selrepr = item->getRepr(); if (selrepr) { sp_repr_css_change_recursive(selrepr, css, "style"); - SPObject *markerObj = getMarkerObj(marker, document); - spw->setMarkerColor(markerObj, marker_combo->get_loc(), item); } item->requestModified(SP_OBJECT_MODIFIED_FLAG); -- GitLab From 2e15f8adb4213c8784a67a6fe42f35bcae720f26 Mon Sep 17 00:00:00 2001 From: Samuel Buttigieg Date: Fri, 9 Nov 2018 18:14:29 +0000 Subject: [PATCH 3/4] Update stroke-style.cpp --- src/widgets/stroke-style.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 9d61d42421..f8bda7801d 100755 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -1246,13 +1246,8 @@ StrokeStyle::updateAllMarkers(std::vector const &objects, bool skip_und auto simplified_list = std::vector(); for (SPItem *item : objects) { - SPObject *o = SP_OBJECT (item); - if (SP_IS_GROUP(o)) { - buildGroupedItemList(o, simplified_list); - } else { - simplified_list.push_back(o); - } - } + buildGroupedItemList(o, simplified_list); + } for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { MarkerComboBox *combo = static_cast(keyloc[i].key); -- GitLab From d9a367aff69d17e672b9e0fdf48c3e3829439ba2 Mon Sep 17 00:00:00 2001 From: Samuel Buttigieg Date: Fri, 9 Nov 2018 18:16:13 +0000 Subject: [PATCH 4/4] Update stroke-style.cpp --- src/widgets/stroke-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index f8bda7801d..db33dccd65 100755 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -1246,7 +1246,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects, bool skip_und auto simplified_list = std::vector(); for (SPItem *item : objects) { - buildGroupedItemList(o, simplified_list); + buildGroupedItemList(item, simplified_list); } for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { -- GitLab