1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 using Tizen.NUI.BaseComponents;
21 /// Touch events are a collection of points at a specific moment in time.<br>
22 /// When a multi-touch event occurs, each point represents the points that are currently being
23 /// touched or the points where a touch has stopped.<br>
25 public class Touch : BaseHandle
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal Touch(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Touch_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Touch obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 protected override void Dispose(DisposeTypes type)
46 if(type == DisposeTypes.Explicit)
49 //Release your own managed resources here.
50 //You should release all of your own disposable objects here.
53 //Release your own unmanaged resources here.
54 //You should not access any managed member here except static instance.
55 //because the execution order of Finalizes is non-deterministic.
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62 NDalicPINVOKE.delete_Touch(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 internal static Touch GetTouchFromPtr(global::System.IntPtr cPtr)
73 Touch ret = new Touch(cPtr, false);
74 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79 /// An uninitialized Touch instance.<br>
80 /// Calling member functions with an uninitialized Touch handle is not allowed.<br>
82 public Touch() : this(NDalicPINVOKE.new_Touch__SWIG_0(), true)
84 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87 internal Touch(Touch other) : this(NDalicPINVOKE.new_Touch__SWIG_1(Touch.getCPtr(other)), true)
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 /// Returns the time (in ms) that the touch event occurred.
95 /// <returns>The time (in ms) that the touch event occurred</returns>
98 uint ret = NDalicPINVOKE.Touch_GetTime(swigCPtr);
99 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104 /// Returns the total number of points in this TouchData.
106 /// <returns>Total number of Points</returns>
107 public uint GetPointCount()
109 uint ret = NDalicPINVOKE.Touch_GetPointCount(swigCPtr);
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 /// Returns the ID of the device used for the Point specified.<br>
116 /// Each point has a unique device ID which specifies the device used for that
117 /// point. This is returned by this method.<br>
118 /// If point is greater than GetPointCount() then this method will return -1.<br>
120 /// <param name="point">The point required</param>
121 /// <returns>The Device ID of this point</returns>
122 public int GetDeviceId(uint point)
124 int ret = NDalicPINVOKE.Touch_GetDeviceId(swigCPtr, point);
125 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 /// Retrieves the State of the point specified.<br>
131 /// If point is greater than GetPointCount() then this method will return PointState.Finished.<br>
133 /// <param name="point">The point required</param>
134 /// <returns>The state of the point specified</returns>
135 public PointStateType GetState(uint point)
137 PointStateType ret = (PointStateType)NDalicPINVOKE.Touch_GetState(swigCPtr, point);
138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 /// Retrieves the actor that was underneath the point specified.<br>
144 /// If point is greater than GetPointCount() then this method will return an empty handle.<br>
146 /// <param name="point">The point required</param>
147 /// <returns>The actor that was underneath the point specified</returns>
148 public View GetHitView(uint point)
150 View ret = new View(NDalicPINVOKE.Touch_GetHitActor(swigCPtr, point), true);
151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 /// Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified.<br>
157 /// The top-left of an actor is (0.0, 0.0, 0.5).<br>
158 /// If you require the local coordinates of another actor (e.g the parent of the hit actor),
159 /// then you should use Actor::ScreenToLocal().<br>
160 /// If point is greater than GetPointCount() then this method will return Vector2.Zero.<br>
162 /// <param name="point">The point required</param>
163 /// <returns>The co-ordinates relative to the top-left of the hit-actor of the point specified</returns>
164 public Vector2 GetLocalPosition(uint point)
166 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetLocalPosition(swigCPtr, point), false);
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 /// Retrieves the co-ordinates relative to the top-left of the screen of the point specified.<br>
173 /// If point is greater than GetPointCount() then this method will return Vector2.Zero.<br>
175 /// <param name="point">The point required</param>
176 /// <returns>The co-ordinates relative to the top-left of the screen of the point specified</returns>
177 public Vector2 GetScreenPosition(uint point)
179 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetScreenPosition(swigCPtr, point), false);
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 /// Retrieves the radius of the press point.<br>
186 /// This is the average of both the horizontal and vertical radii of the press point.<br>
187 /// If point is greater than GetPointCount() then this method will return 0.0f.<br>
189 /// <param name="point">The point required</param>
190 /// <returns>The radius of the press point</returns>
191 public float GetRadius(uint point)
193 float ret = NDalicPINVOKE.Touch_GetRadius(swigCPtr, point);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 /// Retrieves BOTH the horizontal and the vertical radii of the press point.<br>
200 /// If point is greater than GetPointCount() then this method will return Vector2.Zero.<br>
202 /// <param name="point">The point required</param>
203 /// <returns>The horizontal and vertical radii of the press point</returns>
204 public Vector2 GetEllipseRadius(uint point)
206 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetEllipseRadius(swigCPtr, point), false);
207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 /// Retrieves the touch pressure.<br>
213 /// The pressure range starts at 0.0f.<br>
214 /// Normal pressure is defined as 1.0f.<br>
215 /// A value between 0.0f and 1.0f means light pressure has been applied.<br>
216 /// A value greater than 1.0f means more pressure than normal has been applied.<br>
217 /// If point is greater than GetPointCount() then this method will return 1.0f.<br>
219 /// <param name="point">point The point required</param>
220 /// <returns>The touch pressure</returns>
221 public float GetPressure(uint point)
223 float ret = NDalicPINVOKE.Touch_GetPressure(swigCPtr, point);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228 internal Degree GetAngle(uint point)
230 Degree ret = new Degree(NDalicPINVOKE.Touch_GetAngle(swigCPtr, point), true);
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();