(Builder) Added Constants that can be used by Custom shaders
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / builder / builder.h
old mode 100755 (executable)
new mode 100644 (file)
index 1f8ea4a..b255c11
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_UIBUILDER_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/animation/path-constrainer.h>
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/animation/linear-constrainer.h>
-#include <dali/devel-api/animation/path-constrainer.h>
-#include <dali/public-api/images/frame-buffer-image.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal DALI_INTERNAL
 {
 class Builder;
@@ -122,9 +119,9 @@ class Builder;
  */
 
 class DALI_TOOLKIT_API Builder : public BaseHandle
- {
- public:
-   /**
+{
+public:
+  /**
     * Create an Builder handle; this can be initialised with Builder::New()
     * Calling member functions with an uninitialised handle is not allowed.
     */
@@ -148,7 +145,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    */
   enum UIFormat
   {
-    JSON,                 ///< String is JSON
+    JSON, ///< String is JSON
   };
 
   /**
@@ -160,20 +157,34 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param data A string represenation of an Actor tree
    * @param format The string representation format ie JSON
    */
-  void LoadFromString( const std::string& data, UIFormat format = JSON );
+  void LoadFromString(const std::string& data, UIFormat format = JSON);
 
   /**
    * @brief Adds user defined constants to all future style template or animation expansions
    *
    * e.g.
-   *   Property::Map map;
-   *   map["IMAGE_DIRECTORY"] = "/usr/share/images";
-   *   builder.AddConstants( map );
+   * @code
+   * Property::Map map;
+   * map["IMAGE_DIRECTORY"] = "/usr/share/images";
+   * builder.AddConstants( map );
+   * @endcode
+   *
+   * The following shows a list of constants available by default:
+   *
+   *  Constant                     | Description
+   * ----------------------------- | ----------------------------------------------------------------------------------------------------
+   *   DALI_IMAGE_DIR              | The Image Directory used by Toolkit.
+   *   DALI_SOUND_DIR              | The Sound Directory used by Toolkit.
+   *   DALI_STYLE_DIR              | The Style directory that the Toolkit uses.
+   *   DALI_STYLE_IMAGE_DIR        | The directory that stores all the images used by Toolkit's style.
+   *   DALI_SHADER_VERSION_PREFIX  | For use in custom shaders to prepend the shader version in use. @ref Shader::GetShaderVersionPrefix
+   *   DALI_VERTEX_SHADER_PREFIX   | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetVertexShaderPrefix
+   *   DALI_FRAGMENT_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetFragmentShaderPrefix()
    *
    * @pre The Builder has been initialized.
    * @param map The user defined constants used in template expansions.
    */
-  void AddConstants( const Property::Map& map );
+  void AddConstants(const Property::Map& map);
 
   /**
    * @brief Adds or modifies a user defined constant to all future style template or animation expansions
@@ -183,11 +194,13 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
    * @endcode
    *
+   * @see AddConstants(const Property::Map&) for builder pre-defined default constants.
+   *
    * @pre The Builder has been initialized.
    * @param key The constant name to add or update
    * @param value The new value for the constant.
    */
-  void AddConstant( const std::string& key, const Property::Value& value );
+  void AddConstant(const std::string& key, const Property::Value& value);
 
   /**
    * @brief Gets all currently defined configurations.
@@ -225,7 +238,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @pre The Builder has been initialized.
    * @param key The constant name to search for.
    */
-  const Property::Value& GetConstant( const std::string& key ) const;
+  const Property::Value& GetConstant(const std::string& key) const;
 
   /**
    * Creates an animation from the set of known animations
@@ -238,14 +251,14 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param animationName The animation name to create
    * @returns The base handle of the created object
    */
-  Animation CreateAnimation( const std::string& animationName );
+  Animation CreateAnimation(const std::string& animationName);
 
   /**
    * @brief Creates an animation from the set of known animations with user defined constants
    *
    * e.g.
    *   Property::Map map;
-   *   map["ACTOR"] = actor.GetName();       // replaces '{ACTOR} in the template
+   *   map["ACTOR"] = actor.GetProperty< std::string >( Dali::Actor::Property::NAME );       // replaces '{ACTOR} in the template
    *   Animation a = builder.CreateAnimation( "wobble");
    *
    * @pre The Builder has been initialized.
@@ -256,7 +269,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param map The user defined constants used in style template expansion.
    * @returns The base handle of the created object
    */
-  Animation CreateAnimation( const std::string& animationName, const Property::Map& map );
+  Animation CreateAnimation(const std::string& animationName, const Property::Map& map);
 
   /**
    * @brief Creates an animation from the set of known animations.
@@ -273,7 +286,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param sourceActor The starting point in an actor tree, from which to look for property owners
    * @returns The base handle of the created object
    */
-  Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor );
+  Animation CreateAnimation(const std::string& animationName, Dali::Actor sourceActor);
 
   /**
    * @brief Creates an animation from the set of known animations with user defined constants
@@ -281,7 +294,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * The animation is applied to a specific actor.
    * e.g.
    *   Property::Map map;
-   *   map["ACTOR"] = actor.GetName();       // replaces '{ACTOR} in the template
+   *   map["ACTOR"] = actor.GetProperty< std::string >( Dali::Actor::Property::NAME );       // replaces '{ACTOR} in the template
    *   Actor myInstance = builder.Create( "templateActorTree" )
    *   Animation a = builder.CreateAnimation( "wobble", myInstance);
    *
@@ -294,7 +307,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param sourceActor The starting point in an actor tree, from which to look for property owners
    * @returns The base handle of the created object
    */
-  Animation CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor );
+  Animation CreateAnimation(const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor);
 
   /**
    * @brief Creates an object (e.g. an actor) from the set of known style templates
@@ -309,7 +322,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param templateName The template to apply in creation.
    * @returns The base handle of the created object
    */
