Merge branch 'genete_static_values'
[synfig.git] / synfig-core / src / synfig / valuenode_const.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuenode_const.cpp
3 **      \brief Implementation of the "Constant" valuenode conversion.
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "valuenode_const.h"
33 #include "general.h"
34
35 #endif
36
37 /* === U S I N G =========================================================== */
38
39 using namespace std;
40 using namespace etl;
41 using namespace synfig;
42
43 /* === M A C R O S ========================================================= */
44
45 /* === G L O B A L S ======================================================= */
46
47 /* === P R O C E D U R E S ================================================= */
48
49 /* === M E T H O D S ======================================================= */
50
51 ValueNode_Const::ValueNode_Const()
52 {
53 }
54
55
56 ValueNode_Const::ValueNode_Const(const ValueBase &x):
57         ValueNode       (x.get_type()),
58         value           (x)
59 {
60 }
61
62
63 ValueNode_Const*
64 ValueNode_Const::create(const ValueBase &x)
65 {
66         return new ValueNode_Const(x);
67 }
68
69
70 ValueNode*
71 ValueNode_Const::clone(const GUID& deriv_guid)const
72 {
73         { ValueNode* x(find_value_node(get_guid()^deriv_guid).get()); if(x)return x; }
74         ValueNode* ret(new ValueNode_Const(value));
75         ret->set_guid(get_guid()^deriv_guid);
76         return ret;
77 }
78
79
80 ValueNode_Const::~ValueNode_Const()
81 {
82 }
83
84
85 ValueBase
86 ValueNode_Const::operator()(Time /*t*/)const
87 {
88         if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
89                 printf("%s:%d operator()\n", __FILE__, __LINE__);
90
91         return value;
92 }
93
94
95 const ValueBase &
96 ValueNode_Const::get_value()const
97 {
98         return value;
99 }
100
101 ValueBase &
102 ValueNode_Const::get_value()
103 {
104         return value;
105 }
106
107 void
108 ValueNode_Const::set_value(const ValueBase &data)
109 {
110         if(data!=value)
111         {
112                 value=data;
113                 changed();
114         }
115 }
116
117
118 String
119 ValueNode_Const::get_name()const
120 {
121         return get_static()?"static":"constant";
122 }
123
124 String
125 ValueNode_Const::get_local_name()const
126 {
127         return get_static()?_("Static"):_("Constant");
128 }
129
130 void ValueNode_Const::get_times_vfunc(Node::time_set &/*set*/) const
131 {
132 }