Merge "Added New methods to cater for second step initialization" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / builder-impl.h
index 4fb7aba..4c018aa 100644 (file)
@@ -23,6 +23,7 @@
 #include <list>
 #include <map>
 #include <dali/public-api/common/stage.h>
+#include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/object/property-map.h>
@@ -30,8 +31,8 @@
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/builder/json-parser.h>
-#include <dali-toolkit/public-api/builder/builder.h>
+#include <dali-toolkit/devel-api/builder/json-parser.h>
+#include <dali-toolkit/devel-api/builder/builder.h>
 #include <dali-toolkit/internal/builder/builder-declarations.h>
 
 // Warning messages usually displayed
@@ -163,16 +164,6 @@ public:
   void CreateRenderTask( const std::string &name );
 
   /**
-   * @copydoc Toolkit::Builder::GetShaderEffect
-   */
-  ShaderEffect GetShaderEffect( const std::string &name );
-
-  /**
-   * @copydoc Toolkit::Builder::GetShaderEffect
-   */
-  ShaderEffect GetShaderEffect( const std::string &name, const Replacement& constant );
-
-  /**
    * @copydoc Toolkit::Builder::GetFrameBufferImage
    */
   FrameBufferImage GetFrameBufferImage( const std::string &name );
@@ -186,6 +177,33 @@ public:
    * @copydoc Toolkit::Builder::GetPath
    */
   Path GetPath( const std::string &name );
+
+  /**
+   * @copydoc Toolkit::Builder::GetPathConstrainer
+   */
+  Dali::PathConstrainer GetPathConstrainer( const std::string& name );
+
+  /*
+   * Check if a given constrainer is of type PathConstrainer
+   * @param[in] name The name of the constrainer
+   * @return True if constainer is of type PathConstrainer, False otherwise
+   *
+   */
+  bool IsPathConstrainer( const std::string& name );
+
+  /**
+   * @copydoc Toolkit::Builder::GetLinearConstrainer
+   */
+  Dali::LinearConstrainer GetLinearConstrainer( const std::string& name );
+
+  /*
+   * Check if a given constrainer is of type LinearConstrainer
+   * @param[in] name The name of the constrainer
+   * @return True if constainer is of type LinearConstrainer, False otherwise
+   *
+   */
+  bool IsLinearConstrainer( const std::string& name );
+
   /**
    * @copydoc Toolkit::Builder::QuitSignal
    */
@@ -207,22 +225,32 @@ private:
 
   void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement );
 
+  void SetCustomProperties( const TreeNode& node, Handle& handle, const Replacement& constant, const std::string& childName, Property::AccessMode accessMode );
+
 private:
   Toolkit::JsonParser mParser;
 
   typedef std::map<const std::string, FrameBufferImage> ImageLut;
   ImageLut mFrameBufferImageLut;
 
-  typedef std::map<const std::string, ShaderEffect> ShaderEffectLut;
-  ShaderEffectLut mShaderEffectLut;
-
   typedef std::map<const std::string, Path> PathLut;
   PathLut mPathLut;
 
+  typedef struct{ std::string name; Dali::PathConstrainer pathConstrainer; } PathConstrainerEntry;
+  typedef std::vector<PathConstrainerEntry> PathConstrainerLut;
+  PathConstrainerLut mPathConstrainerLut;
+
+  typedef struct{ std::string name; Dali::LinearConstrainer linearConstrainer; } LinearConstrainerEntry;
+  typedef std::vector<LinearConstrainerEntry> LinearConstrainerLut;
+  LinearConstrainerLut mLinearConstrainerLut;
+
   SlotDelegate<Builder> mSlotDelegate;
 
   Property::Map mReplacementMap;
 
+  typedef std::vector< TreeNode::KeyNodePair > MappingsLut;
+  MappingsLut mCompleteMappings;
+
   BaseHandle Create( const std::string& templateName, const Replacement& constant );
 
   BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements );
@@ -235,6 +263,39 @@ private:
 
   Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor );
 
+  typedef std::vector<const char*> KeyStack;
+
+  /**
+   * Tests if the value is a string delimited by <>. If it is, then it attempts to
+   * change the value to the mapping from a matching key in the mappings table.
+   * @param[in] mappingRoot The JSON node containing the mappings
+   * @param[in,out] keyStack the stack of visited keys
+   * @param[in,out] value The string value to test and write back to.
+   * @return true if the value was converted, false otherwise.
+   */
+  bool ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack, Property::Value& value );
+
+  /**
+   * Find the key in the mapping table, if it's present, then generate a property value for it (of the given type if available), recursing as necessary, and stopping if any cycles
+   * are detected.
+   * @param[in] mappingRoot The JSON node containing the mappings
+   * @param[in] theKey The key to search for
+   * @param[in,out] keyStack the stack of visited keys
+   * @param[in] propertyType The property type if known, or NONE
+   * @param[in,out] value The string value to test and write back to.
+   */
+  bool RecursePropertyMap( const TreeNode& mappingRoot, KeyStack& keyStack, const char* theKey, Property::Type propertyType, Property::Value& value );
+
+  /**
+   * Find the key in the mapping table, if it's present, then generate a property value for it (of the given type if available), recursing as necessary, and stopping if any cycles
+   * are detected.
+   * @param[in] mappingRoot The JSON node containing the mappings
+   * @param[in] theKey The key to search for
+   * @param[in] propertyType The property type if known, or NONE
+   * @param[in,out] value The string value to test and write back to.
+   */
+  bool GetPropertyMap( const TreeNode& mappingRoot, const char* theKey, Property::Type propertyType, Property::Value& value );
+
   void ApplyProperties( const TreeNode& root, const TreeNode& node,
                         Dali::Handle& handle, const Replacement& constant );