Remove a dead virtual method from proxy object
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / active-constraint-base.h
index 2ebc1b7..de4e751 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/animation/time-period.h>
 #include <dali/public-api/common/dali-common.h>
+#include <dali/internal/event/animation/constraint-source-impl.h>
 
 namespace Dali
 {
@@ -35,7 +36,8 @@ namespace Internal
 {
 
 class EventToUpdate;
-class ProxyObject;
+typedef Dali::Vector<ProxyObject*>     ProxyObjectContainer;
+typedef ProxyObjectContainer::Iterator ProxyObjectIter;
 
 namespace SceneGraph
 {
@@ -48,7 +50,7 @@ class AnimatableProperty;
 /**
  * An abstract base class for active constraints.
  */
-class ActiveConstraintBase : public ProxyObject
+class ActiveConstraintBase : public ProxyObject, public ProxyObject::Observer
 {
 public:
 
@@ -59,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.
@@ -94,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.
@@ -137,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);
@@ -176,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.
@@ -192,11 +192,6 @@ public:
 public: // Default property extensions from ProxyObject
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
-   */
-  virtual bool IsSceneObjectRemovable() const;
-
-  /**
    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
    */
   virtual unsigned int GetDefaultPropertyCount() const;
@@ -209,7 +204,7 @@ public: // Default property extensions from ProxyObject
   /**
    * @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()
@@ -271,46 +266,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:
+
+  /**
+   * Helper to observe a proxy, if not already observing it
+   */
+  void ObserveProxy( ProxyObject& proxy );
 
   /**
-   * Used to observe the lifetime of an object with custom "weight" property
-   * @param [in] weightObject The object.
+   * Helper to stop observing proxies
    */
-  virtual void OnCustomWeightSet( ProxyObject& weightObject ) = 0;
+  void StopObservation();
 
   /**
-   * Set the parent of the active-constraint; called during OnFirstApply().
-   * @param [in] parent The parent object.
+   * Helper called after the first apply animation.
+   * @param [in] object The active constraint.
    */
-  virtual void OnFirstApply( ProxyObject& parent ) = 0;
+  static void FirstApplyFinished( Object* object );
+
+  // To be implemented in derived classes
 
   /**
-   * Notification for the derived class, when BeginRemove() is called.
+   * Create and connect a constraint for a scene-object.
    */
-  virtual void OnBeginRemove() = 0;
+  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;
 
@@ -318,8 +325,6 @@ protected:
 
   float mOffstageWeight;
 
-  TimePeriod mRemoveTime;
-
   AlphaFunction mAlphaFunction;
 
   RemoveAction mRemoveAction;
@@ -330,8 +335,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
-
 
 };