Refactored more code into Actor::Relayouter
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.h
index 2857f87..73a98aa 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali/internal/event/actors/actor-declarations.h>
 #include <dali/internal/event/actors/actor-parent-impl.h>
 #include <dali/internal/event/actors/actor-parent.h>
+#include <dali/internal/event/actors/actor-renderer-container.h>
 #include <dali/internal/event/common/object-impl.h>
 #include <dali/internal/event/common/stage-def.h>
 #include <dali/internal/update/nodes/node-declarations.h>
@@ -57,10 +58,6 @@ class RenderTask;
 class Renderer;
 class Scene;
 
-using RendererPtr       = IntrusivePtr<Renderer>;
-using RendererContainer = std::vector<RendererPtr>;
-using RendererIter      = RendererContainer::iterator;
-
 class ActorDepthTreeNode;
 using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator<ActorDepthTreeNode>;
 
@@ -170,7 +167,7 @@ public:
   bool IsRenderable() const
   {
     // inlined as this is called a lot in hit testing
-    return mRenderers && !mRenderers->empty();
+    return mRenderers && !mRenderers->IsEmpty();
   }
 
   /**
@@ -192,12 +189,17 @@ public:
   /**
    * @copydoc Dali::Internal::ActorParent::Add()
    */
-  void Add(Actor& child) override;
+  void Add(Actor& child, bool notify = true) override;
 
   /**
    * @copydoc Dali::Internal::ActorParent::Remove()
    */
-  void Remove(Actor& child) override;
+  void Remove(Actor& child, bool notify = true) override;
+
+  /**
+   * @copydoc Dali::DevelActor::SwitchParent()
+   */
+  void SwitchParent(Actor& newParent);
 
   /**
    * @copydoc Dali::Actor::Unparent
@@ -256,13 +258,19 @@ public:
   /**
    * @copydoc DevelActor::SetNeedGesturePropagation.
    */
-  void SetNeedGesturePropagation(bool propagation);
+  void SetNeedGesturePropagation(bool propagation)
+  {
+    mNeedGesturePropagation = propagation;
+  }
 
   /**
    * Retrieve need gesture propagation value
    * @return The actor's need gesture propagation value.
    */
-  bool NeedGesturePropagation();
+  bool NeedGesturePropagation() const
+  {
+    return mNeedGesturePropagation;
+  }
 
   /**
    * Sets the size of an actor.
@@ -381,6 +389,13 @@ public:
   const Vector3& GetCurrentAnchorPoint() const;
 
   /**
+   * If the position uses the anchor point, return the anchor point, otherwise
+   * return top left.
+   * @return The anchor point for positioning.
+   */
+  Vector3 GetAnchorPointForPosition() const;
+
+  /**
    * Sets the position of the Actor.
    * The coordinates are relative to the Actor's parent.
    * The Actor's z position will be set to 0.0f.
@@ -765,11 +780,20 @@ public:
    *
    * @return The depth used for hit-testing and renderer sorting
    */
-  uint32_t GetSortingDepth()
+  inline uint32_t GetSortingDepth()
   {
     return mSortedDepth;
   }
 
+  /**
+   * Set the actor's sorted depth. Used during recreation of depth tree
+   * @param[in] sortedDepth the new sorted depth
+   */
+  inline void SetSortingDepth(uint32_t sortedDepth)
+  {
+    mSortedDepth = sortedDepth;
+  }
+
 public:
   // Size negotiation virtual functions
 
@@ -1030,22 +1054,6 @@ public:
   float NegotiateFromParent(Dimension::Type dimension);
 
   /**
-   * Negotiate a dimension based on the size of the parent. Fitting inside.
-   *
-   * @param[in] dimension The dimension to negotiate on
-   * @return Return the negotiated size
-   */
-  float NegotiateFromParentFit(Dimension::Type dimension);
-
-  /**
-   * Negotiate a dimension based on the size of the parent. Flooding the whole space.
-   *
-   * @param[in] dimension The dimension to negotiate on
-   * @return Return the negotiated size
-   */
-  float NegotiateFromParentFlood(Dimension::Type dimension);
-
-  /**
    * @brief Negotiate a dimension based on the size of the children
    *
    * @param[in] dimension The dimension to negotiate on
@@ -1225,7 +1233,7 @@ public:
   void RemoveRenderer(uint32_t index);
 
   /**
-   * Set BlendEquation at each renderer that added on this Actor.
+   * @brief Set BlendEquation at each renderer that added on this Actor.
    */
   void SetBlendEquation(DevelBlendEquation::Type blendEquation);
 
@@ -1234,6 +1242,16 @@ public:
    */
   DevelBlendEquation::Type GetBlendEquation() const;
 
+  /**
+   * @brief Set this Actor is transparent or not without any affection on the child Actors.
+   */
+  void SetTransparent(bool transparent);
+
+  /**
+   * @brief Get this Actor is transparent or not.
+   */
+  bool IsTransparent() const;
+
 public:
   /**
    * Converts screen coordinates into the actor's coordinate system.
@@ -1319,6 +1337,40 @@ public:
   }
 
   /**
+   * @copydoc Dali::Actor::SetKeyboardFocusableChildren()
+   */
+  void SetKeyboardFocusableChildren(bool focusable)
+  {
+    mKeyboardFocusableChildren = focusable;
+  }
+
+  /**
+   * @copydoc Dali::Actor::AreChildrenKeyBoardFocusable()
+   */
+  bool AreChildrenKeyBoardFocusable() const
+  {
+    return mKeyboardFocusableChildren;
+  }
+
+  /**
+   * Set whether this view can focus by touch.
+   * @param[in] focusable focuable by touch.
+   */
+  void SetTouchFocusable(bool focusable)
+  {
+    mTouchFocusable = focusable;
+  }
+
+  /**
+   * This returns whether this actor can focus by touch.
+   * @return true if this actor can focus by touch.
+   */
+  bool IsTouchFocusable() const
+  {
+    return mTouchFocusable;
+  }
+
+  /**
    * Query whether the application or derived actor type requires intercept touch events.
    * @return True if intercept touch events are required.
    */
