Added class to replace TouchEvent
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-data-impl.cpp
1 /*
2  * Copyright (c) 2015 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 TouchData::~TouchData()
43 {
44 }
45
46 unsigned long TouchData::GetTime() const
47 {
48   return mTime;
49 }
50
51 size_t TouchData::GetPointCount() const
52 {
53   return mPoints.size();
54 }
55
56 int32_t TouchData::GetDeviceId( size_t point ) const
57 {
58   if( point < mPoints.size() )
59   {
60     return mPoints[ point ].deviceId;
61   }
62   return -1;
63 }
64
65 PointState::Type TouchData::GetState( size_t point ) const
66 {
67   if( point < mPoints.size() )
68   {
69     return static_cast< PointState::Type >( mPoints[ point ].state );
70   }
71   return PointState::FINISHED;
72 }
73
74 Dali::Actor TouchData::GetHitActor( size_t point ) const
75 {
76   if( point < mPoints.size() )
77   {
78     return mPoints[ point ].hitActor;
79   }
80   return Dali::Actor();
81 }
82
83 const Vector2& TouchData::GetLocalPosition( size_t point ) const
84 {
85   if( point < mPoints.size() )
86   {
87     return mPoints[ point ].local;
88   }
89   return Vector2::ZERO;
90 }
91
92 const Vector2& TouchData::GetScreenPosition( size_t point ) const
93 {
94   if( point < mPoints.size() )
95   {
96     return mPoints[ point ].screen;
97   }
98   return Vector2::ZERO;
99 }
100
101 const TouchPoint& TouchData::GetPoint( size_t point ) const
102 {
103   DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
104   return mPoints[ point ];
105 }
106
107 void TouchData::AddPoint( const TouchPoint& point )
108 {
109   mPoints.push_back( point );
110 }
111
112 void TouchData::SetPoints( const TouchPointContainer& points )
113 {
114   mPoints = points;
115 }
116
117 } // namsespace Internal
118
119 } // namespace Dali