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 public class QuitEventArgs : EventArgs
41 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
42 private delegate void QuitEventCallbackDelegate();
43 private DaliEventHandler<object, QuitEventArgs> _builderQuitEventHandler;
44 private QuitEventCallbackDelegate _builderQuitEventCallbackDelegate;
45 private VoidSignal quitSignal;
47 public event DaliEventHandler<object, QuitEventArgs> Quit
51 // Restricted to only one listener
52 if (_builderQuitEventHandler == null)
54 _builderQuitEventHandler += value;
56 _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit);
57 quitSignal = this.QuitSignal();
58 quitSignal?.Connect(_builderQuitEventCallbackDelegate);
64 if (_builderQuitEventHandler != null)
66 quitSignal?.Disconnect(_builderQuitEventCallbackDelegate);
69 _builderQuitEventHandler -= value;
73 // Callback for Builder QuitSignal
76 QuitEventArgs e = new QuitEventArgs();
78 if (_builderQuitEventHandler != null)
80 //here we send all data to user event handlers
81 _builderQuitEventHandler(this, e);
86 public void LoadFromFile(string fileName)
90 string json = System.IO.File.ReadAllText(fileName);
97 throw new global::System.InvalidOperationException("Failed to load file " + fileName);
101 catch (System.Exception e)
103 NUILog.Error(e.Message);
104 throw new global::System.InvalidOperationException("Failed to parse " + fileName);
108 public Builder() : this(Interop.Builder.New(), true)
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 public void LoadFromString(string data, Builder.UIFormat format)
115 Interop.Builder.LoadFromString(SwigCPtr, data, (int)format);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 public void LoadFromString(string data)
121 Interop.Builder.LoadFromString(SwigCPtr, data);
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 public void AddConstants(PropertyMap map)
127 Interop.Builder.AddConstants(SwigCPtr, PropertyMap.getCPtr(map));
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 public void AddConstant(string key, PropertyValue value)
133 Interop.Builder.AddConstant(SwigCPtr, key, PropertyValue.getCPtr(value));
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 public PropertyMap GetConstants()
139 PropertyMap ret = new PropertyMap(Interop.Builder.GetConstants(SwigCPtr), false);
140 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144 public PropertyValue GetConstant(string key)
146 PropertyValue ret = new PropertyValue(Interop.Builder.GetConstant(SwigCPtr, key), false);
147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
151 public Animation CreateAnimation(string animationName)
153 Animation ret = new Animation(Interop.Builder.CreateAnimation(SwigCPtr, animationName), true);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 public Animation CreateAnimation(string animationName, PropertyMap map)
160 Animation ret = new Animation(Interop.Builder.CreateAnimationWithPropertyMap(SwigCPtr, animationName, PropertyMap.getCPtr(map)), true);
161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 public Animation CreateAnimation(string animationName, View sourceActor)
167 Animation ret = new Animation(Interop.Builder.CreateAnimationWithView(SwigCPtr, animationName, View.getCPtr(sourceActor)), true);
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 public Animation CreateAnimation(string animationName, PropertyMap map, View sourceActor)
174 Animation ret = new Animation(Interop.Builder.CreateAnimation(SwigCPtr, animationName, PropertyMap.getCPtr(map), View.getCPtr(sourceActor)), true);
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 public View Create(string templateName)
181 View ret = new View(Interop.Builder.Create(SwigCPtr, templateName), true);
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186 public BaseHandle Create(string templateName, PropertyMap map)
188 BaseHandle ret = new BaseHandle(Interop.Builder.Create(SwigCPtr, templateName, PropertyMap.getCPtr(map)), true);
189 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193 public BaseHandle CreateFromJson(string json)
195 BaseHandle ret = new BaseHandle(Interop.Builder.CreateFromJson(SwigCPtr, json), true);
196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 public bool ApplyStyle(string styleName, Animatable handle)
202 bool ret = Interop.Builder.ApplyStyle(SwigCPtr, styleName, Animatable.getCPtr(handle));
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 public bool ApplyFromJson(Animatable handle, string json)
209 bool ret = Interop.Builder.ApplyFromJson(SwigCPtr, Animatable.getCPtr(handle), json);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214 public void AddViews(View toActor)
216 Interop.Builder.AddActors(SwigCPtr, View.getCPtr(toActor));
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220 public void AddViews(string sectionName, View toActor)
222 Interop.Builder.AddActors(SwigCPtr, sectionName, View.getCPtr(toActor));
223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 public void CreateRenderTask(string name)
228 Interop.Builder.CreateRenderTask(SwigCPtr, name);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 public Path GetPath(string name)
234 Path ret = new Path(Interop.Builder.GetPath(SwigCPtr, name), true);
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 internal PathConstrainer GetPathConstrainer(string pathConstrainerName)
241 PathConstrainer ret = new PathConstrainer(Interop.Builder.GetPathConstrainer(SwigCPtr, pathConstrainerName), true);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 internal LinearConstrainer GetLinearConstrainer(string linearConstrainerName)
248 LinearConstrainer ret = new LinearConstrainer(Interop.Builder.GetLinearConstrainer(SwigCPtr, linearConstrainerName), true);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 internal VoidSignal QuitSignal()
255 VoidSignal ret = new VoidSignal(Interop.Builder.QuitSignal(SwigCPtr), false);
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();