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 = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Touch;
76 ret = new Touch(cPtr, false);
79 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 /// An uninitialized touch instance.<br>
85 /// Calling member functions with an uninitialized touch handle is not allowed.<br>
87 public Touch() : this(NDalicPINVOKE.new_Touch__SWIG_0(), true)
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92 internal Touch(Touch other) : this(NDalicPINVOKE.new_Touch__SWIG_1(Touch.getCPtr(other)), true)
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98 /// Returns the time (in ms) that the touch event occurred.
100 /// <returns>The time (in ms) that the touch event occurred.</returns>
101 public uint GetTime()
103 uint ret = NDalicPINVOKE.Touch_GetTime(swigCPtr);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109 /// Returns the total number of points in this TouchData.
111 /// <returns>The total number of points.</returns>
112 public uint GetPointCount()
114 uint ret = NDalicPINVOKE.Touch_GetPointCount(swigCPtr);
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120 /// Returns the ID of the device used for the point specified.<br>
121 /// Each point has a unique device ID, which specifies the device used for that
122 /// point. This is returned by this method.<br>
123 /// If a point is greater than GetPointCount(), then this method will return -1.<br>
125 /// <param name="point">The point required.</param>
126 /// <returns>The device ID of this point.</returns>
127 public int GetDeviceId(uint point)
129 int ret = NDalicPINVOKE.Touch_GetDeviceId(swigCPtr, point);
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 /// Retrieves the state of the point specified.<br>
136 /// If a point is greater than GetPointCount(), then this method will return PointState.Finished.<br>
138 /// <param name="point">The point required.</param>
139 /// <returns>The state of the point specified.</returns>
140 public PointStateType GetState(uint point)
142 PointStateType ret = (PointStateType)NDalicPINVOKE.Touch_GetState(swigCPtr, point);
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 /// Retrieves the actor that was underneath the point specified.<br>
149 /// If a point is greater than GetPointCount(), then this method will return an empty handle.<br>
151 /// <param name="point">The point required.</param>
152 /// <returns>The actor that was underneath the point specified.</returns>
153 public View GetHitView(uint point)
155 global::System.IntPtr cPtr = NDalicPINVOKE.Touch_GetHitActor(swigCPtr, point);
156 View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 /// Retrieves the coordinates relative to the top-left of the hit actor at the point specified.<br>
164 /// The top-left of an actor is (0.0, 0.0, 0.5).<br>
165 /// If you require the local coordinates of another actor (for example, the parent of the hit actor),
166 /// then you should use Actor::ScreenToLocal().<br>
167 /// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.<br>
169 /// <param name="point">The point required.</param>
170 /// <returns>The coordinates relative to the top-left of the hit actor of the point specified.</returns>
171 public Vector2 GetLocalPosition(uint point)
173 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetLocalPosition(swigCPtr, point), false);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 /// Retrieves the coordinates relative to the top-left of the screen of the point specified.<br>
180 /// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.<br>
182 /// <param name="point">The point required.</param>
183 /// <returns>The coordinates relative to the top-left of the screen of the point specified.</returns>
184 public Vector2 GetScreenPosition(uint point)
186 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetScreenPosition(swigCPtr, point), false);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 /// Retrieves the radius of the press point.<br>
193 /// This is the average of both the horizontal and vertical radii of the press point.<br>
194 /// If point is greater than GetPointCount(), then this method will return 0.0f.<br>
196 /// <param name="point">The point required.</param>
197 /// <returns>The radius of the press point.</returns>
198 public float GetRadius(uint point)
200 float ret = NDalicPINVOKE.Touch_GetRadius(swigCPtr, point);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 /// Retrieves both the horizontal and the vertical radii of the press point.<br>
207 /// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.<br>
209 /// <param name="point">The point required.</param>
210 /// <returns>The horizontal and vertical radii of the press point.</returns>
211 public Vector2 GetEllipseRadius(uint point)
213 Vector2 ret = new Vector2(NDalicPINVOKE.Touch_GetEllipseRadius(swigCPtr, point), false);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// Retrieves the touch pressure.<br>
220 /// The pressure range starts at 0.0f.<br>
221 /// Normal pressure is defined as 1.0f.<br>
222 /// A value between 0.0f and 1.0f means light pressure has been applied.<br>
223 /// A value greater than 1.0f means more pressure than normal has been applied.<br>
224 /// If point is greater than GetPointCount(), then this method will return 1.0f.<br>
226 /// <param name="point">The point required.</param>
227 /// <returns>The touch pressure.</returns>
228 public float GetPressure(uint point)
230 float ret = NDalicPINVOKE.Touch_GetPressure(swigCPtr, point);
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235 internal Degree GetAngle(uint point)
237 Degree ret = new Degree(NDalicPINVOKE.Touch_GetAngle(swigCPtr, point), true);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();