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>
32 namespace Internal DALI_INTERNAL
38 * @addtogroup dali_core_events
46 * @brief Touch events are a collection of points at a specific moment in time.
48 * When a multi-touch event occurs, each point represents the points that are currently being
49 * touched or the points where a touch has stopped.
51 * The first point is the primary point that's used for hit-testing.
53 * @note Should not use this in a TouchData container as it is just a handle and the internal object can change.
55 class DALI_IMPORT_API TouchData : public BaseHandle
59 // Construction & Destruction
62 * @brief An uninitialized TouchData instance.
64 * Calling member functions with an uninitialized TouchData handle is not allowed.
70 * @brief Copy constructor
73 * @param[in] other The TouchEventHandle to copy from.
75 TouchData( const TouchData& other );
87 * @brief Assignment Operator
90 * @param[in] other The TouchEventHandle to copy from.
92 TouchData& operator=( const TouchData& other );
97 * @brief Returns the time (in ms) that the touch event occurred.
100 * @return The time (in ms) that the touch event occurred.
102 unsigned long GetTime() const;
105 * @brief Returns the total number of points in this TouchEventHandle.
108 * @return Total number of Points.
110 size_t GetPointCount() const;
113 * @brief Returns the ID of the device used for the Point specified.
115 * Each point has a unique device ID which specifies the device used for that
116 * point. This is returned by this method.
119 * @param[in] point The point required.
120 * @return The Device ID of this point.
121 * @note If point is greater than GetPointCount() then this method will return -1.
123 int32_t GetDeviceId( size_t point ) const;
126 * @brief Retrieves the State of the point specified.
129 * @param[in] point The point required.
130 * @return The state of the point specified.
131 * @note If point is greater than GetPointCount() then this method will
132 * return PointState::FINISHED.
135 PointState::Type GetState( 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
146 Actor GetHitActor( 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( 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( size_t point ) const;
172 public: // Not intended for application developers
175 * @brief This constructor is used internally to Create an initialized TouchData handle.
178 * @param [in] touchData A pointer to a newly allocated Dali resource
180 explicit DALI_INTERNAL TouchData( Internal::TouchData* touchData );
188 #endif // __DALI_TOUCH_DATA_H__