This is similar to MouseButton in TouchEvent.
Now, you can see from which input the tap was made.
Change-Id: I80800ebd805e283581486d76d046b5e269cbb8ba
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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
}
};
+Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, int source, uint32_t time)
+{
+ Integration::TouchEvent touchEvent;
+ Integration::Point point;
+ point.SetState(state);
+ point.SetDeviceId(4);
+ point.SetScreenPosition(screenPosition);
+ point.SetDeviceClass(Device::Class::TOUCH);
+ point.SetDeviceSubclass(Device::Subclass::NONE);
+ point.SetMouseButton(static_cast<MouseButton::Type>(source));
+ touchEvent.points.push_back(point);
+ touchEvent.time = time;
+ return touchEvent;
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
END_TEST;
}
+
+int UtcDaliTapGestureGetSourceType(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(actor);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ SignalData data;
+ GestureReceivedFunctor functor(data);
+
+ TapGestureDetector detector = TapGestureDetector::New();
+ detector.Attach(actor);
+ 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.SendNotification();
+
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::PRIMARY, TEST_LOCATION);
+
+ data.Reset();
+
+ // Emit a down signal with MouseButton
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 3, 1300));
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 3, 1320));
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::SECONDARY, TEST_LOCATION);
+
+ data.Reset();
+
+ // Emit a down signal with MouseButton
+ application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 2, 1900));
+ application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 2, 1920));
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+ DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::TERTIARY, TEST_LOCATION);
+
+ END_TEST;
+}
\ No newline at end of file
TapGestureEvent::TapGestureEvent(GestureState state)
: GestureEvent(GestureType::TAP, state),
numberOfTaps(1),
- numberOfTouches(1)
+ numberOfTouches(1),
+ gestureSourceType(GestureSourceType::INVALID)
{
}
* 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
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};
+ Vector2 mScreenPoint;
+ Vector2 mLocalPoint;
+ uint32_t mNumberOfTaps{1u};
+ uint32_t mNumberOfTouches{1u};
+ GestureSourceType mGestureSourceType{GestureSourceType::INVALID};
};
} // namespace Internal
tap->SetNumberOfTouches(tapEvent.numberOfTouches);
tap->SetScreenPoint(tapEvent.point);
tap->SetLocalPoint(localPoint);
+ tap->SetGestureSourceType(tapEvent.gestureSourceType);
Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
mTapsRegistered(0),
mTouchPosition(),
mTouchTime(0u),
- mLastTapTime(0u)
+ mLastTapTime(0u),
+ mGestureSourceType(GestureSourceType::INVALID)
{
}
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:
mLastTapTime = 0u;
mTapsRegistered = 0;
mState = TOUCHED;
+
EmitPossibleState(event);
}
void TapGestureRecognizer::EmitPossibleState(const Integration::TouchEvent& event)
{
TapGestureEvent tapEvent(GestureState::POSSIBLE);
- tapEvent.point = mTouchPosition;
- tapEvent.time = event.time;
+ tapEvent.point = mTouchPosition;
+ tapEvent.time = event.time;
+ tapEvent.gestureSourceType = mGestureSourceType;
ProcessEvent(tapEvent);
}
void TapGestureRecognizer::EmitTap(uint32_t time, TapGestureEvent& event)
{
- event.numberOfTaps = mTapsRegistered;
- event.point = mTouchPosition;
- event.time = time;
+ event.numberOfTaps = mTapsRegistered;
+ event.point = mTouchPosition;
+ event.time = time;
+ event.gestureSourceType = mGestureSourceType;
ProcessEvent(event);
}
Vector2 mTouchPosition; ///< The initial touch down position.
uint32_t mTouchTime; ///< The initial touch down time.
uint32_t mLastTapTime; ///< Time last tap gesture was registered
+
+ GestureSourceType mGestureSourceType; /// < Gesture input source type value.
};
} // namespace Internal
#define DALI_GESTURE_ENUMERATIONS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
POSSIBLE ///< A gesture is possible. @SINCE_1_9.28
};
+/**
+ * @brief Enumeration for gesture input source type.
+ */
+enum class GestureSourceType : int8_t
+{
+ INVALID = -1, ///< invalid data
+ PRIMARY = 1, ///< Primary
+ SECONDARY = 3, ///< Secondary
+ TERTIARY = 2, ///< Third (tertiary)
+};
+
} // namespace Dali
#endif // DALI_GESTURE_ENUMERATIONS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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
/**