#define DALI_INTERNAL_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2019 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>
#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;
namespace Internal
{
-class GestureRequest;
+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.
*
* 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)
{
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);
}
protected:
-
/**
- * Protected Constructor. Should only be able to create derived class objects.
+ * 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 )
+ GestureRecognizer(Vector2 screenSize, GestureType::Value detectorType)
: mScreenSize(screenSize),
mType(detectorType),
- mScene(nullptr)
+ mScene(nullptr),
+ mSourceType(GestureSourceType::INVALID),
+ mSourceData(GestureSourceData::INVALID)
+ {
+ }
+
+ /**
+ * Protected Constructor. Should only be able to create derived class objects.
+ *
+ * Use this constructor with the screen size is not used in the dereived class.
+ * @param[in] detectorType The type of gesture detector.
+ */
+ 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