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 : global::System.IDisposable
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
37 /// A Flat to check if it is already disposed.
39 /// <since_tizen> 3 </since_tizen>
40 protected bool disposed = false;
42 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
44 //A Flag to check who called Dispose(). (By User or DisposeQueue)
45 private bool isDisposeQueued = false;
48 /// The default constructor.
50 /// <since_tizen> 3 </since_tizen>
51 public Hover() : this(Interop.Hover.new_Hover__SWIG_0(), true)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59 /// <param name="time">The time the event occurred.</param>
60 internal Hover(uint time) : this(Interop.Hover.new_Hover__SWIG_1(time), true)
62 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65 internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn)
67 swigCMemOwn = cMemoryOwn;
68 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
74 /// <since_tizen> 3 </since_tizen>
79 isDisposeQueued = true;
80 DisposeQueue.Instance.Add(this);
85 /// The time (in ms) that the hover event occurred.
87 /// <since_tizen> 3 </since_tizen>
96 private TouchPointContainer points
100 Interop.Hover.Hover_points_set(swigCPtr, TouchPointContainer.getCPtr(value));
101 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 global::System.IntPtr cPtr = Interop.Hover.Hover_points_get(swigCPtr);
106 TouchPointContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new TouchPointContainer(cPtr, false);
107 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 Interop.Hover.Hover_time_set(swigCPtr, value);
117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 uint ret = Interop.Hover.Hover_time_get(swigCPtr);
122 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 />
132 /// <param name="point">The point required.</param>
133 /// <returns>The device ID of this point.</returns>
134 /// <since_tizen> 3 </since_tizen>
135 public int GetDeviceId(uint point)
137 if (point < points.Count)
139 return points[(int)point].DeviceId;
145 /// Retrieves the state of the point specified.
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 if (point < points.Count)
154 return (Tizen.NUI.PointStateType)(points[(int)point].State);
156 return PointStateType.Finished;
160 /// Retrieves the view that was underneath the point specified.
162 /// <param name="point">The point required.</param>
163 /// <returns>The view that was underneath the point specified.</returns>
164 /// <since_tizen> 3 </since_tizen>
165 public View GetHitView(uint point)
167 if (point < points.Count)
169 return points[(int)point].HitView;
173 // Return a native empty handle
174 View view = new View();
181 /// Retrieves the coordinates relative to the top-left of the hit-view at the point specified.
183 /// <param name="point">The point required.</param>
184 /// <returns>The coordinates relative to the top-left of the hit-view of the point specified.</returns>
185 /// <since_tizen> 3 </since_tizen>
186 public Vector2 GetLocalPosition(uint point)
188 if (point < points.Count)
190 return points[(int)point].Local;
192 return new Vector2(0.0f, 0.0f);
196 /// Retrieves the coordinates relative to the top-left of the screen of the point specified.
198 /// <param name="point">The point required.</param>
199 /// <returns>The coordinates relative to the top-left of the screen of the point specified.</returns>
200 /// <since_tizen> 3 </since_tizen>
201 public Vector2 GetScreenPosition(uint point)
203 if (point < points.Count)
205 return points[(int)point].Screen;
207 return new Vector2(0.0f, 0.0f);
211 /// Returns the total number of points.
213 /// <returns>Total number of points.</returns>
214 /// <since_tizen> 3 </since_tizen>
215 public uint GetPointCount()
217 uint ret = Interop.Hover.Hover_GetPointCount(swigCPtr);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 /// <since_tizen> 3 </since_tizen>
226 public void Dispose()
228 //Throw excpetion if Dispose() is called in separate thread.
229 if (!Window.IsInstalled())
231 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
236 Dispose(DisposeTypes.Implicit);
240 Dispose(DisposeTypes.Explicit);
241 System.GC.SuppressFinalize(this);
245 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Hover obj)
247 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
250 internal static Hover GetHoverFromPtr(global::System.IntPtr cPtr)
252 Hover ret = new Hover(cPtr, false);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 internal TouchPoint GetPoint(uint point)
259 TouchPoint ret = new TouchPoint(Interop.Hover.Hover_GetPoint(swigCPtr, point), false);
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 /// <since_tizen> 3 </since_tizen>
268 protected virtual void Dispose(DisposeTypes type)
275 if (type == DisposeTypes.Explicit)
278 //Release your own managed resources here.
279 //You should release all of your own disposable objects here.
282 //Release your own unmanaged resources here.
283 //You should not access any managed member here except static instance.
284 //because the execution order of Finalizes is non-deterministic.
286 if (swigCPtr.Handle != global::System.IntPtr.Zero)
291 Interop.Hover.delete_Hover(swigCPtr);
293 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);