1 #ifndef DALI_INTERNAL_HOVER_EVENT_H
2 #define DALI_INTERNAL_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 <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/events/hover-event.h>
24 #include <dali/devel-api/events/touch-point.h>
25 #include <dali/public-api/object/base-object.h>
26 #include <dali/integration-api/events/point.h>
35 using HoverEventPtr = IntrusivePtr<HoverEvent>;
38 * @copydoc Dali::HoverEvent
40 class HoverEvent : public BaseObject
44 // Construction & Destruction
47 * @brief Default constructor
53 * @param[in] time The time the event occurred
55 HoverEvent( unsigned long time );
58 * @brief Clones the HoverEvent object.
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.
64 static HoverEventPtr Clone( const HoverEvent& rhs );
69 * @copydoc Dali::HoverEvent::GetTime()
71 unsigned long GetTime() const;
74 * @copydoc Dali::HoverEvent::GetPointCount()
76 std::size_t GetPointCount() const;
79 * @copydoc Dali::HoverEvent::GetDeviceId()
81 int32_t GetDeviceId( std::size_t point ) const;
84 * @copydoc Dali::HoverEvent::GetGetState()
86 PointState::Type GetState( std::size_t point ) const;
89 * @copydoc Dali::HoverEvent::GetHitActor()
91 Dali::Actor GetHitActor( std::size_t point ) const;
94 * @copydoc Dali::HoverEvent::GetLocalPosition()
96 const Vector2& GetLocalPosition( std::size_t point ) const;
99 * @copydoc Dali::HoverEvent::GetScreenPosition()
101 const Vector2& GetScreenPosition( std::size_t point ) const;
104 * @brief Returns a const reference to a point at the index requested.
106 * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
108 * @param[in] point The index of the required Point.
109 * @return A const reference to the Point at the position requested
110 * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
112 const Integration::Point& GetPoint( std::size_t point ) const;
115 * @brief Returns a reference to a point at the index requested.
117 * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
119 * @param[in] point The index of the required Point.
120 * @return A reference to the Point at the position requested
121 * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
123 Integration::Point& GetPoint( std::size_t point );
128 * @brief Adds a point to this hover event.
129 * @param[in] point The point to add to the hover event.
131 void AddPoint( const Integration::Point& point );
138 * A reference counted object may only be deleted by calling Unreference()
140 ~HoverEvent() override = default;
142 // Not copyable or movable
144 HoverEvent( const HoverEvent& rhs ) = delete; ///< Deleted copy constructor
145 HoverEvent( HoverEvent&& rhs ) = delete; ///< Deleted move constructor
146 HoverEvent& operator=( const HoverEvent& rhs ) = delete; ///< Deleted copy assignment operator
147 HoverEvent& operator=( HoverEvent&& rhs ) = delete; ///< Deleted move assignment operator
151 std::vector< Integration::Point > mPoints; ///< Container of the points for this hover event
152 unsigned long mTime; ///< The time (in ms) that the hover event occurred
155 } // namespace Internal
157 // Helpers for public-api forwarding methods
159 inline Internal::HoverEvent& GetImplementation( Dali::HoverEvent& hoverEvent )
161 DALI_ASSERT_ALWAYS( hoverEvent && "Hover Event handle is empty" );
163 BaseObject& object = hoverEvent.GetBaseObject();
165 return static_cast< Internal::HoverEvent& >( object );
168 inline const Internal::HoverEvent& GetImplementation( const Dali::HoverEvent& hoverEvent )
170 DALI_ASSERT_ALWAYS( hoverEvent && "Hover Event handle is empty" );
172 const BaseObject& object = hoverEvent.GetBaseObject();
174 return static_cast< const Internal::HoverEvent& >( object );
179 #endif // DALI_INTERNAL_HOVER_EVENT_H