7b1cfd2072261399739b5a77fd520fea40a9041f
[platform/core/uifw/dali-core.git] / dali / public-api / events / touch-data.h
1 #ifndef __DALI_TOUCH_DATA_H__
2 #define __DALI_TOUCH_DATA_H__
3
4 /*
5  * Copyright (c) 2016 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 <stdint.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/events/point-state.h>
27 #include <dali/public-api/object/base-handle.h>
28
29 namespace Dali
30 {
31
32 namespace Internal DALI_INTERNAL
33 {
34 class TouchData;
35 }
36
37 /**
38  * @addtogroup dali_core_events
39  * @{
40  */
41
42 class Actor;
43 struct Vector2;
44
45 /**
46  * @brief Touch events are a collection of points at a specific moment in time.
47  *
48  * When a multi-touch event occurs, each point represents the points that are currently being
49  * touched or the points where a touch has stopped.
50  *
51  * The first point is the primary point that's used for hit-testing.
52  * @SINCE_1_1.37
53  * @note Should not use this in a TouchData container as it is just a handle and the internal object can change.
54  */
55 class DALI_IMPORT_API TouchData : public BaseHandle
56 {
57 public:
58
59   // Construction & Destruction
60
61   /**
62    * @brief An uninitialized TouchData instance.
63    *
64    * Calling member functions with an uninitialized TouchData handle is not allowed.
65    * @SINCE_1_1.37
66    */
67   TouchData();
68
69   /**
70    * @brief Copy constructor
71    *
72    * @SINCE_1_1.37
73    * @param[in]  other  The TouchEventHandle to copy from.
74    */
75   TouchData( const TouchData& other );
76
77   /**
78    * @brief Destructor
79    *
80    * @SINCE_1_1.37
81    */
82   ~TouchData();
83
84   // Operators
85
86   /**
87    * @brief Assignment Operator
88    *
89    * @SINCE_1_1.37
90    * @param[in]  other  The TouchEventHandle to copy from.
91    */
92   TouchData& operator=( const TouchData& other );
93
94   // Getters
95
96   /**
97    * @brief Returns the time (in ms) that the touch event occurred.
98    *
99    * @SINCE_1_1.37
100    * @return The time (in ms) that the touch event occurred.
101    */
102   unsigned long GetTime() const;
103
104   /**
105    * @brief Returns the total number of points in this TouchEventHandle.
106    *
107    * @SINCE_1_1.37
108    * @return Total number of Points.
109    */
110   size_t GetPointCount() const;
111
112   /**
113    * @brief Returns the ID of the device used for the Point specified.
114    *
115    * Each point has a unique device ID which specifies the device used for that
116    * point. This is returned by this method.
117    *
118    * @SINCE_1_1.37
119    * @param[in]  point  The point required.
120    * @return The Device ID of this point.
121    * @note If point is greater than GetPointCount() then this method will return -1.
122    */
123   int32_t GetDeviceId( size_t point ) const;
124
125   /**
126    * @brief Retrieves the State of the point specified.
127    *
128    * @SINCE_1_1.37
129    * @param[in]  point  The point required.
130    * @return The state of the point specified.
131    * @note If point is greater than GetPointCount() then this method will
132    * return PointState::FINISHED.
133    * @see State
134    */
135   PointState::Type GetState( size_t point ) const;
136
137   /**
138    * @brief Retrieve the actor that was underneath the point specified.
139    *
140    * @SINCE_1_1.37
141    * @param[in]  point  The point required.
142    * @return The actor that was underneath the point specified.
143    * @note If point is greater than GetPointCount() then this method will return
144    * an empty handle.
145    */
146   Actor GetHitActor( size_t point ) const;
147
148   /**
149    * @brief Retrieve the co-ordinates relative to the top-left of the hit-actor at the point specified.
150    *
151    * @SINCE_1_1.37
152    * @param[in]  point  The point required.
153    * @return The co-ordinates relative to the top-left of the hit-actor of the point specified.
154    *
155    * @note The top-left of an actor is (0.0, 0.0, 0.5).
156    * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
157    * then you should use Actor::ScreenToLocal().
158    * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
159    */
160   const Vector2& GetLocalPosition( size_t point ) const;
161
162   /**
163    * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
164    *
165    * @SINCE_1_1.37
166    * @param[in]  point  The point required.
167    * @return The co-ordinates relative to the top-left of the screen of the point specified.
168    * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
169    */
170   const Vector2& GetScreenPosition( size_t point ) const;
171
172 public: // Not intended for application developers
173
174   /**
175    * @brief This constructor is used internally to Create an initialized TouchData handle.
176    *
177    * @SINCE_1_1.37
178    * @param [in] touchData A pointer to a newly allocated Dali resource
179    */
180   explicit DALI_INTERNAL TouchData( Internal::TouchData* touchData );
181 };
182
183 /**
184  * @}
185  */
186 } // namespace Dali
187
188 #endif // __DALI_TOUCH_DATA_H__