X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Fcanvasinterface.cpp;h=f8f935e97c911bca97d0b11a3e3229bd0b698e3c;hb=990f7bb7694e0472ed6ad165e0724864539071cd;hp=6619719e16f4184e1c9d6857f22885636a7be3aa;hpb=6064c8b90dca08162df16620032b7fd8e395936a;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp b/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp index 6619719..f8f935e 100644 --- a/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp +++ b/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp @@ -216,6 +216,8 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas // 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()); @@ -300,7 +302,7 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas // 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) @@ -463,7 +465,7 @@ CanvasInterface::generate_param_list(const std::list &valu 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) @@ -477,30 +479,59 @@ CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc) 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(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(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(this)); + action->set_param("id",x); + + if(!get_instance()->perform_action(action)) + get_ui_interface()->error(_("Action Failed.")); + signal_id_changed_(); - return true; } @@ -531,7 +562,7 @@ CanvasInterface::jump_to_prev_keyframe() } 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")); @@ -550,16 +581,16 @@ CanvasInterface::import(const synfig::String &filename, bool /*copy*/) // 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); @@ -567,7 +598,7 @@ CanvasInterface::import(const synfig::String &filename, bool /*copy*/) } catch(String x) { - get_ui_interface()->error(x+" -- "+filename); + get_ui_interface()->error(filename + ": " + x); return false; } catch(...) @@ -594,22 +625,34 @@ CanvasInterface::import(const synfig::String &filename, bool /*copy*/) 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]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])set_param("tl",ValueBase(-x/2))) throw int(); if(!layer->set_param("br",ValueBase(x/2))) @@ -647,7 +690,7 @@ CanvasInterface::waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Wayp 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) @@ -676,7 +719,7 @@ CanvasInterface::waypoint_remove(synfigapp::ValueDesc value_desc,synfig::Waypoin 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) @@ -700,7 +743,7 @@ CanvasInterface::auto_export(synfig::ValueNode::Handle /*value_node*/) if(value_node->is_exported()) return; - Action::Handle action(Action::create("value_node_add")); + Action::Handle action(Action::create("ValueNodeAdd")); assert(action); if(!action) @@ -727,7 +770,7 @@ CanvasInterface::auto_export(const ValueDesc& /*value_desc*/) if(value_desc.is_exported()) return; - Action::Handle action(Action::create("value_desc_export")); + Action::Handle action(Action::create("ValueDescExport")); assert(action); if(!action) @@ -774,7 +817,7 @@ CanvasInterface::change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase { 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;