my log
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / valuenodeconstset.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuenodeconstset.cpp
3 **      \brief Template File
4 **
5 **      $Id: valuenodeconstset.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "valuenodeconstset.h"
32 #include <synfigapp/canvasinterface.h>
33
34 #endif
35
36 using namespace std;
37 using namespace etl;
38 using namespace synfig;
39 using namespace synfigapp;
40 using namespace Action;
41
42 /* === M A C R O S ========================================================= */
43
44 ACTION_INIT(Action::ValueNodeConstSet);
45 ACTION_SET_NAME(Action::ValueNodeConstSet,"value_node_const_set");
46 ACTION_SET_LOCAL_NAME(Action::ValueNodeConstSet,_("Set ValueNode_Const"));
47 ACTION_SET_TASK(Action::ValueNodeConstSet,"set");
48 ACTION_SET_CATEGORY(Action::ValueNodeConstSet,Action::CATEGORY_VALUENODE);
49 ACTION_SET_PRIORITY(Action::ValueNodeConstSet,0);
50 ACTION_SET_VERSION(Action::ValueNodeConstSet,"0.0");
51 ACTION_SET_CVS_ID(Action::ValueNodeConstSet,"$Id: valuenodeconstset.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
52
53 /* === G L O B A L S ======================================================= */
54
55 /* === P R O C E D U R E S ================================================= */
56
57 /* === M E T H O D S ======================================================= */
58
59 Action::ValueNodeConstSet::ValueNodeConstSet()
60 {
61         set_dirty(true);
62 }
63
64 Action::ParamVocab
65 Action::ValueNodeConstSet::get_param_vocab()
66 {
67         ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
68         
69         ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
70                 .set_local_name(_("ValueNode_Const"))
71         );
72
73         ret.push_back(ParamDesc("new_value",Param::TYPE_VALUE)
74                 .set_local_name(_("ValueBase"))
75         );
76         
77         return ret;
78 }
79
80 bool
81 Action::ValueNodeConstSet::is_canidate(const ParamList &x)
82 {
83         if(canidate_check(get_param_vocab(),x))
84         {
85                 if(ValueNode_Const::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()))
86                         return true;
87         }
88         return false;
89 }
90
91 bool
92 Action::ValueNodeConstSet::set_param(const synfig::String& name, const Action::Param &param)
93 {
94         if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
95         {
96                 value_node=ValueNode_Const::Handle::cast_dynamic(param.get_value_node());
97                 
98                 return (bool)value_node;
99         }
100
101         if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
102         {
103                 new_value=param.get_value();
104                 
105                 return true;
106         }
107
108         return Action::CanvasSpecific::set_param(name,param);
109 }
110
111 bool
112 Action::ValueNodeConstSet::is_ready()const
113 {
114         if(!value_node || !new_value.is_valid())
115                 return false;
116         return Action::CanvasSpecific::is_ready();
117 }
118
119 void
120 Action::ValueNodeConstSet::perform()
121 {
122         //set_dirty(true);
123         
124         old_value=value_node->get_value();
125
126         value_node->set_value(new_value);       
127         
128         // Signal that a layer has been inserted
129         /*if(get_canvas_interface())
130         {
131                 get_canvas_interface()->signal_value_node_changed()(value_node);
132         }*/
133 }
134
135 void
136 Action::ValueNodeConstSet::undo()
137 {
138         //set_dirty(true);
139
140         value_node->set_value(old_value);       
141         
142         // Signal that a layer has been inserted
143         /*if(get_canvas_interface())
144         {
145                 get_canvas_interface()->signal_value_node_changed()(value_node);
146         }*/
147 }