typedef std::map<std::string, Property::Value> PropertyValueMap;
/**
- * Builder
- * This class provides the ability to load an actor tree from a string representation.
+ * This class provides the ability to load and style an actor tree from a string representation.
*
- * The following example is hello world in JSON.
+ * The following is an example in JSON.
*
* @code
*
* {
- * "styles":
+ * "templates": // are named instantiable actor trees
* {
* "default-text":
* {
* "scale": [50,50,1]
* }
* },
+ * "styles": // are named property sets applied to actor trees
+ * {
+ * "my-style":
+ * {
+ * "size": [10,10,1] // root properties applied to a given root actor
+ * "actors": // properties applied to actors found by name from root
+ * {
+ * "ok": // properties for an actor named "ok"
+ * {
+ * "scale":[5,5,1],
+ * },
+ * "cancel":
+ * {
+ * "scale":[50,50,1],
+ * }
+ * },
+ * },
+ * },
* "stage":
* [
* {
* ]
* }
*
- *
- *
* @endcode
*
- * The following is how to load the json data.
- *
+ * The following shows a method to load the json file.
* @code
- *
* Builder builder = Builder::New();
- *
* std::string json_data(ReadFile("layout.json"));
- *
* builder.LoadFromString(json_data);
- *
- * // 1) load all actors in the "stage" section to the root layer
+ * @endcode
+ * Examples
+ * - Load all actors in the "stage" section to the root layer
+ * @code
* builder.AddActors( Stage::GetCurrent().GetRootLayer() );
+ * @endcode
*
- * // or 2) create an actor from the library "templates" section
+ * - Create an actor tree from the "templates" section
+ * @code
* TextActor actor = TextActor::DownCast( builder.Create( "default-text" ) );
+ * @endcode
+ *
+ * - Style an actor tree from the "styles" section
+ * @code
+ * builder.ApplyStyle( "my-style", actor );
+ * @endcode
*
+ * - Create an actor tree from json
+ * @code
+ * TextActor actor = TextActor::DownCast( builder.CreateFromJson("{\"type\":\"TextActor\",\"font\":\"\",\"scale\":[50,50,1]}") );
* @endcode
+ *
+ * - Apply a style to an actor tree from json
+ * @code
+ * builder.ApplyFromJson( textActor, ("{\"scale\":[5,5,1]}") );
+ * @endcode
+ *
*/
- class Builder : public BaseHandle
+
+class Builder : public BaseHandle
{
public:
/**
static Builder New();
/**
- * Virtual destructor.
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
*/
- virtual ~Builder();
+ ~Builder();
/**
* UI string data format
Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor );
/**
- * @deprecated Use Create()
- */
- BaseHandle CreateFromStyle( const std::string& styleName );
-
- /**
- * @deprecated Use Create()
- */
- BaseHandle CreateFromStyle( const std::string& styleName, const PropertyValueMap& map );
-
- /**
* @brief Creates an object (e.g. an actor) from the set of known style templates
*
* e.g.
BaseHandle Create( const std::string& templateName, const PropertyValueMap& map );
/**
+ * @brief Creates an object (e.g. an actor) from given json snippet
+ *
+ * e.g.
+ * Actor a = Actor::DownCast(builder.CreateFromJson( "{\"type\":\"TextActor\"}"));
+ *
+ * @pre The Builder has been initialized.
+ * @pre Preconditions have been met for creating dali objects ie Images, Actors etc
+ * @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 );
+
+ /**
* Apply a style (a collection of properties) to an actor.
* @pre The Builder has been initialized.
* @pre Preconditions have been met for creating dali objects ie Images, Actors etc
bool ApplyStyle( const std::string& styleName, Handle& handle );
/**
+ * Apply a style (a collection of properties) to an actor from the given json snippet
+ * @pre The Builder has been initialized.
+ * @pre Preconditions have been met for creating dali objects ie Images, Actors etc
+ * @param handle Then handle of the object on which to set the properties.
+ * @param json The json snippet used to create the object.
+ *
+ * @return Return true if the json snippet was parsed
+ */
+ bool ApplyFromJson( Handle& handle, const std::string& json );
+
+
+ /**
* Add the actor tree in the "stage" section to the actor toActor.
* ie if the representation has a 'stage' section that contains a tree of
* actors then
void AddActors( const std::string §ionName, Actor toActor );
/**
- * @deprecated Font as a separate asset is no longer supported
- * Get's a Font asset previously created at load time
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name given to a Font in the loaded representation
- * @return A handle to a Font if found, otherwise empty.
- */
- Font GetFont( const std::string &name ) const;
-
- /**
- * Get's a TextStyle asset previously created at load time
- * @pre The Builder has been initialized.
- * @param name The name given to a TextStyle in the loaded representation
- * @return a Created TextStyle if found, otherwise return a TextStyle created by Default constructor
- */
- TextStyle GetTextStyle( const std::string &name ) const;
-
- /**
- * @deprecated Images as a separate asset is no longer supported
- * Get's an Image asset previously created at load time
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name given to an Image in the loaded representation
- * @return A handle to an Image if found, otherwise empty
- */
- Image GetImage( const std::string &name ) const;
-
- /**
- * @deprecated Actors no longer held by builder
- * Get's an Actor previously created at load time
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name given to an Actor in the loaded representation
- * @return A handle to an Actor if found, otherwise empty
- */
- Actor GetActor( const std::string &name ) const;
-
- /**
- * @deprecated Animations no longer held by builder
- * Get's an Animation previously created at load time
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name given to an Animation in the loaded representation
- * @return A handle to an Animation if found, otherwise empty
- */
- Animation GetAnimation( const std::string &name ) const;
-
- /**
* Create a render task set.
* @pre The Builder has been initialized.
* @param name The library name of the render task set.
*/
FrameBufferImage GetFrameBufferImage( const std::string &name );
+ // Signals
+
+ /**
+ * @brief Builder signal type
+ */
+ typedef SignalV2< void () > Signal;
+
/**
- * @deprecated. Builder no longer holds actor handles/references
- * Provides a list of the top level actors previously created at load time
- * @return A container of Actors found at the top level of the loaded representation
+ * @brief Signal emitted when a quit action is requested by the builder.
*/
- ActorContainer GetTopLevelActors( void ) const;
+ Signal& QuitSignal();
private:
Builder(Internal::Builder *impl);