From 5cc3e6061bf5e9f75405cfbf99219b776580e4d1 Mon Sep 17 00:00:00 2001 From: dooglus Date: Fri, 28 Mar 2008 21:11:18 +0000 Subject: [PATCH] Allow a BLineCalcTangent's tangent duck to be dragged and have it edit the 'offset' sub-parameter. git-svn-id: http://svn.voria.com/code@1935 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/canvasview.cpp | 36 +++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index d2ce33d..1356afa 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -2585,21 +2586,6 @@ CanvasView::duck_change_param(const synfig::Point &value,synfig::Layer::Handle l bool CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc) { - if( ValueNode_BLineCalcVertex::Handle bline_vertex = - ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()) - ) - { - Real radius = 0.0; - ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))); - Real amount = synfig::find_closest_point( - (*bline)(get_time()), - value, - radius, - bline->get_loop() - ); - return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount); - } - switch(value_desc.get_value_type()) { case ValueBase::TYPE_REAL: @@ -2608,7 +2594,25 @@ CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDes case ValueBase::TYPE_ANGLE: return canvas_interface()->change_value(value_desc,Angle::tan(value[1],value[0])); break; - default: + case ValueBase::TYPE_VECTOR: + if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node())) + { + Angle old_angle = (*bline_tangent)(get_time()).get(Vector()).angle(); + Angle new_angle = value.angle(); + int offset_index = bline_tangent->get_link_index_from_name("offset"); + Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle())); + return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + new_angle - old_angle); + } + + if (ValueNode_BLineCalcVertex::Handle bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node())) + { + ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))); + Real radius = 0.0; + Real amount = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop()); + return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount); + } + default: // fall through + return canvas_interface()->change_value(value_desc,value); break; } -- 2.7.4