X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fbuilder%2Fbuilder.h;h=b255c11704a5f4aedb1c4d7a51e1c12439e9884c;hp=703d54e07c06a1edbffee11d87c96dad1e53e24b;hb=53eb583fbee4c4a305d6e04b36b16bf173790219;hpb=c3f7ea6cb0c0b75c2276193aff88b5c7a679a2d5 diff --git a/dali-toolkit/devel-api/builder/builder.h b/dali-toolkit/devel-api/builder/builder.h index 703d54e..b255c11 100644 --- a/dali-toolkit/devel-api/builder/builder.h +++ b/dali-toolkit/devel-api/builder/builder.h @@ -1,8 +1,8 @@ -#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. @@ -19,19 +19,18 @@ */ // EXTERNAL INCLUDES +#include #include #include #include -#include -#include -#include + +// INTERNAL INCLUDES +#include namespace Dali { - namespace Toolkit { - namespace Internal DALI_INTERNAL { class Builder; @@ -47,17 +46,17 @@ 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 @@ -76,7 +75,7 @@ class Builder; * "stage": * [ * { - * "type":"default-text", + * "type":"defaultText", * "text":"Hello World", * "position":[0,0,0] * }, @@ -99,12 +98,12 @@ class Builder; * * - 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 @@ -119,10 +118,10 @@ class Builder; * */ -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. */ @@ -146,7 +145,7 @@ class DALI_IMPORT_API Builder : public BaseHandle */ enum UIFormat { - JSON, ///< String is JSON + JSON, ///< String is JSON }; /** @@ -158,20 +157,34 @@ class DALI_IMPORT_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 @@ -181,11 +194,21 @@ class DALI_IMPORT_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. + * + * @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. @@ -215,7 +238,7 @@ class DALI_IMPORT_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 @@ -228,14 +251,14 @@ class DALI_IMPORT_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. @@ -246,14 +269,14 @@ class DALI_IMPORT_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. * * 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. @@ -263,7 +286,7 @@ class DALI_IMPORT_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 @@ -271,8 +294,8 @@ class DALI_IMPORT_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 - * 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. @@ -284,13 +307,13 @@ class DALI_IMPORT_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 * * 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 @@ -299,7 +322,7 @@ class DALI_IMPORT_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 @@ -307,7 +330,7 @@ class DALI_IMPORT_API Builder : public BaseHandle * 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 @@ -317,7 +340,7 @@ class DALI_IMPORT_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 @@ -330,7 +353,7 @@ class DALI_IMPORT_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. @@ -341,7 +364,7 @@ class DALI_IMPORT_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 @@ -352,8 +375,7 @@ class DALI_IMPORT_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. @@ -363,7 +385,7 @@ class DALI_IMPORT_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. @@ -374,32 +396,14 @@ class DALI_IMPORT_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 §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. @@ -408,38 +412,38 @@ class DALI_IMPORT_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 * 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 BuilderSignalType; /** * @brief Signal emitted when a quit action is requested by the builder. @@ -447,7 +451,7 @@ class DALI_IMPORT_API Builder : public BaseHandle BuilderSignalType& QuitSignal(); private: - explicit DALI_INTERNAL Builder(Internal::Builder *impl); + explicit DALI_INTERNAL Builder(Internal::Builder* impl); }; // class Builder @@ -455,4 +459,4 @@ private: } // namespace Dali -#endif // __DALI_TOOLKIT_UIBUILDER_H__ +#endif // DALI_TOOLKIT_UIBUILDER_H