Load and save canvas now understand load and save static option for real value base.
authorCarlos Lopez <genetita@gmail.com>
Sun, 22 Aug 2010 19:10:52 +0000 (21:10 +0200)
committerCarlos Lopez <genetita@gmail.com>
Sun, 22 Aug 2010 19:10:52 +0000 (21:10 +0200)
It is pending all the rest of value base types.

synfig-core/src/synfig/loadcanvas.cpp
synfig-core/src/synfig/loadcanvas.h
synfig-core/src/synfig/savecanvas.cpp

index 08a0f06..37c5d1d 100644 (file)
@@ -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);
index b347850..8cfc482 100644 (file)
@@ -203,6 +203,9 @@ private:
        //! Dynamic List Parsnig Function
        etl::handle<ValueNode_DynamicList> 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 ======================================================= */
index 7682195..af459cb 100644 (file)
@@ -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: