use modern construct 'override' in the derive class.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / tap-gesture / tap-gesture-processor.h
1 #ifndef DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_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 // INTERNAL INCLUDES
22 #include <dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h>
23 #include <dali/internal/event/events/gesture-processor.h>
24 #include <dali/internal/event/events/actor-observer.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class Scene;
33 class Stage;
34 class Actor;
35
36 struct GestureEvent;
37 struct TapGestureEvent;
38
39 /**
40  * Tap Gesture Event Processing:
41  *
42  * When we receive a tap gesture event, we do the following:
43  * - Find the actor that requires a tap where the tap occurred.
44  * - Emit the gesture if the tap gesture event satisfies the detector conditions.
45  */
46 class TapGestureProcessor : public GestureProcessor, public RecognizerObserver<TapGestureEvent>
47 {
48 public:
49
50   /**
51    * Create a tap gesture processor.
52    */
53   TapGestureProcessor();
54
55   /**
56    * Non-virtual destructor; TapGestureProcessor is not a base class
57    */
58   ~TapGestureProcessor() override;
59
60 public: // To be called by GestureEventProcessor
61
62   /**
63    * This method is called whenever a tap gesture event occurs.
64    * @param[in] scene The scene the tap gesture event occurs in.
65    * @param[in] tapEvent The event that has occurred.
66    */
67   void Process( Scene& scene, const TapGestureEvent& event) override;
68
69   /**
70    * Adds a gesture detector to this gesture processor.
71    * If this is the first gesture detector being added, then this method registers the required
72    * gesture with the adaptor.
73    * @param[in]  gestureDetector  The gesture detector being added.
74    */
75   void AddGestureDetector(TapGestureDetector* gestureDetector, Scene& scene);
76
77   /**
78    * Removes the specified gesture detector from this gesture processor.  If, after removing this
79    * gesture detector, there are no more gesture detectors registered, then this method unregisters
80    * the gesture from the adaptor.
81    * @param[in]  gestureDetector  The gesture detector being removed.
82    */
83   void RemoveGestureDetector(TapGestureDetector* gestureDetector);
84
85   /**
86    * This method updates the gesture detection parameters.
87    * @param[in]  gestureDetector  The gesture detector that has been updated.
88    */
89   void GestureDetectorUpdated(TapGestureDetector* gestureDetector);
90
91 private:
92
93   // Undefined
94   TapGestureProcessor(const TapGestureProcessor&);
95   TapGestureProcessor& operator=(const TapGestureProcessor& rhs);
96
97 private:
98
99   /**
100    * Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
101    * its detection policy.  If it does, it sends the appropriate gesture update request to adaptor.
102    */
103   void UpdateDetection();
104
105   // GestureProcessor overrides
106
107   /**
108    * @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
109    */
110   void OnGesturedActorStageDisconnection() override { /* Nothing to do */ }
111
112   /**
113    * @copydoc GestureProcessor::CheckGestureDetector()
114    */
115   bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
116
117   /**
118    * @copydoc GestureProcessor::EmitGestureSignal()
119    */
120   void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
121
122 private:
123
124   TapGestureDetectorContainer mTapGestureDetectors;
125
126   unsigned int mMinTapsRequired;
127   unsigned int mMaxTapsRequired;
128   unsigned int mMinTouchesRequired;
129   unsigned int mMaxTouchesRequired;
130
131   ActorObserver mCurrentTapActor; ///< Observer for the current gesture actor
132   const TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
133   bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
134 };
135
136 } // namespace Internal
137
138 } // namespace Dali
139
140 #endif // DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H