X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Fcanvasinterface.cpp;h=6619719e16f4184e1c9d6857f22885636a7be3aa;hb=a0306607ec66a57fe2537e921a6772eaab606d2c;hp=aa228ebbcf16556a16f23a453f9d29e12eff521e;hpb=26ed1c813d50bee5c39b3cfc4401a0a41506edb8;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp b/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp index aa228eb..6619719 100644 --- a/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp +++ b/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp @@ -6,7 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -91,7 +92,8 @@ CanvasInterface::CanvasInterface(etl::loose_handle instance,etl::handl CanvasInterface::~CanvasInterface() { - synfig::info("synfigapp::CanvasInterface::~CanvasInterface(): Deleted"); + if (getenv("SYNFIG_DEBUG_DESTRUCTORS")) + synfig::info("CanvasInterface::~CanvasInterface(): Deleted"); } void @@ -227,15 +229,42 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas // Grab the layer's list of parameters Layer::ParamList paramlist=layer->get_param_list(); Layer::ParamList::iterator iter; + + // loop through the static parameters for(iter=paramlist.begin();iter!=paramlist.end();++iter) { ValueNode::Handle value_node; + // if we find any which are list values then make them + // into dynamic list valuenodes, unless every element of + // the list is a blinepoint, in which case convert it to a + // bline if(iter->second.get_type()==ValueBase::TYPE_LIST) - value_node=LinkableValueNode::create("dynamic_list",iter->second); + { + // check whether it's a list of blinepoints only + vector list(iter->second.get_list()); + if (list.size()) + { + vector::iterator iter2; + for (iter2 = list.begin(); iter2 != list.end(); iter2++) + 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) + value_node=LinkableValueNode::create("dynamic_list",iter->second); + } + // otherwise, if it's a type that can be converted to + // 'composite' (other than the types that can be radial + // composite) then do so else if(LinkableValueNode::check_type("composite",iter->second.get_type()) && - (iter->second.get_type()!=ValueBase::TYPE_COLOR && iter->second.get_type()!=ValueBase::TYPE_VECTOR) - ) + (iter->second.get_type()!=ValueBase::TYPE_COLOR && + iter->second.get_type()!=ValueBase::TYPE_VECTOR)) value_node=LinkableValueNode::create("composite",iter->second); if(value_node) @@ -266,7 +295,8 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas return 0; } - synfig::info("DEPTH=%d",depth); + // synfig::info("DEPTH=%d",depth); + // Action to move the layer (if necessary) if(depth>0) { @@ -610,6 +640,13 @@ CanvasInterface::import(const synfig::String &filename, bool /*copy*/) void CanvasInterface::waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint) { + ValueNode::Handle value_node(); + waypoint_duplicate(value_desc.get_value_node(), waypoint); +} + +void +CanvasInterface::waypoint_duplicate(ValueNode::Handle value_node,synfig::Waypoint waypoint) +{ Action::Handle action(Action::create("waypoint_set_smart")); assert(action); @@ -619,8 +656,6 @@ CanvasInterface::waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Wayp waypoint.make_unique(); waypoint.set_time(get_time()); - ValueNode::Handle value_node(value_desc.get_value_node()); - action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",etl::loose_handle(this)); action->set_param("waypoint",waypoint); @@ -634,14 +669,19 @@ CanvasInterface::waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Wayp void CanvasInterface::waypoint_remove(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint) { + ValueNode::Handle value_node(); + waypoint_remove(value_desc.get_value_node(), waypoint); +} + +void +CanvasInterface::waypoint_remove(ValueNode::Handle value_node,synfig::Waypoint waypoint) +{ Action::Handle action(Action::create("waypoint_remove")); assert(action); if(!action) return; - ValueNode::Handle value_node(value_desc.get_value_node()); - action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",etl::loose_handle(this)); action->set_param("waypoint",waypoint); @@ -713,19 +753,22 @@ CanvasInterface::change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase 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=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=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...?"); }