[dali_2.3.23] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / integration-api / events / point.cpp
1 /*
2  * Copyright (c) 2020 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 #include <dali/public-api/events/mouse-button.h>
21
22 namespace Dali
23 {
24 namespace Integration
25 {
26 Point::Point()
27 : mTouchPoint(0, PointState::STARTED, 0.0f, 0.0f),
28   mEllipseRadius(),
29   mAngle(0.0f),
30   mDeviceClass(Device::Class::NONE),
31   mDeviceSubclass(Device::Subclass::NONE),
32   mPressure(1.0f),
33   mRadius(0.0f),
34   mMouseButton(MouseButton::INVALID)
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   mMouseButton(MouseButton::INVALID)
47 {
48 }
49
50 Point::~Point() = default;
51
52 void Point::SetDeviceId(int32_t deviceId)
53 {
54   mTouchPoint.deviceId = deviceId;
55 }
56
57 void Point::SetState(PointState::Type state)
58 {
59   mTouchPoint.state = static_cast<PointState::Type>(state);
60 }
61
62 void Point::SetScreenPosition(const Vector2& screenPosition)
63 {
64   mTouchPoint.screen = screenPosition;
65 }
66
67 void Point::SetRadius(float radius)
68 {
69   mRadius = mEllipseRadius.x = mEllipseRadius.y = radius;
70 }
71
72 void Point::SetRadius(float radius, Vector2 ellipseRadius)
73 {
74   mRadius        = radius;
75   mEllipseRadius = ellipseRadius;
76 }
77
78 void Point::SetPressure(float pressure)
79 {
80   mPressure = pressure;
81 }
82
83 void Point::SetAngle(Degree angle)
84 {
85   mAngle = angle;
86 }
87
88 int Point::GetDeviceId() const
89 {
90   return mTouchPoint.deviceId;
91 }
92
93 PointState::Type Point::GetState() const
94 {
95   return static_cast<PointState::Type>(mTouchPoint.state);
96 }
97
98 const Vector2& Point::GetScreenPosition() const
99 {
100   return mTouchPoint.screen;
101 }
102
103 float Point::GetRadius() const
104 {
105   return mRadius;
106 }
107
108 const Vector2& Point::GetEllipseRadius() const
109 {
110   return mEllipseRadius;
111 }
112
113 float Point::GetPressure() const
114 {
115   return mPressure;
116 }
117
118 Degree Point::GetAngle() const
119 {
120   return mAngle;
121 }
122
123 void Point::SetHitActor(Actor hitActor)
124 {
125   mTouchPoint.hitActor = hitActor;
126 }
127
128 void Point::SetLocalPosition(const Vector2& localPosition)
129 {
130   mTouchPoint.local = localPosition;
131 }
132
133 Actor Point::GetHitActor() const
134 {
135   return mTouchPoint.hitActor;
136 }
137
138 const Vector2& Point::GetLocalPosition() const
139 {
140   return mTouchPoint.local;
141 }
142
143 const TouchPoint& Point::GetTouchPoint() const
144 {
145   return mTouchPoint;
146 }
147
148 void Point::SetDeviceClass(Device::Class::Type deviceClass)
149 {
150   mDeviceClass = deviceClass;
151 }
152
153 void Point::SetDeviceSubclass(Device::Subclass::Type deviceSubclass)
154 {
155   mDeviceSubclass = deviceSubclass;
156 }
157
158 Device::Class::Type Point::GetDeviceClass() const
159 {
160   return mDeviceClass;
161 }
162
163 Device::Subclass::Type Point::GetDeviceSubclass() const
164 {
165   return mDeviceSubclass;
166 }
167
168 MouseButton::Type Point::GetMouseButton() const
169 {
170   return mMouseButton;
171 }
172
173 void Point::SetMouseButton(MouseButton::Type button)
174 {
175   mMouseButton = button;
176 }
177
178 } // namespace Integration
179
180 } // namespace Dali