a91916f675b9cc36b3db4ff270514b445fcd2e02
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / TouchPoint.cs
1 /*
2  * Copyright(c) 2017 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 Tizen.NUI.BaseComponents;
18
19 namespace Tizen.NUI
20 {
21     internal class TouchPoint : Disposable
22     {
23         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
24         protected bool swigCMemOwn;
25
26         internal TouchPoint(global::System.IntPtr cPtr, bool cMemoryOwn)
27         {
28             swigCMemOwn = cMemoryOwn;
29             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
30         }
31
32         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TouchPoint obj)
33         {
34             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35         }
36
37         protected override void Dispose(DisposeTypes type)
38         {
39             if (disposed)
40             {
41                 return;
42             }
43
44             //Release your own unmanaged resources here.
45             //You should not access any managed member here except static instance.
46             //because the execution order of Finalizes is non-deterministic.
47
48             if (swigCPtr.Handle != global::System.IntPtr.Zero)
49             {
50                 if (swigCMemOwn)
51                 {
52                     swigCMemOwn = false;
53                     Interop.TouchPoint.delete_TouchPoint(swigCPtr);
54                 }
55                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
56             }
57
58             base.Dispose(type);
59         }
60
61
62         public TouchPoint(int id, TouchPoint.StateType state, float screenX, float screenY) : this(Interop.TouchPoint.new_TouchPoint__SWIG_0(id, (int)state, screenX, screenY), true)
63         {
64             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65         }
66
67         public TouchPoint(int id, TouchPoint.StateType state, float screenX, float screenY, float localX, float localY) : this(Interop.TouchPoint.new_TouchPoint__SWIG_1(id, (int)state, screenX, screenY, localX, localY), true)
68         {
69             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
70         }
71
72         public int DeviceId
73         {
74             set
75             {
76                 Interop.TouchPoint.TouchPoint_deviceId_set(swigCPtr, value);
77                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78             }
79             get
80             {
81                 int ret = Interop.TouchPoint.TouchPoint_deviceId_get(swigCPtr);
82                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83                 return ret;
84             }
85         }
86
87         public TouchPoint.StateType State
88         {
89             set
90             {
91                 Interop.TouchPoint.TouchPoint_state_set(swigCPtr, (int)value);
92                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93             }
94             get
95             {
96                 TouchPoint.StateType ret = (TouchPoint.StateType)Interop.TouchPoint.TouchPoint_state_get(swigCPtr);
97                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98                 return ret;
99             }
100         }
101
102         public View HitView
103         {
104             set
105             {
106                 Interop.TouchPoint.TouchPoint_hitActor_set(swigCPtr, View.getCPtr(value));
107                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108             }
109             get
110             {
111                 global::System.IntPtr cPtr = Interop.TouchPoint.TouchPoint_hitActor_get(swigCPtr);
112                 View ret = (cPtr == global::System.IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
113                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114                 return ret;
115             }
116         }
117
118         public Vector2 Local
119         {
120             set
121             {
122                 Interop.TouchPoint.TouchPoint_local_set(swigCPtr, Vector2.getCPtr(value));
123                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124             }
125             get
126             {
127                 global::System.IntPtr cPtr = Interop.TouchPoint.TouchPoint_local_get(swigCPtr);
128                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
129                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130                 return ret;
131             }
132         }
133
134         public Vector2 Screen
135         {
136             set
137             {
138                 Interop.TouchPoint.TouchPoint_screen_set(swigCPtr, Vector2.getCPtr(value));
139                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140             }
141             get
142             {
143                 global::System.IntPtr cPtr = Interop.TouchPoint.TouchPoint_screen_get(swigCPtr);
144                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
145                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146                 return ret;
147             }
148         }
149
150         /// <since_tizen> 3 </since_tizen>
151         public enum StateType
152         {
153             Started,
154             Finished,
155             Down = Started,
156             Up = Finished,
157             Motion,
158             Leave,
159             Stationary,
160             Interrupted,
161             Last
162         }
163     }
164 }