1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
25 internal class Builder : BaseHandle
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal Builder(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Builder_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Builder obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 protected override void Dispose(DisposeTypes type)
46 if (type == DisposeTypes.Explicit)
49 //Release your own managed resources here.
50 //You should release all of your own disposable objects here.
54 //Release your own unmanaged resources here.
55 //You should not access any managed member here except static instance.
56 //because the execution order of Finalizes is non-deterministic.
59 if (swigCPtr.Handle != global::System.IntPtr.Zero)
64 NDalicPINVOKE.delete_Builder(swigCPtr);
66 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 public class QuitEventArgs : EventArgs
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate void QuitEventCallbackDelegate();
80 private DaliEventHandler<object, QuitEventArgs> _builderQuitEventHandler;
81 private QuitEventCallbackDelegate _builderQuitEventCallbackDelegate;
83 public event DaliEventHandler<object, QuitEventArgs> Quit
89 // Restricted to only one listener
90 if (_builderQuitEventHandler == null)
92 _builderQuitEventHandler += value;
94 _builderQuitEventCallbackDelegate = new QuitEventCallbackDelegate(OnQuit);
95 this.QuitSignal().Connect(_builderQuitEventCallbackDelegate);
104 if (_builderQuitEventHandler != null)
106 this.QuitSignal().Disconnect(_builderQuitEventCallbackDelegate);
109 _builderQuitEventHandler -= value;
114 // Callback for Builder QuitSignal
115 private void OnQuit()
117 QuitEventArgs e = new QuitEventArgs();
119 if (_builderQuitEventHandler != null)
121 //here we send all data to user event handlers
122 _builderQuitEventHandler(this, e);
127 public void LoadFromFile(string fileName)
131 string json = System.IO.File.ReadAllText(fileName);
134 LoadFromString(json);
138 throw new global::System.InvalidOperationException("Failed to load file " + fileName);
142 catch (System.Exception e)
144 NUILog.Error(e.Message);
145 throw new global::System.InvalidOperationException("Failed to parse " + fileName);
151 public Builder() : this(NDalicPINVOKE.Builder_New(), true)
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 public void LoadFromString(string data, Builder.UIFormat format)
158 NDalicPINVOKE.Builder_LoadFromString__SWIG_0(swigCPtr, data, (int)format);
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 public void LoadFromString(string data)
164 NDalicPINVOKE.Builder_LoadFromString__SWIG_1(swigCPtr, data);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 public void AddConstants(PropertyMap map)
170 NDalicPINVOKE.Builder_AddConstants(swigCPtr, PropertyMap.getCPtr(map));
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 public void AddConstant(string key, PropertyValue value)
176 NDalicPINVOKE.Builder_AddConstant(swigCPtr, key, PropertyValue.getCPtr(value));
177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 public PropertyMap GetConstants()
182 PropertyMap ret = new PropertyMap(NDalicPINVOKE.Builder_GetConstants(swigCPtr), false);
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 public PropertyValue GetConstant(string key)
189 PropertyValue ret = new PropertyValue(NDalicPINVOKE.Builder_GetConstant(swigCPtr, key), false);
190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 public Animation CreateAnimation(string animationName)
196 Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_0(swigCPtr, animationName), true);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 public Animation CreateAnimation(string animationName, PropertyMap map)
203 Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_1(swigCPtr, animationName, PropertyMap.getCPtr(map)), true);
204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 public Animation CreateAnimation(string animationName, View sourceActor)
210 Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_2(swigCPtr, animationName, View.getCPtr(sourceActor)), true);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 public Animation CreateAnimation(string animationName, PropertyMap map, View sourceActor)
217 Animation ret = new Animation(NDalicPINVOKE.Builder_CreateAnimation__SWIG_3(swigCPtr, animationName, PropertyMap.getCPtr(map), View.getCPtr(sourceActor)), true);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 public View Create(string templateName)
224 View ret = new View(NDalicPINVOKE.Builder_Create__SWIG_0(swigCPtr, templateName), true);
225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 public BaseHandle Create(string templateName, PropertyMap map)
231 BaseHandle ret = new BaseHandle(NDalicPINVOKE.Builder_Create__SWIG_1(swigCPtr, templateName, PropertyMap.getCPtr(map)), true);
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 public BaseHandle CreateFromJson(string json)
238 BaseHandle ret = new BaseHandle(NDalicPINVOKE.Builder_CreateFromJson(swigCPtr, json), true);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 public bool ApplyStyle(string styleName, Animatable handle)
245 bool ret = NDalicPINVOKE.Builder_ApplyStyle(swigCPtr, styleName, Animatable.getCPtr(handle));
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 public bool ApplyFromJson(Animatable handle, string json)
252 bool ret = NDalicPINVOKE.Builder_ApplyFromJson(swigCPtr, Animatable.getCPtr(handle), json);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 public void AddViews(View toActor)
259 NDalicPINVOKE.Builder_AddActors__SWIG_0(swigCPtr, View.getCPtr(toActor));
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 public void AddViews(string sectionName, View toActor)
265 NDalicPINVOKE.Builder_AddActors__SWIG_1(swigCPtr, sectionName, View.getCPtr(toActor));
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 public void CreateRenderTask(string name)
271 NDalicPINVOKE.Builder_CreateRenderTask(swigCPtr, name);
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 internal FrameBufferImage GetFrameBufferImage(string name)
277 FrameBufferImage ret = new FrameBufferImage(NDalicPINVOKE.Builder_GetFrameBufferImage(swigCPtr, name), true);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282 public Path GetPath(string name)
284 Path ret = new Path(NDalicPINVOKE.Builder_GetPath(swigCPtr, name), true);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 internal PathConstrainer GetPathConstrainer(string pathConstrainerName)
291 PathConstrainer ret = new PathConstrainer(NDalicPINVOKE.Builder_GetPathConstrainer(swigCPtr, pathConstrainerName), true);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 internal LinearConstrainer GetLinearConstrainer(string linearConstrainerName)
298 LinearConstrainer ret = new LinearConstrainer(NDalicPINVOKE.Builder_GetLinearConstrainer(swigCPtr, linearConstrainerName), true);
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 internal VoidSignal QuitSignal()
305 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Builder_QuitSignal(swigCPtr), false);
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();