Move device codes & related TouchData & KeyEvent methods to Public API
[platform/core/uifw/dali-core.git] / dali / integration-api / events / point.cpp
1 /*
2  * Copyright (c) 2017 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   mDeviceClass( Device::Class::NONE ),
32   mDeviceSubclass( Device::Subclass::NONE ),
33   mPressure( 1.0f ),
34   mRadius( 0.0f )
35 {
36 }
37
38 Point::Point( const TouchPoint& touchPoint )
39 : mTouchPoint( touchPoint ),
40   mEllipseRadius(),
41   mAngle( 0.0f ),
42   mDeviceClass( Device::Class::NONE ),
43   mDeviceSubclass( Device::Subclass::NONE ),
44   mPressure( 1.0f ),
45   mRadius( 0.0f )
46 {
47 }
48
49 Point::~Point()
50 {
51 }
52
53 void Point::SetDeviceId( int deviceId )
54 {
55   mTouchPoint.deviceId = deviceId;
56 }
57
58 void Point::SetState( PointState::Type state )
59 {
60   mTouchPoint.state = static_cast< TouchPoint::State >( state );
61 }
62
63 void Point::SetScreenPosition( const Vector2& screenPosition )
64 {
65   mTouchPoint.screen = screenPosition;
66 }
67
68 void Point::SetRadius( float radius )
69 {
70   mRadius = mEllipseRadius.x = mEllipseRadius.y = radius;
71 }
72
73 void Point::SetRadius( float radius, Vector2 ellipseRadius )
74 {
75   mRadius = radius;
76   mEllipseRadius = ellipseRadius;
77 }
78
79 void Point::SetPressure( float pressure )
80 {
81   mPressure = pressure;
82 }
83
84 void Point::SetAngle( Degree angle )
85 {
86   mAngle = angle;
87 }
88
89 int Point::GetDeviceId() const
90 {
91   return mTouchPoint.deviceId;
92 }
93
94 PointState::Type Point::GetState() const
95 {
96   return static_cast< PointState::Type >( mTouchPoint.state );
97 }
98
99 const Vector2& Point::GetScreenPosition() const
100 {
101   return mTouchPoint.screen;
102 }
103
104 float Point::GetRadius() const
105 {
106   return mRadius;
107 }
108
109 const Vector2& Point::GetEllipseRadius() const
110 {
111   return mEllipseRadius;
112 }
113
114 float Point::GetPressure() const
115 {
116   return mPressure;
117 }
118
119 Degree Point::GetAngle() const
120 {
121   return mAngle;
122 }
123
124 void Point::SetHitActor( Actor hitActor )
125 {
126   mTouchPoint.hitActor = hitActor;
127 }
128
129 void Point::SetLocalPosition( const Vector2& localPosition )
130 {
131   mTouchPoint.local = localPosition;
132 }
133
134 Actor Point::GetHitActor() const
135 {
136   return mTouchPoint.hitActor;
137 }
138
139 const Vector2& Point::GetLocalPosition() const
140 {
141   return mTouchPoint.local;
142 }
143
144 const TouchPoint& Point::GetTouchPoint() const
145 {
146   return mTouchPoint;
147 }
148
149 void Point::SetDeviceClass( Device::Class::Type deviceClass )
150 {
151   mDeviceClass = deviceClass;
152 }
153
154 void Point::SetDeviceSubclass( Device::Subclass::Type deviceSubclass )
155 {
156   mDeviceSubclass = deviceSubclass;
157 }
158
159 Device::Class::Type Point::GetDeviceClass() const
160 {
161   return mDeviceClass;
162 }
163
164 Device::Subclass::Type Point::GetDeviceSubclass() const
165 {
166   return mDeviceSubclass;
167 }
168
169 } // namespace Integration
170
171 } // namespace Dali