Added PathConstrainer and LinearConstrainer support to builder
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / builder-impl.h
index 3378eee..af1c85c 100644 (file)
@@ -1,28 +1,32 @@
 #ifndef __DALI_TOOLKIT_INTERNAL_BUILDER_H__
 #define __DALI_TOOLKIT_INTERNAL_BUILDER_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // EXTERNAL INCLUDES
 #include <string>
 #include <list>
 #include <map>
-#include <boost/property_tree/ptree.hpp>
-#include <dali/dali.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/render-tasks/render-task.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -81,7 +85,7 @@ public:
   /**
    * @copydoc Toolkit::Builder::AddConstants
    */
-  void AddConstants( const PropertyValueMap& map );
+  void AddConstants( const Property::Map& map );
 
   /**
    * @copydoc Toolkit::Builder::AddConstant
@@ -91,7 +95,7 @@ public:
   /**
    * @copydoc Toolkit::Builder::GetConstants
    */
-  const PropertyValueMap& GetConstants() const;
+  const Property::Map& GetConstants() const;
 
   /**
    * @copydoc Toolkit::Builder::GetConstant
@@ -104,9 +108,9 @@ public:
   Animation CreateAnimation( const std::string& animationName );
 
   /**
-   * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
+   * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const Property::Map& map );
    */
-  Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
+  Animation CreateAnimation( const std::string& animationName, const Property::Map& map );
 
   /**
    * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,Dali::Actor);
@@ -114,44 +118,34 @@ public:
   Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor );
 
   /**
-   * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const PropertyValueMap&,Dali::Actor);
+   * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const Property::Map&, Dali::Actor);
    */
-  Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor );
+  Animation CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor );
 
   /**
-   * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName );
+   * @copydoc Toolkit::Builder::Create( const std::string& templateName );
    */
-  BaseHandle CreateFromStyle( const std::string& styleName );
+  BaseHandle Create( const std::string& templateName );
 
   /**
-   * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName, const PropertyValueMap& map );
+   * @copydoc Toolkit::Builder::Create( const std::string& templateName, const Property::Map& map );
    */
-  BaseHandle CreateFromStyle( const std::string& styleName, const PropertyValueMap& map );
+  BaseHandle Create( const std::string& templateName, const Property::Map& map );
 
   /**
-   * @copydoc Toolkit::Builder::GetFont
+   * @copydoc Toolkit::Builder::CreateFromJson( const std::string& json );
    */
-  Font GetFont(const std::string &name) const;
+  BaseHandle CreateFromJson( const std::string& json );
 
   /**
-   * @copydoc Toolkit::Builder::GetTextStyle
+   * @copydoc Toolkit::Builder::ApplyFromJson( Handle& handle, const std::string& json );
    */
-  TextStyle GetTextStyle(const std::string &name) const;
-
-  /**
-   * @copydoc Toolkit::Builder::GetImage
-   */
-  Image GetImage(const std::string &name) const;
-
-  /**
-   * @copydoc Toolkit::Builder::GetActor
-   */
-  Actor GetActor( const std::string &name ) const;
+  bool ApplyFromJson(  Handle& handle, const std::string& json );
 
   /**
    * @copydoc Toolkit::Builder::ApplyStyle
    */
-  void ApplyStyle( const std::string& styleName, Handle& handle );
+  bool ApplyStyle( const std::string& styleName, Handle& handle );
 
   /**
    * @copydoc Toolkit::Builder::AddActors
@@ -164,11 +158,6 @@ public:
   void AddActors( const std::string &sectionName, Actor toActor );
 
   /**
-   * @copydoc Toolkit::Builder::GetAnimation
-   */
-  Animation GetAnimation( const std::string &name ) const;
-
-  /**
    * @copydoc Toolkit::Builder::CreateRenderTask
    */
   void CreateRenderTask( const std::string &name );
@@ -194,9 +183,45 @@ public:
   FrameBufferImage GetFrameBufferImage( const std::string &name, const Replacement& constant );
 
   /**
-   * @copydoc Toolkit::Builder::GetTopLevelActors
+   * @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
    */
-  ActorContainer GetTopLevelActors( void ) const;
+  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
+   */
+  Toolkit::Builder::BuilderSignalType& QuitSignal();
+
+  /**
+   * Emits the quit signal
+   */
+  void EmitQuitSignal();
 
 protected:
 
@@ -218,20 +243,45 @@ private:
   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;
 
-  PropertyValueMap mReplacementMap;
+  Property::Map mReplacementMap;
+
+  BaseHandle Create( const std::string& templateName, const Replacement& constant );
+
+  BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements );
 
-  BaseHandle Create( const OptionalChild& optionalStyles, const TreeNode& node, const TreeNode& root, Actor parent,
-                     const Replacement& replacement );
+  void LoadConstants( const TreeNode& root, Property::Map& intoMap );
 
-  void LoadConstants();
+  void LoadIncludes( const std::string& data );
 
-  void ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
+  bool ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
 
   Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor );
 
-  BaseHandle CreateFromStyle( const std::string& styleName, const Replacement& replacement );
+  void ApplyProperties( const TreeNode& root, const TreeNode& node,
+                        Dali::Handle& handle, const Replacement& constant );
+
+  void ApplyStylesByActor( const TreeNode& root, const TreeNode& node,
+                           Dali::Handle& handle, const Replacement& constant );
+
+  void ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node,
+                                Dali::Handle& handle, const Replacement& constant );
+
+  void SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant );
+
+  Toolkit::Builder::BuilderSignalType mQuitSignal;
 };
 
 } // namespace Internal