Revert "[Tizen] Restore Uploaded signal for BufferImage and ResourceImage"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pinch-gesture / pinch-gesture-recognizer.h
1 #ifndef DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H
2 #define DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/event/events/gesture-recognizer.h>
26 #include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
27
28 namespace Dali
29 {
30
31 namespace Integration
32 {
33 struct TouchEvent;
34 }
35
36 namespace Internal
37 {
38
39 /**
40  * When given a set of touch events, this detector attempts to determine if a pinch gesture has taken place.
41  */
42 class PinchGestureRecognizer : public GestureRecognizer
43 {
44 public:
45
46   using Observer = RecognizerObserver<PinchGestureEvent>;
47
48   /**
49    * Constructor
50    * @param[in] screenSize The size of the screen.
51    * @param[in] minimumPinchDistance in pixels
52    */
53   PinchGestureRecognizer(Observer& observer, Vector2 screenSize, float minimumPinchDistance);
54
55   /**
56    * Virtual destructor.
57    */
58   virtual ~PinchGestureRecognizer();
59
60 public:
61
62   void SetMinimumPinchDistance(float value);
63
64   /**
65    * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
66    */
67   virtual void SendEvent(const Integration::TouchEvent& event);
68
69   /**
70    * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
71    */
72   virtual void Update(const GestureRequest& request);
73
74 private:
75
76   /**
77    * Emits the pinch gesture event to the core.
78    * @param[in]  state         The state of the pinch (whether it's starting, continuing or finished).
79    * @param[in]  currentEvent  The latest touch event.
80    */
81   void SendPinch(Gesture::State state, const Integration::TouchEvent& currentEvent);
82
83 private:
84
85   // Reference to the gesture processor for this recognizer
86   Observer& mObserver;
87
88   /**
89    * Internal state machine.
90    */
91   enum State
92   {
93     Clear,    ///< No gesture detected.
94     Possible, ///< The current touch event data suggests that a gesture is possible.
95     Started,  ///< A gesture has been detected.
96   };
97
98   State mState; ///< The current state of the detector.
99   std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
100
101   float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
102
103   float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
104 };
105
106 } // namespace Internal
107
108 } // namespace Dali
109
110 #endif // DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H