1 /* === S Y N F I G ========================================================= */
2 /*! \file canvasinterface.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
36 #include <synfig/valuenode_scale.h>
37 #include <synfig/valuenode_timedswap.h>
38 #include <synfig/valuenode_composite.h>
39 #include <synfig/valuenode_subtract.h>
40 #include <synfig/valuenode_linear.h>
41 #include <synfig/valuenode_reference.h>
42 #include <synfig/valuenode_twotone.h>
43 #include <synfig/valuenode_stripes.h>
44 #include <synfig/valuenode_bline.h>
46 #include <synfig/waypoint.h>
47 #include <synfig/loadcanvas.h>
48 #include <synfig/importer.h>
49 #include <synfig/guidset.h>
51 #include "canvasinterface.h"
54 #include "actions/layeradd.h"
55 #include "actions/valuedescconvert.h"
56 #include "actions/valuenodeadd.h"
57 #include "actions/editmodeset.h"
58 #include "action_system.h"
62 #include <synfig/gradient.h>
68 /* === U S I N G =========================================================== */
72 using namespace synfig;
73 using namespace synfigapp;
75 /* === M A C R O S ========================================================= */
77 /* === G L O B A L S ======================================================= */
79 /* === P R O C E D U R E S ================================================= */
81 /* === M E T H O D S ======================================================= */
83 CanvasInterface::CanvasInterface(etl::loose_handle<Instance> instance,etl::handle<synfig::Canvas> canvas):
86 cur_time_(canvas->rend_desc().get_frame_start()),
87 mode_(MODE_NORMAL|MODE_ANIMATE_PAST|MODE_ANIMATE_FUTURE)
89 set_selection_manager(get_instance()->get_selection_manager());
90 set_ui_interface(get_instance()->get_ui_interface());
93 CanvasInterface::~CanvasInterface()
95 if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
96 synfig::info("CanvasInterface::~CanvasInterface(): Deleted");
100 CanvasInterface::set_time(synfig::Time x)
102 if(get_canvas()->rend_desc().get_frame_rate())
104 float fps(get_canvas()->rend_desc().get_frame_rate());
105 Time r(x.round(fps));
106 //synfig::info("CanvasInterface::set_time(): %s rounded to %s\n",x.get_string(fps).c_str(),r.get_string(fps).c_str());
109 if(cur_time_.is_equal(x))
111 get_canvas()->set_time(cur_time_=x);
113 // update the time in all the child canvases
114 Canvas::Children children = get_canvas()->get_root()->children();
115 handle<CanvasInterface> interface;
116 for (Canvas::Children::iterator iter = children.begin(); iter != children.end(); iter++)
117 if ((interface = get_instance()->find_canvas_interface(*iter)) != this)
118 interface->set_time(interface->get_canvas()->get_time());
120 signal_time_changed()();
121 signal_dirty_preview()();
125 CanvasInterface::get_time()const
131 CanvasInterface::refresh_current_values()
133 get_canvas()->set_time(cur_time_);
134 signal_time_changed()();
135 signal_dirty_preview()();
138 etl::handle<CanvasInterface>
139 CanvasInterface::create(etl::loose_handle<Instance> instance, etl::handle<synfig::Canvas> canvas)
141 etl::handle<CanvasInterface> intrfc;
142 intrfc=new CanvasInterface(instance,canvas);
143 instance->canvas_interface_list().push_front(intrfc);
148 CanvasInterface::set_mode(Mode x)
150 Action::Handle action(Action::EditModeSet::create());
154 action->set_param("canvas",get_canvas());
155 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
156 action->set_param("edit_mode",x);
158 if(!action->is_ready())
160 get_ui_interface()->error(_("Action Not Ready, unable to change mode"));
165 if(!get_instance()->perform_action(action))
166 get_ui_interface()->error(_("Unable to change mode"));
169 // signal_mode_changed_(x);
172 CanvasInterface::Mode
173 CanvasInterface::get_mode()const
181 CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas, int depth)
183 synfigapp::Action::PassiveGrouper group(get_instance().get(),_("Add Layer To"));
185 Layer::Handle layer(Layer::create(name));
192 if(canvas!=get_canvas() && !canvas->is_inline())
194 synfig::error("Bad canvas passed to \"add_layer_to\"");
198 // automatically export the Index parameter of new Duplicate layers
199 if (name == "duplicate")
200 for (int i = 1; ; i++)
202 String name = strprintf(_("Index %d"), i);
205 canvas->find_value_node(name);
207 catch (Exception::IDNotFound x)
209 add_value_node(layer->dynamic_param_list().find("index")->second, name);
214 layer->set_canvas(canvas);
216 // Apply some defaults
217 if(layer->set_param("fg",synfigapp::Main::get_foreground_color()))
218 layer->set_param("bg",synfigapp::Main::get_background_color());
220 layer->set_param("color",synfigapp::Main::get_foreground_color());
222 layer->set_param("width",synfigapp::Main::get_bline_width().units(get_canvas()->rend_desc()));
223 layer->set_param("gradient",synfigapp::Main::get_gradient());
225 layer->set_param("amount",synfigapp::Main::get_opacity());
226 layer->set_param("blend_method",synfigapp::Main::get_blend_method());
229 // Grab the layer's list of parameters
230 Layer::ParamList paramlist=layer->get_param_list();
231 Layer::ParamList::iterator iter;
233 // loop through the static parameters
234 for(iter=paramlist.begin();iter!=paramlist.end();++iter)
236 ValueNode::Handle value_node;
238 // if we find any which are list values then make them
239 // into dynamic list valuenodes, unless every element of
240 // the list is a blinepoint, in which case convert it to a
242 if(iter->second.get_type()==ValueBase::TYPE_LIST)
244 // check whether it's a list of blinepoints only
245 vector<ValueBase> list(iter->second.get_list());
248 vector<ValueBase>::iterator iter2;
249 for (iter2 = list.begin(); iter2 != list.end(); iter2++)
250 if (iter2->get_type() != ValueBase::TYPE_BLINEPOINT)
252 if (iter2 == list.end())
254 value_node=LinkableValueNode::create("bline",iter->second);
255 ValueNode_BLine::Handle::cast_dynamic(value_node)->set_member_canvas(canvas);
260 value_node=LinkableValueNode::create("dynamic_list",iter->second);
262 // otherwise, if it's a type that can be converted to
263 // 'composite' (other than the types that can be radial
264 // composite) then do so
265 else if(LinkableValueNode::check_type("composite",iter->second.get_type()) &&
266 (iter->second.get_type()!=ValueBase::TYPE_COLOR &&
267 iter->second.get_type()!=ValueBase::TYPE_VECTOR))
268 value_node=LinkableValueNode::create("composite",iter->second);
271 layer->connect_dynamic_param(iter->first,value_node);
275 // Action to add the layer
276 Action::Handle action(Action::LayerAdd::create());
282 action->set_param("canvas",canvas);
283 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
284 action->set_param("new",layer);
286 if(!action->is_ready())
288 get_ui_interface()->error(_("Action Not Ready"));
292 if(!get_instance()->perform_action(action))
294 get_ui_interface()->error(_("Action Failed."));
298 // synfig::info("DEPTH=%d",depth);
300 // Action to move the layer (if necessary)
303 Action::Handle action(Action::create("layer_move"));
309 action->set_param("canvas",canvas);
310 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
311 action->set_param("layer",layer);
312 action->set_param("new_index",depth);
314 if(!action->is_ready())
316 get_ui_interface()->error(_("Move Action Not Ready"));
320 if(!get_instance()->perform_action(action))
322 get_ui_interface()->error(_("Move Action Failed."));
333 CanvasInterface::convert(ValueDesc value_desc, synfig::String type)
335 Action::Handle action(Action::ValueDescConvert::create());
341 action->set_param("canvas",get_canvas());
342 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
343 action->set_param("value_desc",value_desc);
344 action->set_param("type",type);
345 action->set_param("time",get_time());
347 if(!action->is_ready())
349 get_ui_interface()->error(_("Action Not Ready"));
353 if(get_instance()->perform_action(action))
356 get_ui_interface()->error(_("Action Failed."));
361 CanvasInterface::add_value_node(synfig::ValueNode::Handle value_node, synfig::String name)
365 get_ui_interface()->error(_("Empty name!"));
369 Action::Handle action(Action::ValueNodeAdd::create());
375 action->set_param("canvas",get_canvas());
376 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
377 action->set_param("new",value_node);
378 action->set_param("name",name);
380 if(!action->is_ready())
382 get_ui_interface()->error(_("Action Not Ready"));
386 if(get_instance()->perform_action(action))
389 get_ui_interface()->error(_("Action Failed."));
394 CanvasInterface::generate_param_list(const ValueDesc &value_desc)
396 synfigapp::Action::ParamList param_list;
397 param_list.add("time",get_time());
398 param_list.add("canvas_interface",etl::handle<CanvasInterface>(this));
399 param_list.add("canvas",get_canvas());
401 param_list.add("value_desc",value_desc);
403 if(value_desc.parent_is_value_node())
404 param_list.add("parent_value_node",value_desc.get_parent_value_node());
406 if(value_desc.is_value_node())
407 param_list.add("value_node",value_desc.get_value_node());
409 if(value_desc.is_const())
411 // Fix 1868911: if we put a ValueBase holding a Canvas handle
412 // into the param_list and then export the canvas, the handle
413 // will miss out of having its reference count reduced,
414 // because by the time the handle is destructed the canvas
415 // will no longer be inline. So let's not propogate that
416 // ValueBase any further than here.
417 if (value_desc.get_value_type() == ValueBase::TYPE_CANVAS)
418 param_list.add("value",Canvas::LooseHandle(value_desc.get_value().get(Canvas::LooseHandle())));
420 param_list.add("value",value_desc.get_value());
423 if(value_desc.parent_is_layer_param())
425 param_list.add("parent_layer",value_desc.get_layer());
426 param_list.add("parent_layer_param",value_desc.get_param_name());
430 synfigapp::SelectionManager::ChildrenList children_list;
431 children_list=get_selection_manager()->get_selected_children();
432 if(!value_desc.parent_is_canvas() && children_list.size()==1)
434 param_list.add("dest",value_desc);
435 param_list.add("src",children_list.front().get_value_node());
442 CanvasInterface::generate_param_list(const std::list<synfigapp::ValueDesc> &value_desc_list)
444 synfigapp::Action::ParamList param_list;
445 param_list.add("time",get_time());
446 param_list.add("canvas_interface",etl::handle<CanvasInterface>(this));
447 param_list.add("canvas",get_canvas());
449 std::list<synfigapp::ValueDesc>::const_iterator iter;
450 for(iter=value_desc_list.begin();iter!=value_desc_list.end();++iter)
452 param_list.add("value_desc",*iter);
453 if(iter->is_value_node())
455 param_list.add("value_node",iter->get_value_node());
464 CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc)
466 Action::Handle action(Action::create("canvas_rend_desc_set"));
472 action->set_param("canvas",get_canvas());
473 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
474 action->set_param("rend_desc",rend_desc);
476 if(!get_instance()->perform_action(action))
477 get_ui_interface()->error(_("Action Failed."));
481 CanvasInterface::set_name(const synfig::String &x)
483 Action::Handle action(Action::create("canvas_name_set"));
489 action->set_param("canvas",get_canvas());
490 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
491 action->set_param("name",x);
493 if(!get_instance()->perform_action(action))
494 get_ui_interface()->error(_("Action Failed."));
496 signal_id_changed_();
500 CanvasInterface::set_description(const synfig::String &x)
502 Action::Handle action(Action::create("canvas_description_set"));
508 action->set_param("canvas",get_canvas());
509 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
510 action->set_param("description",x);
512 if(!get_instance()->perform_action(action))
513 get_ui_interface()->error(_("Action Failed."));
517 CanvasInterface::set_id(const synfig::String &x)
519 Action::Handle action(Action::create("canvas_id_set"));
525 action->set_param("canvas",get_canvas());
526 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
527 action->set_param("id",x);
529 if(!get_instance()->perform_action(action))
530 get_ui_interface()->error(_("Action Failed."));
532 signal_id_changed_();
537 CanvasInterface::jump_to_next_keyframe()
539 synfig::info("Current time: %s",get_time().get_string().c_str());
542 synfig::Keyframe keyframe(*get_canvas()->keyframe_list().find_next(get_time()));
543 synfig::info("Jumping to keyframe \"%s\" at %s",keyframe.get_description().c_str(),keyframe.get_time().get_string().c_str());
544 set_time(keyframe.get_time());
546 catch(...) { synfig::warning("Unable to find next keyframe"); }
550 CanvasInterface::jump_to_prev_keyframe()
552 synfig::info("Current time: %s",get_time().get_string().c_str());
555 synfig::Keyframe keyframe(*get_canvas()->keyframe_list().find_prev(get_time()));
556 synfig::info("Jumping to keyframe \"%s\" at %s",keyframe.get_description().c_str(),keyframe.get_time().get_string().c_str());
557 set_time(keyframe.get_time());
559 catch(...) { synfig::warning("Unable to find prev keyframe"); }
563 CanvasInterface::import(const synfig::String &filename, synfig::String &errors, synfig::String &warnings, bool resize_image)
565 Action::PassiveGrouper group(get_instance().get(),_("Import Image"));
567 synfig::info("Attempting to import "+filename);
569 if (filename_extension(filename) == "")
571 get_ui_interface()->error(_("Filename must have an extension!"));
575 String ext(filename_extension(filename));
576 if (ext.size()) ext = ext.substr(1); // skip initial '.'
577 std::transform(ext.begin(),ext.end(),ext.begin(),&::tolower);
579 // If this is a SIF file, then we need to do things slightly differently
580 if(ext=="sif" || ext=="sifz")try
582 Canvas::Handle outside_canvas(synfig::open_canvas(filename, errors, warnings));
584 throw String(_("Unable to open this composition")) + ":\n\n" + errors;
586 Layer::Handle layer(add_layer_to("PasteCanvas",get_canvas()));
588 throw String(_("Unable to create \"Paste Canvas\" layer"));
589 if(!layer->set_param("canvas",ValueBase(outside_canvas)))
591 get_canvas()->register_external_canvas(filename, outside_canvas);
593 //layer->set_description(basename(filename));
594 signal_layer_new_description()(layer,filename);
599 get_ui_interface()->error(filename + ": " + x);
604 get_ui_interface()->error(_("Uncaught exception when attempting\nto open this composition -- ")+filename);
608 if(!Importer::book().count(ext))
610 get_ui_interface()->error(_("I don't know how to open images of this type -- ")+ext);
616 Layer::Handle layer(add_layer_to("Import",get_canvas()));
620 if(!layer->set_param("filename",ValueBase(filename)))
622 w=layer->get_param("_width").get(int());
623 h=layer->get_param("_height").get(int());
626 Vector x, size=ValueBase(get_canvas()->rend_desc().get_br()-get_canvas()->rend_desc().get_tl());
628 // vector from top left of canvas to bottom right
631 if(abs(size[0])<abs(size[1])) // if canvas is tall and thin
633 x[0]=size[0]; // use full width
634 x[1]=size[0]/w*h; // and scale for height
635 if((size[0]<0) ^ (size[1]<0))
638 else // else canvas is short and fat (or maybe square)
640 x[1]=size[1]; // use full height
641 x[0]=size[1]/h*w; // and scale for width
642 if((size[0]<0) ^ (size[1]<0))
650 if((size[0]<0)) x[0]=-x[0];
651 if((size[1]<0)) x[1]=-x[1];
654 if(!layer->set_param("tl",ValueBase(-x/2)))
656 if(!layer->set_param("br",ValueBase(x/2)))
661 if(!layer->set_param("tl",ValueBase(get_canvas()->rend_desc().get_tl())))
663 if(!layer->set_param("br",ValueBase(get_canvas()->rend_desc().get_br())))
667 layer->set_description(basename(filename));
668 signal_layer_new_description()(layer,filename);
674 get_ui_interface()->error("Unable to import "+filename);
682 CanvasInterface::waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint)
684 ValueNode::Handle value_node();
685 waypoint_duplicate(value_desc.get_value_node(), waypoint);
689 CanvasInterface::waypoint_duplicate(ValueNode::Handle value_node,synfig::Waypoint waypoint)
691 Action::Handle action(Action::create("waypoint_set_smart"));
697 waypoint.make_unique();
698 waypoint.set_time(get_time());
700 action->set_param("canvas",get_canvas());
701 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
702 action->set_param("waypoint",waypoint);
703 action->set_param("time",get_time());
704 action->set_param("value_node",value_node);
706 if(!get_instance()->perform_action(action))
707 get_ui_interface()->error(_("Action Failed."));
711 CanvasInterface::waypoint_remove(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint)
713 ValueNode::Handle value_node();
714 waypoint_remove(value_desc.get_value_node(), waypoint);
718 CanvasInterface::waypoint_remove(ValueNode::Handle value_node,synfig::Waypoint waypoint)
720 Action::Handle action(Action::create("waypoint_remove"));
726 action->set_param("canvas",get_canvas());
727 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
728 action->set_param("waypoint",waypoint);
729 action->set_param("value_node",value_node);
731 if(!get_instance()->perform_action(action))
732 get_ui_interface()->error(_("Action Failed."));
737 CanvasInterface::auto_export(synfig::ValueNode::Handle /*value_node*/)
740 // Check to see if we are already exported.
741 if(value_node->is_exported())
744 Action::Handle action(Action::create("value_node_add"));
750 String name(strprintf(_("Unnamed%08d"),synfig::UniqueID().get_uid()));
752 action->set_param("canvas",get_canvas());
753 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
754 action->set_param("new",value_node);
755 action->set_param("name",name);
757 if(!get_instance()->perform_action(action))
758 get_ui_interface()->error(_("Action Failed."));
763 CanvasInterface::auto_export(const ValueDesc& /*value_desc*/)
765 // THIS FUNCTION IS DEPRECATED, AND IS NOW A STUB.
767 // Check to see if we are already exported.
768 if(value_desc.is_exported())
771 Action::Handle action(Action::create("value_desc_export"));
777 String name(strprintf(_("Unnamed%08d"),synfig::UniqueID().get_uid()));
779 action->set_param("canvas",get_canvas());
780 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
781 action->set_param("value_desc",value_desc);
782 action->set_param("name",name);
784 if(!get_instance()->perform_action(action))
785 get_ui_interface()->error(_("Action Failed."));
790 CanvasInterface::change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase new_value)
792 // If this isn't really a change, then don't bother
793 if(new_value==value_desc.get_value(get_time()))
796 // If this change needs to take place elsewhere, then so be it.
797 if(value_desc.get_canvas())
799 if (value_desc.get_canvas()->get_root() != get_canvas()->get_root())
801 etl::handle<Instance> instance;
802 instance=find_instance(value_desc.get_canvas()->get_root());
805 return instance->find_canvas_interface(value_desc.get_canvas())->change_value(value_desc,new_value);
808 get_ui_interface()->error(_("The value you are trying to edit is in a composition\nwhich doesn't seem to be open. Open that composition and you\nshould be able to edit this value as normal."));
815 { synfig::warning("Can't get canvas from value desc...?"); }
818 synfigapp::Action::Handle action(synfigapp::Action::create("value_desc_set"));
824 action->set_param("canvas",get_canvas());
825 action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
826 action->set_param("time",get_time());
827 action->set_param("value_desc",value_desc);
828 action->set_param("new_value",new_value);
830 return get_instance()->perform_action(action);
834 CanvasInterface::set_meta_data(const synfig::String& key,const synfig::String& data)
836 get_canvas()->set_meta_data(key,data);
840 // this function goes with find_important_value_descs()
842 _process_value_desc(const synfigapp::ValueDesc& value_desc,std::vector<synfigapp::ValueDesc>& out, synfig::GUIDSet& guid_set)
846 if(value_desc.get_value_type()==ValueBase::TYPE_CANVAS)
848 Canvas::Handle canvas;
849 canvas=value_desc.get_value().get(canvas);
850 if(!canvas || !canvas->is_inline())
852 ret+=CanvasInterface::find_important_value_descs(canvas,out,guid_set);
855 if(value_desc.is_value_node())
857 ValueNode::Handle value_node(value_desc.get_value_node());
859 if(guid_set.count(value_node->get_guid()))
861 guid_set.insert(value_node->get_guid());
863 if(LinkableValueNode::Handle::cast_dynamic(value_node))
865 if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
867 out.push_back(value_desc);
870 // Process the linkable ValueNode's children
871 LinkableValueNode::Handle value_node_copy(LinkableValueNode::Handle::cast_dynamic(value_node));
873 for(i=0;i<value_node_copy->link_count();i++)
875 ValueNode::Handle link(value_node_copy->get_link(i));
876 if(!link->is_exported())
877 ret+=_process_value_desc(ValueDesc(value_node_copy,i),out,guid_set);
880 else if(ValueNode_Animated::Handle::cast_dynamic(value_node))
882 out.push_back(value_desc);
891 CanvasInterface::find_important_value_descs(synfig::Canvas::Handle canvas,std::vector<synfigapp::ValueDesc>& out,synfig::GUIDSet& guid_set)
894 if(!canvas->is_inline())
896 ValueNodeList::const_iterator iter;
899 iter=canvas->value_node_list().begin();
900 iter!=canvas->value_node_list().end();
902 ret+=_process_value_desc(ValueDesc(canvas,(*iter)->get_id()),out,guid_set);
905 Canvas::const_iterator iter;
907 for(iter=canvas->begin();iter!=canvas->end();++iter)
909 Layer::Handle layer(*iter);
911 Layer::DynamicParamList::const_iterator iter;
913 iter=layer->dynamic_param_list().begin();
914 iter!=layer->dynamic_param_list().end();
917 if(!iter->second->is_exported())
918 ret+=_process_value_desc(ValueDesc(layer,iter->first),out,guid_set);
920 ValueBase value(layer->get_param("canvas"));
922 ret+=_process_value_desc(ValueDesc(layer,"canvas"),out,guid_set);
929 CanvasInterface::find_important_value_descs(std::vector<synfigapp::ValueDesc>& out)
932 return find_important_value_descs(get_canvas(),out,tmp);
936 CanvasInterface::seek_frame(int frames)
940 float fps(get_canvas()->rend_desc().get_frame_rate());
941 Time newtime(get_time()+(float)frames/fps);
942 newtime=newtime.round(fps);
944 if(newtime<=get_canvas()->rend_desc().get_time_start())
945 newtime=get_canvas()->rend_desc().get_time_start();
946 if(newtime>=get_canvas()->rend_desc().get_time_end())
947 newtime=get_canvas()->rend_desc().get_time_end();
952 CanvasInterface::seek_time(synfig::Time time)
957 float fps(get_canvas()->rend_desc().get_frame_rate());
959 if(time>=synfig::Time::end())
961 set_time(get_canvas()->rend_desc().get_time_end());
964 if(time<=synfig::Time::begin())
966 set_time(get_canvas()->rend_desc().get_time_start());
970 Time newtime(get_time()+time);
971 newtime=newtime.round(fps);
973 if(newtime<=get_canvas()->rend_desc().get_time_start())
974 newtime=get_canvas()->rend_desc().get_time_start();
975 if(newtime>=get_canvas()->rend_desc().get_time_end())
976 newtime=get_canvas()->rend_desc().get_time_end();