fb7589fe535ecc40be74c612b315a210c8dd28f8
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-data-impl.h
1 #ifndef __DALI_INTERNAL_TOUCH_DATA_H__
2 #define __DALI_INTERNAL_TOUCH_DATA_H__
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/events/point-state.h>
24 #include <dali/public-api/events/touch-data.h>
25 #include <dali/public-api/events/touch-point.h>
26 #include <dali/public-api/object/base-object.h>
27
28 namespace Dali
29 {
30
31 class Actor;
32 struct Vector2;
33
34 namespace Internal
35 {
36
37 /**
38  * @copydoc Dali::TouchData
39  */
40 class TouchData : public BaseObject
41 {
42 public:
43
44   // Construction & Destruction
45
46   /**
47    * @brief Default constructor
48    */
49   TouchData();
50
51   /**
52    * @brief Constructor
53    * @param[in]  time  The time the event occurred
54    */
55   TouchData( unsigned long time );
56
57   /**
58    * @brief Destructor
59    */
60   ~TouchData();
61
62   // Getters
63
64   /**
65    * @copydoc Dali::TouchData::GetTime()
66    */
67   unsigned long GetTime() const;
68
69   /**
70    * @copydoc Dali::TouchData::GetPointCount()
71    */
72   size_t GetPointCount() const;
73
74   /**
75    * @copydoc Dali::TouchData::GetDeviceId()
76    */
77   int32_t GetDeviceId( size_t point ) const;
78
79   /**
80    * @copydoc Dali::TouchData::GetGetState()
81    */
82   PointState::Type GetState( size_t point  ) const;
83
84   /**
85    * @copydoc Dali::TouchData::GetHitActor()
86    */
87   Dali::Actor GetHitActor( size_t point ) const;
88
89   /**
90    * @copydoc Dali::TouchData::GetLocalPosition()
91    */
92   const Vector2& GetLocalPosition( size_t point ) const;
93
94   /**
95    * @copydoc Dali::TouchData::GetScreenPosition()
96    */
97   const Vector2& GetScreenPosition( size_t point ) const;
98
99   /**
100    * @brief Returns a reference to a point at the index requested.
101    *
102    * The first point in the set is always the primary point (i.e. the first point touched in a multi-touch event).
103    *
104    * @SINCE_1_1.36
105    * @param[in]  point  The index of the required Point.
106    * @return A reference to the Point at the position requested
107    * @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
108    */
109   const TouchPoint& GetPoint( size_t point ) const;
110
111   // Setters
112
113   /**
114    * @brief Adds a point to this touch event handler.
115    * @param[in]  point  The point to add to the touch event handler.
116    */
117   void AddPoint( const TouchPoint& point );
118
119   /**
120    * @brief Overwrites the internal container with the point container specified.
121    *
122    * @param[in]  points  The point container.
123    */
124   void SetPoints( const TouchPointContainer& points );
125
126 private:
127
128   /// Undefined Copy constructor
129   TouchData( const TouchData& other );
130
131   /// Undefined
132   TouchData& operator=( const TouchData& other );
133
134   TouchPointContainer mPoints;   ///< Container of the points for this touch event.
135   unsigned long       mTime;     ///< The time (in ms) that the touch event occurred.
136 };
137
138 } // namespace Internal
139
140 // Helpers for public-api forwarding methods
141
142 inline Internal::TouchData& GetImplementation( Dali::TouchData& touchData )
143 {
144   DALI_ASSERT_ALWAYS( touchData && "Touch Data handle is empty" );
145
146   BaseObject& object = touchData.GetBaseObject();
147
148   return static_cast< Internal::TouchData& >( object );
149 }
150
151 inline const Internal::TouchData& GetImplementation( const Dali::TouchData& touchData )
152 {
153   DALI_ASSERT_ALWAYS( touchData && "Touch Data handle is empty" );
154
155   const BaseObject& object = touchData.GetBaseObject();
156
157   return static_cast< const Internal::TouchData& >( object );
158 }
159
160 } // namespace Dali
161
162 #endif // __DALI_INTERNAL_TOUCH_DATA_H__