1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_subtract.cpp
3 ** \brief Template File
5 ** $Id: valuenode_twotone.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
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 ======================================================= */
33 #include "valuenode_twotone.h"
34 #include "valuenode_const.h"
41 /* === U S I N G =========================================================== */
45 using namespace synfig;
47 /* === M A C R O S ========================================================= */
49 /* === G L O B A L S ======================================================= */
51 /* === P R O C E D U R E S ================================================= */
53 /* === M E T H O D S ======================================================= */
55 synfig::ValueNode_TwoTone::ValueNode_TwoTone():LinkableValueNode(synfig::ValueBase::TYPE_GRADIENT)
57 set_link("color1",ValueNode_Const::create(Color::black()));
58 set_link("color2",ValueNode_Const::create(Color::white()));
63 ValueNode_TwoTone::create_new()const
65 return new ValueNode_TwoTone();
69 ValueNode_TwoTone::create(const ValueBase& x)
71 ValueBase::Type id(x.get_type());
72 if(id!=ValueBase::TYPE_GRADIENT)
75 throw runtime_error("synfig::ValueNode_TwoTone:Bad type "+ValueBase::type_name(id));
78 ValueNode_TwoTone* value_node=new ValueNode_TwoTone();
80 assert(value_node->get_type()==id);
85 synfig::ValueNode_TwoTone::~ValueNode_TwoTone()
91 synfig::ValueNode_TwoTone::set_lhs(ValueNode::Handle a)
93 if(a->get_type()!=ValueBase::TYPE_COLOR)
102 synfig::ValueNode_TwoTone::set_rhs(ValueNode::Handle b)
104 if(b->get_type()!=ValueBase::TYPE_COLOR)
111 synfig::ValueNode_TwoTone::operator()(Time t)const
113 return Gradient((*ref_a)(t).get(Color()),(*ref_b)(t).get(Color()));
117 ValueNode_TwoTone::set_link_vfunc(int i,ValueNode::Handle x)
123 if(set_lhs(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
124 else { return false; }
126 if(set_rhs(x)) { signal_child_changed()(i);signal_value_changed()(); return true; }
127 else { return false; }
133 ValueNode::LooseHandle
134 ValueNode_TwoTone::get_link_vfunc(int i)const
148 ValueNode_TwoTone::link_count()const
154 ValueNode_TwoTone::link_local_name(int i)const
168 ValueNode_TwoTone::link_name(int i)const
182 ValueNode_TwoTone::get_link_index_from_name(const String &name)const
188 throw Exception::BadLinkName(name);
192 ValueNode_TwoTone::get_name()const
198 ValueNode_TwoTone::get_local_name()const
200 return _("Two-Tone");
204 ValueNode_TwoTone::check_type(ValueBase::Type type)
206 return type==ValueBase::TYPE_GRADIENT;