2 * Copyright(c) 2021 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 internal Builder(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
31 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
33 Interop.Builder.DeleteBuilder(swigCPtr);
36 public class QuitEventArgs : EventArgs
40 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
41 private delegate void QuitEventCallbackDelegate();
42 private DaliEventHandler<object, QuitEventArgs> builderQuitEventHandler;
43 private QuitEventCallbackDelegate builderQuitEventCallbackDelegate;
44 private VoidSignal quitSignal;
46 public event DaliEventHandler<object, QuitEventArgs> Quit
50 // Restricted to only one listener
51 if (builderQuitEventHandler == null)
53 builderQuitEventHandler += value;
55 builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit);
56 quitSignal = this.QuitSignal();
57 quitSignal?.Connect(builderQuitEventCallbackDelegate);
63 if (builderQuitEventHandler != null)
65 quitSignal?.Disconnect(builderQuitEventCallbackDelegate);
68 builderQuitEventHandler -= value;
72 // Callback for Builder QuitSignal
75 QuitEventArgs e = new QuitEventArgs();
77 if (builderQuitEventHandler != null)
79 //here we send all data to user event handlers
80 builderQuitEventHandler(this, e);
85 public void LoadFromFile(string fileName)
89 string json = System.IO.File.ReadAllText(fileName);
96 throw new global::System.InvalidOperationException("Failed to load file " + fileName);
100 catch (System.Exception e)
102 NUILog.Error(e.Message);
103 throw new global::System.InvalidOperationException("Failed to parse " + fileName);
107 public Builder() : this(Interop.Builder.New(), true)
109 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 public void LoadFromString(string data, Builder.UIFormat format)
114 Interop.Builder.LoadFromString(SwigCPtr, data, (int)format);
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 public void LoadFromString(string data)
120 Interop.Builder.LoadFromString(SwigCPtr, data);
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124 public void AddConstants(PropertyMap map)
126 Interop.Builder.AddConstants(SwigCPtr, PropertyMap.getCPtr(map));
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 public void AddConstant(string key, PropertyValue value)
132 Interop.Builder.AddConstant(SwigCPtr, key, PropertyValue.getCPtr(value));
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 public PropertyMap GetConstants()
138 PropertyMap ret = new PropertyMap(Interop.Builder.GetConstants(SwigCPtr), false);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 public PropertyValue GetConstant(string key)
145 PropertyValue ret = new PropertyValue(Interop.Builder.GetConstant(SwigCPtr, key), false);
146 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150 public Animation CreateAnimation(string animationName)
152 Animation ret = new Animation(Interop.Builder.CreateAnimation(SwigCPtr, animationName), true);
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 public Animation CreateAnimation(string animationName, PropertyMap map)
159 Animation ret = new Animation(Interop.Builder.CreateAnimationWithPropertyMap(SwigCPtr, animationName, PropertyMap.getCPtr(map)), true);
160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164 public Animation CreateAnimation(string animationName, View sourceActor)
166 Animation ret = new Animation(Interop.Builder.CreateAnimationWithView(SwigCPtr, animationName, View.getCPtr(sourceActor)), true);
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 public Animation CreateAnimation(string animationName, PropertyMap map, View sourceActor)
173 Animation ret = new Animation(Interop.Builder.CreateAnimation(SwigCPtr, animationName, PropertyMap.getCPtr(map), View.getCPtr(sourceActor)), true);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 public View Create(string templateName)
180 View ret = new View(Interop.Builder.Create(SwigCPtr, templateName), true);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 public BaseHandle Create(string templateName, PropertyMap map)
187 BaseHandle ret = new BaseHandle(Interop.Builder.Create(SwigCPtr, templateName, PropertyMap.getCPtr(map)), true);
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 public BaseHandle CreateFromJson(string json)
194 BaseHandle ret = new BaseHandle(Interop.Builder.CreateFromJson(SwigCPtr, json), true);
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 public bool ApplyStyle(string styleName, Animatable handle)
201 bool ret = Interop.Builder.ApplyStyle(SwigCPtr, styleName, Animatable.getCPtr(handle));
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 public bool ApplyFromJson(Animatable handle, string json)
208 bool ret = Interop.Builder.ApplyFromJson(SwigCPtr, Animatable.getCPtr(handle), json);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 public void AddViews(View toActor)
215 Interop.Builder.AddActors(SwigCPtr, View.getCPtr(toActor));
216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 public void AddViews(string sectionName, View toActor)
221 Interop.Builder.AddActors(SwigCPtr, sectionName, View.getCPtr(toActor));
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 public void CreateRenderTask(string name)
227 Interop.Builder.CreateRenderTask(SwigCPtr, name);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 public Path GetPath(string name)
233 Path ret = new Path(Interop.Builder.GetPath(SwigCPtr, name), true);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 internal PathConstrainer GetPathConstrainer(string pathConstrainerName)
240 PathConstrainer ret = new PathConstrainer(Interop.Builder.GetPathConstrainer(SwigCPtr, pathConstrainerName), true);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 internal LinearConstrainer GetLinearConstrainer(string linearConstrainerName)
247 LinearConstrainer ret = new LinearConstrainer(Interop.Builder.GetLinearConstrainer(SwigCPtr, linearConstrainerName), true);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 internal VoidSignal QuitSignal()
254 VoidSignal ret = new VoidSignal(Interop.Builder.QuitSignal(SwigCPtr), false);
255 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();