2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.BaseComponents;
24 internal class Builder : BaseHandle
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal Builder(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Builder.Builder_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Builder obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 //Release your own unmanaged resources here.
46 //You should not access any managed member here except static instance.
47 //because the execution order of Finalizes is non-deterministic.
48 if (swigCPtr.Handle != global::System.IntPtr.Zero)
53 Interop.Builder.delete_Builder(swigCPtr);
55 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
61 /// <since_tizen> 3 </since_tizen>
62 public class QuitEventArgs : EventArgs
66 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
67 private delegate void QuitEventCallbackDelegate();
68 private DaliEventHandler<object, QuitEventArgs> _builderQuitEventHandler;
69 private QuitEventCallbackDelegate _builderQuitEventCallbackDelegate;
71 public event DaliEventHandler<object, QuitEventArgs> Quit
77 // Restricted to only one listener
78 if (_builderQuitEventHandler == null)
80 _builderQuitEventHandler += value;
82 _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit);
83 this.QuitSignal().Connect(_builderQuitEventCallbackDelegate);
92 if (_builderQuitEventHandler != null)
94 this.QuitSignal().Disconnect(_builderQuitEventCallbackDelegate);
97 _builderQuitEventHandler -= value;
102 // Callback for Builder QuitSignal
103 private void OnQuit()
105 QuitEventArgs e = new QuitEventArgs();
107 if (_builderQuitEventHandler != null)
109 //here we send all data to user event handlers
110 _builderQuitEventHandler(this, e);
115 public void LoadFromFile(string fileName)
119 string json = System.IO.File.ReadAllText(fileName);
122 LoadFromString(json);
126 throw new global::System.InvalidOperationException("Failed to load file " + fileName);
130 catch (System.Exception e)
132 NUILog.Error(e.Message);
133 throw new global::System.InvalidOperationException("Failed to parse " + fileName);
137 public Builder() : this(Interop.Builder.Builder_New(), true)
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 public void LoadFromString(string data, Builder.UIFormat format)
144 Interop.Builder.Builder_LoadFromString__SWIG_0(swigCPtr, data, (int)format);
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 public void LoadFromString(string data)
150 Interop.Builder.Builder_LoadFromString__SWIG_1(swigCPtr, data);
151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 public void AddConstants(PropertyMap map)
156 Interop.Builder.Builder_AddConstants(swigCPtr, PropertyMap.getCPtr(map));
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 public void AddConstant(string key, PropertyValue value)
162 Interop.Builder.Builder_AddConstant(swigCPtr, key, PropertyValue.getCPtr(value));
163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166 public PropertyMap GetConstants()
168 PropertyMap ret = new PropertyMap(Interop.Builder.Builder_GetConstants(swigCPtr), false);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 public PropertyValue GetConstant(string key)
175 PropertyValue ret = new PropertyValue(Interop.Builder.Builder_GetConstant(swigCPtr, key), false);
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 public Animation CreateAnimation(string animationName)
182 Animation ret = new Animation(Interop.Builder.Builder_CreateAnimation__SWIG_0(swigCPtr, animationName), true);
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 public Animation CreateAnimation(string animationName, PropertyMap map)
189 Animation ret = new Animation(Interop.Builder.Builder_CreateAnimation__SWIG_1(swigCPtr, animationName, PropertyMap.getCPtr(map)), true);
190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 public Animation CreateAnimation(string animationName, View sourceActor)
196 Animation ret = new Animation(Interop.Builder.Builder_CreateAnimation__SWIG_2(swigCPtr, animationName, View.getCPtr(sourceActor)), true);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 public Animation CreateAnimation(string animationName, PropertyMap map, View sourceActor)
203 Animation ret = new Animation(Interop.Builder.Builder_CreateAnimation__SWIG_3(swigCPtr, animationName, PropertyMap.getCPtr(map), View.getCPtr(sourceActor)), true);
204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 public View Create(string templateName)
210 View ret = new View(Interop.Builder.Builder_Create__SWIG_0(swigCPtr, templateName), true);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 public BaseHandle Create(string templateName, PropertyMap map)
217 BaseHandle ret = new BaseHandle(Interop.Builder.Builder_Create__SWIG_1(swigCPtr, templateName, PropertyMap.getCPtr(map)), true);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 public BaseHandle CreateFromJson(string json)
224 BaseHandle ret = new BaseHandle(Interop.Builder.Builder_CreateFromJson(swigCPtr, json), true);
225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 public bool ApplyStyle(string styleName, Animatable handle)
231 bool ret = Interop.Builder.Builder_ApplyStyle(swigCPtr, styleName, Animatable.getCPtr(handle));
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 public bool ApplyFromJson(Animatable handle, string json)
238 bool ret = Interop.Builder.Builder_ApplyFromJson(swigCPtr, Animatable.getCPtr(handle), json);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 public void AddViews(View toActor)
245 Interop.Builder.Builder_AddActors__SWIG_0(swigCPtr, View.getCPtr(toActor));
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 public void AddViews(string sectionName, View toActor)
251 Interop.Builder.Builder_AddActors__SWIG_1(swigCPtr, sectionName, View.getCPtr(toActor));
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 public void CreateRenderTask(string name)
257 Interop.Builder.Builder_CreateRenderTask(swigCPtr, name);
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 public Path GetPath(string name)
263 Path ret = new Path(Interop.Builder.Builder_GetPath(swigCPtr, name), true);
264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268 internal PathConstrainer GetPathConstrainer(string pathConstrainerName)
270 PathConstrainer ret = new PathConstrainer(Interop.Builder.Builder_GetPathConstrainer(swigCPtr, pathConstrainerName), true);
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 internal LinearConstrainer GetLinearConstrainer(string linearConstrainerName)
277 LinearConstrainer ret = new LinearConstrainer(Interop.Builder.Builder_GetLinearConstrainer(swigCPtr, linearConstrainerName), true);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282 internal VoidSignal QuitSignal()
284 VoidSignal ret = new VoidSignal(Interop.Builder.Builder_QuitSignal(swigCPtr), false);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 /// <since_tizen> 3 </since_tizen>