Use LinkableValueNode members functions when possible in the derived valuenodes.
[synfig.git] / synfig-core / src / synfig / valuenode_blinecalcwidth.cpp
index 4d8ee0e..9bd5947 100644 (file)
@@ -58,6 +58,8 @@ using namespace synfig;
 ValueNode_BLineCalcWidth::ValueNode_BLineCalcWidth(const ValueBase::Type &x):
        LinkableValueNode(x)
 {
+       Vocab ret(get_children_vocab());
+       set_children_vocab(ret);
        if(x!=ValueBase::TYPE_REAL)
                throw Exception::BadType(ValueBase::type_local_name(x));
 
@@ -177,54 +179,40 @@ ValueNode_BLineCalcWidth::get_link_vfunc(int i)const
        return 0;
 }
 
-int
-ValueNode_BLineCalcWidth::link_count()const
+bool
+ValueNode_BLineCalcWidth::check_type(ValueBase::Type type)
 {
-       return 4;
+       return type==ValueBase::TYPE_REAL;
 }
 
-String
-ValueNode_BLineCalcWidth::link_name(int i)const
+LinkableValueNode::Vocab
+ValueNode_BLineCalcWidth::get_children_vocab_vfunc()const
 {
-       assert(i>=0 && i<link_count());
+       if(children_vocab.size())
+               return children_vocab;
 
-       switch(i)
-       {
-               case 0: return "bline";
-               case 1: return "loop";
-               case 2: return "amount";
-               case 3: return "scale";
-       }
-       return String();
-}
+       LinkableValueNode::Vocab ret;
 
-String
-ValueNode_BLineCalcWidth::link_local_name(int i)const
-{
-       assert(i>=0 && i<link_count());
+       ret.push_back(ParamDesc(ValueBase(),"bline")
+               .set_local_name(_("BLine"))
+               .set_description(_("The BLine where the width is linked to"))
+       );
 
-       switch(i)
-       {
-               case 0: return _("BLine");
-               case 1: return _("Loop");
-               case 2: return _("Amount");
-               case 3: return _("Scale");
-       }
-       return String();
-}
+       ret.push_back(ParamDesc(ValueBase(),"loop")
+               .set_local_name(_("Loop"))
+               .set_description(_("When checked, the amount would loop"))
+       );
 
-int
-ValueNode_BLineCalcWidth::get_link_index_from_name(const String &name)const
-{
-       if(name=="bline")  return 0;
-       if(name=="loop")   return 1;
-       if(name=="amount") return 2;
-       if(name=="scale")  return 3;
-       throw Exception::BadLinkName(name);
-}
+       ret.push_back(ParamDesc(ValueBase(),"amount")
+               .set_local_name(_("Amount"))
+               .set_description(_("The position of the linked width on the BLine (0,1]"))
+       );
 
-bool
-ValueNode_BLineCalcWidth::check_type(ValueBase::Type type)
-{
-       return type==ValueBase::TYPE_REAL;
+       ret.push_back(ParamDesc(ValueBase(),"scale")
+               .set_local_name(_("Scale"))
+               .set_description(_("Scale of the width"))
+       );
+
+       return ret;
 }
+