Ensuring that Registry.Unregister is called from the most derived class before the...
[platform/core/csapi/nui.git] / Tizen.NUI / src / internal / Camera.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     internal class Camera : Animatable
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23
24         internal Camera(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.CameraActor_SWIGUpcast(cPtr), cMemoryOwn)
25         {
26             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
27         }
28
29         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Camera obj)
30         {
31             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
32         }
33
34         protected override void Dispose(DisposeTypes type)
35         {
36             if (disposed)
37             {
38                 return;
39             }
40
41             if (type == DisposeTypes.Explicit)
42             {
43                 //Called by User
44                 //Release your own managed resources here.
45                 //You should release all of your own disposable objects here.
46
47             }
48
49             //Release your own unmanaged resources here.
50             //You should not access any managed member here except static instance.
51             //because the execution order of Finalizes is non-deterministic.
52
53             if (swigCPtr.Handle != global::System.IntPtr.Zero)
54             {
55                 if (swigCMemOwn)
56                 {
57                     swigCMemOwn = false;
58
59                     //Unreference this instance from Registry.
60                     Registry.Unregister(this);
61
62                     NDalicPINVOKE.delete_CameraActor(swigCPtr);
63                 }
64                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65             }
66
67             base.Dispose(type);
68         }
69
70
71
72         public class Property : global::System.IDisposable
73         {
74             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
75             protected bool swigCMemOwn;
76
77             internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
78             {
79                 swigCMemOwn = cMemoryOwn;
80                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
81             }
82
83             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
84             {
85                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
86             }
87
88             //A Flag to check who called Dispose(). (By User or DisposeQueue)
89             private bool isDisposeQueued = false;
90             //A Flat to check if it is already disposed.
91             protected bool disposed = false;
92
93             ~Property()
94             {
95                 if (!isDisposeQueued)
96                 {
97                     isDisposeQueued = true;
98                     DisposeQueue.Instance.Add(this);
99                 }
100             }
101
102             public void Dispose()
103             {
104                 //Throw excpetion if Dispose() is called in separate thread.
105                 if (!Window.IsInstalled())
106                 {
107                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
108                 }
109
110                 if (isDisposeQueued)
111                 {
112                     Dispose(DisposeTypes.Implicit);
113                 }
114                 else
115                 {
116                     Dispose(DisposeTypes.Explicit);
117                     System.GC.SuppressFinalize(this);
118                 }
119             }
120
121             protected virtual void Dispose(DisposeTypes type)
122             {
123                 if (disposed)
124                 {
125                     return;
126                 }
127
128                 if (type == DisposeTypes.Explicit)
129                 {
130                     //Called by User
131                     //Release your own managed resources here.
132                     //You should release all of your own disposable objects here.
133
134                 }
135
136                 //Release your own unmanaged resources here.
137                 //You should not access any managed member here except static instance.
138                 //because the execution order of Finalizes is non-deterministic.
139
140                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
141                 {
142                     if (swigCMemOwn)
143                     {
144                         swigCMemOwn = false;
145                         NDalicPINVOKE.delete_CameraActor_Property(swigCPtr);
146                     }
147                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
148                 }
149
150                 disposed = true;
151             }
152
153
154             public Property() : this(NDalicPINVOKE.new_CameraActor_Property(), true)
155             {
156                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157             }
158
159             public static readonly int TYPE = NDalicPINVOKE.CameraActor_Property_TYPE_get();
160             public static readonly int PROJECTION_MODE = NDalicPINVOKE.CameraActor_Property_PROJECTION_MODE_get();
161             public static readonly int FIELD_OF_VIEW = NDalicPINVOKE.CameraActor_Property_FIELD_OF_VIEW_get();
162             public static readonly int ASPECT_RATIO = NDalicPINVOKE.CameraActor_Property_ASPECT_RATIO_get();
163             public static readonly int NEAR_PLANE_DISTANCE = NDalicPINVOKE.CameraActor_Property_NEAR_PLANE_DISTANCE_get();
164             public static readonly int FAR_PLANE_DISTANCE = NDalicPINVOKE.CameraActor_Property_FAR_PLANE_DISTANCE_get();
165             public static readonly int LEFT_PLANE_DISTANCE = NDalicPINVOKE.CameraActor_Property_LEFT_PLANE_DISTANCE_get();
166             public static readonly int RIGHT_PLANE_DISTANCE = NDalicPINVOKE.CameraActor_Property_RIGHT_PLANE_DISTANCE_get();
167             public static readonly int TOP_PLANE_DISTANCE = NDalicPINVOKE.CameraActor_Property_TOP_PLANE_DISTANCE_get();
168             public static readonly int BOTTOM_PLANE_DISTANCE = NDalicPINVOKE.CameraActor_Property_BOTTOM_PLANE_DISTANCE_get();
169             public static readonly int TARGET_POSITION = NDalicPINVOKE.CameraActor_Property_TARGET_POSITION_get();
170             public static readonly int PROJECTION_MATRIX = NDalicPINVOKE.CameraActor_Property_PROJECTION_MATRIX_get();
171             public static readonly int VIEW_MATRIX = NDalicPINVOKE.CameraActor_Property_VIEW_MATRIX_get();
172             public static readonly int INVERT_Y_AXIS = NDalicPINVOKE.CameraActor_Property_INVERT_Y_AXIS_get();
173
174         }
175
176         public Camera() : this(NDalicPINVOKE.CameraActor_New__SWIG_0(), true)
177         {
178             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179
180         }
181         public Camera(Vector2 size) : this(NDalicPINVOKE.CameraActor_New__SWIG_1(Vector2.getCPtr(size)), true)
182         {
183             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184
185         }
186         public new static Camera DownCast(BaseHandle handle)
187         {
188             Camera ret = new Camera(NDalicPINVOKE.CameraActor_DownCast(BaseHandle.getCPtr(handle)), true);
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190             return ret;
191         }
192
193         public Camera(Camera copy) : this(NDalicPINVOKE.new_CameraActor__SWIG_1(Camera.getCPtr(copy)), true)
194         {
195             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196         }
197
198         public Camera Assign(Camera rhs)
199         {
200             Camera ret = new Camera(NDalicPINVOKE.CameraActor_Assign(swigCPtr, Camera.getCPtr(rhs)), false);
201             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202             return ret;
203         }
204
205         public void SetType(CameraType type)
206         {
207             NDalicPINVOKE.CameraActor_SetType(swigCPtr, (int)type);
208             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209         }
210
211         public CameraType GetType()
212         {
213             CameraType ret = (CameraType)NDalicPINVOKE.CameraActor_GetType(swigCPtr);
214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215             return ret;
216         }
217
218         public void SetProjectionMode(ProjectionMode mode)
219         {
220             NDalicPINVOKE.CameraActor_SetProjectionMode(swigCPtr, (int)mode);
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222         }
223
224         public ProjectionMode GetProjectionMode()
225         {
226             ProjectionMode ret = (ProjectionMode)NDalicPINVOKE.CameraActor_GetProjectionMode(swigCPtr);
227             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228             return ret;
229         }
230
231         public void SetFieldOfView(float fieldOfView)
232         {
233             NDalicPINVOKE.CameraActor_SetFieldOfView(swigCPtr, fieldOfView);
234             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235         }
236
237         public float GetFieldOfView()
238         {
239             float ret = NDalicPINVOKE.CameraActor_GetFieldOfView(swigCPtr);
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241             return ret;
242         }
243
244         public void SetAspectRatio(float aspectRatio)
245         {
246             NDalicPINVOKE.CameraActor_SetAspectRatio(swigCPtr, aspectRatio);
247             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248         }
249
250         public float GetAspectRatio()
251         {
252             float ret = NDalicPINVOKE.CameraActor_GetAspectRatio(swigCPtr);
253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254             return ret;
255         }
256
257         public void SetNearClippingPlane(float nearClippingPlane)
258         {
259             NDalicPINVOKE.CameraActor_SetNearClippingPlane(swigCPtr, nearClippingPlane);
260             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261         }
262
263         public float GetNearClippingPlane()
264         {
265             float ret = NDalicPINVOKE.CameraActor_GetNearClippingPlane(swigCPtr);
266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267             return ret;
268         }
269
270         public void SetFarClippingPlane(float farClippingPlane)
271         {
272             NDalicPINVOKE.CameraActor_SetFarClippingPlane(swigCPtr, farClippingPlane);
273             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274         }
275
276         public float GetFarClippingPlane()
277         {
278             float ret = NDalicPINVOKE.CameraActor_GetFarClippingPlane(swigCPtr);
279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280             return ret;
281         }
282
283         public void SetTargetPosition(Vector3 targetPosition)
284         {
285             NDalicPINVOKE.CameraActor_SetTargetPosition(swigCPtr, Vector3.getCPtr(targetPosition));
286             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287         }
288
289         public Vector3 GetTargetPosition()
290         {
291             Vector3 ret = new Vector3(NDalicPINVOKE.CameraActor_GetTargetPosition(swigCPtr), true);
292             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293             return ret;
294         }
295
296         public void SetInvertYAxis(bool invertYAxis)
297         {
298             NDalicPINVOKE.CameraActor_SetInvertYAxis(swigCPtr, invertYAxis);
299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300         }
301
302         public bool GetInvertYAxis()
303         {
304             bool ret = NDalicPINVOKE.CameraActor_GetInvertYAxis(swigCPtr);
305             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306             return ret;
307         }
308
309         public void SetPerspectiveProjection(Vector2 size)
310         {
311             NDalicPINVOKE.CameraActor_SetPerspectiveProjection(swigCPtr, Vector2.getCPtr(size));
312             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313         }
314
315         public void SetOrthographicProjection(Vector2 size)
316         {
317             NDalicPINVOKE.CameraActor_SetOrthographicProjection__SWIG_0(swigCPtr, Vector2.getCPtr(size));
318             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319         }
320
321         public void SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far)
322         {
323             NDalicPINVOKE.CameraActor_SetOrthographicProjection__SWIG_1(swigCPtr, left, right, top, bottom, near, far);
324             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325         }
326
327         public string Type
328         {
329             get
330             {
331                 string temp;
332                 GetProperty(Camera.Property.TYPE).Get(out temp);
333                 return temp;
334             }
335             set
336             {
337                 SetProperty(Camera.Property.TYPE, new Tizen.NUI.PropertyValue(value));
338             }
339         }
340         public string ProjectionMode
341         {
342             get
343             {
344                 string temp;
345                 GetProperty(Camera.Property.PROJECTION_MODE).Get(out temp);
346                 return temp;
347             }
348             set
349             {
350                 SetProperty(Camera.Property.PROJECTION_MODE, new Tizen.NUI.PropertyValue(value));
351             }
352         }
353         public float FieldOfView
354         {
355             get
356             {
357                 float temp = 0.0f;
358                 GetProperty(Camera.Property.FIELD_OF_VIEW).Get(out temp);
359                 return temp;
360             }
361             set
362             {
363                 SetProperty(Camera.Property.FIELD_OF_VIEW, new Tizen.NUI.PropertyValue(value));
364             }
365         }
366         public float AspectRatio
367         {
368             get
369             {
370                 float temp = 0.0f;
371                 GetProperty(Camera.Property.ASPECT_RATIO).Get(out temp);
372                 return temp;
373             }
374             set
375             {
376                 SetProperty(Camera.Property.ASPECT_RATIO, new Tizen.NUI.PropertyValue(value));
377             }
378         }
379         public float NearPlaneDistance
380         {
381             get
382             {
383                 float temp = 0.0f;
384                 GetProperty(Camera.Property.NEAR_PLANE_DISTANCE).Get(out temp);
385                 return temp;
386             }
387             set
388             {
389                 SetProperty(Camera.Property.NEAR_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
390             }
391         }
392         public float FarPlaneDistance
393         {
394             get
395             {
396                 float temp = 0.0f;
397                 GetProperty(Camera.Property.FAR_PLANE_DISTANCE).Get(out temp);
398                 return temp;
399             }
400             set
401             {
402                 SetProperty(Camera.Property.FAR_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
403             }
404         }
405         public float LeftPlaneDistance
406         {
407             get
408             {
409                 float temp = 0.0f;
410                 GetProperty(Camera.Property.LEFT_PLANE_DISTANCE).Get(out temp);
411                 return temp;
412             }
413             set
414             {
415                 SetProperty(Camera.Property.LEFT_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
416             }
417         }
418         public float RightPlaneDistance
419         {
420             get
421             {
422                 float temp = 0.0f;
423                 GetProperty(Camera.Property.RIGHT_PLANE_DISTANCE).Get(out temp);
424                 return temp;
425             }
426             set
427             {
428                 SetProperty(Camera.Property.RIGHT_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
429             }
430         }
431         public float TopPlaneDistance
432         {
433             get
434             {
435                 float temp = 0.0f;
436                 GetProperty(Camera.Property.TOP_PLANE_DISTANCE).Get(out temp);
437                 return temp;
438             }
439             set
440             {
441                 SetProperty(Camera.Property.TOP_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
442             }
443         }
444         public float BottomPlaneDistance
445         {
446             get
447             {
448                 float temp = 0.0f;
449                 GetProperty(Camera.Property.BOTTOM_PLANE_DISTANCE).Get(out temp);
450                 return temp;
451             }
452             set
453             {
454                 SetProperty(Camera.Property.BOTTOM_PLANE_DISTANCE, new Tizen.NUI.PropertyValue(value));
455             }
456         }
457         public Vector3 TargetPosition
458         {
459             get
460             {
461                 Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
462                 GetProperty(Camera.Property.TARGET_POSITION).Get(temp);
463                 return temp;
464             }
465             set
466             {
467                 SetProperty(Camera.Property.TARGET_POSITION, new Tizen.NUI.PropertyValue(value));
468             }
469         }
470         internal Matrix ProjectionMatrix
471         {
472             get
473             {
474                 Matrix temp = new Matrix();
475                 GetProperty(Camera.Property.PROJECTION_MATRIX).Get(temp);
476                 return temp;
477             }
478         }
479         internal Matrix ViewMatrix
480         {
481             get
482             {
483                 Matrix temp = new Matrix();
484                 GetProperty(Camera.Property.VIEW_MATRIX).Get(temp);
485                 return temp;
486             }
487         }
488         public bool InvertYAxis
489         {
490             get
491             {
492                 bool temp = false;
493                 GetProperty(Camera.Property.INVERT_Y_AXIS).Get(out temp);
494                 return temp;
495             }
496             set
497             {
498                 SetProperty(Camera.Property.INVERT_Y_AXIS, new Tizen.NUI.PropertyValue(value));
499             }
500         }
501
502     }
503
504 }