-#ifndef __DALI_TOOLKIT_UIBUILDER_H__
-#define __DALI_TOOLKIT_UIBUILDER_H__
+#ifndef DALI_TOOLKIT_UIBUILDER_H
+#define DALI_TOOLKIT_UIBUILDER_H
/*
- * Copyright (c) 2015 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>
-#include <dali/public-api/shader-effects/shader-effect.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
namespace Dali
{
-
namespace Toolkit
{
-
namespace Internal DALI_INTERNAL
{
class Builder;
* {
* "templates": // are named instantiable actor trees
* {
- * "default-text":
+ * "defaultText":
* {
* "type":"TextActor",
* "font":"",
- * "parent-origin":[0.5,0.5,0],
+ * "parentOrigin":[0.5,0.5,0],
* "scale": [50,50,1]
* }
* },
* "styles": // are named property sets applied to actor trees
* {
- * "my-style":
+ * "myStyle":
* {
* "size": [10,10,1] // root properties applied to a given root actor
* "actors": // properties applied to actors found by name from root
* "stage":
* [
* {
- * "type":"default-text",
+ * "type":"defaultText",
* "text":"Hello World",
* "position":[0,0,0]
* },
*
* - Create an actor tree from the "templates" section
* @code
- * TextActor actor = TextActor::DownCast( builder.Create( "default-text" ) );
+ * TextActor actor = TextActor::DownCast( builder.Create( "defaultText" ) );
* @endcode
*
* - Style an actor tree from the "styles" section
* @code
- * builder.ApplyStyle( "my-style", actor );
+ * builder.ApplyStyle( "myStyle", actor );
* @endcode
*
* - Create an actor tree from json
*
*/
-class DALI_IMPORT_API Builder : public BaseHandle
- {
- public:
- /**
+class DALI_TOOLKIT_API Builder : public BaseHandle
+{
+public:
+ /**
* Create an Builder handle; this can be initialised with Builder::New()
* Calling member functions with an uninitialised handle is not allowed.
*/
*/
enum UIFormat
{
- JSON, ///< String is JSON
+ JSON, ///< String is JSON
};
/**
* @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
* 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.
+ *
+ * @pre The Builder has been initialized.
+ * @return A reference to the currently defined configurations.
+ */
+ const Property::Map& GetConfigurations() const;
/**
* @brief Gets all currently defined constants.
* @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
* @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.
* @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.
*
* The animation is applied to a specific actor.
* e.g.
- * Actor myInstance = builder.Create( "template-actor-tree" )
+ * Actor myInstance = builder.Create( "templateActorTree" )
* Animation a = builder.CreateAnimation( "wobble", myInstance );
*
* @pre The Builder has been initialized.
* @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
* The animation is applied to a specific actor.
* e.g.
* Property::Map map;
- * map["ACTOR"] = actor.GetName(); // replaces '{ACTOR} in the template
- * Actor myInstance = builder.Create( "template-actor-tree" )
+ * 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);
*
* @pre The Builder has been initialized.
* @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
*
* e.g.
- * mActor.Add( Actor::DownCast(builder.Create( "default-text")) );
+ * mActor.Add( Actor::DownCast(builder.Create( "defaultText")) );
*
* @pre The Builder has been initialized.
* @pre Preconditions have been met for creating dali objects ie Images, Actors etc
* @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
* e.g.
* Property::Map map;
* map["IMAGE_DIR"] = "/usr/share/images"; // replaces '{IMAGE_DIR} in the template
- * mActor.Add( Actor::DownCast(builder.Create( "default-image", map) ) );
+ * mActor.Add( Actor::DownCast(builder.Create( "defaultImage", map) ) );
*
* @pre The Builder has been initialized.
* @pre Preconditions have been met for creating dali objects ie Images, Actors etc
* @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
* @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.
*
* @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
*
* @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.
* 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.
* @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 §ionName, 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 );
-
- /**
- * Get or create ShaderEffect from the ShaderEffect instance library.
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name of a ShaderEffect in the loaded representation
- * @return A handle to a ShaderEffect if found, otherwise empty
- */
- ShaderEffect GetShaderEffect( const std::string &name );
-
- /**
- * Get or create FrameBufferImage from the FrameBufferImage instance library.
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name of a FrameBufferImage in the loaded representation
- * @return A handle to a FrameBufferImage if found, otherwise empty
- */
- FrameBufferImage GetFrameBufferImage( const std::string &name );
+ void CreateRenderTask(const std::string& name);
/**
* Get or create Path from the Path instance library.
* @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
* e.g.
- * PathConstrainer a = builder.GetPathConstrainer( "my-path-constrainer");
+ * PathConstrainer a = builder.GetPathConstrainer( "myPathConstrainer");
*
* @pre The Builder has been initialized.
* @pre The pathConstrainerName exists in the Constrainers section of the data representation
* @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
* e.g.
- * LinearConstrainer a = builder.GetLinearConstrainer( "my-linear-constrainer");
+ * LinearConstrainer a = builder.GetLinearConstrainer( "myLinearConstrainer");
*
* @pre The Builder has been initialized.
* @pre The linearConstrainerName exists in the Constrainers section of the data representation
* @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.
BuilderSignalType& QuitSignal();
private:
- explicit DALI_INTERNAL Builder(Internal::Builder *impl);
+ explicit DALI_INTERNAL Builder(Internal::Builder* impl);
}; // class Builder
} // namespace Dali
-#endif // __DALI_TOOLKIT_UIBUILDER_H__
+#endif // DALI_TOOLKIT_UIBUILDER_H