485c4ed10f66b93e11c1b81269c83a754ceb1369
[platform/core/uifw/dali-core.git] / dali / integration-api / events / point.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/integration-api/events/point.h>
20
21 namespace Dali
22 {
23
24 namespace Integration
25 {
26
27 Point::Point()
28 : mTouchPoint( 0, TouchPoint::Started, 0.0f, 0.0f ),
29   mEllipseRadius(),
30   mAngle( 0.0f ),
31   mPressure( 1.0f ),
32   mRadius( 0.0f )
33 {
34 }
35
36 Point::Point( const TouchPoint& touchPoint )
37 : mTouchPoint( touchPoint ),
38   mEllipseRadius(),
39   mAngle( 0.0f ),
40   mPressure( 1.0f ),
41   mRadius( 0.0f )
42 {
43 }
44
45 Point::~Point()
46 {
47 }
48
49 void Point::SetDeviceId( int deviceId )
50 {
51   mTouchPoint.deviceId = deviceId;
52 }
53
54 void Point::SetState( PointState::Type state )
55 {
56   mTouchPoint.state = static_cast< TouchPoint::State >( state );
57 }
58
59 void Point::SetScreenPosition( const Vector2& screenPosition )
60 {
61   mTouchPoint.screen = screenPosition;
62 }
63
64 void Point::SetRadius( float radius )
65 {
66   mRadius = mEllipseRadius.x = mEllipseRadius.y = radius;
67 }
68
69 void Point::SetRadius( float radius, Vector2 ellipseRadius )
70 {
71   mRadius = radius;
72   mEllipseRadius = ellipseRadius;
73 }
74
75 void Point::SetPressure( float pressure )
76 {
77   mPressure = pressure;
78 }
79
80 void Point::SetAngle( Degree angle )
81 {
82   mAngle = angle;
83 }
84
85 int Point::GetDeviceId() const
86 {
87   return mTouchPoint.deviceId;
88 }
89
90 PointState::Type Point::GetState() const
91 {
92   return static_cast< PointState::Type >( mTouchPoint.state );
93 }
94
95 const Vector2& Point::GetScreenPosition() const
96 {
97   return mTouchPoint.screen;
98 }
99
100 float Point::GetRadius() const
101 {
102   return mRadius;
103 }
104
105 const Vector2& Point::GetEllipseRadius() const
106 {
107   return mEllipseRadius;
108 }
109
110 float Point::GetPressure() const
111 {
112   return mPressure;
113 }
114
115 Degree Point::GetAngle() const
116 {
117   return mAngle;
118 }
119
120 void Point::SetHitActor( Actor hitActor )
121 {
122   mTouchPoint.hitActor = hitActor;
123 }
124
125 void Point::SetLocalPosition( const Vector2& localPosition )
126 {
127   mTouchPoint.local = localPosition;
128 }
129
130 Actor Point::GetHitActor() const
131 {
132   return mTouchPoint.hitActor;
133 }
134
135 const Vector2& Point::GetLocalPosition() const
136 {
137   return mTouchPoint.local;
138 }
139
140 const TouchPoint& Point::GetTouchPoint() const
141 {
142   return mTouchPoint;
143 }
144
145 } // namespace Integration
146
147 } // namespace Dali