#define DALI_INTERNAL_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/ref-object.h>
-#include <dali/internal/event/events/gesture-event.h>
namespace Dali
{
-
namespace Integration
{
struct TouchEvent;
struct GestureRequest;
class Scene;
-template< typename T>
+template<typename T>
class RecognizerObserver
{
public:
- virtual void Process( Scene& scene, const T& event ) = 0;
+ virtual void Process(Scene& scene, const T& event) = 0;
- virtual ~RecognizerObserver(){};
+ virtual ~RecognizerObserver() = default;
+ ;
};
-
/**
* Abstract Base class for all adaptor gesture detectors.
*
class GestureRecognizer : public RefObject
{
public:
-
/**
* Called when it gets a touch event. The gesture recognizer should
* evaluate this event along with previously received events to determine
* Returns the type of gesture detector.
* @return Type of gesture detector.
*/
- Gesture::Type GetType() const { return mType; }
+ GestureType::Value GetType() const
+ {
+ return mType;
+ }
/**
* Called when we get a touch event.
* @param[in] scene The scene the touch event has occurred on
* @param[in] event The latest touch event
*/
- void SendEvent( Scene& scene, const Integration::TouchEvent& event )
+ void SendEvent(Scene& scene, const Integration::TouchEvent& event)
{
mScene = &scene;
- SendEvent( event );
+ if(event.GetPointCount() > 0)
+ {
+ const Integration::Point& point = event.points[0];
+ MouseButton::Type mouseButton = point.GetMouseButton();
+ if(mouseButton != MouseButton::INVALID)
+ {
+ Device::Class::Type type = point.GetDeviceClass();
+ if(type == Device::Class::Type::MOUSE)
+ {
+ mSourceType = GestureSourceType::MOUSE;
+ }
+ else if(type == Device::Class::Type::TOUCH)
+ {
+ mSourceType = GestureSourceType::TOUCH;
+ }
+ 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);
}
protected:
-
/**
* Protected Constructor. Should only be able to create derived class objects.
* @param[in] screenSize The size of the screen.
* @param[in] detectorType The type of gesture detector.
*/
- GestureRecognizer( Vector2 screenSize, Gesture::Type detectorType )
- : mScreenSize( screenSize ),
- mType( detectorType ),
- mScene( nullptr )
+ GestureRecognizer(Vector2 screenSize, GestureType::Value detectorType)
+ : mScreenSize(screenSize),
+ mType(detectorType),
+ mScene(nullptr),
+ mSourceType(GestureSourceType::INVALID),
+ mSourceData(GestureSourceData::INVALID)
{
}
* Use this constructor with the screen size is not used in the dereived class.
* @param[in] detectorType The type of gesture detector.
*/
- GestureRecognizer( Gesture::Type detectorType )
- : GestureRecognizer( Vector2::ZERO, detectorType )
+ GestureRecognizer(GestureType::Value detectorType)
+ : GestureRecognizer(Vector2::ZERO, detectorType)
{
}
/**
* Virtual destructor.
*/
- virtual ~GestureRecognizer() {}
+ ~GestureRecognizer() override = default;
protected:
- Vector2 mScreenSize;
- Gesture::Type mType;
- Scene* mScene;
+ Vector2 mScreenSize;
+ GestureType::Value mType;
+ Scene* mScene;
+ GestureSourceType mSourceType; /// < Gesture input source type.
+ GestureSourceData mSourceData; /// < Gesture input source data.
};
-typedef IntrusivePtr<GestureRecognizer> GestureRecognizerPtr;
+using GestureRecognizerPtr = IntrusivePtr<GestureRecognizer>;
} // namespace Internal