|
Carlos Lopez |
a09598 |
/* === S Y N F I G ========================================================= */
|
|
Carlos Lopez |
a09598 |
/*! \file layerlower.cpp
|
|
Carlos Lopez |
a09598 |
** \brief Template File
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** $Id$
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** \legal
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2008 Chris Moore
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** This package is free software; you can redistribute it and/or
|
|
Carlos Lopez |
a09598 |
** modify it under the terms of the GNU General Public License as
|
|
Carlos Lopez |
a09598 |
** published by the Free Software Foundation; either version 2 of
|
|
Carlos Lopez |
a09598 |
** the License, or (at your option) any later version.
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** This package is distributed in the hope that it will be useful,
|
|
Carlos Lopez |
a09598 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Carlos Lopez |
a09598 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Carlos Lopez |
a09598 |
** General Public License for more details.
|
|
Carlos Lopez |
a09598 |
** \endlegal
|
|
Carlos Lopez |
a09598 |
*/
|
|
Carlos Lopez |
a09598 |
/* ========================================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === H E A D E R S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#ifdef USING_PCH
|
|
Carlos Lopez |
a09598 |
# include "pch.h"
|
|
Carlos Lopez |
a09598 |
#else
|
|
Carlos Lopez |
a09598 |
#ifdef HAVE_CONFIG_H
|
|
Carlos Lopez |
a09598 |
# include <config.h></config.h>
|
|
Carlos Lopez |
a09598 |
#endif
|
|
Carlos Lopez |
a09598 |
|
|
bw |
94d8a6 |
#include <synfig general.h=""></synfig>
|
|
bw |
94d8a6 |
|
|
Carlos Lopez |
a09598 |
#include "layerlower.h"
|
|
Carlos Lopez |
a09598 |
#include "layermove.h"
|
|
Carlos Lopez |
a09598 |
#include <synfigapp canvasinterface.h=""></synfigapp>
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
abdbf2 |
#include <synfigapp localization.h=""></synfigapp>
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#endif
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
using namespace std;
|
|
Carlos Lopez |
a09598 |
using namespace etl;
|
|
Carlos Lopez |
a09598 |
using namespace synfig;
|
|
Carlos Lopez |
a09598 |
using namespace synfigapp;
|
|
Carlos Lopez |
a09598 |
using namespace Action;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === M A C R O S ========================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
ACTION_INIT_NO_GET_LOCAL_NAME(Action::LayerLower);
|
|
Carlos Lopez |
a09598 |
ACTION_SET_NAME(Action::LayerLower,"LayerLower");
|
|
Carlos Lopez |
a09598 |
ACTION_SET_LOCAL_NAME(Action::LayerLower,N_("Lower Layer"));
|
|
Carlos Lopez |
a09598 |
ACTION_SET_TASK(Action::LayerLower,"lower");
|
|
Carlos Lopez |
a09598 |
ACTION_SET_CATEGORY(Action::LayerLower,Action::CATEGORY_LAYER);
|
|
Carlos Lopez |
a09598 |
ACTION_SET_PRIORITY(Action::LayerLower,10);
|
|
Carlos Lopez |
a09598 |
ACTION_SET_VERSION(Action::LayerLower,"0.0");
|
|
Carlos Lopez |
a09598 |
ACTION_SET_CVS_ID(Action::LayerLower,"$Id$");
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === G L O B A L S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === P R O C E D U R E S ================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === M E T H O D S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::LayerLower()
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
synfig::String
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::get_local_name()const
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
return get_layer_descriptions(layers, _("Lower Layer"), _("Lower Layers"));
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Action::ParamVocab
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::get_param_vocab()
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
|
|
Carlos Lopez |
a09598 |
.set_local_name(_("Layer"))
|
|
Carlos Lopez |
a09598 |
.set_desc(_("Layer to be lowered"))
|
|
Carlos Lopez |
a09598 |
.set_supports_multiple()
|
|
Carlos Lopez |
a09598 |
);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
return ret;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
bool
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::is_candidate(const ParamList &x)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(!candidate_check(get_param_vocab(),x))
|
|
Carlos Lopez |
a09598 |
return false;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Layer::Handle layer(x.find("layer")->second.get_layer());
|
|
Carlos Lopez |
a09598 |
//synfig::info("layer->get_depth()= %d ; layer->get_canvas()->size()=%d ;",layer->get_depth(),layer->get_canvas()->size());
|
|
Carlos Lopez |
a09598 |
if(layer->get_depth()+1>=layer->get_canvas()->size())
|
|
Carlos Lopez |
a09598 |
return false;
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
bool
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::set_param(const synfig::String& name, const Action::Param ¶m)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
layers.push_back(param.get_layer());
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
return Action::CanvasSpecific::set_param(name,param);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
bool
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::is_ready()const
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(layers.empty())
|
|
Carlos Lopez |
a09598 |
return false;
|
|
Carlos Lopez |
a09598 |
return Action::CanvasSpecific::is_ready();
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
void
|
|
Carlos Lopez |
a09598 |
Action::LayerLower::prepare()
|
|
Carlos Lopez |
a09598 |
{
|
|
![](https://seccdn.libravatar.org/avatar/41f7be7efd9c6a5e79c9949b62f1e9b1c95ddbe097b5368ec4c9383d10210602?d=retro&s=16) |
cfd415 |
std::list<synfig::layer::handle>::const_iterator i;</synfig::layer::handle>
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
clear();
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/41f7be7efd9c6a5e79c9949b62f1e9b1c95ddbe097b5368ec4c9383d10210602?d=retro&s=16) |
cfd415 |
for(i=layers.begin();i!=layers.end();++i)
|
|
Carlos Lopez |
a09598 |
{
|
|
![](https://seccdn.libravatar.org/avatar/41f7be7efd9c6a5e79c9949b62f1e9b1c95ddbe097b5368ec4c9383d10210602?d=retro&s=16) |
cfd415 |
Layer::Handle layer(*i);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Canvas::Handle subcanvas(layer->get_canvas());
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
b98a79 |
// Find the index of the layer
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
b98a79 |
int new_index = -1;
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
b98a79 |
Canvas::iterator iter = subcanvas->find_index(layer, new_index);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// If we couldn't find the layer in the canvas, then bail
|
|
Carlos Lopez |
a09598 |
if(*iter!=layer)
|
|
Carlos Lopez |
a09598 |
throw Error(_("This layer doesn't exist anymore."));
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// If the subcanvas isn't the same as the canvas,
|
|
Carlos Lopez |
a09598 |
// then it had better be an inline canvas. If not,
|
|
Carlos Lopez |
a09598 |
// bail
|
|
Carlos Lopez |
a09598 |
//if(get_canvas()!=subcanvas && !subcanvas->is_inline())
|
|
Carlos Lopez |
a09598 |
// throw Error(_("This layer doesn't belong to this canvas anymore"));
|
|
Carlos Lopez |
a09598 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
b98a79 |
++iter;
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
b98a79 |
++new_index;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
// If this lowers the layer past the bottom then don't bother
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
b98a79 |
if(iter == subcanvas->end())
|
|
Carlos Lopez |
a09598 |
continue;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Action::Handle layer_move(LayerMove::create());
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
layer_move->set_param("canvas",get_canvas());
|
|
Carlos Lopez |
a09598 |
layer_move->set_param("canvas_interface",get_canvas_interface());
|
|
Carlos Lopez |
a09598 |
layer_move->set_param("layer",layer);
|
|
Carlos Lopez |
a09598 |
layer_move->set_param("new_index",new_index);
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
add_action_front(layer_move);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
}
|