1 /* === S Y N F I G ========================================================= */
2 /*! \file action_layerremove.cpp
3 ** \brief Template File
5 ** $Id: groupremovelayers.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "groupremovelayers.h"
32 #include <synfigapp/canvasinterface.h>
38 using namespace synfig;
39 using namespace synfigapp;
40 using namespace Action;
42 /* === M A C R O S ========================================================= */
44 ACTION_INIT(Action::GroupRemoveLayers);
45 ACTION_SET_NAME(Action::GroupRemoveLayers,"group_remove_layers");
46 ACTION_SET_LOCAL_NAME(Action::GroupRemoveLayers,"Remove Layers from a Group");
47 ACTION_SET_TASK(Action::GroupRemoveLayers,"remove");
48 ACTION_SET_CATEGORY(Action::GroupRemoveLayers,Action::CATEGORY_LAYER|Action::CATEGORY_GROUP);
49 ACTION_SET_PRIORITY(Action::GroupRemoveLayers,0);
50 ACTION_SET_VERSION(Action::GroupRemoveLayers,"0.0");
51 ACTION_SET_CVS_ID(Action::GroupRemoveLayers,"$Id: groupremovelayers.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Action::GroupRemoveLayers::GroupRemoveLayers()
64 Action::GroupRemoveLayers::get_param_vocab()
66 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
68 ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
69 .set_local_name(_("Layer"))
70 .set_desc(_("Layer to be added to group"))
71 .set_supports_multiple()
74 ret.push_back(ParamDesc("group",Param::TYPE_STRING)
75 .set_local_name(_("Group"))
76 .set_desc(_("Name of the Group to add the Layers to"))
84 Action::GroupRemoveLayers::is_canidate(const ParamList &x)
86 return canidate_check(get_param_vocab(),x);
90 Action::GroupRemoveLayers::set_param(const synfig::String& name, const Action::Param ¶m)
92 if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
94 std::pair<synfig::Layer::Handle,String> layer_pair;
95 layer_pair.first=param.get_layer();
96 layer_list.push_back(layer_pair);
101 if(name=="group" && param.get_type()==Param::TYPE_STRING)
103 group=param.get_string();
108 return Action::CanvasSpecific::set_param(name,param);
112 Action::GroupRemoveLayers::is_ready()const
114 if(layer_list.empty() || group.empty())
116 return Action::CanvasSpecific::is_ready();
120 Action::GroupRemoveLayers::perform()
122 std::list<std::pair<synfig::Layer::Handle,String> >::iterator iter;
123 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
125 Layer::Handle layer(iter->first);
126 iter->second=layer->get_group();
128 layer->remove_from_group(group);
133 Action::GroupRemoveLayers::undo()
135 std::list<std::pair<synfig::Layer::Handle,String> >::iterator iter;
136 for(iter=layer_list.begin();iter!=layer_list.end();++iter)
138 Layer::Handle layer(iter->first);
140 layer->add_to_group(iter->second);