From: Nikita Kitaev Date: Sun, 4 Oct 2009 03:51:31 +0000 (-0700) Subject: Remove hard-coded link positions in reference to ValueDesc X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=39ed56eeecf6cbdc5e923df9020fa7dc3697737f;p=synfig.git Remove hard-coded link positions in reference to ValueDesc Instead, the link positions are determined from the valuenode names. --- diff --git a/synfig-studio/src/gtkmm/instance.cpp b/synfig-studio/src/gtkmm/instance.cpp index 9a247cb..947bd25 100644 --- a/synfig-studio/src/gtkmm/instance.cpp +++ b/synfig-studio/src/gtkmm/instance.cpp @@ -1024,7 +1024,8 @@ Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfiga param_list2=canvas_interface->generate_param_list( synfigapp::ValueDesc( ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) - ,0 + ,ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) + ->get_link_index_from_name("point") ) ); param_list2.add("origin",location); diff --git a/synfig-studio/src/gtkmm/state_normal.cpp b/synfig-studio/src/gtkmm/state_normal.cpp index f2bb3b9..a264423 100644 --- a/synfig-studio/src/gtkmm/state_normal.cpp +++ b/synfig-studio/src/gtkmm/state_normal.cpp @@ -387,7 +387,8 @@ StateNormal_Context::event_multiple_ducks_clicked_handler(const Smach::event& /* value_desc_list.push_back( synfigapp::ValueDesc( ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) - ,0 + ,ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()) + ->get_link_index_from_name("point") ) ); } diff --git a/synfig-studio/src/synfigapp/actions/blinepointtangentmerge.cpp b/synfig-studio/src/synfigapp/actions/blinepointtangentmerge.cpp index 75d775e..491d517 100644 --- a/synfig-studio/src/synfigapp/actions/blinepointtangentmerge.cpp +++ b/synfig-studio/src/synfigapp/actions/blinepointtangentmerge.cpp @@ -157,7 +157,7 @@ Action::BLinePointTangentMerge::prepare() action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("value_desc",ValueDesc(value_node,3)); + action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split"))); action->set_param("time",time); action->set_param("new_value",synfig::ValueBase(false)); diff --git a/synfig-studio/src/synfigapp/actions/blinepointtangentsplit.cpp b/synfig-studio/src/synfigapp/actions/blinepointtangentsplit.cpp index 67cc22f..8e2e593 100644 --- a/synfig-studio/src/synfigapp/actions/blinepointtangentsplit.cpp +++ b/synfig-studio/src/synfigapp/actions/blinepointtangentsplit.cpp @@ -157,7 +157,7 @@ Action::BLinePointTangentSplit::prepare() action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("value_desc",ValueDesc(value_node,3)); + action->set_param("value_desc",ValueDesc(value_node,value_node->get_link_index_from_name("split"))); action->set_param("time",time); action->set_param("new_value",synfig::ValueBase(true)); diff --git a/synfig-studio/src/synfigapp/actions/valuedescset.cpp b/synfig-studio/src/synfigapp/actions/valuedescset.cpp index 7bb44f4..9b7a7d4 100644 --- a/synfig-studio/src/synfigapp/actions/valuedescset.cpp +++ b/synfig-studio/src/synfigapp/actions/valuedescset.cpp @@ -156,7 +156,8 @@ Action::ValueDescSet::prepare() // tangent. if( value_desc.parent_is_value_node() && value_desc.get_parent_value_node()->get_type()==ValueBase::TYPE_BLINEPOINT && - (value_desc.get_index()==4 || value_desc.get_index()==5) && + (value_desc.get_name()=="t1" || value_desc.get_name()=="t2") && + //(value_desc.get_index()==4 || value_desc.get_index()==5) && (*value_desc.get_parent_value_node())(time).get(BLinePoint()).get_split_tangent_flag()==false) { { @@ -168,7 +169,8 @@ Action::ValueDescSet::prepare() Vector t2((*parent_value_node->get_link("t2"))(time)); } - if (value_desc.get_index()==4) { + //if (value_desc.get_index()==4) { + if (value_desc.get_name()=="t1") { ValueNode_Composite::Handle parent_value_node; parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node()); @@ -183,7 +185,7 @@ Action::ValueDescSet::prepare() action->set_param("canvas_interface",get_canvas_interface()); action->set_param("time",time); action->set_param("new_value",value); - action->set_param("value_desc",ValueDesc(parent_value_node,5)); + action->set_param("value_desc",ValueDesc(parent_value_node, parent_value_node->get_link_index_from_name("t2"))); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); @@ -371,7 +373,7 @@ Action::ValueDescSet::prepare() action->set_param("canvas_interface",get_canvas_interface()); action->set_param("time",time); action->set_param("new_value",(*parent_value_node->get_link("t1"))(time)); - action->set_param("value_desc",ValueDesc(parent_value_node,5)); + action->set_param("value_desc",ValueDesc(parent_value_node,parent_value_node->get_link_index_from_name("t2"))); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); @@ -396,7 +398,7 @@ Action::ValueDescSet::prepare() action->set_param("canvas_interface",get_canvas_interface()); action->set_param("time",time); action->set_param("new_value",average); - action->set_param("value_desc",ValueDesc(parent_value_node,4)); + action->set_param("value_desc",ValueDesc(parent_value_node,parent_value_node->get_link_index_from_name("t1"))); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); @@ -414,7 +416,7 @@ Action::ValueDescSet::prepare() action->set_param("canvas_interface",get_canvas_interface()); action->set_param("time",time); action->set_param("new_value",average); - action->set_param("value_desc",ValueDesc(parent_value_node,5)); + action->set_param("value_desc",ValueDesc(parent_value_node,parent_value_node->get_link_index_from_name("t2"))); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); diff --git a/synfig-studio/src/synfigapp/value_desc.h b/synfig-studio/src/synfigapp/value_desc.h index ccc562a..909e4cb 100644 --- a/synfig-studio/src/synfigapp/value_desc.h +++ b/synfig-studio/src/synfigapp/value_desc.h @@ -130,6 +130,7 @@ public: synfig::ValueNode::Handle get_parent_value_node()const { assert(parent_is_value_node()); return parent_value_node; } int get_index()const { assert(parent_is_linkable_value_node()); return index; } + synfig::String get_name()const { assert(parent_is_linkable_value_node()); return (synfig::LinkableValueNode::Handle::cast_reinterpret(parent_value_node))->link_name(index); } synfig::Time get_waypoint_time()const { assert(parent_is_waypoint()); return waypoint_time; } const synfig::String& get_value_node_id()const { assert(parent_is_canvas()); return name; }