From 0f6cbbaa466e8da2ac71586793015854d27f72be Mon Sep 17 00:00:00 2001 From: dooglus Date: Sun, 30 Mar 2008 09:15:54 +0000 Subject: [PATCH] Allow direct editing of calculated widths - like the previous commit did for tangents. git-svn-id: http://svn.voria.com/code@1939 1f10aa63-cdf2-0310-b900-c93c546f37ac --- .../trunk/src/synfig/valuenode_blinecalcwidth.cpp | 10 ++++++++-- synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.h | 1 + synfig-studio/trunk/src/gtkmm/canvasview.cpp | 11 +++++++++++ synfig-studio/trunk/src/gtkmm/duckmatic.cpp | 17 ++++++++++++++++- synfig-studio/trunk/src/synfigapp/instance.cpp | 4 +++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.cpp b/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.cpp index 1e50ae9..bfb291b 100644 --- a/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.cpp @@ -86,14 +86,13 @@ ValueNode_BLineCalcWidth::~ValueNode_BLineCalcWidth() } ValueBase -ValueNode_BLineCalcWidth::operator()(Time t)const +ValueNode_BLineCalcWidth::operator()(Time t, Real amount)const { const std::vector bline((*bline_)(t)); handle bline_value_node(bline_); const bool looped(bline_value_node->get_loop()); int size = bline.size(), from_vertex; bool loop((*loop_)(t).get(bool())); - Real amount((*amount_)(t).get(Real())); Real scale((*scale_)(t).get(Real())); BLinePoint blinepoint0, blinepoint1; @@ -125,6 +124,13 @@ ValueNode_BLineCalcWidth::operator()(Time t)const return Real((width0 + (amount-from_vertex) * (width1-width0)) * scale); } +ValueBase +ValueNode_BLineCalcWidth::operator()(Time t)const +{ + Real amount((*amount_)(t).get(Real())); + return (*this)(t, amount); +} + String ValueNode_BLineCalcWidth::get_name()const { diff --git a/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.h b/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.h index d44084f..0aa6932 100644 --- a/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.h +++ b/synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.h @@ -49,6 +49,7 @@ public: typedef etl::handle Handle; typedef etl::handle ConstHandle; + virtual ValueBase operator()(Time t, Real amount)const; virtual ValueBase operator()(Time t)const; virtual ~ValueNode_BLineCalcWidth(); diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index 2c48158..9357698 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -2589,6 +2590,16 @@ CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDes switch(value_desc.get_value_type()) { case ValueBase::TYPE_REAL: + if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_desc.get_value_node())) + { + Real old_width((*bline_width)(get_time()).get(Real())); + Real new_width(value.mag()); + int scale_index(bline_width->get_link_index_from_name("scale")); + Real scale((*(bline_width->get_link(scale_index)))(get_time()).get(Real())); + if (!(canvas_interface()->change_value(synfigapp::ValueDesc(bline_width,scale_index), + new_width * scale / old_width))) + return false; + } return canvas_interface()->change_value(value_desc,value.mag()); break; case ValueBase::TYPE_ANGLE: diff --git a/synfig-studio/trunk/src/gtkmm/duckmatic.cpp b/synfig-studio/trunk/src/gtkmm/duckmatic.cpp index 0be4a9e..e9f00e4 100644 --- a/synfig-studio/trunk/src/gtkmm/duckmatic.cpp +++ b/synfig-studio/trunk/src/gtkmm/duckmatic.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -555,12 +556,17 @@ DuckDrag_Translate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector { int t1_index(value_node_composite->get_link_index_from_name("t1")); int t2_index(value_node_composite->get_link_index_from_name("t2")); + int width_index(value_node_composite->get_link_index_from_name("width")); + ValueNode::Handle t1_value_node(value_node_composite->get_link(t1_index)); ValueNode::Handle t2_value_node(value_node_composite->get_link(t2_index)); + ValueNode::Handle width_value_node(value_node_composite->get_link(width_index)); + ValueNode_BLineCalcTangent::Handle bline_tangent_1(ValueNode_BLineCalcTangent::Handle::cast_dynamic(t1_value_node)); ValueNode_BLineCalcTangent::Handle bline_tangent_2(ValueNode_BLineCalcTangent::Handle::cast_dynamic(t2_value_node)); + ValueNode_BLineCalcWidth::Handle bline_width(ValueNode_BLineCalcWidth::Handle::cast_dynamic(width_value_node)); - if (bline_tangent_1 || bline_tangent_2) + if (bline_tangent_1 || bline_tangent_2 || bline_width) { synfig::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")))); @@ -585,6 +591,15 @@ DuckDrag_Translate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector if ((*iter)->get_value_desc().get_value_node() == t2_value_node) (*iter)->set_point(tangent); } + + if (bline_width) + { + Real width = (*bline_width)(time, amount).get(Real()); + DuckList::iterator iter; + for (iter=duck_list.begin(); iter!=duck_list.end(); iter++) + if ((*iter)->get_value_desc().get_value_node() == width_value_node) + (*iter)->set_point(Point(width, 0)); + } } } } diff --git a/synfig-studio/trunk/src/synfigapp/instance.cpp b/synfig-studio/trunk/src/synfigapp/instance.cpp index 4b95f36..92fd239 100644 --- a/synfig-studio/trunk/src/synfigapp/instance.cpp +++ b/synfig-studio/trunk/src/synfigapp/instance.cpp @@ -38,8 +38,9 @@ #include #include #include -#include #include +#include +#include #include #include "general.h" @@ -71,6 +72,7 @@ synfigapp::is_editable(synfig::ValueNode::Handle value_node) || ValueNode_Reference::Handle::cast_dynamic(value_node) || ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_node) || ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_node) + || ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_node) ) return true; return false; -- 2.7.4