2 * Copyright(c) 2017 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.
20 using Tizen.NUI.BaseComponents;
22 /// Touch events are a collection of points at a specific moment in time.<br />
23 /// When a multi-touch event occurs, each point represents the points that are currently being
24 /// touched or the points where a touch has stopped.<br />
26 public class Touch : BaseHandle
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal Touch(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Touch_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Touch obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43 /// <since_tizen> 3 </since_tizen>
44 protected override void Dispose(DisposeTypes type)
51 if(type == DisposeTypes.Explicit)
54 //Release your own managed resources here.
55 //You should release all of your own disposable objects here.
58 //Release your own unmanaged resources here.
59 //You should not access any managed member here except static instance.
60 //because the execution order of Finalizes is non-deterministic.
62 if (swigCPtr.Handle != global::System.IntPtr.Zero)
67 NDalicPINVOKE.delete_Touch(swigCPtr);
69 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
76 internal static Touch GetTouchFromPtr(global::System.IntPtr cPtr)
78 Touch ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Touch;
81 ret = new Touch(cPtr, false);
84 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89 /// An uninitialized touch instance.<br />
90 /// Calling member functions with an uninitialized touch handle is not allowed.<br />
92 /// <since_tizen> 3 </since_tizen>
93 public Touch() : this(NDalicPINVOKE.new_Touch__SWIG_0(), true)
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98 internal Touch(Touch other) : this(NDalicPINVOKE.new_Touch__SWIG_1(Touch.getCPtr(other)), true)
100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104 /// Returns the time (in ms) that the touch event occurred.
106 /// <returns>The time (in ms) that the touch event occurred.</returns>
107 /// <since_tizen> 3 </since_tizen>
108 public uint GetTime()
110 uint ret = NDalicPINVOKE.Touch_GetTime(swigCPtr);
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 /// Returns the total number of points in this TouchData.
118 /// <returns>The total number of points.</returns>
119 /// <since_tizen> 3 </since_tizen>
120 public uint GetPointCount()
122 uint ret = NDalicPINVOKE.Touch_GetPointCount(swigCPtr);
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128 /// Returns the ID of the device used for the point specified.<br />
129 /// Each point has a unique device ID, which specifies the device used for that
130 /// point. This is returned by this method.<br />
131 /// If a point is greater than GetPointCount(), then this method will return -1.<br />
133 /// <param name="point">The point required.</param>
134 /// <returns>The device ID of this point.</returns>
135 /// <since_tizen> 3 </since_tizen>
136 public int GetDeviceId(uint point)
138 int ret = NDalicPINVOKE.Touch_GetDeviceId(swigCPtr, point);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144 /// Retrieves the state of the point specified.<br />
145 /// If a point is greater than GetPointCount(), then this method will return PointState.Finished.<br />
147 /// <param name="point">The point required.</param>
148 /// <returns>The state of the point specified.</returns>
149 /// <since_tizen> 3 </since_tizen>
150 public PointStateType GetState(uint point)
152 PointStateType ret = (PointStateType)NDalicPINVOKE.Touch_GetState(swigCPtr, point);
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 /// Retrieves the actor that was underneath the point specified.<br />
159 /// If a point is greater than GetPointCount(), then this method will return an empty handle.<br />
161 /// <param name="point">The point required.</param>
162 /// <returns>The actor that was underneath the point specified.</returns>
163 /// <since_tizen> 3 </since_tizen>
164 public View GetHitView(uint point)
166 global::System.IntPtr cPtr = NDalicPINVOKE.Touch_GetHitActor(swigCPtr, point);
167 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 /// Retrieves the coordinates relative to the top-left of the hit actor at the point specified.<br />
175 /// The top-left of an actor is (0.0, 0.0, 0.5).<br />
176 /// If you require the local coordinates of another actor (for example, the parent of the hit actor),
177 /// then you should use Actor::ScreenToLocal().<br />
178 /// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.<br />
180 /// <param name="point">The point required.</param>
181 /// <returns>The coordinates relative to the top-left of the hit actor of the point specified.</returns>
182 /// <since_tizen> 3 </since_tizen>
183 public Vector2 GetLocalPosition(uint point)
185 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetLocalPosition(swigCPtr, point), false);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 /// Retrieves the coordinates relative to the top-left of the screen of the point specified.<br />
192 /// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.<br />
194 /// <param name="point">The point required.</param>
195 /// <returns>The coordinates relative to the top-left of the screen of the point specified.</returns>
196 /// <since_tizen> 3 </since_tizen>
197 public Vector2 GetScreenPosition(uint point)
199 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetScreenPosition(swigCPtr, point), false);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// Retrieves the radius of the press point.<br />
206 /// This is the average of both the horizontal and vertical radii of the press point.<br />
207 /// If point is greater than GetPointCount(), then this method will return 0.0f.<br />
209 /// <param name="point">The point required.</param>
210 /// <returns>The radius of the press point.</returns>
211 /// <since_tizen> 3 </since_tizen>
212 public float GetRadius(uint point)
214 float ret = NDalicPINVOKE.Touch_GetRadius(swigCPtr, point);
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220 /// Retrieves both the horizontal and the vertical radii of the press point.<br />
221 /// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.<br />
223 /// <param name="point">The point required.</param>
224 /// <returns>The horizontal and vertical radii of the press point.</returns>
225 /// <since_tizen> 3 </since_tizen>
226 public Vector2 GetEllipseRadius(uint point)
228 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetEllipseRadius(swigCPtr, point), false);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 /// Retrieves the touch pressure.<br />
235 /// The pressure range starts at 0.0f.<br />
236 /// Normal pressure is defined as 1.0f.<br />
237 /// A value between 0.0f and 1.0f means light pressure has been applied.<br />
238 /// A value greater than 1.0f means more pressure than normal has been applied.<br />
239 /// If point is greater than GetPointCount(), then this method will return 1.0f.<br />
241 /// <param name="point">The point required.</param>
242 /// <returns>The touch pressure.</returns>
243 /// <since_tizen> 3 </since_tizen>
244 public float GetPressure(uint point)
246 float ret = NDalicPINVOKE.Touch_GetPressure(swigCPtr, point);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 internal Degree GetAngle(uint point)
253 Degree ret = new Degree(NDalicPINVOKE.Touch_GetAngle(swigCPtr, point), true);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();