Added hover event in Dali
[platform/core/uifw/dali-core.git] / dali / public-api / events / touch-point.h
1 #ifndef __DALI_TOUCH_POINT_H__
2 #define __DALI_TOUCH_POINT_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/actors/actor.h>
23 #include <dali/public-api/math/vector2.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 /**
29  * @brief A TouchPoint represents a point on the screen that is currently being touched
30  * or where touch has stopped.
31  */
32 struct TouchPoint
33 {
34   // Enumerations
35
36   /**
37    * @brief Touch state
38    */
39   enum State
40   {
41     Started,        /**< Touch or hover started */
42     Finished,       /**< Touch or hover finished */
43     Down = Started, /**< Screen touched */
44     Up = Finished,  /**< Touch stopped */
45     Motion,         /**< Finger dragged or hovered */
46     Leave,          /**< Leave the boundary of an actor */
47     Stationary,     /**< No change from last event.  Useful when a multi-point event occurs where
48                          all points are sent but indicates that this particular point has not changed
49                          since the last time */
50     Interrupted,    /**< A system event has occurred which has interrupted the touch or hover event sequence. */
51     Last            /**< Number of states. */
52   };
53
54   // Construction & Destruction
55
56   /**
57    * @brief Constructor
58    *
59    * @param[in]  id       The touch device ID.
60    * @param[in]  state    The state.
61    * @param[in]  screenX  The X co-ordinate relative to the screen's origin.
62    * @param[in]  screenY  The Y co-ordinate relative to the screen's origin.
63    */
64   TouchPoint(int id, State state, float screenX, float screenY);
65
66   /**
67    * @brief Constructor
68    *
69    * @param[in]  id       The touch device ID.
70    * @param[in]  state    The state.
71    * @param[in]  screenX  The X co-ordinate relative to the screen's origin.
72    * @param[in]  screenY  The Y co-ordinate relative to the screen's origin.
73    * @param[in]  localX   The X co-ordinate relative to the top-left (0.0, 0.0, 0.5) of the actor.
74    * @param[in]  localY   The Y co-ordinate relative to the top-left (0.0, 0.0, 0.5) of the actor.
75    */
76   TouchPoint(int id, State state, float screenX, float screenY, float localX, float localY);
77
78   /**
79    * @brief Destructor
80    */
81   ~TouchPoint();
82
83   // Data
84
85   /**
86    * @brief Each touch point has a unique device ID which specifies the touch device for that point.
87    */
88   int deviceId;
89
90   /**
91    * @brief State of the point.
92    *
93    * @see State
94    */
95   State state;
96
97   /**
98    * @brief The actor that was underneath the touch point.
99    */
100   Actor hitActor;
101
102   /**
103    * @brief The co-ordinates relative to the top-left of the hit-actor.
104    *
105    * @note The top-left of an actor is (0.0, 0.0, 0.5).
106    * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
107    * then you should use Actor::ScreenToLocal().
108    */
109   Vector2 local;
110
111   /**
112    * @brief The co-ordinates relative to the top-left of the screen.
113    */
114   Vector2 screen;
115 };
116
117 typedef std::vector<TouchPoint> TouchPointContainer; ///< Container of touch points.
118 typedef TouchPointContainer::iterator TouchPointContainerIterator; ///< Iterator for Dali::TouchPointContainer
119 typedef TouchPointContainer::const_iterator TouchPointContainerConstIterator; ///< Const iterator for Dali::TouchPointContainer
120
121 } // namespace Dali
122
123 #endif // __DALI_TOUCH_POINT_H__