X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fanimation%2Factive-constraint-base.h;h=de4e7519aea5826f18c7de6f28641af21b77621c;hb=23bced0a72d755b404c456644c3220800a5a55dd;hp=e20b7496eb8a0be2c25e09c389ac6aede1de8cbe;hpb=ce20e9f082e811130930d13c9e9edc1da4ce1013;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/animation/active-constraint-base.h b/dali/internal/event/animation/active-constraint-base.h index e20b749..de4e751 100644 --- a/dali/internal/event/animation/active-constraint-base.h +++ b/dali/internal/event/animation/active-constraint-base.h @@ -1,21 +1,22 @@ #ifndef __DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H__ #define __DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // INTERNAL INCLUDES #include @@ -26,6 +27,7 @@ #include #include #include +#include namespace Dali { @@ -34,29 +36,35 @@ namespace Internal { class EventToUpdate; -class ProxyObject; +typedef Dali::Vector ProxyObjectContainer; +typedef ProxyObjectContainer::Iterator ProxyObjectIter; namespace SceneGraph { class ConstraintBase; + +template +class AnimatableProperty; } /** * An abstract base class for active constraints. */ -class ActiveConstraintBase : public ProxyObject +class ActiveConstraintBase : public ProxyObject, public ProxyObject::Observer { public: typedef Dali::Constraint::RemoveAction RemoveAction; - typedef boost::any AnyFunction; + typedef Any AnyFunction; /** * Constructor. * @param[in] messageController Used to send messages to the update-thread. * @param[in] targetPropertyIndex The index of the property being constrained. + * @param[in] sources The sources of the input properties. + * @param[in] sourceCount The original number of sources; this may not match sources.size() if objects have died. */ - ActiveConstraintBase( EventToUpdate& messageController, Property::Index targetPropertyIndex ); + ActiveConstraintBase( EventToUpdate& messageController, Property::Index targetPropertyIndex, SourceContainer& sources, unsigned int sourceCount ); /** * Virtual destructor. @@ -70,13 +78,19 @@ public: virtual ActiveConstraintBase* Clone() = 0; /** + * Set a custom "weight" property. + * @param[in] weightObject An object with a "weight" float property. + * @param[in] weightIndex The index of the weight property. + */ + void SetCustomWeightObject( ProxyObject& weightObject, Property::Index weightIndex ); + + /** * Called when the ActiveConstraint is first applied. * @pre The active-constraint does not already have a parent. * @param[in] parent The parent object. * @param[in] applyTime The apply-time for this constraint. - * @param[in] callback A pointer to a callback for the applied signal, or NULL. */ - void FirstApply( ProxyObject& parent, TimePeriod applyTime, ActiveConstraintCallbackType* callback ); + void FirstApply( ProxyObject& parent, TimePeriod applyTime ); /** * Called when the ActiveConstraint is removed. @@ -84,11 +98,19 @@ public: void BeginRemove(); /** - * Query whether the constraint is being removed. - * This is only possible if mRemoveTime.durationSeconds is non-zero. - * @return True if constraint is being removed. + * Called when the target object is destroyed. + */ + void OnParentDestroyed(); + + /** + * Called when the target object is connected to the scene-graph + */ + void OnParentSceneObjectAdded(); + + /** + * Called when the target object is disconnected from the scene-graph */ - bool IsRemoving(); + void OnParentSceneObjectRemoved(); /** * Retrieve the parent of the active-constraint. @@ -127,16 +149,6 @@ public: ActiveConstraintSignalV2& AppliedSignal(); /** - * @copydoc Dali::Constraint::SetRemoveTime() - */ - void SetRemoveTime( TimePeriod timePeriod ); - - /** - * @copydoc Dali::Constraint::GetRemoveTime() - */ - TimePeriod GetRemoveTime() const; - - /** * @copydoc Dali::Constraint::SetAlphaFunction() */ void SetAlphaFunction(AlphaFunction func); @@ -157,6 +169,16 @@ public: RemoveAction GetRemoveAction() const; /** + * @copydoc Dali::Constraint::SetTag() + */ + void SetTag(const unsigned int tag); + + /** + * @copydoc Dali::Constraint::GetTag() + */ + unsigned int GetTag() const; + + /** * Connects a callback function with the object's signals. * @param[in] object The object providing the signal. * @param[in] tracker Used to disconnect the signal. @@ -170,19 +192,19 @@ public: public: // Default property extensions from ProxyObject /** - * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable() + * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount() */ - virtual bool IsSceneObjectRemovable() const; + virtual unsigned int GetDefaultPropertyCount() const; /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount() + * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices() */ - virtual unsigned int GetDefaultPropertyCount() const; + virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const; + virtual const char* GetDefaultPropertyName( Property::Index index ) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -200,6 +222,11 @@ public: // Default property extensions from ProxyObject virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const; /** + * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput() + */ + virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; + + /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType() */ virtual Property::Type GetDefaultPropertyType( Property::Index index ) const; @@ -239,57 +266,76 @@ public: // Default property extensions from ProxyObject */ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const; -private: +public: // ProxyObject::Observer methods /** - * Helper called after the first apply animation. - * @param [in] object The active constraint. + * @copydoc ProxyObject::Observer::SceneObjectAdded() */ - static void FirstApplyFinished( Object* object ); + virtual void SceneObjectAdded( ProxyObject& proxy ); /** - * Helper called after the remove animation. - * @param [in] object The active constraint. + * @copydoc ProxyObject::Observer::SceneObjectRemoved() */ - static void OnRemoveFinished( Object* object ); + virtual void SceneObjectRemoved( ProxyObject& proxy ); - // To be implemented in derived classes + /** + * @copydoc ProxyObject::Observer::ProxyDestroyed() + */ + virtual void ProxyDestroyed( ProxyObject& proxy ); + +private: /** - * Set the parent of the active-constraint; called during OnFirstApply(). - * @param [in] parent The parent object. + * Helper to observe a proxy, if not already observing it */ - virtual void OnFirstApply( ProxyObject& parent ) = 0; + void ObserveProxy( ProxyObject& proxy ); /** - * Notification for the derived class, when BeginRemove() is called. + * Helper to stop observing proxies */ - virtual void OnBeginRemove() = 0; + void StopObservation(); + + /** + * Helper called after the first apply animation. + * @param [in] object The active constraint. + */ + static void FirstApplyFinished( Object* object ); + + // To be implemented in derived classes + + /** + * Create and connect a constraint for a scene-object. + */ + virtual void ConnectConstraint() = 0; protected: EventToUpdate& mEventToUpdate; Property::Index mTargetPropertyIndex; + SourceContainer mSources; + const unsigned int mSourceCount; ProxyObject* mTargetProxy; ///< The proxy-object owns the active-constraint. + ProxyObjectContainer mObservedProxies; // We don't observe the same object twice const SceneGraph::ConstraintBase* mSceneGraphConstraint; - float mOffstageWeight; + const SceneGraph::AnimatableProperty* mCustomWeight; - TimePeriod mRemoveTime; + float mOffstageWeight; AlphaFunction mAlphaFunction; RemoveAction mRemoveAction; + unsigned int mTag; private: ActiveConstraintSignalV2 mAppliedSignal; Dali::Animation mApplyAnimation; ///< Used to automatically animate weight from 0.0f -> 1.0f - Dali::Animation mRemoveAnimation; ///< Used to automatically animate weight back to 0.0f + }; } // namespace Internal