Add GetMouseButton to identify right/left mouse button click
[platform/core/uifw/dali-core.git] / dali / integration-api / events / point.h
1 #ifndef __DALI_INTEGRATION_POINT_H__
2 #define __DALI_INTEGRATION_POINT_H__
3
4 /*
5  * Copyright (c) 2018 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/events/point-state.h>
23 #include <dali/public-api/math/degree.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/events/touch-point.h>
26 #include <dali/public-api/events/device.h>
27 #include <dali/public-api/events/mouse-button.h>
28
29 namespace Dali
30 {
31
32 namespace Integration
33 {
34
35 /**
36  * @brief A Point represents a point on the screen that is currently being touched or where touch has stopped.
37  */
38 struct DALI_CORE_API Point
39 {
40   /**
41    * @brief Default Constructor
42    */
43   Point();
44
45   /**
46    * @brief Constructor which creates a Point instance from a TouchPoint.
47    * @param[in]  touchPoint  The touch-point to copy from.
48    */
49   explicit Point( const TouchPoint& touchPoint );
50
51   /**
52    * @brief Destructor
53    */
54   ~Point();
55
56   /**
57    * @brief Set the Unique Device ID.
58    *
59    * Each touch point has a unique device ID which specifies the touch device for that point.
60    *
61    * @param[in]  deviceId  The Unique Device ID.
62    */
63   void SetDeviceId( int deviceId );
64
65   /**
66    * @brief Set the state of the point.
67    * @param[in]  state  The state of the point.
68    */
69   void SetState( PointState::Type state );
70
71   /**
72    * @brief Set the screen position of the point from the top-left of the screen.
73    * @param[in]  screenPosition  The screen position of the point from the top-left of the screen.
74    */
75   void SetScreenPosition( const Vector2& screenPosition );
76
77   /**
78    * @brief Set the radius of the press point.
79    *
80    * This is the average of both the horizontal and vertical radii of the press point.
81    * @param[in]  radius  The average of both the horizontal and vertical radii.
82    */
83   void SetRadius( float radius );
84
85   /**
86    * @brief Set the radius of the press point as an ellipse.
87    * @param[in]  radius         The average of both the horizontal and vertical radii.
88    * @param[in]  ellipseRadius  The horizontal and vertical radii of the press point (different if an ellipse).
89    */
90   void SetRadius( float radius, Vector2 ellipseRadius );
91
92   /**
93    * @brief Sets the touch pressure.
94    *
95    * The pressure range starts at 0.0f.
96    * Normal pressure is defined as 1.0f.
97    * A value between 0.0f and 1.0f means light pressure has been applied.
98    * A value greater than 1.0f means more pressure than normal has been applied.
99    *
100    * @param[in]  pressure  The touch pressure.
101    */
102   void SetPressure( float pressure );
103
104   /**
105    * @brief Sets the angle of the press point relative to the Y-Axis.
106    * @param[in]  angle  The angle of the press point relative to the Y-Axis.
107    */
108   void SetAngle( Degree angle );
109
110   /**
111    * @brief Sets the class of the device for the event
112    * @param[in] deviceClass The class of the device.
113    */
114   void SetDeviceClass( Device::Class::Type deviceClass );
115
116   /**
117    * @brief Sets the subclass of the device for the event
118    * @param[in] deviceSubclass The subclass of the device.
119    */
120   void SetDeviceSubclass( Device::Subclass::Type deviceSubclass );
121
122   /**
123    * @brief Retrieve the Unique Device ID of the point.
124    * @return The Unique Device ID of the point.
125    */
126   int GetDeviceId() const;
127
128   /**
129    * @brief Retrieve the state of the point.
130    * @return The state of the point.
131    */
132   PointState::Type GetState() const;
133
134   /**
135    * @brief Retrieve the screen position from the top-left of the screen.
136    * @return The screen position from the top-left of the screen.
137    */
138   const Vector2& GetScreenPosition() const;
139
140   /**
141    * @brief Retrieve the radius of the press point.
142    * @return The radius of the press point.
143    * @see SetRadius(float)
144    * @see SetRadius(float,Vector2)
145    */
146   float GetRadius() const;
147
148   /**
149    * @brief Retrieve BOTH the horizontal and the vertical radii of the press point.
150    * @return The radius of the press point.
151    * @see SetRadius(float)
152    * @see SetRadius(float,Vector2)
153    */
154   const Vector2& GetEllipseRadius() const;
155
156   /**
157    * @brief Retrieves the touch pressure.
158    *
159    * @return The touch pressure.
160    * @see SetPressure()
161    */
162   float GetPressure() const;
163
164   /**
165    * @brief Retrieve the angle of the press point relative to the Y-Axis.
166    * @return The angle of the press point.
167    */
168   Degree GetAngle() const;
169
170   /**
171    * @brief Retrieve the class of the device for the event.
172    * @return The class of the device
173    */
174   Device::Class::Type GetDeviceClass() const;
175
176   /**
177    * @brief Retrieve the subclass of the device for the event.
178    * @return The subclass of the device
179    */
180   Device::Subclass::Type GetDeviceSubclass() const;
181
182   /**
183    * @brief Get Mouse Button value. (ex: right/left button)
184    * @return The mouse button value.
185    */
186   MouseButton::Type GetMouseButton() const;
187
188   /**
189    * @brief Set Mouse Button value. (ex: right/left button)
190    */
191   void SetMouseButton(MouseButton::Type button);
192
193
194 public: // Not intended for Integration API developers
195
196   /**
197    * @brief Sets the hit actor under this point.
198    * @param[in]  hitActor  The hit actor.
199    */
200   DALI_INTERNAL void SetHitActor( Actor hitActor );
201
202   /**
203    * @brief Set the co-ordinates relative to the top-left of the hit-actor.
204    * @param[in]  localPosition  The local position.
205    * @note The top-left of an actor is (0.0, 0.0, 0.5).
206    */
207   DALI_INTERNAL void SetLocalPosition( const Vector2& localPosition );
208
209   /**
210    * @brief Retrieve the Hit Actor.
211    * @return The hit actor.
212    */
213   DALI_INTERNAL Actor GetHitActor() const;
214
215   /**
216    * @brief Retrieve the local position relative to the top-left of the hit-actor.
217    * @return The local position.
218    * @note The top-left of an actor is (0.0, 0.0, 0.5).
219    */
220   DALI_INTERNAL const Vector2& GetLocalPosition() const;
221
222   /**
223    * @brief Retrieve the touch point equivalent of this point for old API.
224    * @return The touch point equivalent.
225    */
226   DALI_INTERNAL const TouchPoint& GetTouchPoint() const;
227
228 private:
229
230   TouchPoint mTouchPoint; ///< Stores screen position, device Id, local & screen positions and the hit-actor. @see TouchPoint
231   Vector2 mEllipseRadius; ///< Radius of both the horizontal and vertical radius (useful if an ellipse).
232   Degree mAngle; ///< The angle of the press point, relative to the Y-Axis.
233   Device::Class::Type mDeviceClass;
234   Device::Subclass::Type mDeviceSubclass;
235   float mPressure; ///< The touch pressure.
236   float mRadius; ///< Radius of the press point, an average of the ellipse radius.
237   MouseButton::Type mMouseButton; /// < mouse button value.
238 };
239
240 } // namespace Integration
241
242 } // namespace Dali
243
244 #endif // __DALI_TOUCH_POINT_H__