From: Carlos Lopez Date: Mon, 6 Jul 2009 14:02:03 +0000 (+0200) Subject: Simplified version for reverse manipulation Scale convert types ducks X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9ff670a60001e455fa506f6b6292300e8d1cec8f;p=synfig.git Simplified version for reverse manipulation Scale convert types ducks --- diff --git a/synfig-core/trunk/src/synfig/valuenode_scale.cpp b/synfig-core/trunk/src/synfig/valuenode_scale.cpp index a0bba53..25b3822 100644 --- a/synfig-core/trunk/src/synfig/valuenode_scale.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_scale.cpp @@ -141,6 +141,21 @@ synfig::ValueNode_Scale::operator()(Time t)const return ValueBase(); } +synfig::ValueBase +synfig::ValueNode_Scale::operator()(Time t, const synfig::Point &target_value)const +{ + Real scalar_value((*scalar)(t).get(Real())); + if(scalar_value==0) + return (*value_node)(t).get(value_node->get_type()); + switch (get_type()) + case ValueBase::TYPE_REAL: + return target_value.mag() / scalar_value; + case ValueBase::TYPE_ANGLE: + return Angle::tan(target_value[1] / scalar_value ,target_value[0] / scalar_value); + default: + return target_value / scalar_value; +} + bool ValueNode_Scale::set_link_vfunc(int i,ValueNode::Handle value) diff --git a/synfig-core/trunk/src/synfig/valuenode_scale.h b/synfig-core/trunk/src/synfig/valuenode_scale.h index bb1ccd0..a11f6e0 100644 --- a/synfig-core/trunk/src/synfig/valuenode_scale.h +++ b/synfig-core/trunk/src/synfig/valuenode_scale.h @@ -64,6 +64,9 @@ public: virtual ValueBase operator()(Time t)const; + //! Returns the modified Link to match the target value at time t + virtual ValueBase operator()(Time t, const synfig::Point &target_value) const; + virtual String get_name()const; virtual String get_local_name()const; diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index 4a555a8..50789a9 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -2887,6 +2887,12 @@ CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDes } } + if (ValueNode_Scale::Handle scale_value_node = ValueNode_Scale::Handle::cast_dynamic(value_desc.get_value_node())) + { + int link_index(scale_value_node->get_link_index_from_name("link")); + return canvas_interface()->change_value(synfigapp::ValueDesc(scale_value_node,link_index), scale_value_node(t, value)); + } + switch(value_desc.get_value_type()) { case ValueBase::TYPE_REAL: diff --git a/synfig-studio/trunk/src/synfigapp/instance.cpp b/synfig-studio/trunk/src/synfigapp/instance.cpp index 020d337..c3c542b 100644 --- a/synfig-studio/trunk/src/synfigapp/instance.cpp +++ b/synfig-studio/trunk/src/synfigapp/instance.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "general.h" @@ -74,6 +75,7 @@ synfigapp::is_editable(synfig::ValueNode::Handle value_node) || ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_node) || ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_node) || ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_node) + || ValueNode_Scale::Handle::cast_dynamic(value_node) ) return true; return false;