[NUI] Fix Registry exception for custom view wrapper
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Events / Gesture.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.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// Base structure for different gestures that an application can receive.<br />
23     /// A Gesture is an event that is produced from a combination of several touch events
24     /// in a particular order or within a certain time frame (for example, pinch).<br />
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class Gesture : BaseHandle
28     {
29
30         /// <summary>
31         /// The Copy constructor.
32         /// </summary>
33         /// <param name="rhs">A reference to the copied handle</param>
34         /// <since_tizen> 3 </since_tizen>
35         public Gesture(Gesture rhs) : this(Interop.Gesture.NewGesture(Gesture.getCPtr(rhs)), true)
36         {
37             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38         }
39
40         internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
41         {
42         }
43
44         internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
45         {
46         }
47
48         /// <summary>
49         /// Enumeration for type of gesture.
50         /// </summary>
51         /// <since_tizen> 3 </since_tizen>
52         public enum GestureType
53         {
54             /// <summary>
55             /// When two touch points move away or towards each other.
56             /// </summary>
57             /// <since_tizen> 3 </since_tizen>
58             Pinch = 1 << 0,
59             /// <summary>
60             /// When the user drags their finger(s) in a particular direction.
61             /// </summary>
62             /// <since_tizen> 3 </since_tizen>
63             Pan = 1 << 1,
64             /// <summary>
65             /// When the user taps the screen.
66             /// </summary>
67             /// <since_tizen> 3 </since_tizen>
68             Tap = 1 << 2,
69             /// <summary>
70             ///  When the user continues to touch the same area on the screen for the device configured time.
71             /// </summary>
72             /// <since_tizen> 3 </since_tizen>
73             LongPress = 1 << 3
74         }
75
76         /// <summary>
77         /// Enumeration for state of the gesture.
78         /// </summary>
79         /// <since_tizen> 3 </since_tizen>
80         public enum StateType
81         {
82             /// <summary>
83             /// There is no state associated with this gesture.
84             /// </summary>
85             /// <since_tizen> 3 </since_tizen>
86             Clear,
87             /// <summary>
88             /// The touched points on the screen have moved enough to be considered a gesture.
89             /// </summary>
90             /// <since_tizen> 3 </since_tizen>
91             Started,
92             /// <summary>
93             /// The gesture is continuing.
94             /// </summary>
95             /// <since_tizen> 3 </since_tizen>
96             Continuing,
97             /// <summary>
98             /// The user has lifted a finger or touched an additional point on the screen.
99             /// </summary>
100             /// <since_tizen> 3 </since_tizen>
101             Finished,
102             /// <summary>
103             /// The gesture has been cancelled.
104             /// </summary>
105             /// <since_tizen> 3 </since_tizen>
106             Cancelled,
107             /// <summary>
108             ///  A gesture is possible.
109             /// </summary>
110             /// <since_tizen> 3 </since_tizen>
111             Possible
112         }
113
114         /// <summary>
115         /// This is the value of which source the gesture was started with. (ex : mouse)
116         /// </summary>
117         [EditorBrowsable(EditorBrowsableState.Never)]
118         public enum SourceType
119         {
120             /// <summary>
121             /// invalid data.
122             /// </summary>
123             [EditorBrowsable(EditorBrowsableState.Never)]
124             Invalid,
125             /// <summary>
126             /// Mouse.
127             /// </summary>
128             [EditorBrowsable(EditorBrowsableState.Never)]
129             Mouse,
130             /// <summary>
131             /// Touch.
132             /// </summary>
133             [EditorBrowsable(EditorBrowsableState.Never)]
134             Touch,
135         }
136
137         /// <summary>
138         /// This is the data of source type
139         /// </summary>
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         public enum SourceDataType
142         {
143             /// <summary>
144             /// invalid data.
145             /// </summary>
146             [EditorBrowsable(EditorBrowsableState.Never)]
147             Invalid = -1,
148             /// <summary>
149             /// Primary(Left) mouse button.
150             /// </summary>
151             [EditorBrowsable(EditorBrowsableState.Never)]
152             MousePrimary = 1,
153             /// <summary>
154             /// Secondary(Right) mouse button.
155             /// </summary>
156             [EditorBrowsable(EditorBrowsableState.Never)]
157             MouseSecondary = 3,
158             /// <summary>
159             /// Tertiary(Third) mouse button.
160             /// </summary>
161             [EditorBrowsable(EditorBrowsableState.Never)]
162             MouseTertiary = 2,
163         }
164
165         /// <summary>
166         /// The gesture type.
167         /// </summary>
168         /// <since_tizen> 3 </since_tizen>
169         public Gesture.GestureType Type
170         {
171             get
172             {
173                 return type;
174             }
175         }
176
177         /// <summary>
178         /// The gesture state.
179         /// </summary>
180         /// <since_tizen> 3 </since_tizen>
181         public Gesture.StateType State
182         {
183             get
184             {
185                 return state;
186             }
187         }
188
189         /// <summary>
190         /// The time the gesture took place.
191         /// </summary>
192         /// <since_tizen> 3 </since_tizen>
193         public uint Time
194         {
195             get
196             {
197                 return time;
198             }
199         }
200
201         /// <summary>
202         /// This is the property of which source type the gesture (read-only).
203         /// If you started the gesture with the mouse, it will tell you what type of mouse it is.
204         /// </summary>
205         [EditorBrowsable(EditorBrowsableState.Never)]
206         public Gesture.SourceType Source
207         {
208             get
209             {
210                 return sourceType;
211             }
212         }
213
214         /// <summary>
215         /// This is a property of the source type data (read-only).
216         /// If you started the gesture with the mouse, it will tell you which mouse button you started the gesture with.
217         /// </summary>
218         [EditorBrowsable(EditorBrowsableState.Never)]
219         public Gesture.SourceDataType SourceData
220         {
221             get
222             {
223                 return sourceDataType;
224             }
225         }
226
227         private Gesture.GestureType type
228         {
229             set
230             {
231                 Interop.Gesture.TypeSet(SwigCPtr, (int)value);
232                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233             }
234             get
235             {
236                 Gesture.GestureType ret = (Gesture.GestureType)Interop.Gesture.TypeGet(SwigCPtr);
237                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238                 return ret;
239             }
240         }
241
242         private Gesture.StateType state
243         {
244             set
245             {
246                 Interop.Gesture.StateSet(SwigCPtr, (int)value);
247                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248             }
249             get
250             {
251                 Gesture.StateType ret = (Gesture.StateType)Interop.Gesture.StateGet(SwigCPtr);
252                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253                 return ret;
254             }
255         }
256
257         private uint time
258         {
259             set
260             {
261                 Interop.Gesture.TimeSet(SwigCPtr, value);
262                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263             }
264             get
265             {
266                 uint ret = Interop.Gesture.TimeGet(SwigCPtr);
267                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268                 return ret;
269             }
270         }
271
272         private Gesture.SourceType sourceType
273         {
274             get
275             {
276                 Gesture.SourceType ret = (Gesture.SourceType)Interop.Gesture.SourceTypeGet(SwigCPtr);
277                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278                 return ret;
279             }
280         }
281
282         private Gesture.SourceDataType sourceDataType
283         {
284             get
285             {
286                 Gesture.SourceDataType ret = (Gesture.SourceDataType)Interop.Gesture.SourceDataGet(SwigCPtr);
287                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288                 return ret;
289             }
290         }
291
292         internal static Gesture GetGestureFromPtr(global::System.IntPtr cPtr)
293         {
294             Gesture ret = new Gesture(cPtr, false);
295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296             return ret;
297         }
298
299         /// This will not be public opened.
300         [EditorBrowsable(EditorBrowsableState.Never)]
301         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
302         {
303             Interop.Gesture.DeleteGesture(swigCPtr);
304         }
305     }
306
307 }