From bb03d1b8554070782fab2c3b749c96d791adbf2e Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Wed, 15 Mar 2017 14:47:51 +0000 Subject: [PATCH] Added Getters for Animator Connectors base class Change-Id: I90c6afe299dd565261fe733c4fbe3c53df1988d2 --- .../event/animation/animator-connector-base.h | 65 ++++++++++++++++++++-- dali/internal/event/animation/animator-connector.h | 34 +---------- 2 files changed, 64 insertions(+), 35 deletions(-) diff --git a/dali/internal/event/animation/animator-connector-base.h b/dali/internal/event/animation/animator-connector-base.h index 9c49d14..5a54bc8 100644 --- a/dali/internal/event/animation/animator-connector-base.h +++ b/dali/internal/event/animation/animator-connector-base.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include #include #include @@ -43,19 +44,31 @@ typedef AnimatorConnectorContainer::ConstIterator AnimatorConnectorConstIter; /** * An abstract base class for animator connectors. + * + * The scene-graph objects are created by a Object e.g. Actor is a proxy for SceneGraph::Node. + * AnimatorConnectorBase observes the proxy object, in order to detect when a scene-graph object is created. */ -class AnimatorConnectorBase +class AnimatorConnectorBase: public Object::Observer { public: /** * Constructor. */ - AnimatorConnectorBase(AlphaFunction alpha, const TimePeriod& period) - : mParent(NULL), + AnimatorConnectorBase( + Object& object, + Property::Index propertyIndex, + int componentIndex, + AlphaFunction alpha, + const TimePeriod& period) + : mParent( NULL ), + mObject( &object ), mAlphaFunction(alpha), - mTimePeriod(period) + mTimePeriod(period), + mPropertyIndex( propertyIndex ), + mComponentIndex( componentIndex ) { + object.AddObserver( *this ); } /** @@ -81,12 +94,56 @@ public: return mParent; } + Object* GetObject() const + { + return mObject; + } + + Property::Index GetPropertyIndex() const + { + return mPropertyIndex; + } + + int GetComponentIndex() const + { + return mComponentIndex; + } + +private: + + /** + * From Object::Observer + */ + virtual void SceneObjectAdded( Object& object ) + { + } + + /** + * From Object::Observer + */ + virtual void SceneObjectRemoved( Object& object ) + { + } + + /** + * From Object::Observer + */ + virtual void ObjectDestroyed( Object& object ) + { + mObject = NULL; + } + protected: Animation* mParent; ///< The parent owns the connector. + Object* mObject; ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called. AlphaFunction mAlphaFunction; TimePeriod mTimePeriod; + + Property::Index mPropertyIndex; + int mComponentIndex; + }; } // namespace Internal diff --git a/dali/internal/event/animation/animator-connector.h b/dali/internal/event/animation/animator-connector.h index e06225d..d672329 100644 --- a/dali/internal/event/animation/animator-connector.h +++ b/dali/internal/event/animation/animator-connector.h @@ -19,13 +19,11 @@ */ // INTERNAL INCLUDES -#include #include #include #include #include #include -#include #include namespace Dali @@ -37,14 +35,11 @@ namespace Internal /** * AnimatorConnector is used to connect SceneGraph::Animators for newly created scene-graph objects. * - * The scene-graph objects are created by a Object e.g. Actor is a proxy for SceneGraph::Node. - * AnimatorConnector observes the proxy object, in order to detect when a scene-graph object is created. - * * SceneGraph::Animators weakly reference scene objects, and are automatically deleted when orphaned. * Therefore the AnimatorConnector is NOT responsible for disconnecting animators. */ template < typename PropertyType > -class AnimatorConnector : public AnimatorConnectorBase, public Object::Observer +class AnimatorConnector : public AnimatorConnectorBase { public: @@ -121,14 +116,10 @@ private: Internal::AnimatorFunctionBase* animatorFunction, AlphaFunction alpha, const TimePeriod& period ) - : AnimatorConnectorBase( alpha, period ), - mObject( &object ), + : AnimatorConnectorBase( object, propertyIndex, componentIndex, alpha, period ), mAnimator(0), - mPropertyIndex( propertyIndex ), - mComponentIndex( componentIndex ), mAnimatorFunction( animatorFunction ) { - object.AddObserver( *this ); } // Undefined @@ -143,27 +134,12 @@ private: virtual void SceneObjectAdded( Object& object ) { //If the animator has not been created yet, create it now. - if( !mAnimator ) + if( !mAnimator && mObject ) { CreateAnimator(); } } - /** - * From Object::Observer - */ - virtual void SceneObjectRemoved( Object& object ) - { - } - - /** - * From Object::Observer - */ - virtual void ObjectDestroyed( Object& object ) - { - mObject = NULL; - } - /** * Helper function to create a Scenegraph::Animator and add it to its correspondent SceneGraph::Animation. * @note This function will only be called the first time the object is added to the scene or at creation time if @@ -390,12 +366,8 @@ private: protected: - Object* mObject; ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called. SceneGraph::AnimatorBase* mAnimator; - Property::Index mPropertyIndex; - int mComponentIndex; - Internal::AnimatorFunctionBase* mAnimatorFunction; ///< Owned by the animator connector until an Scenegraph::Animator is created }; -- 2.7.4