1 #ifndef DALI_HOVER_EVENT_H
2 #define DALI_HOVER_EVENT_H
5 * Copyright (c) 2020 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.
22 #include <cstdint> // uint32_t
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>
31 namespace Internal DALI_INTERNAL
37 * @addtogroup dali_core_events
45 * @brief Hover events are a collection of touch points at a specific moment in time.
47 * When a multi-touch event occurs, each touch point represents the points that are currently being
48 * hovered or the points where a hover has stopped.
51 class DALI_CORE_API HoverEvent : public BaseHandle
54 // Construction & Destruction
57 * @brief An uninitialized HoverEvent instance.
59 * Calling member functions with an uninitialized HoverEvent handle is not allowed.
65 * @brief Copy constructor.
68 * @param[in] rhs The HoverEvent to copy from
70 HoverEvent(const HoverEvent& rhs);
73 * @brief Move constructor.
76 * @param[in] rhs A reference to the moved HoverEvent
78 HoverEvent(HoverEvent&& rhs) noexcept;
89 * @brief Copy assignment operator.
92 * @param[in] rhs The HoverEvent to copy from
93 * @return A reference to this
95 HoverEvent& operator=(const HoverEvent& rhs);
98 * @brief Move assignment operator.
101 * @param[in] rhs A reference to the moved HoverEvent
102 * @return A reference to this
104 HoverEvent& operator=(HoverEvent&& rhs) noexcept;
109 * @brief Returns the time (in ms) that the hover event occurred.
112 * @return The time (in ms) that the hover event occurred
114 unsigned long GetTime() const;
117 * @brief Returns the total number of points in this hover event.
120 * @return Total number of Points
122 std::size_t GetPointCount() const;
125 * @brief Returns the ID of the device used for the Point specified.
127 * Each point has a unique device ID which specifies the device used for that
128 * point. This is returned by this method.
131 * @param[in] point The point required
132 * @return The Device ID of this point
133 * @note If point is greater than GetPointCount() then this method will return -1.
135 int32_t GetDeviceId(std::size_t point) const;
138 * @brief Retrieves the State of the point specified.
141 * @param[in] point The point required
142 * @return The state of the point specified
143 * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED.
146 PointState::Type GetState(std::size_t point) const;
149 * @brief Retrieves the actor that was underneath the point specified.
152 * @param[in] point The point required
153 * @return The actor that was underneath the point specified
154 * @note If point is greater than GetPointCount() then this method will return an empty handle.
156 Actor GetHitActor(std::size_t point) const;
159 * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified.
162 * @param[in] point The point required
163 * @return The co-ordinates relative to the top-left of the hit-actor of the point specified
165 * @note The top-left of an actor is (0.0, 0.0, 0.5).
166 * @note If you require the local coordinates of another actor (e.g the parent of the hit actor),
167 * then you should use Actor::ScreenToLocal().
168 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
170 const Vector2& GetLocalPosition(std::size_t point) const;
173 * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
176 * @param[in] point The point required
177 * @return The co-ordinates relative to the top-left of the screen of the point specified
178 * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO.
180 const Vector2& GetScreenPosition(std::size_t point) const;
182 public: // Not intended for application developers
185 * @brief This constructor is used internally to Create an initialized HoverEvent handle.
188 * @param[in] hoverEvent A pointer to a newly allocated Dali resource
190 explicit DALI_INTERNAL HoverEvent(Internal::HoverEvent* hoverEvent);
199 #endif // DALI_HOVER_EVENT_H