Adaptor refactor
[platform/core/uifw/dali-adaptor.git] / dali / internal / input / common / gesture-manager.h
1 #ifndef __DALI_INTERNAL_GESTURE_MANAGER_H__
2 #define __DALI_INTERNAL_GESTURE_MANAGER_H__
3
4 /*
5  * Copyright (c) 2014 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 #include <dali/public-api/math/vector2.h>
24 #include <dali/integration-api/gesture-manager.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/internal/input/common/gesture-detector.h>
28
29 namespace Dali
30 {
31
32 namespace Integration
33 {
34 struct TouchEvent;
35 }
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42
43 class CallbackManager;
44 class CoreEventInterface;
45 class EnvironmentOptions;
46
47 /**
48  * Implementation of the Integration::GestureManager.
49  *
50  * Contains a list of adaptor gesture detectors. It passes touch events to each required detector which
51  * in turn process them to determine if their corresponding gesture has occurred.
52  */
53 class GestureManager : public Integration::GestureManager
54 {
55 public:
56
57   /**
58    * Constructor.
59    * @param[in] coreEventInterface Used to send events to Core.
60    * @param[in] screenSize The size of the screen.
61    * @param[in] callbackManager used to install callbacks
62    * @param[in] environmentOptions Environment Options
63    */
64   GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize, CallbackManager* callbackManager, EnvironmentOptions& environmentOptions);
65
66   /**
67    * The destructor
68    */
69   virtual ~GestureManager();
70
71 public:
72
73   /**
74    * Used by the event handler to send touch events to the Gesture Manager.
75    * @param[in]  event  The latest touch event.
76    */
77   void SendEvent(const Integration::TouchEvent& event);
78
79   /**
80    * Used by the event handler to stop the GestureManager detection.
81    */
82   void Stop();
83
84   /**
85    * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
86    * trigger a pinch gesture
87    *
88    * @param[in] distance The minimum pinch distance in pixels
89    */
90   void SetMinimumPinchDistance(float distance);
91
92 public: // GestureManager overrides
93
94   /**
95    * copydoc Dali::Integration::GestureManager::Register(const Integration::GestureRequest&)
96    */
97   virtual void Register(const Integration::GestureRequest& request);
98
99   /**
100    * copydoc Dali::Integration::GestureManager::Unregister(const Integration::GestureRequest&)
101    */
102   virtual void Unregister(const Integration::GestureRequest& request);
103
104   /**
105    * copydoc Dali::Integration::GestureManager::Unregister(const Integration::GestureRequest&)
106    */
107   virtual void Update(const Integration::GestureRequest& request);
108
109 private:
110
111   /**
112    * Used to delete the gesture detector of the given type.
113    */
114   void DeleteGestureDetector( Gesture::Type type );
115
116 private:
117
118   typedef std::vector<GestureDetectorPtr> GestureDetectorContainer;
119
120   CoreEventInterface& mCoreEventInterface;
121   GestureDetectorContainer mGestureDetectors;
122   Vector2 mScreenSize;
123   CallbackManager* mCallbackManager;
124   EnvironmentOptions& mEnvironmentOptions;
125   float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable. (-1.0f means pinch detector uses default value)
126   bool mRunning; ///< States whether the GestureManager is running or not.
127 };
128
129 } // namespace Adaptor
130
131 } // namespace Internal
132
133 } // namespace Dali
134
135 #endif // __DALI_INTERNAL_GESTURE_MANAGER_H__