DALi Version 2.2.17
[platform/core/uifw/dali-core.git] / dali / public-api / events / hover-event.h
1 #ifndef DALI_HOVER_EVENT_H
2 #define DALI_HOVER_EVENT_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <cstdint> // uint32_t
23
24 // INTERNAL INCLUDES
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
29 namespace Dali
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 class HoverEvent;
34 }
35
36 /**
37  * @addtogroup dali_core_events
38  * @{
39  */
40
41 class Actor;
42 struct Vector2;
43
44 /**
45  * @brief Hover events are a collection of touch points at a specific moment in time.
46  *
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.
49  * @SINCE_1_0.0
50  */
51 class DALI_CORE_API HoverEvent : public BaseHandle
52 {
53 public:
54   // Construction & Destruction
55
56   /**
57    * @brief An uninitialized HoverEvent instance.
58    *
59    * Calling member functions with an uninitialized HoverEvent handle is not allowed.
60    * @SINCE_1_0.0
61    */
62   HoverEvent();
63
64   /**
65    * @brief Copy constructor.
66    *
67    * @SINCE_1_9.25
68    * @param[in] rhs The HoverEvent to copy from
69    */
70   HoverEvent(const HoverEvent& rhs);
71
72   /**
73    * @brief Move constructor.
74    *
75    * @SINCE_1_9.25
76    * @param[in] rhs A reference to the moved HoverEvent
77    */
78   HoverEvent(HoverEvent&& rhs);
79
80   /**
81    * @brief Destructor.
82    * @SINCE_1_0.0
83    */
84   ~HoverEvent();
85
86   // Operators
87
88   /**
89    * @brief Copy assignment operator.
90    *
91    * @SINCE_1_1.37
92    * @param[in] rhs The HoverEvent to copy from
93    * @return A reference to this
94    */
95   HoverEvent& operator=(const HoverEvent& rhs);
96
97   /**
98    * @brief Move assignment operator.
99    *
100    * @SINCE_1_9.25
101    * @param[in] rhs A reference to the moved HoverEvent
102    * @return A reference to this
103    */
104   HoverEvent& operator=(HoverEvent&& rhs);
105
106   // Getters
107
108   /**
109    * @brief Returns the time (in ms) that the hover event occurred.
110    *
111    * @SINCE_1_9.25
112    * @return The time (in ms) that the hover event occurred
113    */
114   unsigned long GetTime() const;
115
116   /**
117    * @brief Returns the total number of points in this hover event.
118    *
119    * @SINCE_1_9.25
120    * @return Total number of Points
121    */
122   std::size_t GetPointCount() const;
123
124   /**
125    * @brief Returns the ID of the device used for the Point specified.
126    *
127    * Each point has a unique device ID which specifies the device used for that
128    * point. This is returned by this method.
129    *
130    * @SINCE_1_9.25
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.
134    */
135   int32_t GetDeviceId(std::size_t point) const;
136
137   /**
138    * @brief Retrieves the State of the point specified.
139    *
140    * @SINCE_1_9.25
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.
144    * @see State
145    */
146   PointState::Type GetState(std::size_t point) const;
147
148   /**
149    * @brief Retrieves the actor that was underneath the point specified.
150    *
151    * @SINCE_1_9.25
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.
155    */
156   Actor GetHitActor(std::size_t point) const;
157
158   /**
159    * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified.
160    *
161    * @SINCE_1_9.25
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
164    *
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.
169    */
170   const Vector2& GetLocalPosition(std::size_t point) const;
171
172   /**
173    * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified.
174    *
175    * @SINCE_1_9.25
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.
179    */
180   const Vector2& GetScreenPosition(std::size_t point) const;
181
182 public: // Not intended for application developers
183   /// @cond internal
184   /**
185    * @brief This constructor is used internally to Create an initialized HoverEvent handle.
186    *
187    * @SINCE_1_9.25
188    * @param[in] hoverEvent A pointer to a newly allocated Dali resource
189    */
190   explicit DALI_INTERNAL HoverEvent(Internal::HoverEvent* hoverEvent);
191   /// @endcond
192 };
193
194 /**
195  * @}
196  */
197 } // namespace Dali
198
199 #endif // DALI_HOVER_EVENT_H