Merge "Removed TouchEvent from actor & stage" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / events / hover-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/hover-event-impl.h>
20
21 namespace Dali
22 {
23
24 namespace Internal
25 {
26
27 HoverEvent::HoverEvent()
28 : mPoints(),
29   mTime( 0 )
30 {
31 }
32
33 HoverEvent::HoverEvent( unsigned long time )
34 : mPoints(),
35   mTime( time )
36 {
37 }
38
39 HoverEventPtr HoverEvent::Clone( const HoverEvent& rhs )
40 {
41   HoverEventPtr hoverEvent( new HoverEvent );
42   hoverEvent->mPoints = rhs.mPoints;
43   hoverEvent->mTime = rhs.mTime;
44   return hoverEvent;
45 }
46
47 HoverEvent::~HoverEvent()
48 {
49 }
50
51 unsigned long HoverEvent::GetTime() const
52 {
53   return mTime;
54 }
55
56 std::size_t HoverEvent::GetPointCount() const
57 {
58   return mPoints.size();
59 }
60
61 int32_t HoverEvent::GetDeviceId( std::size_t point ) const
62 {
63   if( point < mPoints.size() )
64   {
65     return mPoints[ point ].GetDeviceId();
66   }
67   return -1;
68 }
69
70 PointState::Type HoverEvent::GetState( std::size_t point ) const
71 {
72   if( point < mPoints.size() )
73   {
74     return mPoints[ point ].GetState();
75   }
76   return PointState::FINISHED;
77 }
78
79 Dali::Actor HoverEvent::GetHitActor( std::size_t point ) const
80 {
81   if( point < mPoints.size() )
82   {
83     return mPoints[ point ].GetHitActor();
84   }
85   return Dali::Actor();
86 }
87
88 const Vector2& HoverEvent::GetLocalPosition( std::size_t point ) const
89 {
90   if( point < mPoints.size() )
91   {
92     return mPoints[ point ].GetLocalPosition();
93   }
94   return Vector2::ZERO;
95 }
96
97 const Vector2& HoverEvent::GetScreenPosition( std::size_t point ) const
98 {
99   if( point < mPoints.size() )
100   {
101     return mPoints[ point ].GetScreenPosition();
102   }
103   return Vector2::ZERO;
104 }
105
106 const Integration::Point& HoverEvent::GetPoint( std::size_t point ) const
107 {
108   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
109   return mPoints[ point ];
110 }
111
112 Integration::Point& HoverEvent::GetPoint( std::size_t point )
113 {
114   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
115   return mPoints[ point ];
116 }
117
118 void HoverEvent::AddPoint( const Integration::Point& point )
119 {
120   mPoints.push_back( point );
121 }
122
123 } // namsespace Internal
124
125 } // namespace Dali