summaryrefslogtreecommitdiffstats
path: root/src/widgets/stroke-style.cpp
diff options
context:
space:
mode:
authorSamuel Buttigieg <sambut1987@gmail.com>2018-11-10 09:06:31 +0000
committerThomas Holder <thomas@thomas-holder.de>2018-11-10 10:11:43 +0000
commit0b954d5cc1a1e398c561c32faf8e198efb860ac6 (patch)
tree9ed614e90217f19d2cf824bd7f79cb504aadd4cd /src/widgets/stroke-style.cpp
parentChage std::cout to g_warning (diff)
downloadinkscape-0b954d5cc1a1e398c561c32faf8e198efb860ac6.tar.gz
inkscape-0b954d5cc1a1e398c561c32faf8e198efb860ac6.zip
Fix Bug #1796261 update markers in groups
Diffstat (limited to 'src/widgets/stroke-style.cpp')
-rwxr-xr-x[-rw-r--r--]src/widgets/stroke-style.cpp64
1 files changed, 42 insertions, 22 deletions
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 21e8068af..d3dfbbe8a 100644..100755
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -495,8 +495,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);
@@ -1211,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<SPObject*> &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.
*/
@@ -1231,15 +1245,19 @@ StrokeStyle::updateAllMarkers(std::vector<SPItem*> const &objects, bool skip_und
}
}
+ auto simplified_list = std::vector<SPObject *>();
+ for (SPItem *item : objects) {
+ buildGroupedItemList(item, simplified_list);
+ }
+
for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) {
MarkerComboBox *combo = static_cast<MarkerComboBox *>(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,
@@ -1254,30 +1272,32 @@ StrokeStyle::updateAllMarkers(std::vector<SPItem*> const &objects, bool skip_und
combo->setDesktop(desktop);
- if (object->style->marker_ptrs[keyloc[i].loc]->value != nullptr && !all_texts) {
- // If the object has this type of markers,
+ for (SPObject *object : simplified_list) {
+ 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);
+ }
}
}