1 #ifndef DALI_INTERNAL_TOUCH_EVENT_H
2 #define DALI_INTERNAL_TOUCH_EVENT_H
5 * Copyright (c) 2021 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/integration-api/events/point.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/events/point-state.h>
25 #include <dali/public-api/events/touch-event.h>
26 #include <dali/public-api/object/base-object.h>
36 using TouchEventPtr = IntrusivePtr<TouchEvent>;
39 * @copydoc Dali::TouchEvent
41 class TouchEvent : public BaseObject
44 // Construction & Destruction
47 * @brief Default constructor
49 TouchEvent() = default;
53 * @param[in] time The time the event occurred
55 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);
69 TouchEvent(const TouchEvent& other) = delete; ///< Deleted copy constructor.
70 TouchEvent(TouchEvent&& other) = delete; ///< Deleted move constructor.
71 TouchEvent& operator=(const TouchEvent& other) = delete; ///< Deleted copy assignment operator.
72 TouchEvent& operator=(TouchEvent&& other) = delete; ///< Deleted move assignment operator.
77 * @copydoc Dali::TouchEvent::GetTime()
79 inline unsigned long GetTime() const
85 * @copydoc Dali::TouchEvent::GetPointCount()
87 inline std::size_t GetPointCount() const
89 return mPoints.size();
93 * @copydoc Dali::TouchEvent::GetDeviceId()
95 int32_t GetDeviceId(std::size_t point) const;
98 * @copydoc Dali::TouchEvent::GetGetState()
100 PointState::Type GetState(std::size_t point) const;
103 * @copydoc Dali::TouchEvent::GetHitActor()
105 Dali::Actor GetHitActor(std::size_t point) const;
108 * @copydoc Dali::TouchEvent::GetLocalPosition()
110 const Vector2& GetLocalPosition(std::size_t point) const;
113 * @copydoc Dali::TouchEvent::GetScreenPosition()
115 const Vector2& GetScreenPosition(std::size_t point) const;
118 * @copydoc Dali::TouchEvent::GetRadius()
120 float GetRadius(std::size_t point) const;
123 * @copydoc Dali::TouchEvent::GetEllipseRadius()
125 const Vector2& GetEllipseRadius(std::size_t point) const;
128 * @copydoc Dali::TouchEvent::GetPressure()
130 float GetPressure(std::size_t point) const;
133 * @copydoc Dali::TouchEvent::GetAngle()
135 Degree GetAngle(std::size_t point) const;
138 * @brief Returns a const reference to a point at the index requested.
140 * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
142 * @param[in] point The index of the required Point.
143 * @return A const reference to the Point at the position requested
144 * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
146 const Integration::Point& GetPoint(std::size_t point) const;
149 * @brief Returns a reference to a point at the index requested.
151 * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
153 * @param[in] point The index of the required Point.
154 * @return A reference to the Point at the position requested
155 * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
157 Integration::Point& GetPoint(std::size_t point);
160 * @brief Get the device class the mouse/touch event originated from
162 * @return The device class
164 Device::Class::Type GetDeviceClass(std::size_t point) const;
167 * @brief Get the device subclass the mouse/touch event originated from
169 * @return The device subclass
171 Device::Subclass::Type GetDeviceSubclass(std::size_t point) const;
174 * @brief Get mouse's button value (ex: right/left button)
176 * @return The value of mouse button
178 MouseButton::Type GetMouseButton(std::size_t point) const;
183 * @brief Adds a point to this touch event handler.
184 * @param[in] point The point to add to the touch event handler.
186 void AddPoint(const Integration::Point& point);
190 * @brief Virtual Destructor
192 * A reference counted object may only be deleted by calling Unreference()
194 ~TouchEvent() override = default;
197 std::vector<Integration::Point> mPoints; ///< Container of the points for this touch event.
198 unsigned long mTime{0u}; ///< The time (in ms) that the touch event occurred.
201 } // namespace Internal
203 // Helpers for public-api forwarding methods
205 inline Internal::TouchEvent& GetImplementation(Dali::TouchEvent& touchEvent)
207 DALI_ASSERT_ALWAYS(touchEvent && "Touch Event handle is empty");
209 BaseObject& object = touchEvent.GetBaseObject();
211 return static_cast<Internal::TouchEvent&>(object);
214 inline const Internal::TouchEvent& GetImplementation(const Dali::TouchEvent& touchEvent)
216 DALI_ASSERT_ALWAYS(touchEvent && "Touch Event handle is empty");
218 const BaseObject& object = touchEvent.GetBaseObject();
220 return static_cast<const Internal::TouchEvent&>(object);
225 #endif // DALI_INTERNAL_TOUCH_EVENT_H