#include <synfig/valuenode_reference.h>
#include <synfig/valuenode_twotone.h>
#include <synfig/valuenode_stripes.h>
+#include <synfig/valuenode_bline.h>
#include <synfig/waypoint.h>
#include <synfig/loadcanvas.h>
// Apply some defaults
if(layer->set_param("fg",synfigapp::Main::get_foreground_color()))
layer->set_param("bg",synfigapp::Main::get_background_color());
+ else if (name == "SolidColor")
+ layer->set_param("color",synfigapp::Main::get_background_color());
else
layer->set_param("color",synfigapp::Main::get_foreground_color());
if (iter2->get_type() != ValueBase::TYPE_BLINEPOINT)
break;
if (iter2 == list.end())
+ {
value_node=LinkableValueNode::create("bline",iter->second);
+ ValueNode_BLine::Handle::cast_dynamic(value_node)->set_member_canvas(canvas);
+ }
}
if (!value_node)
// Action to move the layer (if necessary)
if(depth>0)
{
- Action::Handle action(Action::create("layer_move"));
+ Action::Handle action(Action::create("LayerMove"));
assert(action);
if(!action)
void
CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc)
{
- Action::Handle action(Action::create("canvas_rend_desc_set"));
+ Action::Handle action(Action::create("CanvasRendDescSet"));
assert(action);
if(!action)
get_ui_interface()->error(_("Action Failed."));
}
-bool
+void
CanvasInterface::set_name(const synfig::String &x)
{
- //! \todo This needs to be converted into an action
- get_canvas()->set_name(x);
+ Action::Handle action(Action::create("CanvasNameSet"));
+
+ assert(action);
+ if(!action)
+ return;
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+ action->set_param("name",x);
+
+ if(!get_instance()->perform_action(action))
+ get_ui_interface()->error(_("Action Failed."));
+
signal_id_changed_();
- return true;
}
-bool
+void
CanvasInterface::set_description(const synfig::String &x)
{
- //! \todo This needs to be converted into an action
- get_canvas()->set_description(x);
- return true;
+ Action::Handle action(Action::create("CanvasDescriptionSet"));
+
+ assert(action);
+ if(!action)
+ return;
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+ action->set_param("description",x);
+
+ if(!get_instance()->perform_action(action))
+ get_ui_interface()->error(_("Action Failed."));
}
-bool
+void
CanvasInterface::set_id(const synfig::String &x)
{
- //! \todo This needs to be converted into an action
- get_canvas()->set_id(x);
+ Action::Handle action(Action::create("CanvasIdSet"));
+
+ assert(action);
+ if(!action)
+ return;
+
+ action->set_param("canvas",get_canvas());
+ action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+ action->set_param("id",x);
+
+ if(!get_instance()->perform_action(action))
+ get_ui_interface()->error(_("Action Failed."));
+
signal_id_changed_();
- return true;
}
}
bool
-CanvasInterface::import(const synfig::String &filename, bool /*copy*/)
+CanvasInterface::import(const synfig::String &filename, synfig::String &errors, synfig::String &warnings, bool resize_image)
{
Action::PassiveGrouper group(get_instance().get(),_("Import Image"));
// If this is a SIF file, then we need to do things slightly differently
if(ext=="sif" || ext=="sifz")try
{
-
- Canvas::Handle outside_canvas(synfig::open_canvas(filename));
+ Canvas::Handle outside_canvas(synfig::open_canvas(filename, errors, warnings));
if(!outside_canvas)
- throw String(_("Unable to open this composition"));
+ throw String(_("Unable to open this composition")) + ":\n\n" + errors;
Layer::Handle layer(add_layer_to("PasteCanvas",get_canvas()));
if(!layer)
throw String(_("Unable to create \"Paste Canvas\" layer"));
if(!layer->set_param("canvas",ValueBase(outside_canvas)))
throw int();
+ get_canvas()->register_external_canvas(filename, outside_canvas);
//layer->set_description(basename(filename));
signal_layer_new_description()(layer,filename);
}
catch(String x)
{
- get_ui_interface()->error(x+" -- "+filename);
+ get_ui_interface()->error(filename + ": " + x);
return false;
}
catch(...)
h=layer->get_param("_height").get(int());
if(w&&h)
{
- Vector size=ValueBase(get_canvas()->rend_desc().get_br()-get_canvas()->rend_desc().get_tl());
- Vector x;
- if(size[0]<size[1])
+ Vector x, size=ValueBase(get_canvas()->rend_desc().get_br()-get_canvas()->rend_desc().get_tl());
+
+ // vector from top left of canvas to bottom right
+ if (resize_image)
{
- x[0]=size[0];
- x[1]=size[0]/w*h;
- if((size[0]<0) ^ (size[1]<0))
- x[1]=-x[1];
+ if(abs(size[0])<abs(size[1])) // if canvas is tall and thin
+ {
+ x[0]=size[0]; // use full width
+ x[1]=size[0]/w*h; // and scale for height
+ if((size[0]<0) ^ (size[1]<0))
+ x[1]=-x[1];
+ }
+ else // else canvas is short and fat (or maybe square)
+ {
+ x[1]=size[1]; // use full height
+ x[0]=size[1]/h*w; // and scale for width
+ if((size[0]<0) ^ (size[1]<0))
+ x[0]=-x[0];
+ }
}
else
{
- x[1]=size[1];
- x[0]=size[1]/h*w;
- if((size[0]<0) ^ (size[1]<0))
- x[0]=-x[0];
+ x[0] = w/60.0;
+ x[1] = h/60.0;
+ if((size[0]<0)) x[0]=-x[0];
+ if((size[1]<0)) x[1]=-x[1];
}
+
if(!layer->set_param("tl",ValueBase(-x/2)))
throw int();
if(!layer->set_param("br",ValueBase(x/2)))
void
CanvasInterface::waypoint_duplicate(ValueNode::Handle value_node,synfig::Waypoint waypoint)
{
- Action::Handle action(Action::create("waypoint_set_smart"));
+ Action::Handle action(Action::create("WaypointSetSmart"));
assert(action);
if(!action)
void
CanvasInterface::waypoint_remove(ValueNode::Handle value_node,synfig::Waypoint waypoint)
{
- Action::Handle action(Action::create("waypoint_remove"));
+ Action::Handle action(Action::create("WaypointRemove"));
assert(action);
if(!action)
if(value_node->is_exported())
return;
- Action::Handle action(Action::create("value_node_add"));
+ Action::Handle action(Action::create("ValueNodeAdd"));
assert(action);
if(!action)
if(value_desc.is_exported())
return;
- Action::Handle action(Action::create("value_desc_export"));
+ Action::Handle action(Action::create("ValueDescExport"));
assert(action);
if(!action)
return true;
// If this change needs to take place elsewhere, then so be it.
- if(value_desc.get_canvas() && value_desc.get_canvas()->get_root()!=get_canvas()->get_root())do
+ if(value_desc.get_canvas())
{
- etl::handle<Instance> instance;
- instance=find_instance(value_desc.get_canvas()->get_root());
-
- if(instance)
- return instance->find_canvas_interface(value_desc.get_canvas())->change_value(value_desc,new_value);
- else
+ if (value_desc.get_canvas()->get_root() != get_canvas()->get_root())
{
- 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."));
- return false;
+ etl::handle<Instance> instance;
+ instance=find_instance(value_desc.get_canvas()->get_root());
+
+ if(instance)
+ return instance->find_canvas_interface(value_desc.get_canvas())->change_value(value_desc,new_value);
+ else
+ {
+ 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."));
+ return false;
+ }
}
- }while(0);
+ }
#ifdef _DEBUG
else
{ synfig::warning("Can't get canvas from value desc...?"); }
#endif
- synfigapp::Action::Handle action(synfigapp::Action::create("value_desc_set"));
+ synfigapp::Action::Handle action(synfigapp::Action::create("ValueDescSet"));
if(!action)
{
return false;