Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / synfig / value.cpp
index 6afa515..e5ef475 100644 (file)
@@ -6,7 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2007, 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
@@ -96,6 +96,40 @@ ValueBase::get(const char*)const
        return get(String()).c_str();
 }
 
+#ifdef _DEBUG
+String
+ValueBase::get_string() const
+{
+       switch(type)
+       {
+       case TYPE_NIL:                  return "Nil";
+       case TYPE_BOOL:                 return strprintf("Bool (%s)", get(bool()) ? "true" : "false");
+       case TYPE_INTEGER:              return strprintf("Integer (%s)", get(int()));
+       case TYPE_ANGLE:                return strprintf("Angle (%.2f)", Angle::deg(get(Angle())).get());
+
+               // All types after this point are larger than 32 bits
+
+       case TYPE_TIME:                 return strprintf("Time (%s)", get(Time()).get_string().c_str());
+       case TYPE_REAL:                 return strprintf("Real (%f)", get(Real()));
+
+               // All types after this point are larger than 64 bits
+
+       case TYPE_VECTOR:               return strprintf("Vector (%f, %f)", get(Vector())[0], get(Vector())[1]);
+       case TYPE_COLOR:                return strprintf("Color (%s)", get(Color()).get_string().c_str());
+       case TYPE_SEGMENT:              return strprintf("Segment ((%f, %f) to (%f, %f))", get(Segment()).p1[0], get(Segment()).p1[1], get(Segment()).p2[0], get(Segment()).p2[1]);
+       case TYPE_BLINEPOINT:   return strprintf("BLinePoint (%s)", get(BLinePoint()).get_vertex()[0], get(BLinePoint()).get_vertex()[1]);
+
+               // All types after this point require construction/destruction
+
+       case TYPE_LIST:                 return strprintf("List (%d elements)", get(list_type()).size());
+       case TYPE_CANVAS:               return strprintf("Canvas (%s)", get(etl::loose_handle<Canvas>())->get_id().c_str());
+       case TYPE_STRING:               return strprintf("String (%s)", get(String()).c_str());
+       case TYPE_GRADIENT:             return strprintf("Gradient (%d cpoints)", get(Gradient()).size());
+       default:                                return "Invalid type";
+       }
+}
+#endif // _DEBUG
+
 void
 ValueBase::set(Canvas* x)
 {
@@ -195,15 +229,13 @@ ValueBase::clear()
                case TYPE_BOOL:                 delete static_cast<bool*>(data);                break;
                case TYPE_INTEGER:              delete static_cast<int*>(data);                 break;
                case TYPE_ANGLE:                delete static_cast<Angle*>(data);               break;
-               case TYPE_VECTOR:               delete static_cast<Vector*>(data);              break;
                case TYPE_TIME:                 delete static_cast<Time*>(data);                break;
                case TYPE_REAL:                 delete static_cast<Real*>(data);                break;
+               case TYPE_VECTOR:               delete static_cast<Vector*>(data);              break;
                case TYPE_COLOR:                delete static_cast<Color*>(data);               break;
                case TYPE_SEGMENT:              delete static_cast<Segment*>(data);             break;
                case TYPE_BLINEPOINT:   delete static_cast<BLinePoint*>(data);  break;
                case TYPE_LIST:                 delete static_cast<list_type*>(data);   break;
-               case TYPE_STRING:               delete static_cast<String*>(data);              break;
-               case TYPE_GRADIENT:             delete static_cast<Gradient*>(data);    break;
                case TYPE_CANVAS:
                {
                        etl::handle<Canvas> canvas(get(etl::loose_handle<Canvas>()));
@@ -213,6 +245,8 @@ ValueBase::clear()
                                delete static_cast<etl::loose_handle<Canvas>*>(data);
                        break;
                }
+               case TYPE_STRING:               delete static_cast<String*>(data);              break;
+               case TYPE_GRADIENT:             delete static_cast<Gradient*>(data);    break;
                default:
                        break;
                }
@@ -230,20 +264,34 @@ ValueBase::type_name(Type id)
        // don't internationalize these type names - they're using in .sif files
        switch(id)
        {
-       case TYPE_REAL:                 return "real";
-       case TYPE_TIME:                 return "time";
-       case TYPE_INTEGER:              return "integer";
-       case TYPE_BOOL:                 return "bool";
-       case TYPE_ANGLE:                return "angle";
-       case TYPE_VECTOR:               return "vector";
-       case TYPE_COLOR:                return "color";
-       case TYPE_STRING:               return "string";
-       case TYPE_CANVAS:               return "canvas";
-       case TYPE_LIST:                 return "list";
-       case TYPE_SEGMENT:              return "segment";
-       case TYPE_GRADIENT:             return "gradient";
-       case TYPE_BLINEPOINT:   return "bline_point";
-       case TYPE_NIL:                  return "nil";
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_BOOL:                 return N_("bool");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_INTEGER:              return N_("integer");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_ANGLE:                return N_("angle");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_TIME:                 return N_("time");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_REAL:                 return N_("real");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_VECTOR:               return N_("vector");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_COLOR:                return N_("color");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_SEGMENT:              return N_("segment");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_BLINEPOINT:   return N_("bline_point");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_LIST:                 return N_("list");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_CANVAS:               return N_("canvas");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_STRING:               return N_("string");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_GRADIENT:             return N_("gradient");
+               /* TRANSLATORS: this is the name of a type -- see http://synfig.org/Types */
+       case TYPE_NIL:                  return N_("nil");
        default:
                break;
        }
@@ -252,6 +300,12 @@ ValueBase::type_name(Type id)
        return "UNKNOWN";
 }
 
+String
+ValueBase::type_local_name(Type id)
+{
+       return dgettext("synfig",type_name(id).c_str());
+}
+
 ValueBase::Type
 ValueBase::ident_type(const String &str)
 {