2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/events/touch-event-impl.h>
22 #include <dali/public-api/actors/actor.h>
30 TouchEvent::TouchEvent()
36 TouchEvent::TouchEvent( unsigned long time )
42 TouchEventPtr TouchEvent::Clone( const TouchEvent& other )
44 TouchEventPtr touchEvent( new TouchEvent );
45 touchEvent->mPoints = other.mPoints;
46 touchEvent->mTime = other.mTime;
50 TouchEvent::~TouchEvent()
54 unsigned long TouchEvent::GetTime() const
59 std::size_t TouchEvent::GetPointCount() const
61 return mPoints.size();
64 int32_t TouchEvent::GetDeviceId( std::size_t point ) const
66 if( point < mPoints.size() )
68 return mPoints[ point ].GetDeviceId();
73 PointState::Type TouchEvent::GetState( std::size_t point ) const
75 if( point < mPoints.size() )
77 return mPoints[ point ].GetState();
79 return PointState::FINISHED;
82 Dali::Actor TouchEvent::GetHitActor( std::size_t point ) const
84 if( point < mPoints.size() )
86 return mPoints[ point ].GetHitActor();
91 const Vector2& TouchEvent::GetLocalPosition( std::size_t point ) const
93 if( point < mPoints.size() )
95 return mPoints[ point ].GetLocalPosition();
100 const Vector2& TouchEvent::GetScreenPosition( std::size_t point ) const
102 if( point < mPoints.size() )
104 return mPoints[ point ].GetScreenPosition();
106 return Vector2::ZERO;
109 float TouchEvent::GetRadius( std::size_t point ) const
111 if( point < mPoints.size() )
113 return mPoints[ point ].GetRadius();
118 const Vector2& TouchEvent::GetEllipseRadius( std::size_t point ) const
120 if( point < mPoints.size() )
122 return mPoints[ point ].GetEllipseRadius();
124 return Vector2::ZERO;
127 float TouchEvent::GetPressure( std::size_t point ) const
129 if( point < mPoints.size() )
131 return mPoints[ point ].GetPressure();
136 Degree TouchEvent::GetAngle( std::size_t point ) const
138 if( point < mPoints.size() )
140 return mPoints[ point ].GetAngle();
145 const Integration::Point& TouchEvent::GetPoint( std::size_t point ) const
147 DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
148 return mPoints[ point ];
151 Integration::Point& TouchEvent::GetPoint( std::size_t point )
153 DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
154 return mPoints[ point ];
157 void TouchEvent::AddPoint( const Integration::Point& point )
159 mPoints.push_back( point );
162 Device::Class::Type TouchEvent::GetDeviceClass( std::size_t point ) const
164 if( point < mPoints.size() )
166 return mPoints[ point ].GetDeviceClass();
168 return Device::Class::NONE;
171 Device::Subclass::Type TouchEvent::GetDeviceSubclass( std::size_t point ) const
173 if( point < mPoints.size() )
175 return mPoints[ point ].GetDeviceSubclass();
177 return Device::Subclass::NONE;
180 MouseButton::Type TouchEvent::GetMouseButton( std::size_t point ) const
182 if( point < mPoints.size() )
184 return mPoints[ point ].GetMouseButton();
186 return MouseButton::INVALID;
189 } // namsespace Internal