示例#1
0
KeyframeList::iterator
KeyframeList::find(const Time &x)
{
	KeyframeList::iterator iter;
	iter=binary_find(begin(),end(),x);
	if(iter!=end() && iter->get_time().is_equal(x))
		return iter;
/*	iter++;
	if(iter!=end() && iter->get_time().is_equal(x))
		return iter;
*/
	throw Exception::NotFound(strprintf("KeyframeList::find(): Can't find Keyframe %s",x.get_string().c_str()));
}
示例#2
0
void
Action::KeyframeSet::perform()
{
	KeyframeList::iterator iter;
	if (!get_canvas()->keyframe_list().find(keyframe, iter))
		throw Error(_("Unable to find the given keyframe"));
	old_time = iter->get_time();
	new_time=keyframe.get_time();

	// Check for collisions
	KeyframeList::iterator i;
	if (old_time != new_time && get_canvas()->keyframe_list().find(new_time, i))
		throw Error(_("Cannot change keyframe time because another keyframe already exists with that time."));
	keyframe_prev = get_canvas()->keyframe_list().find_prev(old_time, i)
	              ? i->get_time() : Time::begin();
	keyframe_next = get_canvas()->keyframe_list().find_next(old_time, i)
	              ? i->get_time() : Time::end();
	get_canvas()->keyframe_list().find_prev_next(old_time, keyframe_prev, keyframe_next);

	old_keyframe = *iter;
	*iter = keyframe;
	get_canvas()->keyframe_list().sync();

	try {
		Action::Super::perform();
	} catch(...) {
		if (get_canvas()->keyframe_list().find(old_keyframe, iter)) {
			*iter = old_keyframe;
			get_canvas()->keyframe_list().sync();
		}
		throw;
	}

	// Signal that a keyframe was changed
	if (get_canvas_interface())
		get_canvas_interface()->signal_keyframe_changed()(keyframe);
	else
		synfig::warning("CanvasInterface not set on action");
}