Revert "[Tizen] Not execute the remove callback"
[platform/core/uifw/dali-core.git] / dali / internal / event / events / hover-event-impl.h
1 #ifndef DALI_INTERNAL_HOVER_EVENT_H
2 #define DALI_INTERNAL_HOVER_EVENT_H
3
4 /*
5  * Copyright (c) 2021 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 // INTERNAL INCLUDES
22 #include <dali/devel-api/events/touch-point.h>
23 #include <dali/integration-api/events/point.h>
24 #include <dali/public-api/common/vector-wrapper.h>
25 #include <dali/public-api/events/hover-event.h>
26 #include <dali/public-api/object/base-object.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 class HoverEvent;
33 using HoverEventPtr = IntrusivePtr<HoverEvent>;
34
35 /**
36  * @copydoc Dali::HoverEvent
37  */
38 class HoverEvent : public BaseObject
39 {
40 public:
41   // Construction & Destruction
42
43   /**
44    * @brief Default constructor
45    */
46   HoverEvent();
47
48   /**
49    * @brief Constructor
50    * @param[in]  time  The time the event occurred
51    */
52   HoverEvent(unsigned long time);
53
54   /**
55    * @brief Clones the HoverEvent object.
56    *
57    * Required because base class copy constructor is not implemented.
58    * @param[in] rhs The HoverEvent to clone from.
59    * @return A new HoverEvent object which is has the same hover event data.
60    */
61   static HoverEventPtr Clone(const HoverEvent& rhs);
62
63   // Getters
64
65   /**
66    * @copydoc Dali::HoverEvent::GetTime()
67    */
68   unsigned long GetTime() const;
69
70   /**
71    * @copydoc Dali::HoverEvent::GetPointCount()
72    */
73   std::size_t GetPointCount() const;
74
75   /**
76    * @copydoc Dali::HoverEvent::GetDeviceId()
77    */
78   int32_t GetDeviceId(std::size_t point) const;
79
80   /**
81    * @copydoc Dali::HoverEvent::GetGetState()
82    */
83   PointState::Type GetState(std::size_t point) const;
84
85   /**
86    * @copydoc Dali::HoverEvent::GetHitActor()
87    */
88   Dali::Actor GetHitActor(std::size_t point) const;
89
90   /**
91    * @copydoc Dali::HoverEvent::GetLocalPosition()
92    */
93   const Vector2& GetLocalPosition(std::size_t point) const;
94
95   /**
96    * @copydoc Dali::HoverEvent::GetScreenPosition()
97    */
98   const Vector2& GetScreenPosition(std::size_t point) const;
99
100   /**
101    * @brief Returns a const reference to a point at the index requested.
102    *
103    * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
104    *
105    * @param[in] point The index of the required Point.
106    * @return A const reference to the Point at the position requested
107    * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
108    */
109   const Integration::Point& GetPoint(std::size_t point) const;
110
111   /**
112    * @brief Returns a reference to a point at the index requested.
113    *
114    * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
115    *
116    * @param[in] point The index of the required Point.
117    * @return A reference to the Point at the position requested
118    * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
119    */
120   Integration::Point& GetPoint(std::size_t point);
121
122   // Setters
123
124   /**
125    * @brief Adds a point to this hover event.
126    * @param[in]  point  The point to add to the hover event.
127    */
128   void AddPoint(const Integration::Point& point);
129
130 private:
131   /**
132    * @brief Destructor
133    *
134    * A reference counted object may only be deleted by calling Unreference()
135    */
136   ~HoverEvent() override = default;
137
138   // Not copyable or movable
139
140   HoverEvent(const HoverEvent& rhs) = delete;            ///< Deleted copy constructor
141   HoverEvent(HoverEvent&& rhs)      = delete;            ///< Deleted move constructor
142   HoverEvent& operator=(const HoverEvent& rhs) = delete; ///< Deleted copy assignment operator
143   HoverEvent& operator=(HoverEvent&& rhs) = delete;      ///< Deleted move assignment operator
144
145 private:
146   std::vector<Integration::Point> mPoints; ///< Container of the points for this hover event
147   unsigned long                   mTime;   ///< The time (in ms) that the hover event occurred
148 };
149
150 } // namespace Internal
151
152 // Helpers for public-api forwarding methods
153
154 inline Internal::HoverEvent& GetImplementation(Dali::HoverEvent& hoverEvent)
155 {
156   DALI_ASSERT_ALWAYS(hoverEvent && "Hover Event handle is empty");
157
158   BaseObject& object = hoverEvent.GetBaseObject();
159
160   return static_cast<Internal::HoverEvent&>(object);
161 }
162
163 inline const Internal::HoverEvent& GetImplementation(const Dali::HoverEvent& hoverEvent)
164 {
165   DALI_ASSERT_ALWAYS(hoverEvent && "Hover Event handle is empty");
166
167   const BaseObject& object = hoverEvent.GetBaseObject();
168
169   return static_cast<const Internal::HoverEvent&>(object);
170 }
171
172 } // namespace Dali
173
174 #endif // DALI_INTERNAL_HOVER_EVENT_H