X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fvaluenode.cpp;h=61714a21e6fa8a33d868a6daa839ff4f0b290fc9;hb=d8a0d032dc97e5c058ef37b79e245689b2ae7c10;hp=f1df7ca0157e471a0a67c6545c5cc73775fc4d1b;hpb=28f28705612902c15cd0702cc891fba35bf2d2df;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/valuenode.cpp b/synfig-core/trunk/src/synfig/valuenode.cpp index f1df7ca..61714a2 100644 --- a/synfig-core/trunk/src/synfig/valuenode.cpp +++ b/synfig-core/trunk/src/synfig/valuenode.cpp @@ -1,20 +1,21 @@ /* === S Y N F I G ========================================================= */ -/*! \file value_node.cpp +/*! \file valuenode.cpp ** \brief Template File ** -** $Id: valuenode.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -43,6 +44,7 @@ #include "valuenode_scale.h" #include "valuenode_segcalctangent.h" #include "valuenode_segcalcvertex.h" +#include "valuenode_repeat_gradient.h" #include "valuenode_stripes.h" #include "valuenode_subtract.h" #include "valuenode_timedswap.h" @@ -52,6 +54,7 @@ #include "valuenode_radialcomposite.h" #include "valuenode_gradientrotate.h" #include "valuenode_sine.h" +#include "valuenode_exp.h" #include "layer.h" @@ -87,26 +90,37 @@ ValueNode::subsys_init() { book_=new LinkableValueNode::Book(); -#define ADD_VALUENODE(c,n) (*book_)[n].factory=reinterpret_cast(&c::create); (*book_)[n].check_type=&c::check_type;(*book_)[n].local_name=n -#define ADD_VALUENODE2(c,n) (*book_)[n].factory=reinterpret_cast(&c::create_from); (*book_)[n].check_type=&c::check_type;(*book_)[n].local_name=n - - ADD_VALUENODE(ValueNode_Linear,"linear"); - ADD_VALUENODE(ValueNode_Composite,"composite"); - ADD_VALUENODE(ValueNode_RadialComposite,"radial_composite"); - ADD_VALUENODE(ValueNode_Reference,"reference"); - ADD_VALUENODE(ValueNode_Scale,"scale"); - ADD_VALUENODE(ValueNode_SegCalcTangent,"segcalctangent"); - ADD_VALUENODE(ValueNode_SegCalcVertex,"segcalcvertex"); - ADD_VALUENODE(ValueNode_Stripes,"stripes"); - ADD_VALUENODE(ValueNode_Subtract,"subtract"); - //ADD_VALUENODE(ValueNode_TimedSwap,"timed_swap"); - ADD_VALUENODE(ValueNode_TwoTone,"twotone"); - ADD_VALUENODE(ValueNode_BLine,"bline"); - ADD_VALUENODE2(ValueNode_DynamicList,"dynamic_list"); - ADD_VALUENODE(ValueNode_GradientRotate,"gradient_rotate"); - ADD_VALUENODE(ValueNode_Sine,"sine"); - +#define ADD_VALUENODE(class,name,local) \ + (*book_)[name].factory=reinterpret_cast(&class::create); \ + (*book_)[name].check_type=&class::check_type; \ + (*book_)[name].local_name=local + +#define ADD_VALUENODE2(class,name,local) \ + (*book_)[name].factory=reinterpret_cast(&class::create_from); \ + (*book_)[name].check_type=&class::check_type; \ + (*book_)[name].local_name=local + + ADD_VALUENODE(ValueNode_Linear, "linear", _("Linear") ); + ADD_VALUENODE(ValueNode_Composite, "composite", _("Composite") ); + ADD_VALUENODE(ValueNode_RadialComposite,"radial_composite", _("Radial Composite") ); + ADD_VALUENODE(ValueNode_Reference, "reference", _("Reference") ); + ADD_VALUENODE(ValueNode_Repeat_Gradient,"repeat_gradient", _("Repeat Gradient") ); + ADD_VALUENODE(ValueNode_Scale, "scale", _("Scale") ); + ADD_VALUENODE(ValueNode_SegCalcTangent, "segcalctangent", _("Segment Tangent") ); + ADD_VALUENODE(ValueNode_SegCalcVertex, "segcalcvertex", _("Segment Vertex") ); + ADD_VALUENODE(ValueNode_Stripes, "stripes", _("Stripes") ); + ADD_VALUENODE(ValueNode_Subtract, "subtract", _("Subtract") ); + ADD_VALUENODE(ValueNode_TimedSwap, "timed_swap", _("Timed Swap") ); + ADD_VALUENODE(ValueNode_TwoTone, "twotone", _("Two-Tone") ); + ADD_VALUENODE(ValueNode_BLine, "bline", _("BLine") ); + ADD_VALUENODE2(ValueNode_DynamicList, "dynamic_list", _("Dynamic List") ); + ADD_VALUENODE(ValueNode_GradientRotate, "gradient_rotate", _("Gradient Rotate") ); + ADD_VALUENODE(ValueNode_Sine, "sine", _("Sine") ); + ADD_VALUENODE(ValueNode_Exp, "exp", _("Exponential") ); + #undef ADD_VALUENODE +#undef ADD_VALUENODE2 + return true; } @@ -121,8 +135,8 @@ ValueNode::subsys_stop() if(global_value_node_map.size()!=value_node_count) synfig::error("value node count mismatch! map.size()!=value_node_count (%d!=%d)",global_value_node_map.size(),value_node_count); - - GlobalValueNodeMap::iterator iter; + + GlobalValueNodeMap::iterator iter; for(iter=global_value_node_map.begin();iter!=global_value_node_map.end();++iter) { if(!iter->second->is_exported()) @@ -177,13 +191,13 @@ bool LinkableValueNode::set_link(int i,ValueNode::Handle x) { ValueNode::Handle previous(get_link(i)); - + if(set_link_vfunc(i,x)) { if(previous) remove_child(previous.get()); add_child(x.get()); - + if(!x->is_exported() && get_parent_canvas()) { x->set_parent_canvas(get_parent_canvas()); @@ -214,7 +228,7 @@ LinkableValueNode::unlink_all() ValueNode::~ValueNode() { value_node_count--; - + begin_delete(); //DEBUGPOINT(); @@ -223,11 +237,14 @@ ValueNode::~ValueNode() void ValueNode::on_changed() { - if(get_parent_canvas()) - get_parent_canvas()->signal_value_node_changed()(this); - else if(get_root_canvas() && get_parent_canvas()) + etl::loose_handle parent_canvas = get_parent_canvas(); + if(parent_canvas) + do // signal to all the ancestor canvases + parent_canvas->signal_value_node_changed()(this); + while (parent_canvas = parent_canvas->parent()); + else if(get_root_canvas()) get_root_canvas()->signal_value_node_changed()(this); - + Node::on_changed(); } @@ -236,7 +253,7 @@ ValueNode::replace(etl::handle x) { if(x.get()==this) return 0; - + while(parent_set.size()) { (*parent_set.begin())->add_child(x.get()); @@ -317,9 +334,9 @@ ValueNodeList::surefind(const String &id) { if(id.empty()) throw Exception::IDNotFound("Empty ID"); - + ValueNode::Handle value_node; - + try { value_node=find(id); @@ -374,11 +391,11 @@ ValueNodeList::add(ValueNode::Handle value_node) return false; } catch(Exception::IDNotFound) - { + { push_back(value_node); return true; } - + return false; } @@ -420,7 +437,7 @@ PlaceholderValueNode::create(ValueBase::Type type) } ValueBase -PlaceholderValueNode::operator()(Time t)const +PlaceholderValueNode::operator()(Time /*t*/)const { assert(0); return ValueBase(); @@ -439,7 +456,7 @@ LinkableValueNode::clone(const GUID& deriv_guid)const int i; LinkableValueNode *ret=create_new(); ret->set_guid(get_guid()^deriv_guid); - + for(i=0;i x)const { assert(is_exported()); assert(canvas_); - + if(x.get()==canvas_.get()) return get_id(); - + return canvas_->_get_relative_id(x)+':'+get_id(); } @@ -484,9 +501,9 @@ ValueNode::set_root_canvas(etl::loose_handle x) void LinkableValueNode::get_times_vfunc(Node::time_set &set) const { ValueNode::LooseHandle h; - + int size = link_count(); - + //just add it to the set... for(int i=0; i < size; ++i) {