/* * Copyright(c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System.ComponentModel; using System.Runtime.InteropServices; using Tizen.NUI.BaseComponents; namespace Tizen.NUI { /// /// Touch events are a collection of points at a specific moment in time.
/// When a multi-touch event occurs, each point represents the points that are currently being /// touched or the points where a touch has stopped.
///
/// 3 public class Touch : BaseHandle { private global::System.Runtime.InteropServices.HandleRef swigCPtr; /// /// An uninitialized touch instance.
/// Calling member functions with an uninitialized touch handle is not allowed.
///
/// 3 public Touch() : this(Interop.Touch.new_Touch__SWIG_0(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Touch(Touch other) : this(Interop.Touch.new_Touch__SWIG_1(Touch.getCPtr(other)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Touch(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Touch.Touch_SWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } /// /// Returns the time (in ms) that the touch event occurred. /// /// The time (in ms) that the touch event occurred. /// 3 public uint GetTime() { uint ret = Interop.Touch.Touch_GetTime(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Returns the total number of points in this TouchData. /// /// The total number of points. /// 3 public uint GetPointCount() { uint ret = Interop.Touch.Touch_GetPointCount(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Returns the ID of the device used for the point specified.
/// Each point has a unique device ID, which specifies the device used for that /// point. This is returned by this method.
/// If a point is greater than GetPointCount(), then this method will return -1.
///
/// The point required. /// The device ID of this point. /// 3 public int GetDeviceId(uint point) { int ret = Interop.Touch.Touch_GetDeviceId(swigCPtr, point); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the state of the point specified.
/// If a point is greater than GetPointCount(), then this method will return PointState.Finished.
///
/// The point required. /// The state of the point specified. /// 3 public PointStateType GetState(uint point) { PointStateType ret = (PointStateType)Interop.Touch.Touch_GetState(swigCPtr, point); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the actor that was underneath the point specified.
/// If a point is greater than GetPointCount(), then this method will return an empty handle.
///
/// The point required. /// The actor that was underneath the point specified. /// 3 public View GetHitView(uint point) { //to fix memory leak issue, match the handle count with native side. global::System.IntPtr cPtr = Interop.Touch.Touch_GetHitActor(swigCPtr, point); HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View; Interop.BaseHandle.delete_BaseHandle(CPtr); CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the coordinates relative to the top-left of the hit actor at the point specified.
/// The top-left of an actor is (0.0, 0.0, 0.5).
/// If you require the local coordinates of another actor (for example, the parent of the hit actor), /// then you should use Actor::ScreenToLocal().
/// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.
///
/// The point required. /// The coordinates relative to the top-left of the hit actor of the point specified. /// 3 public Vector2 GetLocalPosition(uint point) { Vector2 ret = new Vector2(Interop.Touch.Touch_GetLocalPosition(swigCPtr, point), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the coordinates relative to the top-left of the screen of the point specified.
/// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.
///
/// The point required. /// The coordinates relative to the top-left of the screen of the point specified. /// 3 public Vector2 GetScreenPosition(uint point) { Vector2 ret = new Vector2(Interop.Touch.Touch_GetScreenPosition(swigCPtr, point), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the radius of the press point.
/// This is the average of both the horizontal and vertical radii of the press point.
/// If point is greater than GetPointCount(), then this method will return 0.0f.
///
/// The point required. /// The radius of the press point. /// 3 public float GetRadius(uint point) { float ret = Interop.Touch.Touch_GetRadius(swigCPtr, point); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves both the horizontal and the vertical radii of the press point.
/// If a point is greater than GetPointCount(), then this method will return Vector2.Zero.
///
/// The point required. /// The horizontal and vertical radii of the press point. /// 3 public Vector2 GetEllipseRadius(uint point) { Vector2 ret = new Vector2(Interop.Touch.Touch_GetEllipseRadius(swigCPtr, point), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the touch pressure.
/// The pressure range starts at 0.0f.
/// Normal pressure is defined as 1.0f.
/// A value between 0.0f and 1.0f means light pressure has been applied.
/// A value greater than 1.0f means more pressure than normal has been applied.
/// If point is greater than GetPointCount(), then this method will return 1.0f.
///
/// The point required. /// The touch pressure. /// 3 public float GetPressure(uint point) { float ret = Interop.Touch.Touch_GetPressure(swigCPtr, point); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Get mouse device's button value (for example, right or left button) /// /// The point required. /// /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public MouseButton GetMouseButton(uint point) { int ret = Interop.Touch.Touch_GetMouseButton(swigCPtr, point); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return (MouseButton)ret; } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Touch obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } internal static Touch GetTouchFromPtr(global::System.IntPtr cPtr) { Touch ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Touch; if (ret == null) { ret = new Touch(cPtr, false); } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public Degree GetAngle(uint point) { Degree ret = new Degree(Interop.Touch.Touch_GetAngle(swigCPtr, point), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Dispose. /// /// 3 protected override void Dispose(DisposeTypes type) { if (disposed) { return; } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; Interop.Touch.delete_Touch(swigCPtr); } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } base.Dispose(type); } } /// /// Mouse device button type. /// /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public enum MouseButton { /// /// No mouse button event or invalid data. /// /// 5 Invalid = -1, /// /// Primary(Left) mouse button. /// /// 5 Primary = 1, /// /// Secondary(Right) mouse button. /// /// 5 Secondary = 3, /// /// Center(Wheel) mouse button. /// /// 5 Tertiary = 2, } }