1 #ifndef DALI_INTERNAL_TOUCH_EVENT_H
2 #define DALI_INTERNAL_TOUCH_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/point-state.h>
24 #include <dali/public-api/events/touch-event.h>
25 #include <dali/public-api/object/base-object.h>
26 #include <dali/integration-api/events/point.h>
38 typedef IntrusivePtr< TouchEvent > TouchEventPtr;
41 * @copydoc Dali::TouchEvent
43 class TouchEvent : public BaseObject
47 // Construction & Destruction
50 * @brief Default constructor
56 * @param[in] time The time the event occurred
58 TouchEvent( unsigned long time );
61 * @brief Clones the TouchEvent object.
63 * Required because base class copy constructor is not implemented.
64 * @param[in] other The TouchEvent to clone from.
65 * @return A new TouchEvent object which has the same touch point data.
67 static TouchEventPtr Clone( const TouchEvent& other );
77 * @copydoc Dali::TouchEvent::GetTime()
79 unsigned long GetTime() const;
82 * @copydoc Dali::TouchEvent::GetPointCount()
84 std::size_t GetPointCount() const;
87 * @copydoc Dali::TouchEvent::GetDeviceId()
89 int32_t GetDeviceId( std::size_t point ) const;
92 * @copydoc Dali::TouchEvent::GetGetState()
94 PointState::Type GetState( std::size_t point ) const;
97 * @copydoc Dali::TouchEvent::GetHitActor()
99 Dali::Actor GetHitActor( std::size_t point ) const;
102 * @copydoc Dali::TouchEvent::GetLocalPosition()
104 const Vector2& GetLocalPosition( std::size_t point ) const;
107 * @copydoc Dali::TouchEvent::GetScreenPosition()
109 const Vector2& GetScreenPosition( std::size_t point ) const;
112 * @copydoc Dali::TouchEvent::GetRadius()
114 float GetRadius( std::size_t point ) const;
117 * @copydoc Dali::TouchEvent::GetEllipseRadius()
119 const Vector2& GetEllipseRadius( std::size_t point ) const;
122 * @copydoc Dali::TouchEvent::GetPressure()
124 float GetPressure( std::size_t point ) const;
127 * @copydoc Dali::TouchEvent::GetAngle()
129 Degree GetAngle( std::size_t point ) const;
132 * @brief Returns a const reference to a point at the index requested.
134 * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
136 * @param[in] point The index of the required Point.
137 * @return A const reference to the Point at the position requested
138 * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
140 const Integration::Point& GetPoint( std::size_t point ) const;
143 * @brief Returns a reference to a point at the index requested.
145 * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
147 * @param[in] point The index of the required Point.
148 * @return A reference to the Point at the position requested
149 * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
151 Integration::Point& GetPoint( std::size_t point );
156 * @brief Adds a point to this touch event handler.
157 * @param[in] point The point to add to the touch event handler.
159 void AddPoint( const Integration::Point& point );
162 * @brief Get the device class the mouse/touch event originated from
164 * @return The device class
166 Device::Class::Type GetDeviceClass( std::size_t point ) const;
169 * @brief Get the device subclass the mouse/touch event originated from
171 * @return The device subclass
173 Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const;
176 * @brief Get mouse's button value (ex: right/left button)
178 * @return The value of mouse button
180 MouseButton::Type GetMouseButton( std::size_t point ) const;
185 /// Undefined Copy constructor
186 TouchEvent( const TouchEvent& other );
189 TouchEvent& operator=( const TouchEvent& other );
193 std::vector< Integration::Point > mPoints; ///< Container of the points for this touch event.
194 unsigned long mTime; ///< The time (in ms) that the touch event occurred.
197 } // namespace Internal
199 // Helpers for public-api forwarding methods
201 inline Internal::TouchEvent& GetImplementation( Dali::TouchEvent& touchEvent )
203 DALI_ASSERT_ALWAYS( touchEvent && "Touch Event handle is empty" );
205 BaseObject& object = touchEvent.GetBaseObject();
207 return static_cast< Internal::TouchEvent& >( object );
210 inline const Internal::TouchEvent& GetImplementation( const Dali::TouchEvent& touchEvent )
212 DALI_ASSERT_ALWAYS( touchEvent && "Touch Event handle is empty" );
214 const BaseObject& object = touchEvent.GetBaseObject();
216 return static_cast< const Internal::TouchEvent& >( object );
221 #endif // DALI_INTERNAL_TOUCH_EVENT_H