[Tizen] Add EmitWheelEventGeneratedSignal for custom wheel event 44/271544/2 accepted/tizen/6.5/unified/20220223.132722 submit/tizen_6.5/20220223.022356
authorjoogab.yun <joogab.yun@samsung.com>
Thu, 27 Jan 2022 01:11:37 +0000 (10:11 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Wed, 23 Feb 2022 01:10:41 +0000 (10:10 +0900)
For custom wheel events,
we first send the event to the focus manager by WheelEventGeneratedSignal.

Previously, RotaryEvents(CustomWheel type) could always be received only by window.
Now, User can receive Rotary Events in focused View as well.
It is also possible to propagate events to the parent view.

If there is no focused View, the window will receive the event.

This only applies to Rotary Event(CustomWheel type).

Change-Id: I13e2c9b725ee5a65c7408df2f4293c7b61c56035

automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/scene.cpp
dali/integration-api/scene.h
dali/internal/event/common/scene-impl.cpp
dali/internal/event/common/scene-impl.h
dali/internal/event/events/wheel-event-processor.cpp

index fc19ea7..a9a415e 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.
@@ -224,6 +224,50 @@ struct KeyEventGeneratedReceivedFunctor
   KeyEventGeneratedSignalData& signalData;
 };
 
+// Stores data that is populated in the WheelEventGeneratedSignal callback and will be read by the TET cases
+struct WheelEventGeneratedSignalData
+{
+  WheelEventGeneratedSignalData()
+  : functorCalled(false)
+  {
+  }
+
+  void Reset()
+  {
+    functorCalled = false;
+
+    receivedWheelEvent.Reset();
+  }
+
+  bool       functorCalled;
+  WheelEvent receivedWheelEvent;
+};
+
+// Functor that sets the data when called
+struct WheelEventGeneratedReceivedFunctor
+{
+  WheelEventGeneratedReceivedFunctor(WheelEventGeneratedSignalData& data)
+  : signalData(data)
+  {
+  }
+
+  bool operator()(const WheelEvent& wheelEvent)
+  {
+    signalData.functorCalled      = true;
+    signalData.receivedWheelEvent = wheelEvent;
+
+    return true;
+  }
+
+  bool operator()()
+  {
+    signalData.functorCalled = true;
+    return true;
+  }
+
+  WheelEventGeneratedSignalData& signalData;
+};
+
 void GenerateTouch(TestApplication& application, PointState::Type state, const Vector2& screenPosition)
 {
   Integration::TouchEvent touchEvent;
@@ -1659,3 +1703,38 @@ int UtcDaliSceneFrameRenderedPresentedCallback(void)
 
   END_TEST;
 }
+
+int UtcDaliSceneWheelEventGeneratedSignalP(void)
+{
+  TestApplication          application;
+  Dali::Integration::Scene scene = application.GetScene();
+
+  WheelEventGeneratedSignalData      data;
+  WheelEventGeneratedReceivedFunctor functor(data);
+  scene.WheelEventGeneratedSignal().Connect(&application, functor);
+
+  Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
+  application.ProcessEvent(event);
+
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event.type) == data.receivedWheelEvent.GetType());
+  DALI_TEST_CHECK(event.direction == data.receivedWheelEvent.GetDirection());
+  DALI_TEST_CHECK(event.modifiers == data.receivedWheelEvent.GetModifiers());
+  DALI_TEST_CHECK(event.point == data.receivedWheelEvent.GetPoint());
+  DALI_TEST_CHECK(event.delta == data.receivedWheelEvent.GetDelta());
+  DALI_TEST_CHECK(event.timeStamp == data.receivedWheelEvent.GetTime());
+
+  data.Reset();
+
+  Integration::WheelEvent event2(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1000u);
+  application.ProcessEvent(event2);
+
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_CHECK(static_cast<WheelEvent::Type>(event2.type) == data.receivedWheelEvent.GetType());
+  DALI_TEST_CHECK(event2.direction == data.receivedWheelEvent.GetDirection());
+  DALI_TEST_CHECK(event2.modifiers == data.receivedWheelEvent.GetModifiers());
+  DALI_TEST_CHECK(event2.point == data.receivedWheelEvent.GetPoint());
+  DALI_TEST_CHECK(event2.delta == data.receivedWheelEvent.GetDelta());
+  DALI_TEST_CHECK(event2.timeStamp == data.receivedWheelEvent.GetTime());
+  END_TEST;
+}
\ No newline at end of file
index 8fb7a7c..5aaaa4b 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.
@@ -219,6 +219,11 @@ Scene::WheelEventSignalType& Scene::WheelEventSignal()
   return GetImplementation(*this).WheelEventSignal();
 }
 
