diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp old mode 100644 new mode 100755 index bfa21a9eae40989cbf1f9afb8ac7c50a6b2e7445..db33dccd653b07309d11ede176349e13a650fc33 --- 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); @@ -1209,6 +1207,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 +1244,59 @@ StrokeStyle::updateAllMarkers(std::vector const &objects, bool skip_und } } + auto simplified_list = std::vector(); + for (SPItem *item : objects) { + buildGroupedItemList(item, simplified_list); + } + 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); + } } }