]> git.mxchange.org Git - flightgear.git/blobdiff - src/Canvas/property_helper.hxx
Fix a Clang warning in Shiva.
[flightgear.git] / src / Canvas / property_helper.hxx
index c62134ca1ca9d156543f2ca5615ea6c14aa878fe..92e556afcfd617b7d90214d0d64af325103386e6 100644 (file)
@@ -44,12 +44,42 @@ namespace canvas
     return node;
   }
 
+  /**
+   * Get vector of properties
+   */
+  template<typename T, typename T_get /* = T */> // TODO use C++11 or traits
+  std::vector<T> getVectorFromChildren( const SGPropertyNode* parent,
+                                        const char* child_name )
+  {
+    const simgear::PropertyList& props = parent->getChildren(child_name);
+    std::vector<T> values( props.size() );
+
+    for( size_t i = 0; i < props.size(); ++i )
+      values[i] = getValue<T_get>(props[i]);
+
+    return values;
+  }
+
+  /**
+   * Split a string by a delimter and convert the values to float
+   *
+   * TODO do we need other types than float?
+   */
+  std::vector<float> splitAndConvert(const char del[], const std::string& str);
+
+  /**
+   * Parse a (CSS) color
+   */
+  osg::Vec4 parseColor(std::string str);
+
   /**
    * @param name    Name of color node
    * @param parent  Parent for color channel nodes
    * @param nodes   Vector to push color nodes into
    * @param def     Default color
    *
+   * @deprecated Use only a single property instead and parse with #parseColor
+   *
    * <name>
    *   <red type="float">def[0] or existing value</red>
    *   <green type="float">def[1] or existing value</green>
@@ -60,7 +90,19 @@ namespace canvas
   void linkColorNodes( const char* name,
                        SGPropertyNode* parent,
                        std::vector<SGPropertyNode_ptr>& nodes,
-                       const osg::Vec4& def = osg::Vec4(0,0,0,0) );
+                       const osg::Vec4& def = osg::Vec4(0,0,0,1) );
+
+  /**
+   * Trigger a childAdded and valueChanged event for every child of node
+   * (Unlimited depth) and node itself.
+   */
+  void triggerChangeRecursive(SGPropertyNode* node);
+
+  /**
+   * Trigger a childRemoved event for every child of node (Unlimited depth) and
+   * node itself.
+   */
+  void triggerRemoveRecursive(SGPropertyNode* node);
 
 } // namespace canvas