From 5f5f9ab1fe56f1a0478dc2dcde92dc4f6ebbc2b7 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Thu, 27 Jan 2022 10:11:37 +0900 Subject: [PATCH] [Tizen] Add EmitWheelEventGeneratedSignal for custom wheel event 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 | 81 +++++++++++++++++++++- dali/integration-api/scene.cpp | 7 +- dali/integration-api/scene.h | 20 +++++- dali/internal/event/common/scene-impl.cpp | 14 +++- dali/internal/event/common/scene-impl.h | 17 ++++- .../event/events/wheel-event-processor.cpp | 8 ++- 6 files changed, 139 insertions(+), 8 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index fc19ea7..a9a415e 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -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(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(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 diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index 8fb7a7c..5aaaa4b 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -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 diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index d137773..3f2d7ed 100644 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -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; ///< key event generated signal type using TouchEventSignalType = Signal; ///< Touch signal type using WheelEventSignalType = Signal; ///< WheelEvent signal type + using WheelEventGeneratedSignalType = Signal; ///< WheelEvent generated signal type using FrameCallbackContainer = std::vector, 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. diff --git a/dali/internal/event/common/scene-impl.cpp b/dali/internal/event/common/scene-impl.cpp index ba88152..723a1a4 100644 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -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 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 diff --git a/dali/internal/event/common/scene-impl.h b/dali/internal/event/common/scene-impl.h index 34ab1a8..7f9cbc1 100644 --- a/dali/internal/event/common/scene-impl.h +++ b/dali/internal/event/common/scene-impl.h @@ -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 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 diff --git a/dali/internal/event/events/wheel-event-processor.cpp b/dali/internal/event/events/wheel-event-processor.cpp index 5d73dc3..f7a082f 100644 --- a/dali/internal/event/events/wheel-event-processor.cpp +++ b/dali/internal/event/events/wheel-event-processor.cpp @@ -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); + } } } -- 2.7.4