[dali_1.9.28] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-event-impl.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/internal/event/events/touch-event-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 TouchEventPtr TouchEvent::Clone( const TouchEvent& other )
31 {
32   TouchEventPtr touchEvent( new TouchEvent );
33   touchEvent->mPoints = other.mPoints;
34   touchEvent->mTime = other.mTime;
35   return touchEvent;
36 }
37
38 int32_t TouchEvent::GetDeviceId( std::size_t point ) const
39 {
40   if( point < mPoints.size() )
41   {
42     return mPoints[ point ].GetDeviceId();
43   }
44   return -1;
45 }
46
47 PointState::Type TouchEvent::GetState( std::size_t point ) const
48 {
49   if( point < mPoints.size() )
50   {
51     return mPoints[ point ].GetState();
52   }
53   return PointState::FINISHED;
54 }
55
56 Dali::Actor TouchEvent::GetHitActor( std::size_t point ) const
57 {
58   if( point < mPoints.size() )
59   {
60     return mPoints[ point ].GetHitActor();
61   }
62   return Dali::Actor();
63 }
64
65 const Vector2& TouchEvent::GetLocalPosition( std::size_t point ) const
66 {
67   if( point < mPoints.size() )
68   {
69     return mPoints[ point ].GetLocalPosition();
70   }
71   return Vector2::ZERO;
72 }
73
74 const Vector2& TouchEvent::GetScreenPosition( std::size_t point ) const
75 {
76   if( point < mPoints.size() )
77   {
78     return mPoints[ point ].GetScreenPosition();
79   }
80   return Vector2::ZERO;
81 }
82
83 float TouchEvent::GetRadius( std::size_t point ) const
84 {
85   if( point < mPoints.size() )
86   {
87     return mPoints[ point ].GetRadius();
88   }
89   return 0.0f;
90 }
91
92 const Vector2& TouchEvent::GetEllipseRadius( std::size_t point ) const
93 {
94   if( point < mPoints.size() )
95   {
96     return mPoints[ point ].GetEllipseRadius();
97   }
98   return Vector2::ZERO;
99 }
100
101 float TouchEvent::GetPressure( std::size_t point ) const
102 {
103   if( point < mPoints.size() )
104   {
105     return mPoints[ point ].GetPressure();
106   }
107   return 1.0f;
108 }
109
110 Degree TouchEvent::GetAngle( std::size_t point ) const
111 {
112   if( point < mPoints.size() )
113   {
114     return mPoints[ point ].GetAngle();
115   }
116   return Degree();
117 }
118
119 const Integration::Point& TouchEvent::GetPoint( std::size_t point ) const
120 {
121   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
122   return mPoints[ point ];
123 }
124
125 Integration::Point& TouchEvent::GetPoint( std::size_t point )
126 {
127   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
128   return mPoints[ point ];
129 }
130
131 Device::Class::Type TouchEvent::GetDeviceClass( std::size_t point ) const
132 {
133   if( point < mPoints.size() )
134   {
135     return mPoints[ point ].GetDeviceClass();
136   }
137   return Device::Class::NONE;
138 }
139
140 Device::Subclass::Type TouchEvent::GetDeviceSubclass( std::size_t point ) const
141 {
142   if( point < mPoints.size() )
143   {
144     return mPoints[ point ].GetDeviceSubclass();
145   }
146   return Device::Subclass::NONE;
147 }
148
149 MouseButton::Type TouchEvent::GetMouseButton( std::size_t point ) const
150 {
151   if( point < mPoints.size() )
152   {
153     return mPoints[ point ].GetMouseButton();
154   }
155   return MouseButton::INVALID;
156 }
157
158 void TouchEvent::AddPoint( const Integration::Point& point )
159 {
160   mPoints.push_back( point );
161 }
162
163 } // namsespace Internal
164
165 } // namespace Dali