1 #ifndef __DALI_INTEGRATION_POINT_H__
2 #define __DALI_INTEGRATION_POINT_H__
5 * Copyright (c) 2016 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/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>
34 * @brief A Point represents a point on the screen that is currently being touched or where touch has stopped.
36 struct DALI_IMPORT_API Point
39 * @brief Default Constructor
44 * @brief Constructor which creates a Point instance from a TouchPoint.
45 * @param[in] touchPoint The touch-point to copy from.
47 explicit Point( const TouchPoint& touchPoint );
55 * @brief Set the Unique Device ID.
57 * Each touch point has a unique device ID which specifies the touch device for that point.
59 * @param[in] deviceId The Unique Device ID.
61 void SetDeviceId( int deviceId );
64 * @brief Set the state of the point.
65 * @param[in] state The state of the point.
67 void SetState( PointState::Type state );
70 * @brief Set the screen position of the point from the top-left of the screen.
71 * @param[in] screenPosition The screen position of the point from the top-left of the screen.
73 void SetScreenPosition( const Vector2& screenPosition );
76 * @brief Set the radius of the press point.
78 * This is the average of both the horizontal and vertical radii of the press point.
79 * @param[in] radius The average of both the horizontal and vertical radii.
81 void SetRadius( float radius );
84 * @brief Set the radius of the press point as an ellipse.
85 * @param[in] radius The average of both the horizontal and vertical radii.
86 * @param[in] ellipseRadius The horizontal and vertical radii of the press point (different if an ellipse).
88 void SetRadius( float radius, Vector2 ellipseRadius );
91 * @brief Sets the touch pressure.
93 * The pressure range starts at 0.0f.
94 * Normal pressure is defined as 1.0f.
95 * A value between 0.0f and 1.0f means light pressure has been applied.
96 * A value greater than 1.0f means more pressure than normal has been applied.
98 * @param[in] pressure The touch pressure.
100 void SetPressure( float pressure );
103 * @brief Sets the angle of the press point relative to the Y-Axis.
104 * @param[in] angle The angle of the press point relative to the Y-Axis.
106 void SetAngle( Degree angle );
109 * @brief Retrieve the Unique Device ID of the point.
110 * @return The Unique Device ID of the point.
112 int GetDeviceId() const;
115 * @brief Retrieve the state of the point.
116 * @return The state of the point.
118 PointState::Type GetState() const;
121 * @brief Retrieve the screen position from the top-left of the screen.
122 * @return The screen position from the top-left of the screen.
124 const Vector2& GetScreenPosition() const;
127 * @brief Retrieve the radius of the press point.
128 * @return The radius of the press point.
129 * @see SetRadius(float)
130 * @see SetRadius(float,Vector2)
132 float GetRadius() const;
135 * @brief Retrieve BOTH the horizontal and the vertical radii of the press point.
136 * @return The radius of the press point.
137 * @see SetRadius(float)
138 * @see SetRadius(float,Vector2)
140 const Vector2& GetEllipseRadius() const;
143 * @brief Retrieves the touch pressure.
145 * @return The touch pressure.
148 float GetPressure() const;
151 * @brief Retrieve the angle of the press point relative to the Y-Axis.
152 * @return The angle of the press point.
154 Degree GetAngle() const;
156 public: // Not intended for Integration API developers
159 * @brief Sets the hit actor under this point.
160 * @param[in] hitActor The hit actor.
162 DALI_INTERNAL void SetHitActor( Actor hitActor );
165 * @brief Set the co-ordinates relative to the top-left of the hit-actor.
166 * @param[in] localPosition The local position.
167 * @note The top-left of an actor is (0.0, 0.0, 0.5).
169 DALI_INTERNAL void SetLocalPosition( const Vector2& localPosition );
172 * @brief Retrieve the Hit Actor.
173 * @return The hit actor.
175 DALI_INTERNAL Actor GetHitActor() const;
178 * @brief Retrieve the local position relative to the top-left of the hit-actor.
179 * @return The local position.
180 * @note The top-left of an actor is (0.0, 0.0, 0.5).
182 DALI_INTERNAL const Vector2& GetLocalPosition() const;
185 * @brief Retrieve the touch point equivalent of this point for old API.
186 * @return The touch point equivalent.
188 DALI_INTERNAL const TouchPoint& GetTouchPoint() const;
192 TouchPoint mTouchPoint; ///< Stores screen position, device Id, local & screen positions and the hit-actor. @see TouchPoint
193 Vector2 mEllipseRadius; ///< Radius of both the horizontal and vertical radius (useful if an ellipse).
194 Degree mAngle; ///< The angle of the press point, relative to the Y-Axis.
195 float mPressure; ///< The touch pressure.
196 float mRadius; ///< Radius of the press point, an average of the ellipse radius.
199 } // namespace Integration
203 #endif // __DALI_TOUCH_POINT_H__