+Scene::WheelEventGeneratedSignalType& Scene::WheelEventGeneratedSignal()
+{
+  return GetImplementation(*this).WheelEventGeneratedSignal();
+}
+
 } // namespace Integration
 
 } // namespace Dali
index d137773..3f2d7ed 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SCENE_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.
@@ -64,6 +64,7 @@ public:
   using KeyEventGeneratedSignalType       = Signal<bool(const Dali::KeyEvent&)>;   ///< key event generated signal type
   using TouchEventSignalType              = Signal<void(const Dali::TouchEvent&)>; ///< Touch signal type
   using WheelEventSignalType              = Signal<void(const Dali::WheelEvent&)>; ///< WheelEvent signal type
+  using WheelEventGeneratedSignalType     = Signal<bool(const Dali::WheelEvent&)>; ///< WheelEvent generated signal type
 
   using FrameCallbackContainer = std::vector<std::pair<std::unique_ptr<CallbackBase>, int32_t> >;
 
@@ -411,6 +412,23 @@ public:
    */
   WheelEventSignalType& WheelEventSignal();
 
+  /**
+   * @brief When a custom wheel event occurs, it need to process the focused actor first.
+   *
+   * Therefore, KeyboardFocusManager first checks whether WheelEvent is generated as WheelEventGeneratedSignal.
+   * After that wheelEventProcessor must invoke WheelEvent only if wheelEventGeneratedSignal () is not consumed.
+   *
+   * This is only valid for custom wheel events.
+   *
+   * A callback of the following type may be connected:
+   * @code
+   *   bool YourCallbackName(const WheelEvent& event);
+   * @endcode
+   *
+   * @return The return is true if WheelEvent is consumed, otherwise false.
+   */
+  WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
+
 public: // Not intended for application developers
   /**
    * @brief This constructor is used by Dali::New() methods.
index ba88152..723a1a4 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.
@@ -373,6 +373,13 @@ void Scene::EmitWheelEventSignal(const Dali::WheelEvent& event)
   }
 }
 
+bool Scene::EmitWheelEventGeneratedSignal(const Dali::WheelEvent& event)
+{
+  // Emit the WheelEventGenerated signal when WheelEvent is generated
+  Dali::Integration::Scene handle(this);
+  return mWheelEventGeneratedSignal.Emit(event);
+}
+
 void Scene::AddFrameRenderedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId)
 {
   ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
@@ -420,6 +427,11 @@ Integration::Scene::WheelEventSignalType& Scene::WheelEventSignal()
   return mWheelEventSignal;
 }
 
+Integration::Scene::WheelEventGeneratedSignalType& Scene::WheelEventGeneratedSignal()
+{
+  return mWheelEventGeneratedSignal;
+}
+
 } // namespace Internal
 
 } // namespace Dali
index 34ab1a8..7f9cbc1 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_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.
@@ -253,6 +253,13 @@ public:
   void EmitWheelEventSignal(const Dali::WheelEvent& event);
 
   /**
+   * Used by the WheelEventProcessor to emit WheelEventGenerated signals.
+   * @param[in] event The wheel event.
+   * @return The return is true if WheelEvent is consumed, otherwise false.
+   */
+  bool EmitWheelEventGeneratedSignal(const Dali::WheelEvent& event);
+
+  /**
    * @copydoc Dali::Integration::Scene::AddFrameRenderedCallback
    */
   void AddFrameRenderedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId);
@@ -297,6 +304,11 @@ public:
    */
   Integration::Scene::WheelEventSignalType& WheelEventSignal();
 
+  /**
+   * @copydoc Integration::Scene::WheelEventGeneratedSignal()
+   */
+  Integration::Scene::WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
+
 public:
   /**
    * From RenderTaskDefaults; retrieve the default root actor.
@@ -374,7 +386,8 @@ private:
   Integration::Scene::TouchEventSignalType mTouchedSignal;
 
   // The wheel event signal
-  Integration::Scene::WheelEventSignalType mWheelEventSignal;
+  Integration::Scene::WheelEventSignalType          mWheelEventSignal;
+  Integration::Scene::WheelEventGeneratedSignalType mWheelEventGeneratedSignal;
 };
 
 } // namespace Internal
index 5d73dc3..f7a082f 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.
@@ -148,7 +148,11 @@ void WheelEventProcessor::ProcessWheelEvent(const Integration::WheelEvent& event
   else
   {
     // if CUSTOM_WHEEL, emit the wheel event signal from the scene.
-    mScene.EmitWheelEventSignal(wheelEventHandle);
+    bool consumed = mScene.EmitWheelEventGeneratedSignal(wheelEventHandle);
+    if(!consumed)
+    {
+      mScene.EmitWheelEventSignal(wheelEventHandle);
+    }
   }
 }