X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fvaluenode_dynamiclist.cpp;h=a8c253a95a57c7261161762ae70b438889436849;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=a93a752560368ae6362c3dbaae25757c8d9b0478;hpb=5ddcf36f04cfbd10fabda4e3c5633cb27cdd4c0a;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/valuenode_dynamiclist.cpp b/synfig-core/trunk/src/synfig/valuenode_dynamiclist.cpp index a93a752..a8c253a 100644 --- a/synfig-core/trunk/src/synfig/valuenode_dynamiclist.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_dynamiclist.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ /*! \file valuenode_dynamiclist.cpp -** \brief Template File +** \brief Implementation of the "Dynamic List" valuenode conversion. ** -** $Id: valuenode_dynamiclist.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -405,7 +406,7 @@ ValueNode_DynamicList::ListEntry::status_at_time(const Time &t)const ActivepointList::const_iterator prev_iter; bool state(true); - // New "symetric" state mechanism + // New "symmetric" state mechanism if(!timing_info.empty()) { if(timing_info.size()==1) @@ -525,9 +526,17 @@ ValueNode_DynamicList::erase(const ValueNode::Handle &value_node_) if(value_node) { remove_child(value_node.get()); - if(get_parent_canvas()) - get_parent_canvas()->signal_value_node_child_removed()(this,value_node); - else if(get_root_canvas() && get_parent_canvas()) + // changed to fix bug 1420091 - it seems that when a .sif file containing a bline layer encapsulated inside + // another layer, get_parent_canvas() is false and get_root_canvas() is true, but when we come to erase a + // vertex, both are true. So the signal is sent to the parent, but the signal wasn't sent to the parent + // when it was added. This probably isn't the right fix, but it seems to work for now. Note that the same + // strange "if (X) else if (Y && X)" code is also present in the two previous functions, above. + + // if(get_parent_canvas()) + // get_parent_canvas()->signal_value_node_child_removed()(this,value_node); + // else if(get_root_canvas() && get_parent_canvas()) + // get_root_canvas()->signal_value_node_child_removed()(this,value_node); + if(get_root_canvas()) get_root_canvas()->signal_value_node_child_removed()(this,value_node); } break; @@ -568,6 +577,12 @@ ValueNode_DynamicList::create_from(const ValueBase &value) ValueNode_DynamicList* value_node(new ValueNode_DynamicList(value_list.front().get_type())); + // when creating a list of vectors, start it off being looped. + // I think the only time this is used if for creating polygons, + // and we want them to be looped by default + if (value_node->get_contained_type() == ValueBase::TYPE_VECTOR) + value_node->set_loop(true); + for(iter=value_list.begin();iter!=value_list.end();++iter) { ValueNode::Handle item(ValueNode_Const::create(*iter)); @@ -580,6 +595,9 @@ ValueNode_DynamicList::create_from(const ValueBase &value) ValueBase ValueNode_DynamicList::operator()(Time t)const { + if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS")) + printf("%s:%d operator()\n", __FILE__, __LINE__); + std::vector ret_list; std::vector::const_iterator iter; @@ -613,6 +631,7 @@ bool ValueNode_DynamicList::set_link_vfunc(int i,ValueNode::Handle x) { assert(i>=0); + if((unsigned)i>=list.size()) return false; if(x->get_type()!=container_type) @@ -625,6 +644,7 @@ ValueNode::LooseHandle ValueNode_DynamicList::get_link_vfunc(int i)const { assert(i>=0); + if((unsigned)i>=list.size()) return 0; return list[i].value_node; @@ -639,7 +659,8 @@ ValueNode_DynamicList::link_count()const String ValueNode_DynamicList::link_local_name(int i)const { - assert(i>=0 && (unsigned)i=0 && i(create_new()); ret->set_guid(get_guid()^deriv_guid); std::vector::const_iterator iter; @@ -662,7 +683,7 @@ ValueNode_DynamicList::clone(const GUID& deriv_guid)const ListEntry list_entry(*iter); //list_entry.value_node=find_value_node(iter->value_node->get_guid()^deriv_guid).get(); //if(!list_entry.value_node) - list_entry.value_node=iter->value_node->clone(deriv_guid); + list_entry.value_node=iter->value_node->clone(deriv_guid); ret->add(list_entry); //ret->list.back().value_node=iter->value_node.clone(); } @@ -701,6 +722,13 @@ ValueNode_DynamicList::check_type(ValueBase::Type type) return type==ValueBase::TYPE_LIST; } +void +ValueNode_DynamicList::set_member_canvas(etl::loose_handle canvas) +{ + for (vector::iterator iter = list.begin(); iter != list.end(); iter++) + iter->value_node->set_parent_canvas(canvas); +} + ValueBase::Type ValueNode_DynamicList::get_contained_type()const { @@ -710,8 +738,7 @@ ValueNode_DynamicList::get_contained_type()const LinkableValueNode* ValueNode_DynamicList::create_new()const { - assert(0); - return 0; + return new ValueNode_DynamicList(container_type); } int