Merge "Add UserInteractionEnabled property on actor for controlling user interaction...
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.cpp
index 174f5e3..6dc060a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -34,6 +34,7 @@
 #include <dali/devel-api/common/capabilities.h>
 
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/touch-integ.h>
 
 #include <dali/internal/event/actors/actor-coords.h>
 #include <dali/internal/event/actors/actor-parent.h>
@@ -147,6 +148,7 @@ DALI_PROPERTY("touchAreaOffset", RECTANGLE, true, false, false, Dali::DevelActor
 DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION)
 DALI_PROPERTY("touchFocusable", BOOLEAN, true, false, false, Dali::DevelActor::Property::TOUCH_FOCUSABLE)
 DALI_PROPERTY("keyboardFocusableChildren", BOOLEAN, true, false, false, Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN)
+DALI_PROPERTY("userInteractionEnabled", BOOLEAN, true, false, false, Dali::DevelActor::Property::USER_INTERACTION_ENABLED)
 DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties)
 
 // Signals
@@ -1014,6 +1016,22 @@ void Actor::EmitLayoutDirectionChangedSignal(LayoutDirection::Type type)
   EmitSignal(*this, mLayoutDirectionChangedSignal, type);
 }
 
+bool Actor::EmitHitTestResultSignal(Integration::Point point, Vector2 hitPointLocal, uint32_t timeStamp)
+{
+  bool hit = true;
+
+  if(IsHitTestResultRequired())
+  {
+    Dali::Actor        handle(this);
+    Integration::Point newPoint(point);
+    newPoint.SetHitActor(handle);
+    newPoint.SetLocalPosition(hitPointLocal);
+    Dali::TouchEvent touchEvent = Dali::Integration::NewTouchEvent(timeStamp, newPoint);
+    hit                         = mHitTestResultSignal.Emit(handle, touchEvent);
+  }
+  return hit;
+}
+
 DevelActor::ChildChangedSignalType& Actor::ChildAddedSignal()
 {
   return mParentImpl.ChildAddedSignal();
@@ -1048,6 +1066,7 @@ Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node)
   mOnRelayoutSignal(),
   mVisibilityChangedSignal(),
   mLayoutDirectionChangedSignal(),
+  mHitTestResultSignal(),
   mTargetOrientation(Quaternion::IDENTITY),
   mTargetColor(Color::WHITE),
   mTargetPosition(Vector3::ZERO),
@@ -1074,6 +1093,7 @@ Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node)
   mCaptureAllTouchAfterStart(false),
   mIsBlendEquationSet(false),
   mNeedGesturePropagation(false),
+  mUserInteractionEnabled(true),
   mLayoutDirection(LayoutDirection::LEFT_TO_RIGHT),
   mDrawMode(DrawMode::NORMAL),
   mColorMode(Node::DEFAULT_COLOR_MODE),