Write a proper definition for ValueNode_DynamicList::create_new().
[synfig.git] / synfig-core / trunk / src / synfig / valuenode_dynamiclist.cpp
index 7e8f378..0f59a87 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \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
@@ -576,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));
@@ -621,6 +628,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)
@@ -633,6 +641,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;
@@ -647,7 +656,8 @@ ValueNode_DynamicList::link_count()const
 String
 ValueNode_DynamicList::link_local_name(int i)const
 {
-       assert(i>=0 && (unsigned)i<list.size());
+       assert(i>=0 && i<link_count());
+
        return etl::strprintf(_("Item %03d"),i+1);
 }
 
@@ -709,6 +719,13 @@ ValueNode_DynamicList::check_type(ValueBase::Type type)
        return type==ValueBase::TYPE_LIST;
 }
 
+void
+ValueNode_DynamicList::set_member_canvas(etl::loose_handle<Canvas> canvas)
+{
+       for (vector<ListEntry>::iterator iter = list.begin(); iter != list.end(); iter++)
+               iter->value_node->set_parent_canvas(canvas);
+}
+
 ValueBase::Type
 ValueNode_DynamicList::get_contained_type()const
 {
@@ -718,8 +735,7 @@ ValueNode_DynamicList::get_contained_type()const
 LinkableValueNode*
 ValueNode_DynamicList::create_new()const
 {
-       assert(0);
-       return 0;
+       return new ValueNode_DynamicList(container_type);
 }
 
 int