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 Should not use this in a TouchData container as it is just a handle and the internal object can change.
56 class DALI_IMPORT_API TouchData : public BaseHandle
60 // Construction & Destruction
63 * @brief An uninitialized TouchData instance.
65 * Calling member functions with an uninitialized TouchData handle is not allowed.
71 * @brief Copy constructor
74 * @param[in] other The TouchData to copy from.
76 TouchData( const TouchData& other );
88 * @brief Assignment Operator
91 * @param[in] other The TouchData to copy from.
93 TouchData& operator=( const TouchData& other );
98 * @brief Returns the time (in ms) that the touch event occurred.
101 * @return The time (in ms) that the touch event occurred.
103 unsigned long GetTime() const;
106 * @brief Returns the total number of points in this TouchData.
109 * @return Total number of Points.
111 std::size_t GetPointCount() const;
114 * @brief Returns the ID of the device used for the Point specified.
116 * Each point has a unique device ID which specifies the device used for that
117 * point. This is returned by this method.
120 * @param[in] point The point required.
121 * @return The Device ID of this point.
122 * @note If point is greater than GetPointCount() then this method will return -1.
124 int32_t GetDeviceId( std::size_t point ) const;
127 * @brief Retrieves the State of the point specified.
130 * @param[in] point The point required.
131 * @return The state of the point specified.
132 * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED.
135 PointState::Type GetState( std::size_t point ) const;
138 * @brief Retrieve the actor that was underneath the point specified.
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 an empty handle.
145 Actor GetHitActor( std::size_t point ) const;
148 * @brief Retrieve the co-ordinates relative to the top-left of the hit-actor at the point specified.
151 * @param[in] point The point required.
152 * @return The co-ordinates relative to the top-left of the hit-actor of the point specified.
154 * @note The top-left of an actor is (0.0, 0.0, 0.5).
155 * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
156 * then you should use Actor::ScreenToLocal().
157 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
159 const Vector2& GetLocalPosition( std::size_t point ) const;
162 * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
165 * @param[in] point The point required.
166 * @return The co-ordinates relative to the top-left of the screen of the point specified.
167 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
169 const Vector2& GetScreenPosition( std::size_t point ) const;
172 * @brief Retrieve the radius of the press point.
174 * This is the average of both the horizontal and vertical radii of the press point.
177 * @param[in] point The point required.
178 * @return The radius of the press point.
179 * @note If point is greater than GetPointCount() then this method will return 0.0f.
181 float GetRadius( std::size_t point ) const;
184 * @brief Retrieve BOTH the horizontal and the vertical radii of the press point.
187 * @param[in] point The point required.
188 * @return The horizontal and vertical radii of the press point.
189 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
191 const Vector2& GetEllipseRadius( std::size_t point ) const;
194 * @brief Retrieve the touch pressure.
196 * The pressure range starts at 0.0f.
197 * Normal pressure is defined as 1.0f.
198 * A value between 0.0f and 1.0f means light pressure has been applied.
199 * A value greater than 1.0f means more pressure than normal has been applied.
202 * @param[in] point The point required.
203 * @return The touch pressure.
204 * @note If point is greater than GetPointCount() then this method will return 1.0f.
206 float GetPressure( std::size_t point ) const;
209 * @brief Retrieve the angle of the press point relative to the Y-Axis.
212 * @param[in] point The point required.
213 * @return The angle of the press point.
214 * @note If point is greater than GetPointCount() then this method will return Degree().
216 Degree GetAngle( std::size_t point ) const;
218 public: // Not intended for application developers
221 * @brief This constructor is used internally to Create an initialized TouchData handle.
224 * @param [in] touchData A pointer to a newly allocated Dali resource
226 explicit DALI_INTERNAL TouchData( Internal::TouchData* touchData );
234 #endif // __DALI_TOUCH_DATA_H__