Add GetMouseButton to identify right/left mouse button click
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-data-impl.h
1 #ifndef __DALI_INTERNAL_TOUCH_DATA_H__
2 #define __DALI_INTERNAL_TOUCH_DATA_H__
3
4 /*
5  * Copyright (c) 2017 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/point-state.h>
24 #include <dali/public-api/events/touch-data.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 class Actor;
32 struct Vector2;
33
34 namespace Internal
35 {
36
37 class TouchData;
38 typedef IntrusivePtr< TouchData > TouchDataPtr;
39
40 /**
41  * @copydoc Dali::TouchData
42  */
43 class TouchData : public BaseObject
44 {
45 public:
46
47   // Construction & Destruction
48
49   /**
50    * @brief Default constructor
51    */
52   TouchData();
53
54   /**
55    * @brief Constructor
56    * @param[in]  time  The time the event occurred
57    */
58   TouchData( unsigned long time );
59
60   /**
61    * @brief Clones the TouchData object.
62    *
63    * Required because base class copy constructor is not implemented.
64    * @param[in]  other  The TouchData to clone from.
65    * @return A new TouchData object which is has the same touch point data.
66    */
67   static TouchDataPtr Clone( const TouchData& other );
68
69   /**
70    * @brief Destructor
71    */
72   ~TouchData();
73
74   // Getters
75
76   /**
77    * @copydoc Dali::TouchData::GetTime()
78    */
79   unsigned long GetTime() const;
80
81   /**
82    * @copydoc Dali::TouchData::GetPointCount()
83    */
84   std::size_t GetPointCount() const;
85
86   /**
87    * @copydoc Dali::TouchData::GetDeviceId()
88    */
89   int32_t GetDeviceId( std::size_t point ) const;
90
91   /**
92    * @copydoc Dali::TouchData::GetGetState()
93    */
94   PointState::Type GetState( std::size_t point  ) const;
95
96   /**
97    * @copydoc Dali::TouchData::GetHitActor()
98    */
99   Dali::Actor GetHitActor( std::size_t point ) const;
100
101   /**
102    * @copydoc Dali::TouchData::GetLocalPosition()
103    */
104   const Vector2& GetLocalPosition( std::size_t point ) const;
105
106   /**
107    * @copydoc Dali::TouchData::GetScreenPosition()
108    */
109   const Vector2& GetScreenPosition( std::size_t point ) const;
110
111   /**
112    * @copydoc Dali::TouchData::GetRadius()
113    */
114   float GetRadius( std::size_t point ) const;
115
116   /**
117    * @copydoc Dali::TouchData::GetEllipseRadius()
118    */
119   const Vector2& GetEllipseRadius( std::size_t point ) const;
120
121   /**
122    * @copydoc Dali::TouchData::GetPressure()
123    */
124   float GetPressure( std::size_t point ) const;
125
126   /**
127    * @copydoc Dali::TouchData::GetAngle()
128    */
129   Degree GetAngle( std::size_t point ) const;
130
131   /**
132    * @brief Returns a const reference to a point at the index requested.
133    *
134    * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
135    *
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.
139    */
140   const Integration::Point& GetPoint( std::size_t point ) const;
141
142   /**
143    * @brief Returns a reference to a point at the index requested.
144    *
145    * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
146    *
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.
150    */
151   Integration::Point& GetPoint( std::size_t point );
152
153   // Setters
154
155   /**
156    * @brief Adds a point to this touch event handler.
157    * @param[in]  point  The point to add to the touch event handler.
158    */
159   void AddPoint( const Integration::Point& point );
160
161   /**
162    * @brief Get the device class the mouse/touch event originated from
163    *
164    * @return The device class
165    */
166   Device::Class::Type GetDeviceClass( std::size_t point ) const;
167
168   /**
169    * @brief Get the device subclass the mouse/touch event originated from
170    *
171    * @return The device subclass
172    */
173   Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const;
174
175   /**
176    * @brief Get mouse's button value (ex: right/left button)
177    *
178    * @return The value of mouse button
179    */
180   MouseButton::Type GetMouseButton( std::size_t point ) const;
181
182
183 private:
184
185   /// Undefined Copy constructor
186   TouchData( const TouchData& other );
187
188   /// Undefined
189   TouchData& operator=( const TouchData& other );
190
191 private:
192
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.
195 };
196
197 } // namespace Internal
198
199 // Helpers for public-api forwarding methods
200
201 inline Internal::TouchData& GetImplementation( Dali::TouchData& touchData )
202 {
203   DALI_ASSERT_ALWAYS( touchData && "Touch Data handle is empty" );
204
205   BaseObject& object = touchData.GetBaseObject();
206
207   return static_cast< Internal::TouchData& >( object );
208 }
209
210 inline const Internal::TouchData& GetImplementation( const Dali::TouchData& touchData )
211 {
212   DALI_ASSERT_ALWAYS( touchData && "Touch Data handle is empty" );
213
214   const BaseObject& object = touchData.GetBaseObject();
215
216   return static_cast< const Internal::TouchData& >( object );
217 }
218
219 } // namespace Dali
220
221 #endif // __DALI_INTERNAL_TOUCH_DATA_H__