/*
- * 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.
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;
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
/*
- * 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.
return GetImplementation(*this).WheelEventSignal();
}
+Scene::WheelEventGeneratedSignalType& Scene::WheelEventGeneratedSignal()
+{
+ return GetImplementation(*this).WheelEventGeneratedSignal();
+}
+
} // namespace Integration
} // namespace Dali
#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.
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> >;
*/
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.
/*
- * 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.
}
}
+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();
return mWheelEventSignal;
}
+Integration::Scene::WheelEventGeneratedSignalType& Scene::WheelEventGeneratedSignal()
+{
+ return mWheelEventGeneratedSignal;
+}
+
} // namespace Internal
} // namespace Dali
#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.
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);
*/
Integration::Scene::WheelEventSignalType& WheelEventSignal();
+ /**
+ * @copydoc Integration::Scene::WheelEventGeneratedSignal()
+ */
+ Integration::Scene::WheelEventGeneratedSignalType& WheelEventGeneratedSignal();
+
public:
/**
* From RenderTaskDefaults; retrieve the default root actor.
Integration::Scene::TouchEventSignalType mTouchedSignal;
// The wheel event signal
- Integration::Scene::WheelEventSignalType mWheelEventSignal;
+ Integration::Scene::WheelEventSignalType mWheelEventSignal;
+ Integration::Scene::WheelEventGeneratedSignalType mWheelEventGeneratedSignal;
};
} // namespace Internal
/*
- * 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.
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);
+ }
}
}