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