|
Carlos Lopez |
a09598 |
/* === S Y N F I G ========================================================= */
|
|
Carlos Lopez |
a09598 |
/*! \file keyframesetdelta.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 |
**
|
|
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 "keyframesetdelta.h"
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
e18568 |
#include "keyframeset.h"
|
|
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(Action::KeyframeSetDelta);
|
|
Carlos Lopez |
a09598 |
ACTION_SET_NAME(Action::KeyframeSetDelta,"KeyframeSetDelta");
|
|
Carlos Lopez |
a09598 |
ACTION_SET_LOCAL_NAME(Action::KeyframeSetDelta,N_("Set Keyframe Delta"));
|
|
Carlos Lopez |
a09598 |
ACTION_SET_TASK(Action::KeyframeSetDelta,"set");
|
|
Carlos Lopez |
a09598 |
ACTION_SET_CATEGORY(Action::KeyframeSetDelta,Action::CATEGORY_KEYFRAME|Action::CATEGORY_HIDDEN);
|
|
Carlos Lopez |
a09598 |
ACTION_SET_PRIORITY(Action::KeyframeSetDelta,0);
|
|
Carlos Lopez |
a09598 |
ACTION_SET_VERSION(Action::KeyframeSetDelta,"0.0");
|
|
Carlos Lopez |
a09598 |
ACTION_SET_CVS_ID(Action::KeyframeSetDelta,"$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::KeyframeSetDelta::KeyframeSetDelta():
|
|
Carlos Lopez |
a09598 |
delta(0)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
keyframe.set_time(Time::end());
|
|
Carlos Lopez |
a09598 |
set_dirty(false);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
Action::ParamVocab
|
|
Carlos Lopez |
a09598 |
Action::KeyframeSetDelta::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("keyframe",Param::TYPE_KEYFRAME)
|
|
Carlos Lopez |
a09598 |
.set_local_name(_("Keyframe"))
|
|
Carlos Lopez |
a09598 |
);
|
|
Carlos Lopez |
a09598 |
ret.push_back(ParamDesc("delta",Param::TYPE_KEYFRAME)
|
|
Carlos Lopez |
a09598 |
.set_local_name(_("Delta"))
|
|
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::KeyframeSetDelta::is_candidate(const ParamList &x)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
return candidate_check(get_param_vocab(),x);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
bool
|
|
Carlos Lopez |
a09598 |
Action::KeyframeSetDelta::set_param(const synfig::String& name, const Action::Param ¶m)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(name=="keyframe" && param.get_type()==Param::TYPE_KEYFRAME)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
keyframe=param.get_keyframe();
|
|
Carlos Lopez |
a09598 |
return true;
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
if(name=="delta" && param.get_type()==Param::TYPE_TIME)
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
delta=param.get_time();
|
|
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::KeyframeSetDelta::is_ready()const
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
if(keyframe.get_time()==Time::end())
|
|
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::KeyframeSetDelta::prepare()
|
|
Carlos Lopez |
a09598 |
{
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
e18568 |
KeyframeList &list = get_canvas()->keyframe_list();
|
|
![](https://seccdn.libravatar.org/avatar/41f7be7efd9c6a5e79c9949b62f1e9b1c95ddbe097b5368ec4c9383d10210602?d=retro&s=16) |
0589a7 |
KeyframeList::iterator next;
|
|
![](https://seccdn.libravatar.org/avatar/41f7be7efd9c6a5e79c9949b62f1e9b1c95ddbe097b5368ec4c9383d10210602?d=retro&s=16) |
0589a7 |
if (!list.find(keyframe, next)) throw Error(_("Unable to find the given keyframe")); // ???
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
e18568 |
++next;
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
if (next != list.end() && fabs(delta) > 0.00000001)
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
{
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
for(KeyframeList::iterator i = next; i != list.end(); ++i) {
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
Keyframe keyframe(*i);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
keyframe.set_time( keyframe.get_time() + delta );
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
Action::Handle action(KeyframeSet::create());
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
action->set_param("canvas",get_canvas());
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
action->set_param("canvas_interface",get_canvas_interface());
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
action->set_param("keyframe", keyframe);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
assert(action->is_ready());
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
if(!action->is_ready())
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
throw Error(Error::TYPE_NOTREADY);
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
|
|
![](https://seccdn.libravatar.org/avatar/2e5dd0bee1e7e619066117de357c8458fc7e847f4345b0cb8a7a5413aa2a45a0?d=retro&s=16) |
1d69d9 |
if (delta > 0) add_action_front(action); else add_action(action);
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
}
|
|
Carlos Lopez |
a09598 |
}
|