[Tizen] Calculrate screen position with RenderTask
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.h
index 8ab4be7..4557a03 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_ACTOR_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -33,6 +33,8 @@
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/rendering/renderer-devel.h>
 
+#include <dali/integration-api/events/touch-event-integ.h>
+
 #include <dali/internal/common/const-string.h>
 #include <dali/internal/common/internal-constants.h>
 #include <dali/internal/common/memory-pool-object-allocator.h>
@@ -644,6 +646,41 @@ public:
   }
 
   /**
+   * Sets whether an actor should be enabled all user interaction including touch, focus and activation.
+   * This value have higher priority over the sensitve and focusable in negative action,
+   * which means IsSensitive() or IsFocusable() and enable is false, actor will not emits touch or focus event.
+   * An actor is enabled by default.
+   *
+   * If the application wishes to temporarily disable user interaction:
+   * @code
+   * actor.SetUserInteractionEnabled(false);
+   * @endcode
+   *
+   * Then, to re-enable user interaction, the application should call:
+   * @code
+   * actor.SetUserInteractionEnabled(true);
+   * @endcode
+   *
+   * @see IsSensitive(), IsHittable(), IsKeyboardFocusable() and IsTouchFocusable().
+   * @note If an actor's disabled, child still can be enabled.
+   * @param[in]  enabled  true to enable user interaction, false otherwise.
+   */
+  void SetUserInteractionEnabled(bool enabled)
+  {
+    mUserInteractionEnabled = enabled;
+  }
+
+  /**
+   * Query whether an actor is enabled user interaction.
+   * @see SetSensitive(bool)
+   * @return true, if user interaction is enabled, false otherwise.
+   */
+  bool IsUserInteractionEnabled() const
+  {
+    return mUserInteractionEnabled;
+  }
+
+  /**
    * @copydoc Dali::Actor::SetDrawMode
    */
   void SetDrawMode(DrawMode::Type drawMode);
@@ -730,6 +767,21 @@ public:
   }
 
   /**
+   * @brief Get the number of layer with 3D behaviour in ancestors include this. It will be 0 if actor is not on scene.
+   *
+   * @return currently the number of layer with 3D behaviour in ancestors.
+   */
+  inline int32_t GetLayer3DParentCount() const
+  {
+    if(mIsOnScene)
+    {
+      return mLayer3DParentsCount;
+    }
+
+    return 0;
+  }
+
+  /**
    * Get the actor's sorting depth
    *
    * @return The depth used for hit-testing and renderer sorting
@@ -1205,6 +1257,15 @@ public:
   }
 
   /**
+   * Query whether the application or derived actor type requires hit-test result events.
+   * @return True if hit-test result events are required.
+   */
+  bool IsHitTestResultRequired() const
+  {
+    return !mHitTestResultSignal.Empty();
+  }
+
+  /**
    * Query whether the application or derived actor type requires intercept touch events.
    * @return True if intercept touch events are required.
    */
@@ -1247,7 +1308,7 @@ public:
    */
   bool IsHittable() const
   {
-    return IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
+    return (IsUserInteractionEnabled()) && IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
   }
 
   /**
@@ -1277,6 +1338,15 @@ public:
     return mTouchAreaOffset;
   }
 
+  /**
+   * Query whether the actor will only receive own touch.
+   * @return true, if it only receives touches that started from itself.
+   */
+  bool IsAllowedOnlyOwnTouch() const
+  {
+    return mAllowOnlyOwnTouch;
+  }
+
   // Gestures
 
   /**
@@ -1340,6 +1410,23 @@ public:
   void EmitLayoutDirectionChangedSignal(LayoutDirection::Type type);
 
   /**
+   * Used by the EventProcessor to emit hit-test result touch event signals.
+   * @param[in] point The point of event touched.
+   * @param[in] hitPointLocal The hit point in the Actor's local reference system.
+   * @param[in] timeStamp The time the event occurred.
+   * @return True if the event was consumed.
+   */
+  bool EmitHitTestResultSignal(Integration::Point point, Vector2 hitPointLocal, uint32_t timeStamp);
+
+  /**
+   * @copydoc DevelActor::HitTestResultSignal()
+   */
+  Dali::Actor::TouchEventSignalType& HitTestResultSignal()
+  {
+    return mHitTestResultSignal;
+  }
+
+  /**
    * @copydoc DevelActor::InterceptTouchedSignal()
    */
   Dali::Actor::TouchEventSignalType& InterceptTouchedSignal()
@@ -1466,9 +1553,10 @@ 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] layer3DParentsCount The number of 3d layers in the hierarchy.
    * @param[in] notify Emits notification if set to true.
    */
-  void ConnectToScene(uint32_t parentDepth, bool notify);
+  void ConnectToScene(uint32_t parentDepth, uint32_t layer3DParentsCount, bool notify);
 
   /**
    * Connect the Node associated with this Actor to the scene-graph.
@@ -1805,10 +1893,10 @@ private:
   }
 
   /**
-   * @brief Sets the update size hint of an actor.
-   * @param [in] updateSizeHint The update size hint.
+   * @brief Sets the update area hint of an actor.
+   * @param [in] updateAreaHint The update area hint.
    */
-  void SetUpdateSizeHint(const Vector2& updateSizeHint);
+  void SetUpdateAreaHint(const Vector4& updateAreaHint);
 
 protected:
   ActorParentImpl    mParentImpl;   ///< Implementation of ActorParent;
@@ -1830,6 +1918,7 @@ protected:
   Dali::Actor::OnRelayoutSignalType             mOnRelayoutSignal;
   DevelActor::VisibilityChangedSignalType       mVisibilityChangedSignal;
   Dali::Actor::LayoutDirectionChangedSignalType mLayoutDirectionChangedSignal;
+  Dali::Actor::TouchEventSignalType             mHitTestResultSignal;
 
   Quaternion mTargetOrientation; ///< Event-side storage for orientation
   Vector4    mTargetColor;       ///< Event-side storage for color
@@ -1841,6 +1930,8 @@ protected:
   uint32_t    mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order.
   int16_t     mDepth;       ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported
 
+  int16_t mLayer3DParentsCount; ///< The number of layer with 3D behaviour in ancestors include this. It will be 0 if actor is not on scene.
+
   const bool               mIsRoot : 1;                    ///< Flag to identify the root actor
   const bool               mIsLayer : 1;                   ///< Flag to identify that this is a layer
   bool                     mIsOnScene : 1;                 ///< Flag to identify whether the actor is on-scene
@@ -1859,6 +1950,8 @@ protected:
   bool                     mCaptureAllTouchAfterStart : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area.
   bool                     mIsBlendEquationSet : 1;        ///< Flag to identify whether the Blend equation is set
   bool                     mNeedGesturePropagation : 1;    ///< Whether the parent listens for gesture events or not
+  bool                     mUserInteractionEnabled : 1;    ///< Whether the actor should be enabled user interaction.
+  bool                     mAllowOnlyOwnTouch : 1;         ///< whether the actor will only receive own touch. it only receives touches that started from itself.
   LayoutDirection::Type    mLayoutDirection : 2;           ///< Layout direction, Left to Right or Right to Left.
   DrawMode::Type           mDrawMode : 3;                  ///< Cached: How the actor and its children should be drawn
   ColorMode                mColorMode : 3;                 ///< Cached: Determines whether mWorldColor is inherited