diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2015-05-09 12:59:00 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2015-05-09 12:59:00 +0000 |
| commit | 9b1d6715ff2a56c9f1b94c0f8474c3e4efd48539 (patch) | |
| tree | 79f7fb25fb74141a6c1c9d9fccf2ae4c718a9d0c /src | |
| parent | fix crash introduces by recent rev when clipping (diff) | |
| download | inkscape-9b1d6715ff2a56c9f1b94c0f8474c3e4efd48539.tar.gz inkscape-9b1d6715ff2a56c9f1b94c0f8474c3e4efd48539.zip | |
duplicating layers now respect prefs for clone relinking
Fixed bugs:
- https://launchpad.net/bugs/267565
(bzr r14134)
Diffstat (limited to 'src')
| -rw-r--r-- | src/selection-chemistry.cpp | 25 | ||||
| -rw-r--r-- | src/selection-chemistry.h | 2 | ||||
| -rw-r--r-- | src/verbs.cpp | 36 |
3 files changed, 24 insertions, 39 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index a21a82983..d6e9a1e32 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -107,6 +107,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "live_effects/effect.h" #include "live_effects/effect-enum.h" #include "live_effects/parameter/originalpath.h" +#include "layer-manager.h" #include "enums.h" #include "sp-item-group.h" @@ -438,7 +439,7 @@ static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj) } } -void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) +void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicateLayer) { if (desktop == NULL) { return; @@ -449,12 +450,17 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty()) { + if (selection->isEmpty() && !duplicateLayer) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate.")); return; } std::vector<Inkscape::XML::Node*> reprs(selection->reprList()); + if(duplicateLayer){ + reprs.clear(); + reprs.push_back(desktop->currentLayer()->getRepr()); + } + selection->clear(); // sorting items from different parents sorts each parent's subset without possibly mixing @@ -474,7 +480,10 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); - parent->appendChild(copy); + if(! duplicateLayer) + parent->appendChild(copy); + else + parent->addChild(copy, old_repr); if (relink_clones) { SPObject *old_obj = doc->getObjectByRepr(old_repr); @@ -535,8 +544,14 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DUPLICATE, _("Duplicate")); } - - selection->setReprList(newsel); + if(!duplicateLayer) + selection->setReprList(newsel); + else{ + SPObject* new_layer = doc->getObjectByRepr(newsel[0]); + gchar* name = g_strdup_printf(_("%s copy"), new_layer->label()); + desktop->layer_manager->renameLayer( new_layer, name, TRUE ); + g_free(name); + } } void sp_edit_clear_all(Inkscape::Selection *selection) diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 8bcab664b..5bcc5b1ea 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -52,7 +52,7 @@ namespace LivePathEffect { } // namespace Inkscape void sp_selection_delete(SPDesktop *desktop); -void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone = false); +void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone = false, bool duplicateLayer = false); void sp_edit_clear_all(Inkscape::Selection *selection); void sp_edit_select_all(SPDesktop *desktop); diff --git a/src/verbs.cpp b/src/verbs.cpp index ea2c06dcf..e0ef27b0d 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1350,39 +1350,9 @@ void LayerVerb::perform(SPAction *action, void *data) } case SP_VERB_LAYER_DUPLICATE: { if ( dt->currentLayer() != dt->currentRoot() ) { - // Note with either approach: - // Any clone masters are duplicated, their clones use the *original*, - // but the duplicated master is not linked up as master nor clone of the original. -#if 0 - // Only copies selectable things, honoring locks, visibility, avoids sublayers. - SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), LPOS_BELOW); - if ( dt->currentLayer()->label() ) { - gchar* name = g_strdup_printf(_("%s copy"), dt->currentLayer()->label()); - dt->layer_manager->renameLayer( new_layer, name, TRUE ); - g_free(name); - } - sp_edit_select_all(dt); - sp_selection_duplicate(dt, true); - sp_selection_to_prev_layer(dt, true); - dt->setCurrentLayer(new_layer); - sp_edit_select_all(dt); -#else - // Copies everything, regardless of locks, visibility, sublayers. - //XML Tree being directly used here while it shouldn't be. - Inkscape::XML::Node *selected = dt->currentLayer()->getRepr(); - Inkscape::XML::Node *parent = selected->parent(); - Inkscape::XML::Node *dup = selected->duplicate(parent->document()); - parent->addChild(dup, selected); - SPObject *new_layer = dt->currentLayer()->next; - if (new_layer) { - if (new_layer->label()) { - gchar* name = g_strdup_printf(_("%s copy"), new_layer->label()); - dt->layer_manager->renameLayer( new_layer, name, TRUE ); - g_free(name); - } - dt->setCurrentLayer(new_layer); - } -#endif + + sp_selection_duplicate(dt, true, true); + DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_DUPLICATE, _("Duplicate layer")); |
