This is similar to MouseButton in TouchEvent.
Now, you can see from which input the gesture was made.
Change-Id: Id1289e1482b21e756ebd5a549b7d8e9d1b1e19b7
/*
- * 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.
END_TEST;
}
-
-int UtcDaliTapGestureSetGetSourceTypeP(void)
-{
- TapGesture gesture = DevelTapGesture::New(GestureState::STARTED);
- DALI_TEST_EQUALS(gesture.GetSourceType(), GestureSourceType::INVALID, TEST_LOCATION);
-
- GetImplementation(gesture).SetGestureSourceType(GestureSourceType::PRIMARY);
- DALI_TEST_EQUALS(gesture.GetSourceType(), GestureSourceType::PRIMARY, TEST_LOCATION);
-
- GetImplementation(gesture).SetGestureSourceType(GestureSourceType::SECONDARY);
- DALI_TEST_EQUALS(gesture.GetSourceType(), GestureSourceType::SECONDARY, TEST_LOCATION);
-
- GetImplementation(gesture).SetGestureSourceType(GestureSourceType::TERTIARY);
- DALI_TEST_EQUALS(gesture.GetSourceType(), GestureSourceType::TERTIARY, TEST_LOCATION);
-
- END_TEST;
-}
\ No newline at end of file
detector.DetectedSignal().Connect(&application, functor);
// Emit a down signal with MouseButton
- application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 0, 100));
- application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 0, 120));
- application.SendNotification();
-
- DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::INVALID, TEST_LOCATION);
-
- data.Reset();
-
- // Emit a down signal with MouseButton
- application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 1, 700));
- application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 1, 720));
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 1, 100));
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 1, 120));
application.SendNotification();
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::PRIMARY, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::MOUSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceData(), GestureSourceData::MOUSE_PRIMARY, TEST_LOCATION);
data.Reset();
application.SendNotification();
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::SECONDARY, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::MOUSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceData(), GestureSourceData::MOUSE_SECONDARY, TEST_LOCATION);
data.Reset();
application.SendNotification();
DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
- DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::TERTIARY, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::MOUSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceData(), GestureSourceData::MOUSE_TERTIARY, TEST_LOCATION);
END_TEST;
}
/*
- * 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.
GestureEvent::GestureEvent(GestureType::Value gesture, GestureState gestureState)
: gestureType(gesture),
state(gestureState),
- time(0)
+ time(0),
+ sourceType(GestureSourceType::INVALID),
+ sourceData(GestureSourceData::INVALID)
{
}
} // namespace Internal
#define DALI_INTERNAL_EVENT_GESTURE_EVENT_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.
*/
uint32_t time;
+ /**
+ * This is the value of which source the gesture was started with. (ex : mouse)
+ */
+ GestureSourceType sourceType;
+
+ /**
+ * The data of the source type.
+ */
+ GestureSourceData sourceData;
+
protected: // Constructors only to be used by derived structures.
/**
* This constructor is only used by derived classes.
#define DALI_INTERNAL_GESTURE_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.
return mTime;
}
+ /**
+ * @brief Sets the value of which source the gesture was started with. (ex : mouse)
+ * @param[in] source The gesture source type.
+ */
+ inline void SetSourceType(GestureSourceType source)
+ {
+ mSourceType = source;
+ }
+
+ /**
+ * @brief Gets the value of which source the gesture was started with.
+ * @return The gesture source type.
+ */
+ inline GestureSourceType GetSourceType() const
+ {
+ return mSourceType;
+ }
+
+ /**
+ * @brief Sets the value of source data.
+ * @param[in] data The gesture source data.
+ */
+ inline void SetSourceData(GestureSourceData data)
+ {
+ mSourceData = data;
+ }
+
+ /**
+ * @brief Gets the data of source type.
+ * @return The gesture source data.
+ */
+ inline GestureSourceData GetSourceData() const
+ {
+ return mSourceData;
+ }
+
Gesture(const Gesture&) = delete; ///< Deleted copy constructor
Gesture(Gesture&&) = delete; ///< Deleted move constructor
Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator
*/
Gesture(GestureType::Value gestureType, GestureState gestureState)
: mGestureType(gestureType),
- mState(gestureState)
+ mState(gestureState),
+ mSourceType(GestureSourceType::INVALID),
+ mSourceData(GestureSourceData::INVALID)
{
}
GestureType::Value mGestureType;
GestureState mState;
uint32_t mTime{0u};
+ GestureSourceType mSourceType;
+ GestureSourceData mSourceData;
};
} // namespace Internal
#define DALI_INTERNAL_GESTURE_RECOGNIZER_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.
*/
// EXTERNAL INCLUDES
+#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/internal/event/events/gesture-event.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/events/gesture.h>
void SendEvent(Scene& scene, const Integration::TouchEvent& event)
{
mScene = &scene;
+ if(event.GetPointCount() > 0)
+ {
+ const Integration::Point& point = event.points[0];
+ MouseButton::Type mouseButton = point.GetMouseButton();
+ if(mouseButton != MouseButton::INVALID)
+ {
+ mSourceType = GestureSourceType::MOUSE;
+ switch(mouseButton)
+ {
+ case MouseButton::PRIMARY:
+ {
+ mSourceData = GestureSourceData::MOUSE_PRIMARY;
+ break;
+ }
+ case MouseButton::SECONDARY:
+ {
+ mSourceData = GestureSourceData::MOUSE_SECONDARY;
+ break;
+ }
+ case MouseButton::TERTIARY:
+ {
+ mSourceData = GestureSourceData::MOUSE_TERTIARY;
+ break;
+ }
+ default:
+ {
+ mSourceData = GestureSourceData::INVALID;
+ break;
+ }
+ }
+ }
+ }
SendEvent(event);
}
GestureRecognizer(Vector2 screenSize, GestureType::Value detectorType)
: mScreenSize(screenSize),
mType(detectorType),
- mScene(nullptr)
+ mScene(nullptr),
+ mSourceType(GestureSourceType::INVALID),
+ mSourceData(GestureSourceData::INVALID)
{
}
Vector2 mScreenSize;
GestureType::Value mType;
Scene* mScene;
+ GestureSourceType mSourceType; /// < Gesture input source type.
+ GestureSourceData mSourceData; /// < Gesture input source data.
};
using GestureRecognizerPtr = IntrusivePtr<GestureRecognizer>;
/*
- * 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.
longPress->SetNumberOfTouches(longPressEvent.numberOfTouches);
longPress->SetScreenPoint(longPressEvent.point);
longPress->SetLocalPoint(localPoint);
+ longPress->SetSourceType(longPressEvent.sourceType);
+ longPress->SetSourceData(longPressEvent.sourceData);
Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
/*
- * 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.
{
longPress.time += mMinimumHoldingTime;
}
+ longPress.sourceType = mSourceType;
+ longPress.sourceData = mSourceData;
if(mScene)
{
pan->SetNumberOfTouches(panEvent.numberOfTouches);
pan->SetScreenPosition(panEvent.currentPosition);
pan->SetPosition(localCurrent);
+ pan->SetSourceType(panEvent.sourceType);
+ pan->SetSourceData(panEvent.sourceData);
RenderTask& renderTaskImpl(*renderTask.Get());
gesture.timeDelta = 0;
}
- gesture.time = currentEvent.time;
+ gesture.time = currentEvent.time;
+ gesture.sourceType = mSourceType;
+ gesture.sourceData = mSourceData;
if(mScene)
{
/*
- * 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.
pinch->SetScreenCenterPoint(pinchEvent.centerPoint);
pinch->SetLocalCenterPoint(localCenter);
+ pinch->SetSourceType(pinchEvent.sourceType);
+ pinch->SetSourceData(pinchEvent.sourceData);
Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
/*
- * 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.
gesture.state = GestureState::CANCELLED;
}
- gesture.time = currentEvent.time;
+ gesture.time = currentEvent.time;
+ gesture.sourceType = mSourceType;
+ gesture.sourceData = mSourceData;
if(mScene)
{
/*
- * 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.
rotation->SetRotation(rotationEvent.rotation);
rotation->SetScreenCenterPoint(rotationEvent.centerPoint);
rotation->SetLocalCenterPoint(localCenter);
+ rotation->SetSourceType(rotationEvent.sourceType);
+ rotation->SetSourceData(rotationEvent.sourceData);
Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
/*
- * 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.
gesture.state = GestureState::CANCELLED;
}
- gesture.time = currentEvent.time;
+ gesture.time = currentEvent.time;
+ gesture.sourceType = mSourceType;
+ gesture.sourceData = mSourceData;
if(mScene)
{
internalTap->SetNumberOfTouches(tap.GetNumberOfTouches());
internalTap->SetScreenPoint(tap.GetScreenPoint());
internalTap->SetLocalPoint(tap.GetLocalPoint());
- internalTap->SetGestureSourceType(tap.GetSourceType());
+ internalTap->SetSourceType(tap.GetSourceType());
+ internalTap->SetSourceData(tap.GetSourceData());
internalTap->SetNumberOfTaps(numberOfTaps == 0u ? mMaximumTapsRequired : numberOfTaps);
mTap = Dali::TapGesture(internalTap.Get());
if(numberOfTaps == 0u || mReceiveAllTapEvents)
/*
- * 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.
TapGestureEvent::TapGestureEvent(GestureState state)
: GestureEvent(GestureType::TAP, state),
numberOfTaps(1),
- numberOfTouches(1),
- gestureSourceType(GestureSourceType::INVALID)
+ numberOfTouches(1)
{
}
#define DALI_INTERNAL_EVENT_TAP_GESTURE_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.
* If a multi-touch tap, then this should be the centroid of all the touch points.
*/
Vector2 point;
-
- /**
- * This is the value of which input was tapped.
- */
- GestureSourceType gestureSourceType;
};
} // namespace Internal
#define DALI_INTERNAL_TAP_GESTURE_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.
return mLocalPoint;
}
- /**
- * @brief This is the value of which input was tapped.
- * @param[in] source This is the value of which input was tapped to set.
- */
- inline void SetGestureSourceType(const GestureSourceType sourceType)
- {
- mGestureSourceType = sourceType;
- }
-
- /**
- * @copydoc Dali::TapGesture::GetSourceType()
- */
- inline const GestureSourceType& GetSourceType() const
- {
- return mGestureSourceType;
- }
-
private:
/**
* @brief Virtual destructor
~TapGesture() override = default;
private:
- Vector2 mScreenPoint;
- Vector2 mLocalPoint;
- uint32_t mNumberOfTaps{1u};
- uint32_t mNumberOfTouches{1u};
- GestureSourceType mGestureSourceType{GestureSourceType::INVALID};
+ Vector2 mScreenPoint;
+ Vector2 mLocalPoint;
+ uint32_t mNumberOfTaps{1u};
+ uint32_t mNumberOfTouches{1u};
};
} // namespace Internal
tap->SetNumberOfTouches(tapEvent.numberOfTouches);
tap->SetScreenPoint(tapEvent.point);
tap->SetLocalPoint(localPoint);
- tap->SetGestureSourceType(tapEvent.gestureSourceType);
+ tap->SetSourceType(tapEvent.sourceType);
+ tap->SetSourceData(tapEvent.sourceData);
Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
mTouchTime(0u),
mLastTapTime(0u),
mLastTouchTime(0u),
- mGestureSourceType(GestureSourceType::INVALID),
mMaximumAllowedTime(maximumAllowedTime)
{
}
const Integration::Point& point = event.points[0];
PointState::Type pointState = point.GetState();
- MouseButton::Type mouseButton = point.GetMouseButton();
- switch(mouseButton)
- {
- case MouseButton::INVALID:
- {
- mGestureSourceType = GestureSourceType::INVALID;
- break;
- }
- case MouseButton::PRIMARY:
- {
- mGestureSourceType = GestureSourceType::PRIMARY;
- break;
- }
- case MouseButton::SECONDARY:
- {
- mGestureSourceType = GestureSourceType::SECONDARY;
- break;
- }
- case MouseButton::TERTIARY:
- {
- mGestureSourceType = GestureSourceType::TERTIARY;
- break;
- }
- default:
- {
- mGestureSourceType = GestureSourceType::INVALID;
- break;
- }
- }
-
switch(mState)
{
case CLEAR:
void TapGestureRecognizer::EmitPossibleState(const Integration::TouchEvent& event)
{
TapGestureEvent tapEvent(GestureState::POSSIBLE);
- tapEvent.point = mTouchPosition;
- tapEvent.time = event.time;
- tapEvent.gestureSourceType = mGestureSourceType;
+ tapEvent.point = mTouchPosition;
+ tapEvent.time = event.time;
ProcessEvent(tapEvent);
}
void TapGestureRecognizer::EmitTap(uint32_t time, TapGestureEvent& event)
{
- event.numberOfTaps = mTapsRegistered;
- event.point = mTouchPosition;
- event.time = time;
- event.gestureSourceType = mGestureSourceType;
+ event.numberOfTaps = mTapsRegistered;
+ event.point = mTouchPosition;
+ event.time = time;
ProcessEvent(event);
}
void TapGestureRecognizer::ProcessEvent(TapGestureEvent& event)
{
+ event.sourceType = mSourceType;
+ event.sourceData = mSourceData;
if(mScene)
{
// Create another handle so the recognizer cannot be destroyed during process function
uint32_t mLastTapTime; ///< Time last tap gesture was registered
uint32_t mLastTouchTime; ///< The last touch down time.
- GestureSourceType mGestureSourceType; /// < Gesture input source type value.
- uint32_t mMaximumAllowedTime; ///< The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
+ uint32_t mMaximumAllowedTime; ///< The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
};
} // namespace Internal
#define DALI_GESTURE_ENUMERATIONS_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.
/**
* @brief Enumeration for gesture input source type.
+ * @SINCE_2_2.0
*/
enum class GestureSourceType : int8_t
{
- INVALID = -1, ///< invalid data
- PRIMARY = 1, ///< Primary
- SECONDARY = 3, ///< Secondary
- TERTIARY = 2, ///< Third (tertiary)
+ INVALID, ///< invalid data
+ MOUSE, ///< mouse
+};
+
+/**
+ * @brief Enumeration for data of gesture input source type.
+ * @SINCE_2_2.0
+ */
+enum class GestureSourceData : int8_t
+{
+ INVALID = -1, ///< invalid data
+ MOUSE_PRIMARY = 1, /**< Primary(Left) mouse button */
+ MOUSE_SECONDARY = 3, /**< Secondary(Right) mouse button */
+ MOUSE_TERTIARY = 2, /**< Center(Wheel) mouse button */
};
} // namespace Dali
/*
- * Copyright (c) 2020 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).GetTime();
}
+GestureSourceType Gesture::GetSourceType() const
+{
+ return GetImplementation(*this).GetSourceType();
+}
+
+GestureSourceData Gesture::GetSourceData() const
+{
+ return GetImplementation(*this).GetSourceData();
+}
+
} // namespace Dali
#define DALI_GESTURE_H
/*
- * Copyright (c) 2020 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.
*/
uint32_t GetTime() const;
+ /**
+ * @brief Gets the value of which source the gesture was started with. (ex : mouse)
+ * @SINCE_2_2.0
+ * @return The gesture input source.
+ */
+ GestureSourceType GetSourceType() const;
+
+ /**
+ * @brief Gets the data of the source type.
+ * @SINCE_2_2.0
+ * @return The gesture source data.
+ */
+ GestureSourceData GetSourceData() const;
+
public: // Not intended for application developers
/// @cond 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.
return GetImplementation(*this).GetLocalPoint();
}
-const GestureSourceType& TapGesture::GetSourceType() const
-{
- return GetImplementation(*this).GetSourceType();
-}
-
} // namespace Dali
#define DALI_TAP_GESTURE_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.
*/
const Vector2& GetLocalPoint() const;
- /**
- * @brief This is the input type of which was tapped.
- * @return The input type which was tapped.
- */
- const GestureSourceType& GetSourceType() const;
-
public: // Not intended for application developers
/// @cond internal
/**