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.
92 * @return A reference to this
94 TouchData& operator=( const TouchData& other );
99 * @brief Returns the time (in ms) that the touch event occurred.
102 * @return The time (in ms) that the touch event occurred.
104 unsigned long GetTime() const;
107 * @brief Returns the total number of points in this TouchData.
110 * @return Total number of Points.
112 std::size_t GetPointCount() const;
115 * @brief Returns the ID of the device used for the Point specified.
117 * Each point has a unique device ID which specifies the device used for that
118 * point. This is returned by this method.
121 * @param[in] point The point required.
122 * @return The Device ID of this point.
123 * @note If point is greater than GetPointCount() then this method will return -1.
125 int32_t GetDeviceId( std::size_t point ) const;
128 * @brief Retrieves the State of the point specified.
131 * @param[in] point The point required.
132 * @return The state of the point specified.
133 * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED.
136 PointState::Type GetState( std::size_t point ) const;
139 * @brief Retrieve the actor that was underneath the point specified.
142 * @param[in] point The point required.
143 * @return The actor that was underneath the point specified.
144 * @note If point is greater than GetPointCount() then this method will return an empty handle.
146 Actor GetHitActor( std::size_t point ) const;
149 * @brief Retrieve the co-ordinates relative to the top-left of the hit-actor at the point specified.
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.
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.
160 const Vector2& GetLocalPosition( std::size_t point ) const;
163 * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
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.
170 const Vector2& GetScreenPosition( std::size_t point ) const;
173 * @brief Retrieve the radius of the press point.
175 * This is the average of both the horizontal and vertical radii of the press point.
178 * @param[in] point The point required.
179 * @return The radius of the press point.
180 * @note If point is greater than GetPointCount() then this method will return 0.0f.
182 float GetRadius( std::size_t point ) const;
185 * @brief Retrieve BOTH the horizontal and the vertical radii of the press point.
188 * @param[in] point The point required.
189 * @return The horizontal and vertical radii of the press point.
190 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
192 const Vector2& GetEllipseRadius( std::size_t point ) const;
195 * @brief Retrieve the touch pressure.
197 * The pressure range starts at 0.0f.
198 * Normal pressure is defined as 1.0f.
199 * A value between 0.0f and 1.0f means light pressure has been applied.
200 * A value greater than 1.0f means more pressure than normal has been applied.
203 * @param[in] point The point required.
204 * @return The touch pressure.
205 * @note If point is greater than GetPointCount() then this method will return 1.0f.
207 float GetPressure( std::size_t point ) const;
210 * @brief Retrieve the angle of the press point relative to the Y-Axis.
213 * @param[in] point The point required.
214 * @return The angle of the press point.
215 * @note If point is greater than GetPointCount() then this method will return Degree().
217 Degree GetAngle( std::size_t point ) const;
219 public: // Not intended for application developers
223 * @brief This constructor is used internally to Create an initialized TouchData handle.
226 * @param [in] touchData A pointer to a newly allocated Dali resource
228 explicit DALI_INTERNAL TouchData( Internal::TouchData* touchData );
237 #endif // __DALI_TOUCH_DATA_H__