1 /* === S Y N F I G ========================================================= */
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "layerparamset.h"
33 #include "valuenodeconstset.h"
34 #include "valuedescconnect.h"
35 #include "waypointsetsmart.h"
38 #include <synfigapp/canvasinterface.h>
39 #include <synfigapp/main.h>
41 #include <synfigapp/general.h>
47 using namespace synfig;
48 using namespace synfigapp;
49 using namespace Action;
51 /* === M A C R O S ========================================================= */
53 ACTION_INIT(Action::ColorSetFromOC);
54 ACTION_SET_NAME(Action::ColorSetFromOC, "ColorSetFromOC");
55 ACTION_SET_LOCAL_NAME(Action::ColorSetFromOC, N_("Apply Outline Color"));
56 ACTION_SET_TASK(Action::ColorSetFromOC, "set");
57 ACTION_SET_CATEGORY(Action::ColorSetFromOC, Action::CATEGORY_VALUEDESC);
58 ACTION_SET_PRIORITY(Action::ColorSetFromOC, 0);
59 ACTION_SET_VERSION(Action::ColorSetFromOC, "0.0");
60 ACTION_SET_CVS_ID(Action::ColorSetFromOC, "$Id$");
62 ACTION_INIT(Action::ColorSetFromFC);
63 ACTION_SET_NAME(Action::ColorSetFromFC, "ColorSetFromFC");
64 ACTION_SET_LOCAL_NAME(Action::ColorSetFromFC, N_("Apply Fill Color"));
65 ACTION_SET_TASK(Action::ColorSetFromFC, "set");
66 ACTION_SET_CATEGORY(Action::ColorSetFromFC, Action::CATEGORY_VALUEDESC);
67 ACTION_SET_PRIORITY(Action::ColorSetFromFC, 0);
68 ACTION_SET_VERSION(Action::ColorSetFromFC, "0.0");
69 ACTION_SET_CVS_ID(Action::ColorSetFromFC, "$Id$");
71 /* === G L O B A L S ======================================================= */
73 /* === P R O C E D U R E S ================================================= */
75 /* === M E T H O D S ======================================================= */
77 Action::ColorSet::ColorSet(bool use_outline_color):
78 time(0), use_outline_color(use_outline_color)
83 Action::ColorSet::get_param_vocab()
85 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
87 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
88 .set_local_name(_("ValueDesc"))
89 .set_supports_multiple()
92 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
93 .set_local_name(_("Time"))
101 Action::ColorSet::is_candidate(const ParamList &x)
103 if (!candidate_check(get_param_vocab(), x))
106 std::multimap<synfig::String, Param>::const_iterator iter;
107 for (iter = x.begin(); iter != x.end(); ++iter)
109 if (iter->first == "value_desc" &&
110 iter->second.get_value_desc().get_value_type() != ValueBase::TYPE_COLOR)
118 Action::ColorSet::set_param(const synfig::String& name, const Action::Param ¶m)
120 if (name == "value_desc" && param.get_type() == Param::TYPE_VALUEDESC)
122 // Grab the value_desc
123 ValueDesc value_desc = param.get_value_desc();
124 if (value_desc.get_value_type() != ValueBase::TYPE_COLOR)
127 value_desc_list.push_back(value_desc);
129 // Grab the current outline or fill color
130 if (use_outline_color)
131 color = synfigapp::Main::get_outline_color();
133 color = synfigapp::Main::get_fill_color();
138 if (name == "time" && param.get_type() == Param::TYPE_TIME)
140 time = param.get_time();
145 return Action::CanvasSpecific::set_param(name, param);
149 Action::ColorSet::is_ready() const
151 if (value_desc_list.size() == 0)
154 return Action::CanvasSpecific::is_ready();
158 Action::ColorSet::prepare()
162 std::list<ValueDesc>::iterator iter;
163 for (iter = value_desc_list.begin(); iter != value_desc_list.end(); ++iter)
165 ValueDesc& value_desc(*iter);
167 Action::Handle action = Action::create("ValueDescSet");
168 action->set_param("canvas", get_canvas());
169 action->set_param("canvas_interface", get_canvas_interface());
170 action->set_param("value_desc", value_desc);
171 action->set_param("new_value", ValueBase(color));
172 action->set_param("time", time);
174 if (!action->is_ready())
175 throw Error(Error::TYPE_NOTREADY);
177 add_action_front(action);