From: Carlos Lopez Date: Sun, 22 Aug 2010 19:10:52 +0000 (+0200) Subject: Load and save canvas now understand load and save static option for real value base. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b890431f7577909e7c5887b21b0456267ce1faa4;p=synfig.git Load and save canvas now understand load and save static option for real value base. It is pending all the rest of value base types. --- diff --git a/synfig-core/src/synfig/loadcanvas.cpp b/synfig-core/src/synfig/loadcanvas.cpp index 08a0f06..37c5d1d 100644 --- a/synfig-core/src/synfig/loadcanvas.cpp +++ b/synfig-core/src/synfig/loadcanvas.cpp @@ -824,11 +824,35 @@ CanvasParser::parse_angle(xmlpp::Element *element) return Angle::deg(atof(val.c_str())); } +bool +CanvasParser::parse_static(xmlpp::Element *element) +{ + if(!element->get_attribute("static")) + return false; + + string val=element->get_attribute("static")->get_value(); + + if(val=="true" || val=="1") + return true; + if(val=="false" || val=="0") + return false; + + error(element,strprintf(_("Bad value \"%s\" in <%s>"),val.c_str(),"bool")); + + return false; +} + + ValueBase CanvasParser::parse_value(xmlpp::Element *element,Canvas::Handle canvas) { if(element->get_name()=="real") - return parse_real(element); + { + ValueBase ret; + ret.set(parse_real(element)); + ret.set_static(parse_static(element)); + return ret; + } else if(element->get_name()=="time") return parse_time(element,canvas); diff --git a/synfig-core/src/synfig/loadcanvas.h b/synfig-core/src/synfig/loadcanvas.h index b347850..8cfc482 100644 --- a/synfig-core/src/synfig/loadcanvas.h +++ b/synfig-core/src/synfig/loadcanvas.h @@ -203,6 +203,9 @@ private: //! Dynamic List Parsnig Function etl::handle parse_dynamic_list(xmlpp::Element *node,Canvas::Handle canvas); + //! Static option for ValueBase parsing fucntion + bool parse_static(xmlpp::Element *node); + }; // END of CanvasParser /* === E X T E R N S ======================================================= */ diff --git a/synfig-core/src/synfig/savecanvas.cpp b/synfig-core/src/synfig/savecanvas.cpp index 7682195..af459cb 100644 --- a/synfig-core/src/synfig/savecanvas.cpp +++ b/synfig-core/src/synfig/savecanvas.cpp @@ -92,10 +92,12 @@ xmlpp::Element* encode_keyframe(xmlpp::Element* root,const Keyframe &kf, float f } -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)); + if(s) + root->set_attribute("static", s?"true":"false"); return root; } @@ -212,7 +214,7 @@ 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())); case ValueBase::TYPE_INTEGER: