Allow direct editing of calculated widths - like the previous commit did for tangents.
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 30 Mar 2008 09:15:54 +0000 (09:15 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 30 Mar 2008 09:15:54 +0000 (09:15 +0000)
git-svn-id: http://svn.voria.com/code@1939 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.cpp
synfig-core/trunk/src/synfig/valuenode_blinecalcwidth.h
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/duckmatic.cpp
synfig-studio/trunk/src/synfigapp/instance.cpp

index 1e50ae9..bfb291b 100644 (file)
@@ -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<ValueBase> bline((*bline_)(t));
        handle<ValueNode_BLine> 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
 {
index d44084f..0aa6932 100644 (file)
@@ -49,6 +49,7 @@ public:
        typedef etl::handle<ValueNode_BLineCalcWidth> Handle;
        typedef etl::handle<const ValueNode_BLineCalcWidth> ConstHandle;
 
+       virtual ValueBase operator()(Time t, Real amount)const;
        virtual ValueBase operator()(Time t)const;
 
        virtual ~ValueNode_BLineCalcWidth();
index 2c48158..9357698 100644 (file)
@@ -55,6 +55,7 @@
 #include <synfig/valuenode_stripes.h>
 #include <synfig/valuenode_blinecalctangent.h>
 #include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
 #include <synfig/valuenode_bline.h>
 #include <synfig/layer.h>
 
@@ -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:
index 0be4a9e..e9f00e4 100644 (file)
@@ -46,6 +46,7 @@
 #include <synfig/valuenode_bline.h>
 #include <synfig/valuenode_blinecalctangent.h>
 #include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
 
 #include <synfig/curve_helper.h>
 
@@ -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));
+                                               }
                                        }
                                }
                        }
index 4b95f36..92fd239 100644 (file)
@@ -38,8 +38,9 @@
 #include <synfig/valuenode_composite.h>
 #include <synfig/valuenode_radialcomposite.h>
 #include <synfig/valuenode_reference.h>
-#include <synfig/valuenode_blinecalcvertex.h>
 #include <synfig/valuenode_blinecalctangent.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
 #include <map>
 
 #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;