X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fsynfig%2Fsavecanvas.cpp;h=34f3fbddc5452a046bb6bb512cc083d082219f5e;hb=d43ed398fd84b93b96eb91d91dafdf65c80537e6;hp=fa984ab9ef5d51c5e4c7e35565796702da03a680;hpb=47b46269fa64ab7c2cbff066c0708db780ad6cb8;p=synfig.git diff --git a/synfig-core/src/synfig/savecanvas.cpp b/synfig-core/src/synfig/savecanvas.cpp index fa984ab..34f3fbd 100644 --- a/synfig-core/src/synfig/savecanvas.cpp +++ b/synfig-core/src/synfig/savecanvas.cpp @@ -38,13 +38,9 @@ #include "general.h" #include "valuenode.h" #include "valuenode_animated.h" -//#include "valuenode_composite.h" #include "valuenode_const.h" -//#include "valuenode_linear.h" #include "valuenode_dynamiclist.h" #include "valuenode_reference.h" -//#include "valuenode_segcalctangent.h" -//#include "valuenode_segcalcvertex.h" #include "valuenode_bline.h" #include "time.h" #include "keyframe.h" @@ -95,74 +91,90 @@ xmlpp::Element* encode_keyframe(xmlpp::Element* root,const Keyframe &kf, float f return root; } +xmlpp::Element* encode_static(xmlpp::Element* root,bool s) +{ + if(s) + root->set_attribute("static", s?"true":"false"); + return root; +} -xmlpp::Element* encode_real(xmlpp::Element* root,Real v) + +xmlpp::Element* encode_real(xmlpp::Element* root,Real v,bool s=false) { root->set_name("real"); - root->set_attribute("value",strprintf(VECTOR_VALUE_TYPE_FORMAT,v)); + root->set_attribute("value",strprintf(VECTOR_VALUE_TYPE_FORMAT,v)); + encode_static(root, s); return root; } -xmlpp::Element* encode_time(xmlpp::Element* root,Time t) +xmlpp::Element* encode_time(xmlpp::Element* root,Time t,bool s=false) { root->set_name("time"); - root->set_attribute("value",t.get_string()); + root->set_attribute("value",t.get_string()); + encode_static(root, s); return root; } -xmlpp::Element* encode_integer(xmlpp::Element* root,int i) +xmlpp::Element* encode_integer(xmlpp::Element* root,int i,bool s=false) { root->set_name("integer"); root->set_attribute("value",strprintf("%i",i)); + encode_static(root, s); return root; } -xmlpp::Element* encode_bool(xmlpp::Element* root,bool b) +xmlpp::Element* encode_bool(xmlpp::Element* root, bool b,bool s=false) { root->set_name("bool"); root->set_attribute("value",b?"true":"false"); + encode_static(root, s); return root; } -xmlpp::Element* encode_string(xmlpp::Element* root,const String &str) +xmlpp::Element* encode_string(xmlpp::Element* root,const String &str,bool s=false) { root->set_name("string"); root->set_child_text(str); + encode_static(root, s); return root; } -xmlpp::Element* encode_vector(xmlpp::Element* root,Vector vect) +xmlpp::Element* encode_vector(xmlpp::Element* root,Vector vect,bool s=false) { root->set_name("vector"); root->add_child("x")->set_child_text(strprintf(VECTOR_VALUE_TYPE_FORMAT,(float)vect[0])); root->add_child("y")->set_child_text(strprintf(VECTOR_VALUE_TYPE_FORMAT,(float)vect[1])); + encode_static(root, s); return root; } -xmlpp::Element* encode_color(xmlpp::Element* root,Color color) +xmlpp::Element* encode_color(xmlpp::Element* root,Color color,bool s=false) { root->set_name("color"); root->add_child("r")->set_child_text(strprintf(COLOR_VALUE_TYPE_FORMAT,(float)color.get_r())); root->add_child("g")->set_child_text(strprintf(COLOR_VALUE_TYPE_FORMAT,(float)color.get_g())); root->add_child("b")->set_child_text(strprintf(COLOR_VALUE_TYPE_FORMAT,(float)color.get_b())); root->add_child("a")->set_child_text(strprintf(COLOR_VALUE_TYPE_FORMAT,(float)color.get_a())); + encode_static(root, s); return root; } -xmlpp::Element* encode_angle(xmlpp::Element* root,Angle theta) +xmlpp::Element* encode_angle(xmlpp::Element* root,Angle theta,bool s=false) { root->set_name("angle"); root->set_attribute("value",strprintf("%f",(float)Angle::deg(theta).get())); + encode_static(root, s); return root; } -xmlpp::Element* encode_segment(xmlpp::Element* root,Segment seg) +xmlpp::Element* encode_segment(xmlpp::Element* root,Segment seg,bool s=false) { root->set_name("segment"); encode_vector(root->add_child("p1")->add_child("vector"),seg.p1); encode_vector(root->add_child("t1")->add_child("vector"),seg.t1); encode_vector(root->add_child("p2")->add_child("vector"),seg.p2); encode_vector(root->add_child("t2")->add_child("vector"),seg.t2); + encode_static(root, s); return root; } @@ -181,10 +193,10 @@ xmlpp::Element* encode_bline_point(xmlpp::Element* root,BLinePoint bline_point) return root; } -xmlpp::Element* encode_gradient(xmlpp::Element* root,Gradient x) +xmlpp::Element* encode_gradient(xmlpp::Element* root,Gradient x,bool s=false) { root->set_name("gradient"); - + encode_static(root, s); Gradient::const_iterator iter; x.sort(); for(iter=x.begin();iter!=x.end();iter++) @@ -216,27 +228,27 @@ xmlpp::Element* encode_value(xmlpp::Element* root,const ValueBase &data,Canvas:: switch(data.get_type()) { case ValueBase::TYPE_REAL: - return encode_real(root,data.get(Real())); + return encode_real(root,data.get(Real()), data.get_static()); case ValueBase::TYPE_TIME: - return encode_time(root,data.get(Time())); + return encode_time(root,data.get(Time()), data.get_static()); case ValueBase::TYPE_INTEGER: - return encode_integer(root,data.get(int())); + return encode_integer(root,data.get(int()), data.get_static()); case ValueBase::TYPE_COLOR: - return encode_color(root,data.get(Color())); + return encode_color(root,data.get(Color()), data.get_static()); case ValueBase::TYPE_VECTOR: - return encode_vector(root,data.get(Vector())); + return encode_vector(root,data.get(Vector()), data.get_static()); case ValueBase::TYPE_ANGLE: - return encode_angle(root,data.get(Angle())); + return encode_angle(root,data.get(Angle()), data.get_static()); case ValueBase::TYPE_BOOL: - return encode_bool(root,data.get(bool())); + return encode_bool(root,data.get(bool()), data.get_static()); case ValueBase::TYPE_STRING: - return encode_string(root,data.get(String())); + return encode_string(root,data.get(String()), data.get_static()); case ValueBase::TYPE_SEGMENT: - return encode_segment(root,data.get(Segment())); + return encode_segment(root,data.get(Segment()), data.get_static()); case ValueBase::TYPE_BLINEPOINT: return encode_bline_point(root,data.get(BLinePoint())); case ValueBase::TYPE_GRADIENT: - return encode_gradient(root,data.get(Gradient())); + return encode_gradient(root,data.get(Gradient()), data.get_static()); case ValueBase::TYPE_LIST: return encode_list(root,data,canvas); case ValueBase::TYPE_CANVAS: @@ -265,10 +277,8 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter) { xmlpp::Element *waypoint_node=root->add_child("waypoint"); - //waypoint_node->set_attribute("time",iter->get_time().get_string(canvas->rend_desc().get_frame_rate())); waypoint_node->set_attribute("time",iter->get_time().get_string()); - //waypoint_node->add_child(encode_value(iter->get_value(),canvas)); if(iter->get_value_node()->is_exported()) waypoint_node->set_attribute("use",iter->get_value_node()->get_relative_id(canvas)); else { @@ -437,9 +447,6 @@ xmlpp::Element* encode_linkable_value_node(xmlpp::Element* root,LinkableValueNod ValueBase value((*value_node)(0)); encode_value(root,value,canvas); - // ValueNode_Const::ConstHandle const_value(ValueNode_Const::create((*value_node)(0))); - // encode_value_node(root,const_value,canvas); - return root; } @@ -561,6 +568,8 @@ xmlpp::Element* encode_layer(xmlpp::Element* root,Layer::ConstHandle layer) xmlpp::Element *node=root->add_child("param"); node->set_attribute("name",iter->get_name()); node->set_attribute("use",child->get_relative_id(layer->get_canvas())); + if(value.get_static()) + node->set_attribute("static", value.get_static()?"true":"false"); continue; } } @@ -651,7 +660,11 @@ xmlpp::Element* encode_canvas(xmlpp::Element* root,Canvas::ConstHandle canvas) } // Output the section - //! \todo check where the parentheses should really go - around the && or the ||? + //! Check where the parentheses should really go - around the && or the ||? + //! If children is not empty (there are exported canvases in the current canvas) + //! they must be listed in the defs section regardless the result of check the + //! Value Node list (exported value nodes in the canvas) and if the canvas is + //! in line or not. Inline canvases cannot have exported canvases inside. if((!canvas->is_inline() && !canvas->value_node_list().empty()) || !canvas->children().empty()) { xmlpp::Element *node=root->add_child("defs");