Add GetMouseButton to identify right/left mouse button click
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-data-impl.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/internal/event/events/touch-data-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 TouchData::TouchData()
31 : mPoints(),
32   mTime( 0 )
33 {
34 }
35
36 TouchData::TouchData( unsigned long time )
37 : mPoints(),
38   mTime( time )
39 {
40 }
41
42 TouchDataPtr TouchData::Clone( const TouchData& other )
43 {
44   TouchDataPtr touchData( new TouchData );
45   touchData->mPoints = other.mPoints;
46   touchData->mTime = other.mTime;
47   return touchData;
48 }
49
50 TouchData::~TouchData()
51 {
52 }
53
54 unsigned long TouchData::GetTime() const
55 {
56   return mTime;
57 }
58
59 std::size_t TouchData::GetPointCount() const
60 {
61   return mPoints.size();
62 }
63
64 int32_t TouchData::GetDeviceId( std::size_t point ) const
65 {
66   if( point < mPoints.size() )
67   {
68     return mPoints[ point ].GetDeviceId();
69   }
70   return -1;
71 }
72
73 PointState::Type TouchData::GetState( std::size_t point ) const
74 {
75   if( point < mPoints.size() )
76   {
77     return mPoints[ point ].GetState();
78   }
79   return PointState::FINISHED;
80 }
81
82 Dali::Actor TouchData::GetHitActor( std::size_t point ) const
83 {
84   if( point < mPoints.size() )
85   {
86     return mPoints[ point ].GetHitActor();
87   }
88   return Dali::Actor();
89 }
90
91 const Vector2& TouchData::GetLocalPosition( std::size_t point ) const
92 {
93   if( point < mPoints.size() )
94   {
95     return mPoints[ point ].GetLocalPosition();
96   }
97   return Vector2::ZERO;
98 }
99
100 const Vector2& TouchData::GetScreenPosition( std::size_t point ) const
101 {
102   if( point < mPoints.size() )
103   {
104     return mPoints[ point ].GetScreenPosition();
105   }
106   return Vector2::ZERO;
107 }
108
109 float TouchData::GetRadius( std::size_t point ) const
110 {
111   if( point < mPoints.size() )
112   {
113     return mPoints[ point ].GetRadius();
114   }
115   return 0.0f;
116 }
117
118 const Vector2& TouchData::GetEllipseRadius( std::size_t point ) const
119 {
120   if( point < mPoints.size() )
121   {
122     return mPoints[ point ].GetEllipseRadius();
123   }
124   return Vector2::ZERO;
125 }
126
127 float TouchData::GetPressure( std::size_t point ) const
128 {
129   if( point < mPoints.size() )
130   {
131     return mPoints[ point ].GetPressure();
132   }
133   return 1.0f;
134 }
135
136 Degree TouchData::GetAngle( std::size_t point ) const
137 {
138   if( point < mPoints.size() )
139   {
140     return mPoints[ point ].GetAngle();
141   }
142   return Degree();
143 }
144
145 const Integration::Point& TouchData::GetPoint( std::size_t point ) const
146 {
147   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
148   return mPoints[ point ];
149 }
150
151 Integration::Point& TouchData::GetPoint( std::size_t point )
152 {
153   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
154   return mPoints[ point ];
155 }
156
157 void TouchData::AddPoint( const Integration::Point& point )
158 {
159   mPoints.push_back( point );
160 }
161
162 Device::Class::Type TouchData::GetDeviceClass( std::size_t point ) const
163 {
164   if( point < mPoints.size() )
165   {
166     return mPoints[ point ].GetDeviceClass();
167   }
168   return Device::Class::NONE;
169 }
170
171 Device::Subclass::Type TouchData::GetDeviceSubclass( std::size_t point ) const
172 {
173   if( point < mPoints.size() )
174   {
175     return mPoints[ point ].GetDeviceSubclass();
176   }
177   return Device::Subclass::NONE;
178 }
179
180 MouseButton::Type TouchData::GetMouseButton( std::size_t point ) const
181 {
182   if( point < mPoints.size() )
183   {
184     return mPoints[ point ].GetMouseButton();
185   }
186   return MouseButton::INVALID;
187 }
188
189 } // namsespace Internal
190
191 } // namespace Dali