1 /* === S Y N F I G ========================================================= */
2 /*! \file layerraise.cpp
3 ** \brief Template File
5 ** $Id: layerraise.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "layerraise.h"
33 #include "layermove.h"
34 #include <synfigapp/canvasinterface.h>
40 using namespace synfig;
41 using namespace synfigapp;
42 using namespace Action;
44 /* === M A C R O S ========================================================= */
46 ACTION_INIT(Action::LayerRaise);
47 ACTION_SET_NAME(Action::LayerRaise,"layer_raise");
48 ACTION_SET_LOCAL_NAME(Action::LayerRaise,"Raise Layer");
49 ACTION_SET_TASK(Action::LayerRaise,"raise");
50 ACTION_SET_CATEGORY(Action::LayerRaise,Action::CATEGORY_LAYER);
51 ACTION_SET_PRIORITY(Action::LayerRaise,9);
52 ACTION_SET_VERSION(Action::LayerRaise,"0.0");
53 ACTION_SET_CVS_ID(Action::LayerRaise,"$Id: layerraise.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
55 /* === G L O B A L S ======================================================= */
57 /* === P R O C E D U R E S ================================================= */
59 /* === M E T H O D S ======================================================= */
61 Action::LayerRaise::LayerRaise()
66 Action::LayerRaise::get_param_vocab()
68 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
70 ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
71 .set_local_name(_("Layer"))
72 .set_desc(_("Layer to be raised"))
73 .set_supports_multiple()
80 Action::LayerRaise::is_candidate(const ParamList &x)
82 if(!candidate_check(get_param_vocab(),x))
84 if(x.find("layer")->second.get_layer()->get_depth()==0)
90 Action::LayerRaise::set_param(const synfig::String& name, const Action::Param ¶m)
92 if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
94 layers.push_back(param.get_layer());
99 return Action::CanvasSpecific::set_param(name,param);
103 Action::LayerRaise::is_ready()const
107 return Action::CanvasSpecific::is_ready();
111 Action::LayerRaise::prepare()
113 std::list<synfig::Layer::Handle>::reverse_iterator iter;
117 for(iter=layers.rbegin();!(iter==layers.rend());++iter)
119 Layer::Handle layer(*iter);
121 Canvas::Handle subcanvas(layer->get_canvas());
123 // Find the iterator for the layer
124 Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
126 // If we couldn't find the layer in the canvas, then bail
128 throw Error(_("This layer doesn't exist anymore."));
130 // If the subcanvas isn't the same as the canvas,
131 // then it had better be an inline canvas. If not,
133 //if(get_canvas()!=subcanvas && !subcanvas->is_inline())
134 // throw Error(_("This layer doesn't belong to this canvas anymore"));
136 int new_index=iter-subcanvas->begin();
143 Action::Handle layer_move(LayerMove::create());
145 layer_move->set_param("canvas",get_canvas());
146 layer_move->set_param("canvas_interface",get_canvas_interface());
147 layer_move->set_param("layer",layer);
148 layer_move->set_param("new_index",new_index);
150 add_action_front(layer_move);