3cda040651ff3782952933d747f902945124fff6
[platform/core/uifw/dali-core.git] / dali / devel-api / events / touch-point.h
1 #ifndef DALI_TOUCH_POINT_H
2 #define DALI_TOUCH_POINT_H
3
4 /*
5  * Copyright (c) 2020 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/events/point-state.h>
28 #include <dali/public-api/math/vector2.h>
29
30 namespace Dali
31 {
32 /**
33  * @addtogroup dali_core_events
34  * @{
35  */
36
37 /**
38  * @brief A TouchPoint represents a point on the screen that is currently being touched
39  * or where touch has stopped.
40  * @SINCE_1_0.0
41  */
42 struct DALI_CORE_API TouchPoint
43 {
44   // Construction & Destruction
45
46   /**
47    * @brief Constructor.
48    *
49    * @SINCE_1_9.28
50    * @param[in] id      The touch device ID
51    * @param[in] state   The state
52    * @param[in] screenX The X co-ordinate relative to the screen's origin
53    * @param[in] screenY The Y co-ordinate relative to the screen's origin
54    */
55   TouchPoint(int32_t id, PointState::Type state, float screenX, float screenY);
56
57   /**
58    * @brief Constructor.
59    *
60    * @SINCE_1_9.28
61    * @param[in] id      The touch device ID
62    * @param[in] state   The state
63    * @param[in] screenX The X co-ordinate relative to the screen's origin
64    * @param[in] screenY The Y co-ordinate relative to the screen's origin
65    * @param[in] localX  The X co-ordinate relative to the top-left (0.0, 0.0, 0.5) of the actor
66    * @param[in] localY  The Y co-ordinate relative to the top-left (0.0, 0.0, 0.5) of the actor
67    */
68   TouchPoint(int32_t id, PointState::Type state, float screenX, float screenY, float localX, float localY);
69
70   /**
71    * @brief Destructor.
72    * @SINCE_1_0.0
73    */
74   ~TouchPoint();
75
76   // Data
77
78   /**
79    * @brief Each touch point has a unique device ID which specifies the touch device for that point.
80    */
81   int32_t deviceId;
82
83   /**
84    * @brief State of the point.
85    *
86    * @see Dali::PointState::Type
87    */
88   PointState::Type state;
89
90   /**
91    * @brief The actor that was underneath the touch point.
92    */
93   Actor hitActor;
94
95   /**
96    * @brief The co-ordinates relative to the top-left of the hit-actor.
97    *
98    * @note The top-left of an actor is (0.0, 0.0, 0.5).
99    * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
100    * then you should use Actor::ScreenToLocal().
101    */
102   Vector2 local;
103
104   /**
105    * @brief The co-ordinates relative to the top-left of the screen.
106    */
107   Vector2 screen;
108 };
109
110 typedef std::vector<TouchPoint> TouchPointContainer; ///< Container of touch points. @SINCE_1_0.0
111 typedef TouchPointContainer::iterator TouchPointContainerIterator; ///< Iterator for Dali::TouchPointContainer @SINCE_1_0.0
112 typedef TouchPointContainer::const_iterator TouchPointContainerConstIterator; ///< Const iterator for Dali::TouchPointContainer @SINCE_1_0.0
113
114 /**
115  * @}
116  */
117 } // namespace Dali
118
119 #endif // DALI_TOUCH_POINT_H