Use the translated version of the type name in the parameter dialog.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_scale.cpp
index 7bd8d18..9c2924a 100644 (file)
@@ -1,11 +1,12 @@
 /* === S Y N F I G ========================================================= */
 /*!    \file valuenode_scale.cpp
-**     \brief Template File
+**     \brief Implementation of the "Scale" valuenode conversion.
 **
 **     $Id$
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
 #include "valuenode_scale.h"
 #include "valuenode_const.h"
 #include <stdexcept>
-#include <cassert>
 #include "color.h"
 #include "vector.h"
 #include "time.h"
 #include "angle.h"
+#include <ETL/misc>
 
 #endif
 
@@ -163,23 +164,9 @@ synfig::ValueNode_Scale::operator()(Time t)const
 {
        if(!value_node || !scalar)
                throw runtime_error(strprintf("ValueNode_Scale: %s",_("One or both of my parameters aren't set!")));
-       else
-       if(get_type()==ValueBase::TYPE_VECTOR)
-               return (*value_node)(t).get(Vector())*(*scalar)(t).get(Real());
-       else
-       if(get_type()==ValueBase::TYPE_REAL)
-               return (*value_node)(t).get(Real())*(*scalar)(t).get(Real());
-       else
-       if(get_type()==ValueBase::TYPE_TIME)
-               return (*value_node)(t).get(Time())*(*scalar)(t).get(Time());
-       else
-       if(get_type()==ValueBase::TYPE_INTEGER)
-               return (*value_node)(t).get(int())*(*scalar)(t).get(Real());
-       else
-       if(get_type()==ValueBase::TYPE_ANGLE)
+       else if(get_type()==ValueBase::TYPE_ANGLE)
                return (*value_node)(t).get(Angle())*(*scalar)(t).get(Real());
-       else
-       if(get_type()==ValueBase::TYPE_COLOR)
+       else if(get_type()==ValueBase::TYPE_COLOR)
        {
                Color ret((*value_node)(t).get(Color()));
                Real s((*scalar)(t).get(Real()));
@@ -188,6 +175,14 @@ synfig::ValueNode_Scale::operator()(Time t)const
                ret.set_b(ret.get_b()*s);
                return ret;
        }
+       else if(get_type()==ValueBase::TYPE_INTEGER)
+               return round_to_int((*value_node)(t).get(int())*(*scalar)(t).get(Real()));
+       else if(get_type()==ValueBase::TYPE_REAL)
+               return (*value_node)(t).get(Real())*(*scalar)(t).get(Real());
+       else if(get_type()==ValueBase::TYPE_TIME)
+               return (*value_node)(t).get(Time())*(*scalar)(t).get(Time());
+       else if(get_type()==ValueBase::TYPE_VECTOR)
+               return (*value_node)(t).get(Vector())*(*scalar)(t).get(Real());
 
        assert(0);
        return ValueBase();
@@ -197,8 +192,7 @@ synfig::ValueNode_Scale::operator()(Time t)const
 bool
 ValueNode_Scale::set_link_vfunc(int i,ValueNode::Handle x)
 {
-       if(!(i==0 || i==1))
-               return false;
+       assert(i>=0 && i<link_count());
 
        if(i==0 && !set_value_node(x))
                return false;
@@ -214,7 +208,8 @@ ValueNode_Scale::set_link_vfunc(int i,ValueNode::Handle x)
 ValueNode::LooseHandle
 ValueNode_Scale::get_link_vfunc(int i)const
 {
-       assert(i==0 || i==1);
+       assert(i>=0 && i<link_count());
+
        if(i==0)
                return value_node;
        else if(i==1)
@@ -231,7 +226,8 @@ ValueNode_Scale::link_count()const
 String
 ValueNode_Scale::link_local_name(int i)const
 {
-       assert(i==0 || i==1);
+       assert(i>=0 && i<link_count());
+
        if(i==0)
                return _("Link");
        else if(i==1)
@@ -242,7 +238,8 @@ ValueNode_Scale::link_local_name(int i)const
 String
 ValueNode_Scale::link_name(int i)const
 {
-       assert(i==0 || i==1);
+       assert(i>=0 && i<link_count());
+
        if(i==0)
                return "link";
        else if(i==1)
@@ -277,9 +274,10 @@ bool
 ValueNode_Scale::check_type(ValueBase::Type type)
 {
        return
-               type==ValueBase::TYPE_VECTOR ||
-               type==ValueBase::TYPE_REAL ||
-               type==ValueBase::TYPE_INTEGER ||
+               type==ValueBase::TYPE_ANGLE ||
                type==ValueBase::TYPE_COLOR ||
-               type==ValueBase::TYPE_ANGLE;
+               type==ValueBase::TYPE_INTEGER ||
+               type==ValueBase::TYPE_REAL ||
+               type==ValueBase::TYPE_TIME ||
+               type==ValueBase::TYPE_VECTOR;
 }