X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Factions%2Flayerduplicate.cpp;h=c3e21df130cb57ae7ea8a5f858d0ca055708e03f;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=6036b920dd16615f6ad0c6bdedf859670ef47932;hpb=8ef042c40521681cea99944097c4f90a5ac6cf74;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/actions/layerduplicate.cpp b/synfig-studio/trunk/src/synfigapp/actions/layerduplicate.cpp index 6036b92..c3e21df 100644 --- a/synfig-studio/trunk/src/synfigapp/actions/layerduplicate.cpp +++ b/synfig-studio/trunk/src/synfigapp/actions/layerduplicate.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -31,6 +32,7 @@ #include "layerduplicate.h" #include "layeradd.h" +#include #include #include @@ -45,8 +47,8 @@ using namespace Action; /* === M A C R O S ========================================================= */ -ACTION_INIT(Action::LayerDuplicate); -ACTION_SET_NAME(Action::LayerDuplicate,"layer_duplicate"); +ACTION_INIT_NO_GET_LOCAL_NAME(Action::LayerDuplicate); +ACTION_SET_NAME(Action::LayerDuplicate,"LayerDuplicate"); ACTION_SET_LOCAL_NAME(Action::LayerDuplicate,N_("Duplicate Layer")); ACTION_SET_TASK(Action::LayerDuplicate,"duplicate"); ACTION_SET_CATEGORY(Action::LayerDuplicate,Action::CATEGORY_LAYER); @@ -64,6 +66,12 @@ Action::LayerDuplicate::LayerDuplicate() { } +synfig::String +Action::LayerDuplicate::get_local_name()const +{ + return get_layer_descriptions(layers, _("Duplicate Layer"), _("Duplicate Layers")); +} + Action::ParamVocab Action::LayerDuplicate::get_param_vocab() { @@ -135,7 +143,7 @@ Action::LayerDuplicate::prepare() Layer::Handle new_layer(layer->clone(guid)); { - Action::Handle action(Action::create("layer_move")); + Action::Handle action(Action::create("LayerMove")); action->set_param("canvas",subcanvas); action->set_param("canvas_interface",get_canvas_interface()); @@ -145,7 +153,7 @@ Action::LayerDuplicate::prepare() add_action_front(action); } { - Action::Handle action(Action::create("layer_add")); + Action::Handle action(Action::create("LayerAdd")); action->set_param("canvas",subcanvas); action->set_param("canvas_interface",get_canvas_interface()); @@ -153,5 +161,62 @@ Action::LayerDuplicate::prepare() add_action_front(action); } + + // automatically export the Index parameter of Duplicate layers when duplicating + int index = 1; + export_dup_nodes(new_layer, subcanvas, index); + } +} + +void +Action::LayerDuplicate::export_dup_nodes(synfig::Layer::Handle layer, Canvas::Handle canvas, int &index) +{ + // automatically export the Index parameter of Duplicate layers when duplicating + if (layer->get_name() == "duplicate") + while (true) + { + String name = strprintf(_("Index %d"), index++); + try + { + canvas->find_value_node(name); + } + catch (Exception::IDNotFound x) + { + Action::Handle action(Action::create("ValueNodeAdd")); + + action->set_param("canvas",canvas); + action->set_param("canvas_interface",get_canvas_interface()); + action->set_param("new",layer->dynamic_param_list().find("index")->second); + action->set_param("name",name); + + add_action_front(action); + + break; + } + } + else + { + Layer::ParamList param_list(layer->get_param_list()); + for (Layer::ParamList::const_iterator iter(param_list.begin()) + ; iter != param_list.end() + ; iter++) + if (layer->dynamic_param_list().count(iter->first)==0 && iter->second.get_type()==ValueBase::TYPE_CANVAS) + { + Canvas::Handle subcanvas(iter->second.get(Canvas::Handle())); + if (subcanvas && subcanvas->is_inline()) + for (Context iter = subcanvas->get_context(); iter != subcanvas->end(); iter++) + export_dup_nodes(*iter, canvas, index); + } + + for (Layer::DynamicParamList::const_iterator iter(layer->dynamic_param_list().begin()) + ; iter != layer->dynamic_param_list().end() + ; iter++) + if (iter->second->get_type()==ValueBase::TYPE_CANVAS) + { + Canvas::Handle canvas((*iter->second)(0).get(Canvas::Handle())); + if (canvas->is_inline()) + //! \todo do we need to implement this? and if so, shouldn't we check all canvases, not just the one at t=0s? + warning("%s:%d not yet implemented - do we need to export duplicate valuenodes in dynamic canvas parameters?", __FILE__, __LINE__); + } } }