X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fgesture-recognizer.h;h=0bc013d2c88cd2e4f30098019364bb37c1234fb3;hb=40a0a894d0ba7ec4c875295252ef366a23e37688;hp=f76326dd43a1894ea68d3f5821f997d31872d00e;hpb=34745e42eed50817085b2e4868d301f8d43f9003;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/gesture-recognizer.h b/dali/internal/event/events/gesture-recognizer.h index f76326d..0bc013d 100644 --- a/dali/internal/event/events/gesture-recognizer.h +++ b/dali/internal/event/events/gesture-recognizer.h @@ -2,7 +2,7 @@ #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. @@ -19,15 +19,15 @@ */ // EXTERNAL INCLUDES +#include +#include #include #include #include #include -#include namespace Dali { - namespace Integration { struct TouchEvent; @@ -38,16 +38,16 @@ namespace Internal struct GestureRequest; class Scene; -template< typename T> +template 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. * @@ -56,7 +56,6 @@ public: 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 @@ -75,30 +74,74 @@ public: * Returns the type of gesture detector. * @return Type of gesture detector. */ - GestureType::Value 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, GestureType::Value 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) { } @@ -108,23 +151,25 @@ protected: * 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 ) + GestureRecognizer(GestureType::Value detectorType) + : GestureRecognizer(Vector2::ZERO, detectorType) { } /** * Virtual destructor. */ - virtual ~GestureRecognizer() {} + ~GestureRecognizer() override = default; protected: - Vector2 mScreenSize; + Vector2 mScreenSize; GestureType::Value mType; - Scene* mScene; + Scene* mScene; + GestureSourceType mSourceType; /// < Gesture input source type. + GestureSourceData mSourceData; /// < Gesture input source data. }; -typedef IntrusivePtr GestureRecognizerPtr; +using GestureRecognizerPtr = IntrusivePtr; } // namespace Internal