]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/property_list.cxx
Canvas: Proper fix for OpenVG init handling.
[flightgear.git] / src / GUI / property_list.cxx
index 5aa1e3dbaae639b4dd9114430f936b3e850eb14b..6ceba838ca97112bfa107fc7dcdcfcc6dae8a405 100644 (file)
 #include <simgear/compiler.h>
 
 #include <sstream>
-#include STL_IOMANIP
+#include <iomanip>
 #include <iostream>
-#include STL_STRING
-SG_USING_STD(string);
+#include <string>
+
+using std::string;
 using std::cout;
+using std::endl;
 
 typedef string stdString;      // puObject has a "string" member
 
@@ -44,25 +46,30 @@ typedef string stdString;      // puObject has a "string" member
 
 static string getValueTypeString(const SGPropertyNode *node)
 {
+    using namespace simgear;
     string result;
 
-    SGPropertyNode::Type type = node->getType();
-    if (type == SGPropertyNode::UNSPECIFIED)
+    props::Type type = node->getType();
+    if (type == props::UNSPECIFIED)
         result = "unspecified";
-    else if (type == SGPropertyNode::NONE)
+    else if (type == props::NONE)
         result = "none";
-    else if (type == SGPropertyNode::BOOL)
+    else if (type == props::BOOL)
         result = "bool";
-    else if (type == SGPropertyNode::INT)
+    else if (type == props::INT)
         result = "int";
-    else if (type == SGPropertyNode::LONG)
+    else if (type == props::LONG)
         result = "long";
-    else if (type == SGPropertyNode::FLOAT)
+    else if (type == props::FLOAT)
         result = "float";
-    else if (type == SGPropertyNode::DOUBLE)
+    else if (type == props::DOUBLE)
         result = "double";
-    else if (type == SGPropertyNode::STRING)
+    else if (type == props::STRING)
         result = "string";
+    else if (type == props::VEC3D)
+        result = "vec3d";
+    else if (type == props::VEC4D)
+        result = "vec4d";
 
     return result;
 }
@@ -70,11 +77,12 @@ static string getValueTypeString(const SGPropertyNode *node)
 
 static void dumpProperties(const SGPropertyNode *node)
 {
+    using namespace simgear;
     cout << node->getPath() << '/' << endl;
     for (int i = 0; i < node->nChildren(); i++) {
         const SGPropertyNode *c = node->getChild(i);
-        SGPropertyNode::Type type = c->getType();
-        if (type == SGPropertyNode::ALIAS || c->nChildren())
+        props::Type type = c->getType();
+        if (type == props::ALIAS || c->nChildren())
             continue;
 
         int index = c->getIndex();
@@ -84,21 +92,25 @@ static void dumpProperties(const SGPropertyNode *node)
         cout << " = ";
 
         switch (c->getType()) {
-        case SGPropertyNode::DOUBLE:
-        case SGPropertyNode::FLOAT:
-            cout << std::setprecision(15) << c->getDoubleValue();
-            break;
-        case SGPropertyNode::LONG:
-        case SGPropertyNode::INT:
-            cout << c->getLongValue();
+        case props::DOUBLE:
+        case props::FLOAT:
+        case props::VEC3D:
+        case props::VEC4D:
+        {
+            std::streamsize precision = cout.precision(15);
+            c->printOn(cout);
+            cout.precision(precision);
+        }
             break;
-        case SGPropertyNode::BOOL:
-            cout << (c->getBoolValue() ? "true" : "false");
+        case props::LONG:
+        case props::INT:
+        case props::BOOL:
+            c->printOn(cout);
             break;
-        case SGPropertyNode::STRING:
+        case props::STRING:
             cout << '"' << c->getStringValue() << '"';
             break;
-        case SGPropertyNode::NONE:
+        case props::NONE:
             break;
         default:
             cout << '\'' << c->getStringValue() << '\'';
@@ -194,8 +206,10 @@ void PropertyList::handle_select(puObject *list_box)
         const char *src = prop_list->_entries[selected];
 
         if (prop_list->_dot_files && (selected < 2)) {
-            if (!strcmp(src, ".")) {
-                if (mod_ctrl)
+            if (src[0] == '.' && (src[1] == '\0' || src[1] == ' ')) {
+                if (mod_ctrl && mod_shift)
+                    prop_list->_curr->fireValueChanged();
+                else if (mod_ctrl)
                     prop_list->toggleVerbosity();
                 else if (mod_shift)
                     dumpProperties(prop_list->_curr);
@@ -230,7 +244,7 @@ void PropertyList::handle_select(puObject *list_box)
         }
 
         // it is a regular property
-        if (child->getType() == SGPropertyNode::BOOL && mod_ctrl) {
+        if (child->getType() == simgear::props::BOOL && mod_ctrl) {
             child->setBoolValue(!child->getBoolValue());
             prop_list->update(true);
         } else
@@ -260,8 +274,8 @@ void PropertyList::update(bool restore_pos)
         _num_entries += 2;    // for . and ..
         _entries = new char*[_num_entries + 1];
 
-        _entries[0] = new char[2];
-        strcpy(_entries[0], ".");
+        _entries[0] = new char[16];
+        strcpy(_entries[0], _verbose ? ".     [verbose]" : ".");
 
         _entries[1] = new char[3];
         strcpy(_entries[1], "..");
@@ -297,6 +311,7 @@ void PropertyList::update(bool restore_pos)
 
 void PropertyList::updateTextForEntry(NodeData& data)
 {
+    using namespace simgear;
     SGPropertyNode *node = data.node;
     stdString name = node->getDisplayName(true);
     stdString type = getValueTypeString(node);
@@ -310,8 +325,8 @@ void PropertyList::updateTextForEntry(NodeData& data)
         line << '/';
 
     if (!children || (_verbose && node->hasValue())) {
-        if (node->getType() == SGPropertyNode::STRING
-                || node->getType() == SGPropertyNode::UNSPECIFIED)
+        if (node->getType() == props::STRING
+                || node->getType() == props::UNSPECIFIED)
             sanitize(value);
 
         line << " = '" << value << "' (" << type;
@@ -330,6 +345,8 @@ void PropertyList::updateTextForEntry(NodeData& data)
                 ext += 'A';
             if (node->getAttribute(SGPropertyNode::USERARCHIVE))
                 ext += 'U';
+            if (node->getAttribute(SGPropertyNode::PRESERVE))
+                ext += 'P';
             if (node->isTied())
                 ext += 'T';
 
@@ -344,6 +361,12 @@ void PropertyList::updateTextForEntry(NodeData& data)
         }
         line << ')';
     }
+    else
+    if ((_verbose)&&(node->getAttribute(SGPropertyNode::PRESERVE)))
+    {
+        // only preserve/protection flag matters for nodes without values
+        line << " (P)";
+    }
 
     stdString out = line.str();
     if (out.size() >= PUSTRING_MAX)