Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / events / actor-gesture-data.h
1 #ifndef DALI_INTERNAL_ACTOR_GESTURE_DATA_H
2 #define DALI_INTERNAL_ACTOR_GESTURE_DATA_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/devel-api/events/gesture-devel.h>
23 #include <dali/internal/event/events/gesture-detector-impl.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 /**
32  * Holds gesture specific data for an Actor
33  */
34 class ActorGestureData
35 {
36 public:
37
38   /**
39    * Constructor
40    */
41   ActorGestureData();
42
43   /**
44    * Non-virtual Destructor
45    */
46   ~ActorGestureData();
47
48   /**
49    * Adds a gesture detector to the data so that the owning actor is aware that it requires this
50    * type of gesture.
51    * @param[in] detector The detector being added.
52    * @note A raw pointer to the detector is stored, so the detector MUST remove itself when it is
53    * destroyed using RemoveGestureDetector()
54    */
55   void AddGestureDetector( GestureDetector& detector );
56
57   /**
58    * Removes a previously added gesture detector from the data. If no more gesture detectors of
59    * this type are registered then the actor owning this data will no longer be hit-tested for that
60    * gesture.
61    * @param[in] detector The detector to remove.
62    */
63   void RemoveGestureDetector( GestureDetector& detector );
64
65   /**
66    * Queries whether the actor requires the gesture type.
67    * @param[in] type The gesture type.
68    * @return true if the gesture is required, false otherwise.
69    */
70   inline bool IsGestureRequred( DevelGesture::Type type ) const
71   {
72     return type & gesturesRequired;
73   }
74
75   /**
76    * Retrieve a reference to the detectors for the given type.
77    * @param[in] type The container type required
78    * @pre Ensure IsGestureRequired() is used to check if the container is actually available.
79    */
80   GestureDetectorContainer& GetGestureDetectorContainer( DevelGesture::Type type );
81
82 private:
83
84   /**
85    * Helper to retrieve the appropriate container type.
86    * @param[in] type The container type required.
87    */
88   inline GestureDetectorContainer*& GetContainerPtr( DevelGesture::Type type );
89
90 private:
91
92   DevelGesture::Type gesturesRequired; ///< Stores which gestures are required
93
94   GestureDetectorContainer* panDetectors;       ///< Pointer to a container of pan-detectors
95   GestureDetectorContainer* pinchDetectors;     ///< Pointer to a container of pinch-detectors
96   GestureDetectorContainer* longPressDetectors; ///< Pointer to a container of long-press-detectors
97   GestureDetectorContainer* tapDetectors;       ///< Pointer to a container of tap-detectors
98   GestureDetectorContainer* rotationDetectors;  ///< Pointer to a container of tap-detectors
99 };
100
101 } // namespace Internal
102
103 } // namespace Dali
104
105 #endif // DALI_INTERNAL_ACTOR_GESTURE_DATA_H
106