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