From: Javon Prince Date: Mon, 28 Apr 2014 08:51:14 +0000 (+0100) Subject: Scripting: Create animation on tree of actors starting at a specific root actor. X-Git-Tag: dali-2014-wk20-release~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F20311%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Scripting: Create animation on tree of actors starting at a specific root actor. This allows the mapping of JSON defined animations to arbitrary instances of JSON defined actor tree templates Change-Id: I34130e06c37ca394feef0d5dad7f029f8a46359b Signed-off-by: Javon Prince --- diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 06aa91e..a7b887c 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -743,7 +743,7 @@ void Builder::AddActors( const std::string §ionName, Actor toActor ) } } -Animation Builder::CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor searchRoot ) +Animation Builder::CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor ) { Animation anim; @@ -751,7 +751,7 @@ Animation Builder::CreateAnimation( const std::string& animationName, const Repl { if( OptionalChild animation = IsChild(*animations, animationName) ) { - anim = Dali::Toolkit::Internal::CreateAnimation( *animation, replacement, Stage::GetCurrent().GetRootLayer() ); + anim = Dali::Toolkit::Internal::CreateAnimation( *animation, replacement, sourceActor ); } else { @@ -766,10 +766,10 @@ Animation Builder::CreateAnimation( const std::string& animationName, const Repl return anim; } -Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot ) +Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor ) { Replacement replacement(map, mReplacementMap); - return CreateAnimation( animationName, replacement, searchRoot); + return CreateAnimation( animationName, replacement, sourceActor); } Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map ) @@ -778,16 +778,17 @@ Animation Builder::CreateAnimation( const std::string& animationName, const Prop return CreateAnimation( animationName, replacement, Stage::GetCurrent().GetRootLayer() ); } -Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor searchRoot ) +Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor sourceActor ) { Replacement replacement( mReplacementMap ); - return CreateAnimation( animationName, replacement, searchRoot ); + return CreateAnimation( animationName, replacement, sourceActor ); } Animation Builder::CreateAnimation( const std::string& animationName ) { Replacement replacement( mReplacementMap ); + return CreateAnimation( animationName, replacement, Dali::Stage::GetCurrent().GetRootLayer() ); } diff --git a/dali-toolkit/internal/builder/builder-impl.h b/dali-toolkit/internal/builder/builder-impl.h index 6b538a1..3378eee 100644 --- a/dali-toolkit/internal/builder/builder-impl.h +++ b/dali-toolkit/internal/builder/builder-impl.h @@ -109,14 +109,14 @@ public: Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map ); /** - * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, Dali::Actor searchRoot ); + * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,Dali::Actor); */ - Animation CreateAnimation( const std::string& animationName, Dali::Actor searchRoot ); + Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor ); /** - * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot ); + * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const PropertyValueMap&,Dali::Actor); */ - Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor searchRoot ); + Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor ); /** * @copydoc Toolkit::Builder::CreateFromStyle( const std::string& styleName ); @@ -229,7 +229,7 @@ private: void ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement); - Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor searchRoot ); + Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor ); BaseHandle CreateFromStyle( const std::string& styleName, const Replacement& replacement ); }; diff --git a/dali-toolkit/public-api/builder/builder.cpp b/dali-toolkit/public-api/builder/builder.cpp index 06a1c90..669dd37 100644 --- a/dali-toolkit/public-api/builder/builder.cpp +++ b/dali-toolkit/public-api/builder/builder.cpp @@ -83,6 +83,16 @@ Animation Builder::CreateAnimation( const std::string& animationName, const Prop return GetImpl(*this).CreateAnimation( animationName, map ); } +Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor sourceActor ) +{ + return GetImpl(*this).CreateAnimation( animationName, sourceActor ); +} + +Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor ) +{ + return GetImpl(*this).CreateAnimation( animationName, map, sourceActor ); +} + BaseHandle Builder::CreateFromStyle( const std::string& styleName ) { return GetImpl(*this).CreateFromStyle( styleName ); diff --git a/dali-toolkit/public-api/builder/builder.h b/dali-toolkit/public-api/builder/builder.h index 209f3c2..1f2796b 100644 --- a/dali-toolkit/public-api/builder/builder.h +++ b/dali-toolkit/public-api/builder/builder.h @@ -140,7 +140,7 @@ typedef std::map PropertyValueMap; * @brief Adds or modifies a user defined constant to all future style template or animation expansions * * e.g. - * @code builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" ); + * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" ); * * @pre The Builder has been initialized. * @param key The constant name to add or update @@ -152,9 +152,9 @@ typedef std::map PropertyValueMap; * @brief Gets all currently defined constants. * * e.g. - * @code PropertyValueMap map = builder.GetConstants(); // get copy of current constants - * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification - * builder.AddConstants( map ); // write back changes + * PropertyValueMap map = builder.GetConstants(); // get copy of current constants + * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification + * builder.AddConstants( map ); // write back changes * * @pre The Builder has been initialized. * @return A reference to the currently defined constants. @@ -165,9 +165,9 @@ typedef std::map PropertyValueMap; * @brief Gets a currently defined constant, or returns Property::INVALID * * e.g. - * @code PropertyValueMap map = builder.GetConstants(); // get copy of current constants - * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification - * builder.AddConstants( map ); // write back changes + * PropertyValueMap map = builder.GetConstants(); // get copy of current constants + * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification + * builder.AddConstants( map ); // write back changes * * @pre The Builder has been initialized. * @param key The constant name to search for. @@ -206,6 +206,44 @@ typedef std::map PropertyValueMap; Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map ); /** + * @brief Creates an animation from the set of known animations. + * + * The animation is applied to a specific actor. + * e.g. + * Actor myInstance = builder.CreateFromStyle( "template-actor-tree" ) + * Animation a = builder.CreateAnimation( "wobble", myInstance ); + * + * @pre The Builder has been initialized. + * @pre Preconditions have been met for creating dali objects ie Images, Actors etc + * @pre The animationName exists in the animations section of the data representation + * @param animationName The animation name to create + * @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 ); + + /** + * @brief Creates an animation from the set of known animations with user defined constants + * + * The animation is applied to a specific actor. + * e.g. + * PropertyValueMap map; + * map["ACTOR"] = actor.GetName(); // replaces '{ACTOR} in the template + * Actor myInstance = builder.CreateFromStyle( "template-actor-tree" ) + * Animation a = builder.CreateAnimation( "wobble", myInstance); + * + * @pre The Builder has been initialized. + * @pre Preconditions have been met for creating dali objects ie Images, Actors etc + * @pre The animationName exists in the animations section of the data representation + * @pre The map contains all the constant expansions in the style template + * @param animationName The animation name to create + * @param map The user defined constants used in style template expansion. + * @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 PropertyValueMap& map, Dali::Actor sourceActor ); + + /** * @brief Creates an object (e.g. an actor) from the set of known style templates * * e.g.