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