@@ -1540,31 +1592,6 @@ public:
    */
   DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal();
 
-  /**
-   * 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.
-   * @param[in] signalName The signal to connect to.
-   * @param[in] functor A newly allocated FunctorDelegate.
-   * @return True if the signal was connected.
-   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
-   */
-  static bool DoConnectSignal(BaseObject*                 object,
-                              ConnectionTrackerInterface* tracker,
-                              const std::string&          signalName,
-                              FunctorDelegate*            functor);
-
-  /**
-   * Performs actions as requested using the action name.
-   * @param[in] object The object on which to perform the action.
-   * @param[in] actionName The action to perform.
-   * @param[in] attributes The attributes with which to perfrom this action.
-   * @return true if the action was done.
-   */
-  static bool DoAction(BaseObject*          object,
-                       const std::string&   actionName,
-                       const Property::Map& attributes);
-
 public:
   // For Animation
 
@@ -1605,16 +1632,9 @@ protected:
   /**
    * Called on a child during Add() when the parent actor is connected to the Scene.
    * @param[in] parentDepth The depth of the parent in the hierarchy.
+   * @param[in] notify Emits notification if set to true.
    */
-  void ConnectToScene(uint32_t parentDepth);
-
-  /**
-   * Helper for ConnectToScene, to recursively connect a tree of actors.
-   * This is atomic i.e. not interrupted by user callbacks.
-   * @param[in]  depth The depth in the hierarchy of the actor
-   * @param[out] connectionList On return, the list of connected actors which require notification.
-   */
-  void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
+  void ConnectToScene(uint32_t parentDepth, bool notify);
 
   /**
    * Connect the Node associated with this Actor to the scene-graph.
@@ -1623,20 +1643,15 @@ protected:
 
   /**
    * Helper for ConnectToScene, to notify a connected actor through the public API.
+   * @param[in] notify Emits notification if set to true.
    */
-  void NotifyStageConnection();
+  void NotifyStageConnection(bool notify);
 
   /**
    * Called on a child during Remove() when the actor was previously on the Stage.
+   * @param[in] notify Emits notification if set to true.
    */
-  void DisconnectFromStage();
-
-  /**
-   * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
-   * This is atomic i.e. not interrupted by user callbacks.
-   * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
-   */
-  void RecursiveDisconnectFromStage(ActorContainer& disconnectionList);
+  void DisconnectFromStage(bool notify);
 
   /**
    * Disconnect the Node associated with this Actor from the scene-graph.
@@ -1645,8 +1660,9 @@ protected:
 
   /**
    * Helper for DisconnectFromStage, to notify a disconnected actor through the public API.
+   * @param[in] notify Emits notification if set to true.
    */
-  void NotifyStageDisconnection();
+  void NotifyStageDisconnection(bool notify);
 
   /**
    * When the Actor is OnScene, checks whether the corresponding Node is connected to the scene graph.
@@ -1662,14 +1678,6 @@ public:
    */
   void RebuildDepthTree();
 
-protected:
-  /**
-   * Traverse the actor tree, inserting actors into the depth tree in sibling order.
-   * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
-   * @param[in,out] depthIndex The current depth index (traversal index)
-   */
-  void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
-
 public:
   // Default property extensions from Object
 
@@ -1812,8 +1820,9 @@ private:
   /**
    * Set the actor's parent.
    * @param[in] parent The new parent.
+   * @param[in] notify Emits notification if set to true. Default is true.
    */
-  void SetParent(ActorParent* parent);
+  void SetParent(ActorParent* parent, bool notify = true);
 
   /**
    * For use in derived classes, called after Initialize()
@@ -1988,26 +1997,11 @@ private:
   }
 
   /**
-   * @brief Propagates layout direction recursively.
-   * @param[in] direction New layout direction.
-   */
-  void InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set = false);
-
-  /**
    * @brief Sets the update size hint of an actor.
    * @param [in] updateSizeHint The update size hint.
    */
   void SetUpdateSizeHint(const Vector2& updateSizeHint);
 
-  /**
-   * @brief Recursively emits the visibility-changed-signal on the actor tree.
-   *
-   * @param[in] visible The new visibility of the actor
-   * @param[in] type Whether the actor's visible property has changed or a parent's
-   */
-  void EmitVisibilityChangedSignalRecursively(bool                               visible,
-                                              DevelActor::VisibilityChange::Type type);
-
 protected:
   ActorParentImpl    mParentImpl;   ///< Implementation of ActorParent;
   ActorParent*       mParent;       ///< Each actor (except the root) can have one parent
@@ -2048,6 +2042,8 @@ protected:
   bool                     mSensitive : 1;                 ///< Whether the actor emits touch event signals
   bool                     mLeaveRequired : 1;             ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds
   bool                     mKeyboardFocusable : 1;         ///< Whether the actor should be focusable by keyboard navigation
+  bool                     mKeyboardFocusableChildren : 1; ///< Whether the children of this actor can be focusable by keyboard navigation.
+  bool                     mTouchFocusable : 1;            ///< Whether the actor should be focusable by touch
   bool                     mOnSceneSignalled : 1;          ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection
   bool                     mInsideOnSizeSet : 1;           ///< Whether we are inside OnSizeSet
   bool                     mInheritPosition : 1;           ///< Cached: Whether the parent's position should be inherited.