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.
18 using Tizen.NUI.BaseComponents;
23 /// Hover events are a collection of points at a specific moment in time.<br />
24 /// When a multi-event occurs, each point represents the points that are currently being
25 /// hovered or the points where a hover has stopped.<br />
27 /// <since_tizen> 3 </since_tizen>
28 public class Hover : Disposable
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
36 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
39 /// The default constructor.
41 /// <since_tizen> 3 </since_tizen>
42 public Hover() : this(Interop.Hover.new_Hover__SWIG_0(), true)
44 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50 /// <param name="time">The time the event occurred.</param>
51 internal Hover(uint time) : this(Interop.Hover.new_Hover__SWIG_1(time), true)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56 internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn)
58 swigCMemOwn = cMemoryOwn;
59 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
63 /// The time (in ms) that the hover event occurred.
65 /// <since_tizen> 3 </since_tizen>
74 private TouchPointContainer points
78 Interop.Hover.Hover_points_set(swigCPtr, TouchPointContainer.getCPtr(value));
79 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83 global::System.IntPtr cPtr = Interop.Hover.Hover_points_get(swigCPtr);
84 TouchPointContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new TouchPointContainer(cPtr, false);
85 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94 Interop.Hover.Hover_time_set(swigCPtr, value);
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99 uint ret = Interop.Hover.Hover_time_get(swigCPtr);
100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 /// Returns the ID of the device used for the point specified.<br />
107 /// Each point has a unique device ID which specifies the device used for that
108 /// point. This is returned by this method.<br />
110 /// <param name="point">The point required.</param>
111 /// <returns>The device ID of this point.</returns>
112 /// <since_tizen> 3 </since_tizen>
113 public int GetDeviceId(uint point)
115 if (point < points.Count)
117 return points[(int)point].DeviceId;
123 /// Retrieves the state of the point specified.
125 /// <param name="point">The point required.</param>
126 /// <returns>The state of the point specified.</returns>
127 /// <since_tizen> 3 </since_tizen>
128 public PointStateType GetState(uint point)
130 if (point < points.Count)
132 return (Tizen.NUI.PointStateType)(points[(int)point].State);
134 return PointStateType.Finished;
138 /// Retrieves the view that was underneath the point specified.
140 /// <param name="point">The point required.</param>
141 /// <returns>The view that was underneath the point specified.</returns>
142 /// <since_tizen> 3 </since_tizen>
143 public View GetHitView(uint point)
145 if (point < points.Count)
147 return points[(int)point].HitView;
151 // Return a native empty handle
152 View view = new View();
159 /// Retrieves the coordinates relative to the top-left of the hit-view at the point specified.
161 /// <param name="point">The point required.</param>
162 /// <returns>The coordinates relative to the top-left of the hit-view of the point specified.</returns>
163 /// <since_tizen> 3 </since_tizen>
164 public Vector2 GetLocalPosition(uint point)
166 if (point < points.Count)
168 return points[(int)point].Local;
170 return new Vector2(0.0f, 0.0f);
174 /// Retrieves the coordinates relative to the top-left of the screen of the point specified.
176 /// <param name="point">The point required.</param>
177 /// <returns>The coordinates relative to the top-left of the screen of the point specified.</returns>
178 /// <since_tizen> 3 </since_tizen>
179 public Vector2 GetScreenPosition(uint point)
181 if (point < points.Count)
183 return points[(int)point].Screen;
185 return new Vector2(0.0f, 0.0f);
189 /// Returns the total number of points.
191 /// <returns>Total number of points.</returns>
192 /// <since_tizen> 3 </since_tizen>
193 public uint GetPointCount()
195 uint ret = Interop.Hover.Hover_GetPointCount(swigCPtr);
196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Hover obj)
202 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
205 internal static Hover GetHoverFromPtr(global::System.IntPtr cPtr)
207 Hover ret = new Hover(cPtr, false);
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 internal TouchPoint GetPoint(uint point)
214 TouchPoint ret = new TouchPoint(Interop.Hover.Hover_GetPoint(swigCPtr, point), false);
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 /// <since_tizen> 3 </since_tizen>
223 protected override void Dispose(DisposeTypes type)
230 //Release your own unmanaged resources here.
231 //You should not access any managed member here except static instance.
232 //because the execution order of Finalizes is non-deterministic.
234 if (swigCPtr.Handle != global::System.IntPtr.Zero)
239 Interop.Hover.delete_Hover(swigCPtr);
241 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);