From adedc03ddd123a9aa28fff28930ee57a769fa4f8 Mon Sep 17 00:00:00 2001 From: speare Date: Tue, 10 Mar 2009 02:43:40 +0000 Subject: [PATCH] Edit > Duplicate Layer should duplicate hidden items, locked items, sublayers, everything --- src/verbs.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/verbs.cpp b/src/verbs.cpp index 5e911552c..06abe9369 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1227,19 +1227,38 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) } 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. + Inkscape::XML::Node *selected = dt->currentLayer()->repr; + Inkscape::XML::Node *parent = sp_repr_parent(selected); + 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_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, _("Duplicate layer")); -- 2.30.2