896ee513776b232f4d256929d3649c22d54ee2ae
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / FrameUpdateCallbackInterface.cs
1 /*
2  * Copyright(c) 2021 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
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23
24     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class FrameUpdateCallbackInterface : Disposable
27     {
28         private uint onUpdateCallbackVersion = 0u;
29
30         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         internal FrameUpdateCallbackInterface(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
33         {
34             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
35         }
36
37         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         public FrameUpdateCallbackInterface() : this(0u)
40         {
41         }
42
43         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
44         [EditorBrowsable(EditorBrowsableState.Never)]
45         public FrameUpdateCallbackInterface(uint updateCallbackVersion) : this(Interop.FrameUpdateCallbackInterface.newFrameUpdateCallbackInterface(), true)
46         {
47             onUpdateCallbackVersion = updateCallbackVersion;
48             DirectorConnect();
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
53         [EditorBrowsable(EditorBrowsableState.Never)]
54         public uint UpdateCallbackVersion => onUpdateCallbackVersion;
55
56         private void DirectorConnect()
57         {
58             Delegate1 = new DelegateFrameUpdateCallbackInterfaceV1(DirectorOnUpdate);
59             Interop.FrameUpdateCallbackInterface.FrameUpdateCallbackInterfaceDirectorConnectV1(SwigCPtr, Delegate1);
60         }
61
62         private global::System.IntPtr proxyIntPtr = global::System.IntPtr.Zero;
63
64         private bool DirectorOnUpdate(global::System.IntPtr proxy, float elapsedSeconds)
65         {
66             bool ret = false;
67
68             proxyIntPtr = proxy;
69             if (onUpdateCallbackVersion == 0u)
70             {
71                 OnUpdate(elapsedSeconds);
72             }
73             else if (onUpdateCallbackVersion == 1u)
74             {
75                 ret = OnUpdate(this, elapsedSeconds);
76             }
77             proxyIntPtr = global::System.IntPtr.Zero;
78
79             return ret;
80         }
81
82         internal delegate bool DelegateFrameUpdateCallbackInterfaceV1(global::System.IntPtr proxy, float elapsedSeconds);
83         private DelegateFrameUpdateCallbackInterfaceV1 Delegate1;
84
85         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public virtual void OnUpdate(float elapsedSeconds)
88         {
89         }
90
91         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
92         [EditorBrowsable(EditorBrowsableState.Never)]
93         public virtual bool OnUpdate(FrameUpdateCallbackInterface obj, float elapsedSeconds)
94         {
95             // Let we call Versoin 0 API. To keep backward capability.
96             OnUpdate(elapsedSeconds);
97             return false;
98         }
99
100         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
101         [EditorBrowsable(EditorBrowsableState.Never)]
102         protected bool GetPosition(uint id, Vector3 position)
103         {
104             if (proxyIntPtr == IntPtr.Zero)
105             {
106                 return false;
107             }
108             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceGetPosition(proxyIntPtr, id, Vector3.getCPtr(position));
109             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110             return ret;
111         }
112
113         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
114         [EditorBrowsable(EditorBrowsableState.Never)]
115         protected bool SetPosition(uint id, Vector3 position)
116         {
117             if (proxyIntPtr == IntPtr.Zero)
118             {
119                 return false;
120             }
121             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceSetPosition(proxyIntPtr, id, Vector3.getCPtr(position));
122             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123             return ret;
124         }
125
126         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
127         [EditorBrowsable(EditorBrowsableState.Never)]
128         protected bool BakePosition(uint id, Vector3 position)
129         {
130             if (proxyIntPtr == IntPtr.Zero)
131             {
132                 return false;
133             }
134             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceBakePosition(proxyIntPtr, id, Vector3.getCPtr(position));
135             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136             return ret;
137         }
138
139         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         protected bool GetSize(uint id, Vector3 size)
142         {
143             if (proxyIntPtr == IntPtr.Zero)
144             {
145                 return false;
146             }
147             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceGetSize(proxyIntPtr, id, Vector3.getCPtr(size));
148             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149             return ret;
150         }
151
152         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
153         [EditorBrowsable(EditorBrowsableState.Never)]
154         protected bool SetSize(uint id, Vector3 size)
155         {
156             if (proxyIntPtr == IntPtr.Zero)
157             {
158                 return false;
159             }
160             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceSetSize(proxyIntPtr, id, Vector3.getCPtr(size));
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             return ret;
163         }
164
165         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
166         [EditorBrowsable(EditorBrowsableState.Never)]
167         protected bool BakeSize(uint id, Vector3 size)
168         {
169             if (proxyIntPtr == IntPtr.Zero)
170             {
171                 return false;
172             }
173             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceBakeSize(proxyIntPtr, id, Vector3.getCPtr(size));
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175             return ret;
176         }
177
178         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
179         [EditorBrowsable(EditorBrowsableState.Never)]
180         protected bool GetScale(uint id, Vector3 scale)
181         {
182             if (proxyIntPtr == IntPtr.Zero)
183             {
184                 return false;
185             }
186             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceGetScale(proxyIntPtr, id, Vector3.getCPtr(scale));
187             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188             return ret;
189         }
190
191         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
192         [EditorBrowsable(EditorBrowsableState.Never)]
193         protected bool SetScale(uint id, Vector3 scale)
194         {
195             if (proxyIntPtr == IntPtr.Zero)
196             {
197                 return false;
198             }
199             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceSetScale(proxyIntPtr, id, Vector3.getCPtr(scale));
200             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             return ret;
202         }
203
204         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
205         [EditorBrowsable(EditorBrowsableState.Never)]
206         protected bool BakeScale(uint id, Vector3 scale)
207         {
208             if (proxyIntPtr == IntPtr.Zero)
209             {
210                 return false;
211             }
212             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceBakeScale(proxyIntPtr, id, Vector3.getCPtr(scale));
213             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214             return ret;
215         }
216
217         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
218         [EditorBrowsable(EditorBrowsableState.Never)]
219         protected bool GetColor(uint id, Vector4 color)
220         {
221             if (proxyIntPtr == IntPtr.Zero)
222             {
223                 return false;
224             }
225             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceGetColor(proxyIntPtr, id, Vector4.getCPtr(color));
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227             return ret;
228         }
229
230         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
231         [EditorBrowsable(EditorBrowsableState.Never)]
232         protected bool SetColor(uint id, Vector4 color)
233         {
234             if (proxyIntPtr == IntPtr.Zero)
235             {
236                 return false;
237             }
238             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceSetColor(proxyIntPtr, id, Vector4.getCPtr(color));
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240             return ret;
241         }
242
243         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
244         [EditorBrowsable(EditorBrowsableState.Never)]
245         protected bool BakeColor(uint id, Vector4 color)
246         {
247             if (proxyIntPtr == IntPtr.Zero)
248             {
249                 return false;
250             }
251             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceBakeColor(proxyIntPtr, id, Vector4.getCPtr(color));
252             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253             return ret;
254         }
255
256         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
257         [EditorBrowsable(EditorBrowsableState.Never)]
258         protected bool GetPositionAndSize(uint id, Vector3 Position, Vector3 Size)
259         {
260             if (proxyIntPtr == IntPtr.Zero)
261             {
262                 return false;
263             }
264             bool ret = Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceGetPositionAndSize(proxyIntPtr, id, Vector3.getCPtr(Position), Vector3.getCPtr(Size));
265             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266             return ret;
267         }
268
269         internal void AddFrameUpdateCallback(global::System.Runtime.InteropServices.HandleRef windowCPtr, global::System.Runtime.InteropServices.HandleRef layerCPtr)
270         {
271             Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceAddFrameUpdateCallback(windowCPtr, SwigCPtr, layerCPtr);
272         }
273
274         internal void RemoveFrameUpdateCallback(global::System.Runtime.InteropServices.HandleRef windowCPtr)
275         {
276             Interop.FrameUpdateCallbackInterface.FrameCallbackInterfaceRemoveFrameUpdateCallback(windowCPtr, SwigCPtr);
277         }
278     }
279 }