X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fanimation%2Factive-constraint-base.h;h=f7670b175d2c3b0fa8c5e2ba50784d8a12bd5dc4;hb=8295300529456e6693e04d8bc7998db85263c7c5;hp=38775ad24b6c6d0eb6fd84b69747a9840644c24d;hpb=5c66381841dd4dfd82c5a118d34104a00a2e0e1c;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 38775ad..f7670b1 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,7 +36,8 @@ namespace Internal { class EventToUpdate; -class ProxyObject; +typedef Dali::Vector ProxyObjectContainer; +typedef ProxyObjectContainer::Iterator ProxyObjectIter; namespace SceneGraph { @@ -47,7 +50,7 @@ class AnimatableProperty; /** * An abstract base class for active constraints. */ -class ActiveConstraintBase : public ProxyObject +class ActiveConstraintBase : public ProxyObject, public ProxyObject::Observer { public: @@ -58,8 +61,10 @@ public: * 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. @@ -93,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. */ - bool IsRemoving(); + 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 + */ + void OnParentSceneObjectRemoved(); /** * Retrieve the parent of the active-constraint. @@ -136,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); @@ -175,8 +178,6 @@ public: */ unsigned int GetTag() const; - - /** * Connects a callback function with the object's signals. * @param[in] object The object providing the signal. @@ -270,46 +271,58 @@ 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: /** - * Used to observe the lifetime of an object with custom "weight" property - * @param [in] weightObject The object. + * Helper to observe a proxy, if not already observing it */ - virtual void OnCustomWeightSet( ProxyObject& weightObject ) = 0; + void ObserveProxy( ProxyObject& proxy ); /** - * Set the parent of the active-constraint; called during OnFirstApply(). - * @param [in] parent The parent object. + * Helper to stop observing proxies */ - virtual void OnFirstApply( ProxyObject& parent ) = 0; + void StopObservation(); /** - * Notification for the derived class, when BeginRemove() is called. + * Helper called after the first apply animation. + * @param [in] object The active constraint. */ - virtual void OnBeginRemove() = 0; + 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; @@ -317,8 +330,6 @@ protected: float mOffstageWeight; - TimePeriod mRemoveTime; - AlphaFunction mAlphaFunction; RemoveAction mRemoveAction; @@ -329,8 +340,6 @@ 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 - };