[dali_1.0.1] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / public-api / events / gesture-detector.h
1 #ifndef __DALI_GESTURE_DETECTOR_H__
2 #define __DALI_GESTURE_DETECTOR_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 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/object/handle.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 namespace Internal DALI_INTERNAL
29 {
30 class GestureDetector;
31 }
32
33 class Actor;
34
35 /**
36  * @brief GestureDetectors analyse a stream of touch events and attempt to determine the intention of the user.
37  *
38  * An actor is attached to a gesture detector and if the detector recognises a pattern in its analysis, it will
39  * emit a detected signal to the application.
40  *
41  * This is the base class for different gesture detectors available and provides functionality that is common
42  * to all the gesture detectors.
43  *
44  * @see Gesture
45  */
46 class GestureDetector : public Handle
47 {
48 public: // Creation & Destruction
49
50   /**
51    * @brief Create an uninitialized GestureDetector; this can be initialized with one of the derived gestures' New() methods.
52    *
53    * Calling member functions with an uninitialized Dali::Object is not allowed.
54    */
55   GestureDetector();
56
57   /**
58    * @brief Downcast an Object handle to GestureDetector handle.
59    *
60    * If handle points to a GestureDetector object the
61    * downcast produces valid handle. If not the returned handle is left uninitialized.
62    * @param[in] handle to An object
63    * @return handle to a GestureDetector object or an uninitialized handle
64    */
65   static GestureDetector DownCast( BaseHandle handle );
66
67   /**
68    * @brief Dali::GestureDetector is intended as a base class
69    *
70    * This is non-virtual since derived Handle types must not contain data or virtual methods.
71    */
72   ~GestureDetector();
73
74   /**
75    * @copydoc Dali::BaseHandle::operator=
76    */
77   using BaseHandle::operator=;
78
79 public: // Actor related
80
81   /**
82    * @brief Attaches an actor to the gesture.
83    *
84    * The detected signal will be dispatched when the gesture occurs on
85    * the attached actor.
86    * @note You can attach several actors to a gesture detector.
87    * @param[in]  actor  The actor to attach to the gesture detector
88    * @pre The gesture detector has been initialized.
89    */
90   void Attach(Actor actor);
91
92   /**
93    * @brief Detaches the attached actor from the gesture detector.
94    *
95    * @param[in]  actor  The actor to detach from the gesture detector.
96    * @pre The gesture detector has been initialized.
97    * @pre The specified actor has been attached to the gesture detector.
98    */
99   void Detach(Actor actor);
100
101   /**
102    * @brief Detaches all the actors that have been attached to the gesture detector.
103    *
104    * @pre The gesture detector has been initialized.
105    * @pre At least one actor has been attached to the gesture detector.
106    */
107   void DetachAll();
108
109   /**
110    * @brief Returns a vector of actors attached to the gesture detector.
111    *
112    * @return The attached actor vector.
113    * @pre The gesture detector has been initialized.
114    */
115   std::vector<Actor> GetAttachedActors() const;
116
117 protected:
118
119   /**
120    * @brief This constructor is used by Dali New() methods of derived classes.
121    *
122    * @param [in]  internal  A pointer to a newly allocated Dali resource.
123    */
124   explicit DALI_INTERNAL GestureDetector(Internal::GestureDetector* internal);
125 };
126
127 } // namespace Dali
128
129 #endif // __DALI_GESTURE_DETECTOR_H__