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