-  BaseHandle Create( const std::string& templateName );
+  BaseHandle Create(const std::string& templateName);
 
   /**
    * @brief Creates an object from the style templates with user defined constants
@@ -327,7 +340,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param map The user defined constants used in template expansion.
    * @returns The base handle of the created object
    */
-  BaseHandle Create( const std::string& templateName, const Property::Map& map );
+  BaseHandle Create(const std::string& templateName, const Property::Map& map);
 
   /**
    * @brief Creates an object (e.g. an actor) from given json snippet
@@ -340,7 +353,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param json The json snippet used to create the object.
    * @returns The base handle of the created object if any
    */
-  BaseHandle CreateFromJson( const std::string& json );
+  BaseHandle CreateFromJson(const std::string& json);
 
   /**
    * Apply a style (a collection of properties) to an actor.
@@ -351,7 +364,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    *
    * @return Return true if the style was found
    */
-  bool ApplyStyle( const std::string& styleName, Handle& handle );
+  bool ApplyStyle(const std::string& styleName, Handle& handle);
 
   /**
    * Apply a style (a collection of properties) to an actor from the given json snippet
@@ -362,8 +375,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    *
    * @return Return true if the json snippet was parsed
    */
-  bool ApplyFromJson(  Handle& handle, const std::string& json );
-
+  bool ApplyFromJson(Handle& handle, const std::string& json);
 
   /**
    * Add the actor tree in the "stage" section to the actor toActor.
@@ -373,7 +385,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * will create and add the actors to the stage root layer.
    * @param toActor The actor to add the created actors to
    */
-  void AddActors( Actor toActor );
+  void AddActors(Actor toActor);
 
   /**
    * Adds actors in the sectionName to the actor toActor.
@@ -384,14 +396,14 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param sectionName The section name to search for the actor tree
    * @param toActor The actor to add the created actors to
    */
-  void AddActors( const std::string &sectionName, Actor toActor );
+  void AddActors(const std::string& sectionName, Actor toActor);
 
   /**
    * Create a render task set.
    * @pre The Builder has been initialized.
    * @param name The library name of the render task set.
    */
-  void CreateRenderTask( const std::string &name );
+  void CreateRenderTask(const std::string& name);
 
   /**
    * Get or create Path from the Path instance library.
@@ -400,7 +412,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param name The name of a Path in the loaded representation
    * @return A handle to a Path if found, otherwise empty
    */
-  Path GetPath( const std::string &name );
+  Path GetPath(const std::string& name);
 
   /**
    * Get or create a PathConstrainer from the set of known PathConstrainers
@@ -412,7 +424,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param pathConstrainerName The name of the PathConstrainer
    * @returns A handle to a PathConstrainer if found, otherwise empty
    */
-  PathConstrainer GetPathConstrainer( const std::string& pathConstrainerName );
+  PathConstrainer GetPathConstrainer(const std::string& pathConstrainerName);
 
   /**
    * Get or create a LinearConstrainer from the set of known LinearConstrainers
@@ -424,14 +436,14 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
    * @param linearConstrainerName The name of the LinearConstrainer
    * @returns A handle to a LinearConstrainer if found, otherwise empty
    */
-  LinearConstrainer GetLinearConstrainer( const std::string& linearConstrainerName );
+  LinearConstrainer GetLinearConstrainer(const std::string& linearConstrainerName);
 
   // Signals
 
   /**
    * @brief Builder signal type
    */
-  typedef Signal< void () > BuilderSignalType;
+  typedef Signal<void()> BuilderSignalType;
 
   /**
    * @brief Signal emitted when a quit action is requested by the builder.
@@ -439,7 +451,7 @@ class DALI_TOOLKIT_API Builder : public BaseHandle
   BuilderSignalType& QuitSignal();
 
 private:
-  explicit DALI_INTERNAL Builder(Internal::Builder *impl);
+  explicit DALI_INTERNAL Builder(Internal::Builderimpl);
 
 }; // class Builder