1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_timestring.cpp
3 ** \brief Implementation of the "TimeString" valuenode conversion.
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "valuenode_timestring.h"
34 #include "valuenode_const.h"
40 /* === U S I N G =========================================================== */
44 using namespace synfig;
46 /* === M A C R O S ========================================================= */
48 /* === G L O B A L S ======================================================= */
50 /* === P R O C E D U R E S ================================================= */
52 /* === M E T H O D S ======================================================= */
54 ValueNode_TimeString::ValueNode_TimeString(const ValueBase &value):
55 LinkableValueNode(value.get_type())
57 switch(value.get_type())
59 case ValueBase::TYPE_STRING:
60 set_link("time",ValueNode_Const::create(Time(0)));
63 throw Exception::BadType(ValueBase::type_local_name(value.get_type()));
68 ValueNode_TimeString::create_new()const
70 return new ValueNode_TimeString(get_type());
74 ValueNode_TimeString::create(const ValueBase &x)
76 return new ValueNode_TimeString(x);
79 ValueNode_TimeString::~ValueNode_TimeString()
85 ValueNode_TimeString::operator()(Time t)const
87 if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
88 printf("%s:%d operator()\n", __FILE__, __LINE__);
90 Time time((*time_)(t).get(Time()));
94 case ValueBase::TYPE_STRING:
95 if (get_root_canvas())
96 return time.get_string(get_root_canvas()->rend_desc().get_frame_rate());
98 return time.get_string();
108 ValueNode_TimeString::get_name()const
114 ValueNode_TimeString::get_local_name()const
116 return _("Time String");
120 ValueNode_TimeString::set_link_vfunc(int i,ValueNode::Handle value)
122 assert(i>=0 && i<link_count());
126 case 0: CHECK_TYPE_AND_SET_VALUE(time_, ValueBase::TYPE_TIME);
131 ValueNode::LooseHandle
132 ValueNode_TimeString::get_link_vfunc(int i)const
134 assert(i>=0 && i<link_count());
138 case 0: return time_;
145 ValueNode_TimeString::link_count()const
151 ValueNode_TimeString::link_name(int i)const
153 assert(i>=0 && i<link_count());
157 case 0: return "time";
163 ValueNode_TimeString::link_local_name(int i)const
165 assert(i>=0 && i<link_count());
169 case 0: return _("Time");
175 ValueNode_TimeString::get_link_index_from_name(const String &name)const
177 if (name=="time") return 0;
179 throw Exception::BadLinkName(name);
183 ValueNode_TimeString::check_type(ValueBase::Type type)
186 type==ValueBase::TYPE_STRING;