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