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