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
27 internal Builder(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Builder.Upcast(cPtr), cMemoryOwn)
32 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
34 Interop.Builder.DeleteBuilder(swigCPtr);
37 /// <since_tizen> 3 </since_tizen>
38 public class QuitEventArgs : EventArgs
42 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
43 private delegate void QuitEventCallbackDelegate();
44 private DaliEventHandler<object, QuitEventArgs> _builderQuitEventHandler;
45 private QuitEventCallbackDelegate _builderQuitEventCallbackDelegate;
47 public event DaliEventHandler<object, QuitEventArgs> Quit
53 // Restricted to only one listener
54 if (_builderQuitEventHandler == null)
56 _builderQuitEventHandler += value;
58 _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit);
59 this.QuitSignal().Connect(_builderQuitEventCallbackDelegate);
68 if (_builderQuitEventHandler != null)
70 this.QuitSignal().Disconnect(_builderQuitEventCallbackDelegate);
73 _builderQuitEventHandler -= value;
78 // Callback for Builder QuitSignal
81 QuitEventArgs e = new QuitEventArgs();
83 if (_builderQuitEventHandler != null)
85 //here we send all data to user event handlers
86 _builderQuitEventHandler(this, e);
91 public void LoadFromFile(string fileName)
95 string json = System.IO.File.ReadAllText(fileName);
102 throw new global::System.InvalidOperationException("Failed to load file " + fileName);
106 catch (System.Exception e)
108 NUILog.Error(e.Message);
109 throw new global::System.InvalidOperationException("Failed to parse " + fileName);
113 public Builder() : this(Interop.Builder.New(), true)
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 public void LoadFromString(string data, Builder.UIFormat format)
120 Interop.Builder.LoadFromString(swigCPtr, data, (int)format);
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124 public void LoadFromString(string data)
126 Interop.Builder.LoadFromString(swigCPtr, data);
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 public void AddConstants(PropertyMap map)
132 Interop.Builder.AddConstants(swigCPtr, PropertyMap.getCPtr(map));
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 public void AddConstant(string key, PropertyValue value)
138 Interop.Builder.AddConstant(swigCPtr, key, PropertyValue.getCPtr(value));
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 public PropertyMap GetConstants()
144 PropertyMap ret = new PropertyMap(Interop.Builder.GetConstants(swigCPtr), false);
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 public PropertyValue GetConstant(string key)
151 PropertyValue ret = new PropertyValue(Interop.Builder.GetConstant(swigCPtr, key), false);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 public Animation CreateAnimation(string animationName)
158 Animation ret = new Animation(Interop.Builder.CreateAnimation(swigCPtr, animationName), true);
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 public Animation CreateAnimation(string animationName, PropertyMap map)
165 Animation ret = new Animation(Interop.Builder.CreateAnimationWithPropertyMap(swigCPtr, animationName, PropertyMap.getCPtr(map)), true);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 public Animation CreateAnimation(string animationName, View sourceActor)
172 Animation ret = new Animation(Interop.Builder.CreateAnimationWithView(swigCPtr, animationName, View.getCPtr(sourceActor)), true);
173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 public Animation CreateAnimation(string animationName, PropertyMap map, View sourceActor)
179 Animation ret = new Animation(Interop.Builder.CreateAnimation(swigCPtr, animationName, PropertyMap.getCPtr(map), View.getCPtr(sourceActor)), true);
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 public View Create(string templateName)
186 View ret = new View(Interop.Builder.Create(swigCPtr, templateName), true);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 public BaseHandle Create(string templateName, PropertyMap map)
193 BaseHandle ret = new BaseHandle(Interop.Builder.Create(swigCPtr, templateName, PropertyMap.getCPtr(map)), true);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 public BaseHandle CreateFromJson(string json)
200 BaseHandle ret = new BaseHandle(Interop.Builder.CreateFromJson(swigCPtr, json), true);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 public bool ApplyStyle(string styleName, Animatable handle)
207 bool ret = Interop.Builder.ApplyStyle(swigCPtr, styleName, Animatable.getCPtr(handle));
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 public bool ApplyFromJson(Animatable handle, string json)
214 bool ret = Interop.Builder.ApplyFromJson(swigCPtr, Animatable.getCPtr(handle), json);
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 public void AddViews(View toActor)
221 Interop.Builder.AddActors(swigCPtr, View.getCPtr(toActor));
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 public void AddViews(string sectionName, View toActor)
227 Interop.Builder.AddActors(swigCPtr, sectionName, View.getCPtr(toActor));
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 public void CreateRenderTask(string name)
233 Interop.Builder.CreateRenderTask(swigCPtr, name);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 public Path GetPath(string name)
239 Path ret = new Path(Interop.Builder.GetPath(swigCPtr, name), true);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 internal PathConstrainer GetPathConstrainer(string pathConstrainerName)
246 PathConstrainer ret = new PathConstrainer(Interop.Builder.GetPathConstrainer(swigCPtr, pathConstrainerName), true);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 internal LinearConstrainer GetLinearConstrainer(string linearConstrainerName)
253 LinearConstrainer ret = new LinearConstrainer(Interop.Builder.GetLinearConstrainer(swigCPtr, linearConstrainerName), true);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 internal VoidSignal QuitSignal()
260 VoidSignal ret = new VoidSignal(Interop.Builder.QuitSignal(swigCPtr), false);
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 /// <since_tizen> 3 </since_tizen>