New static member ValueBase::type_local_name() to allow translation of type names.
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_timedswap.cpp
index c0011ea..bb564c6 100644 (file)
@@ -1,11 +1,12 @@
 /* === S Y N F I G ========================================================= */
 /*!    \file valuenode_timedswap.cpp
-**     \brief Template File
+**     \brief Implementation of the "Timed Swap" 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
@@ -34,6 +35,7 @@
 #include "valuenode_const.h"
 #include <stdexcept>
 #include "color.h"
+#include <ETL/misc>
 
 #endif
 
@@ -219,7 +221,7 @@ synfig::ValueNode_TimedSwap::operator()(Time t)const
                        {
                                float a=(float)(*after)(t).get(int());
                                float b=(float)(*before)(t).get(int());
-                               return static_cast<int>((b-a)*amount+a+0.5f);
+                               return round_to_int((b-a)*amount+a);
                        }
                case ValueBase::TYPE_REAL:
                        {
@@ -256,7 +258,8 @@ synfig::ValueNode_TimedSwap::operator()(Time t)const
 bool
 ValueNode_TimedSwap::set_link_vfunc(int i,ValueNode::Handle x)
 {
-       assert(i>=0 && i<4);
+       assert(i>=0 && i<link_count());
+
        switch(i)
        {
        case 0: return set_before(x);
@@ -270,7 +273,8 @@ ValueNode_TimedSwap::set_link_vfunc(int i,ValueNode::Handle x)
 ValueNode::LooseHandle
 ValueNode_TimedSwap::get_link_vfunc(int i)const
 {
-       assert(i>=0 && i<4);
+       assert(i>=0 && i<link_count());
+
        switch(i)
        {
        case 0: return get_before();
@@ -290,7 +294,8 @@ ValueNode_TimedSwap::link_count()const
 String
 ValueNode_TimedSwap::link_local_name(int i)const
 {
-       assert(i>=0 && i<4);
+       assert(i>=0 && i<link_count());
+
        switch(i)
        {
        case 0: return _("Before");
@@ -304,7 +309,8 @@ ValueNode_TimedSwap::link_local_name(int i)const
 String
 ValueNode_TimedSwap::link_name(int i)const
 {
-       assert(i>=0 && i<4);
+       assert(i>=0 && i<link_count());
+
        switch(i)
        {
        case 0: return "before";