[NUI] bug fixed about cMemoryOwn
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / Hover.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// Hover events are a collection of points at a specific moment in time.<br />
25     /// When a multi-event occurs, each point represents the points that are currently being
26     /// hovered or the points where a hover has stopped.<br />
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public class Hover : BaseHandle
30     {
31
32         /// <summary>
33         /// The default constructor.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         public Hover() : this(Interop.Hover.New(0u), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         /// <summary>
42         /// The constructor.
43         /// </summary>
44         /// <param name="time">The time the event occurred.</param>
45         internal Hover(uint time) : this(Interop.Hover.New(time), true)
46         {
47             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
48         }
49
50         internal Hover(Hover other) : this(Interop.Hover.NewHover(Hover.getCPtr(other)), true)
51         {
52             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53         }
54
55         internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
56         {
57         }
58
59         internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
60         {
61         }
62
63         /// <summary>
64         /// The time (in ms) that the hover event occurred.
65         /// </summary>
66         /// <since_tizen> 3 </since_tizen>
67         public uint Time
68         {
69             get
70             {
71                 uint ret = Interop.Hover.GetTime(SwigCPtr);
72                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
73                 return ret;
74             }
75         }
76
77         /// <summary>
78         /// Returns the ID of the device used for the point specified.<br />
79         /// Each point has a unique device ID which specifies the device used for that
80         /// point. This is returned by this method.<br />
81         /// If a point is greater than GetPointCount(), then this method will return -1.<br />
82         /// </summary>
83         /// <param name="point">The point required.</param>
84         /// <returns>The device ID of this point.</returns>
85         /// <since_tizen> 3 </since_tizen>
86         public int GetDeviceId(uint point)
87         {
88             int ret = Interop.Hover.GetDeviceId(SwigCPtr, point);
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90             return ret;
91         }
92
93         /// <summary>
94         /// Retrieves the state of the point specified.<br />
95         /// If a point is greater than GetPointCount(), then this method will return PointState.Finished.<br />
96         /// </summary>
97         /// <param name="point">The point required.</param>
98         /// <returns>The state of the point specified.</returns>
99         /// <since_tizen> 3 </since_tizen>
100         public PointStateType GetState(uint point)
101         {
102             PointStateType ret = (PointStateType)Interop.Hover.GetState(SwigCPtr, point);
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104             return ret;
105         }
106
107         /// <summary>
108         /// Retrieves the view that was underneath the point specified.<br />
109         /// If a point is greater than GetPointCount(), then this method will return an empty handle.<br />
110         /// </summary>
111         /// <param name="point">The point required.</param>
112         /// <returns>The view that was underneath the point specified.</returns>
113         /// <since_tizen> 3 </since_tizen>
114         public View GetHitView(uint point)
115         {
116             global::System.IntPtr cPtr = Interop.Hover.GetHitActor(SwigCPtr, point);
117             View ret = this.GetInstanceSafely<View>(cPtr);
118             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119             return ret;
120         }
121
122         /// <summary>
123         /// Retrieves the coordinates relative to the top-left of the hit-view at the point specified.
124         /// </summary>
125         /// <param name="point">The point required.</param>
126         /// <returns>The coordinates relative to the top-left of the hit-view of the point specified.</returns>
127         /// <since_tizen> 3 </since_tizen>
128         public Vector2 GetLocalPosition(uint point)
129         {
130             Vector2 ret = new Vector2(Interop.Hover.GetLocalPosition(SwigCPtr, point), false);
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132             return ret;
133         }
134
135         /// <summary>
136         /// Retrieves the coordinates relative to the top-left of the screen of the point specified.
137         /// </summary>
138         /// <param name="point">The point required.</param>
139         /// <returns>The coordinates relative to the top-left of the screen of the point specified.</returns>
140         /// <since_tizen> 3 </since_tizen>
141         public Vector2 GetScreenPosition(uint point)
142         {
143             Vector2 ret = new Vector2(Interop.Hover.GetScreenPosition(SwigCPtr, point), false);
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145             return ret;
146         }
147
148         /// <summary>
149         /// Returns the total number of points.
150         /// </summary>
151         /// <returns>Total number of points.</returns>
152         /// <since_tizen> 3 </since_tizen>
153         public uint GetPointCount()
154         {
155             uint ret = Interop.Hover.GetPointCount(SwigCPtr);
156             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157             return ret;
158         }
159
160         internal static Hover GetHoverFromPtr(global::System.IntPtr cPtr)
161         {
162             Hover ret = new Hover(cPtr, false);
163             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164             return ret;
165         }
166
167         /// This will not be public opened.
168         [EditorBrowsable(EditorBrowsableState.Never)]
169         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
170         {
171             Interop.Hover.DeleteHover(swigCPtr);
172         }
173     }
174 }