[dali_1.2.60] Merge branch 'devel/master'
[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) 2017 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/device.h>
27 #include <dali/public-api/events/point-state.h>
28 #include <dali/public-api/object/base-handle.h>
29 #include <dali/public-api/math/degree.h>
30
31 namespace Dali
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 class TouchData;
37 }
38
39 /**
40  * @addtogroup dali_core_events
41  * @{
42  */
43
44 class Actor;
45 struct Vector2;
46
47 /**
48  * @brief Touch events are a collection of points at a specific moment in time.
49  *
50  * When a multi-touch event occurs, each point represents the points that are currently being
51  * touched or the points where a touch has stopped.
52  *
53  * The first point is the primary point that's used for hit-testing.
54  * @SINCE_1_1.37
55  * @note As this is a handle to an internal object, it should not be copied (or used in a container) as all that will do is copy the handle to the same object.
56  * The internal object can change which may not be what an application writer expects.
57  * If data does need to be stored in the application, then only the required data should be saved (retrieved using the methods of this class).
58  *
59  * Should not use this in a TouchData container as it is just a handle and the internal object can change.
60  */
61 class DALI_IMPORT_API TouchData : public BaseHandle
62 {
63 public:
64
65   // Construction & Destruction
66
67   /**
68    * @brief An uninitialized TouchData instance.
69    *
70    * Calling member functions with an uninitialized TouchData handle is not allowed.
71    * @SINCE_1_1.37
72    */
73   TouchData();
74
75   /**
76    * @brief Copy constructor.
77    *
78    * @SINCE_1_1.37
79    * @param[in] other The TouchData to copy from
80    */
81   TouchData( const TouchData& other );
82
83   /**
84    * @brief Destructor.
85    *
86    * @SINCE_1_1.37
87    */
88   ~TouchData();
89
90   // Operators
91
92   /**
93    * @brief Assignment Operator.
94    *
95    * @SINCE_1_1.37
96    * @param[in] other The TouchData to copy from
97    * @return A reference to this
98    */
99   TouchData& operator=( const TouchData& other );
100
101   // Getters
102
103   /**
104    * @brief Returns the time (in ms) that the touch event occurred.
105    *
106    * @SINCE_1_1.37
107    * @return The time (in ms) that the touch event occurred
108    */
109   unsigned long GetTime() const;
110
111   /**
112    * @brief Returns the total number of points in this TouchData.
113    *
114    * @SINCE_1_1.37
115    * @return Total number of Points
116    */
117   std::size_t GetPointCount() const;
118
119   /**
120    * @brief Returns the ID of the device used for the Point specified.
121    *
122    * Each point has a unique device ID which specifies the device used for that
123    * point. This is returned by this method.
124    *
125    * @SINCE_1_1.37
126    * @param[in] point The point required
127    * @return The Device ID of this point
128    * @note If point is greater than GetPointCount() then this method will return -1.
129    */
130   int32_t GetDeviceId( std::size_t point ) const;
131
132   /**
133    * @brief Retrieves the State of the point specified.
134    *
135    * @SINCE_1_1.37
136    * @param[in] point The point required
137    * @return The state of the point specified
138    * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED.
139    * @see State
140    */
141   PointState::Type GetState( std::size_t point ) const;
142
143   /**
144    * @brief Retrieves the actor that was underneath the point specified.
145    *
146    * @SINCE_1_1.37
147    * @param[in] point The point required
148    * @return The actor that was underneath the point specified
149    * @note If point is greater than GetPointCount() then this method will return an empty handle.
150    */
151   Actor GetHitActor( std::size_t point ) const;
152
153   /**
154    * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified.
155    *
156    * @SINCE_1_1.37
157    * @param[in] point The point required
158    * @return The co-ordinates relative to the top-left of the hit-actor of the point specified
159    *
160    * @note The top-left of an actor is (0.0, 0.0, 0.5).
161    * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
162    * then you should use Actor::ScreenToLocal().
163    * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
164    */
165   const Vector2& GetLocalPosition( std::size_t point ) const;
166
167   /**
168    * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
169    *
170    * @SINCE_1_1.37
171    * @param[in] point The point required
172    * @return The co-ordinates relative to the top-left of the screen of the point specified
173    * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
174    */
175   const Vector2& GetScreenPosition( std::size_t point ) const;
176
177   /**
178    * @brief Retrieves the radius of the press point.
179    *
180    * This is the average of both the horizontal and vertical radii of the press point.
181    *
182    * @SINCE_1_1.39
183    * @param[in] point The point required
184    * @return The radius of the press point
185    * @note If point is greater than GetPointCount() then this method will return 0.0f.
186    */
187   float GetRadius( std::size_t point ) const;
188
189   /**
190    * @brief Retrieves BOTH the horizontal and the vertical radii of the press point.
191    *
192    * @SINCE_1_1.39
193    * @param[in] point The point required
194    * @return The horizontal and vertical radii of the press point
195    * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
196    */
197   const Vector2& GetEllipseRadius( std::size_t point ) const;
198
199   /**
200    * @brief Retrieves the touch pressure.
201    *
202    * The pressure range starts at 0.0f.
203    * Normal pressure is defined as 1.0f.
204    * A value between 0.0f and 1.0f means light pressure has been applied.
205    * A value greater than 1.0f means more pressure than normal has been applied.
206    *
207    * @SINCE_1_1.39
208    * @param[in] point The point required
209    * @return The touch pressure
210    * @note If point is greater than GetPointCount() then this method will return 1.0f.
211    */
212   float GetPressure( std::size_t point ) const;
213
214   /**
215    * @brief Retrieves the angle of the press point relative to the Y-Axis.
216    *
217    * @SINCE_1_1.39
218    * @param[in] point The point required
219    * @return The angle of the press point
220    * @note If point is greater than GetPointCount() then this method will return Degree().
221    */
222   Degree GetAngle( std::size_t point ) const;
223
224   /**
225    * @brief Get the device class type the mouse/touch event originated from.
226    *
227    * The device class type is classification type of the input device of event received.
228    * @SINCE_1_2.60
229    * @param[in] point The point required
230    * @return The type of the device class
231    */
232   Device::Class::Type GetDeviceClass( std::size_t point ) const;
233
234   /**
235    * @brief Get the device subclass type the mouse/touch event originated from.
236    *
237    * The device subclass type is subclassification type of the input device of event received.
238    * @SINCE_1_2.60
239    * @param[in] point The point required
240    * @return The type of the device subclass
241    */
242   Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const;
243
244 public: // Not intended for application developers
245
246   /// @cond internal
247   /**
248    * @brief This constructor is used internally to Create an initialized TouchData handle.
249    *
250    * @SINCE_1_1.37
251    * @param[in] touchData A pointer to a newly allocated Dali resource
252    */
253   explicit DALI_INTERNAL TouchData( Internal::TouchData* touchData );
254   /// @endcond
255 };
256
257 /**
258  * @}
259  */
260 } // namespace Dali
261
262 #endif // __DALI_TOUCH_DATA_H__