1 #ifndef __DALI_TOUCH_DATA_H__
2 #define __DALI_TOUCH_DATA_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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 #include <dali/public-api/math/degree.h>
33 namespace Internal DALI_INTERNAL
39 * @addtogroup dali_core_events
47 * @brief Touch events are a collection of points at a specific moment in time.
49 * When a multi-touch event occurs, each point represents the points that are currently being
50 * touched or the points where a touch has stopped.
52 * The first point is the primary point that's used for hit-testing.
54 * @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.
55 * The internal object can change which may not be what an application writer expects.
56 * 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 * Should not use this in a TouchData container as it is just a handle and the internal object can change.
60 class DALI_IMPORT_API TouchData : public BaseHandle
64 // Construction & Destruction
67 * @brief An uninitialized TouchData instance.
69 * Calling member functions with an uninitialized TouchData handle is not allowed.
75 * @brief Copy constructor.
78 * @param[in] other The TouchData to copy from
80 TouchData( const TouchData& other );
92 * @brief Assignment Operator.
95 * @param[in] other The TouchData to copy from
96 * @return A reference to this
98 TouchData& operator=( const TouchData& other );
103 * @brief Returns the time (in ms) that the touch event occurred.
106 * @return The time (in ms) that the touch event occurred
108 unsigned long GetTime() const;
111 * @brief Returns the total number of points in this TouchData.
114 * @return Total number of Points
116 std::size_t GetPointCount() const;
119 * @brief Returns the ID of the device used for the Point specified.
121 * Each point has a unique device ID which specifies the device used for that
122 * point. This is returned by this method.
125 * @param[in] point The point required
126 * @return The Device ID of this point
127 * @note If point is greater than GetPointCount() then this method will return -1.
129 int32_t GetDeviceId( std::size_t point ) const;
132 * @brief Retrieves the State of the point specified.
135 * @param[in] point The point required
136 * @return The state of the point specified
137 * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED.
140 PointState::Type GetState( std::size_t point ) const;
143 * @brief Retrieves the actor that was underneath the point specified.
146 * @param[in] point The point required
147 * @return The actor that was underneath the point specified
148 * @note If point is greater than GetPointCount() then this method will return an empty handle.
150 Actor GetHitActor( std::size_t point ) const;
153 * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified.
156 * @param[in] point The point required
157 * @return The co-ordinates relative to the top-left of the hit-actor of the point specified
159 * @note The top-left of an actor is (0.0, 0.0, 0.5).
160 * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
161 * then you should use Actor::ScreenToLocal().
162 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
164 const Vector2& GetLocalPosition( std::size_t point ) const;
167 * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
170 * @param[in] point The point required
171 * @return The co-ordinates relative to the top-left of the screen of the point specified
172 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
174 const Vector2& GetScreenPosition( std::size_t point ) const;
177 * @brief Retrieves the radius of the press point.
179 * This is the average of both the horizontal and vertical radii of the press point.
182 * @param[in] point The point required
183 * @return The radius of the press point
184 * @note If point is greater than GetPointCount() then this method will return 0.0f.
186 float GetRadius( std::size_t point ) const;
189 * @brief Retrieves BOTH the horizontal and the vertical radii of the press point.
192 * @param[in] point The point required
193 * @return The horizontal and vertical radii of the press point
194 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
196 const Vector2& GetEllipseRadius( std::size_t point ) const;
199 * @brief Retrieves the touch pressure.
201 * The pressure range starts at 0.0f.
202 * Normal pressure is defined as 1.0f.
203 * A value between 0.0f and 1.0f means light pressure has been applied.
204 * A value greater than 1.0f means more pressure than normal has been applied.
207 * @param[in] point The point required
208 * @return The touch pressure
209 * @note If point is greater than GetPointCount() then this method will return 1.0f.
211 float GetPressure( std::size_t point ) const;
214 * @brief Retrieves the angle of the press point relative to the Y-Axis.
217 * @param[in] point The point required
218 * @return The angle of the press point
219 * @note If point is greater than GetPointCount() then this method will return Degree().
221 Degree GetAngle( std::size_t point ) const;
223 public: // Not intended for application developers
227 * @brief This constructor is used internally to Create an initialized TouchData handle.
230 * @param[in] touchData A pointer to a newly allocated Dali resource
232 explicit DALI_INTERNAL TouchData( Internal::TouchData* touchData );
241 #endif // __DALI_TOUCH_DATA_H__