[NUI] Clean NUI codes from Adaptor.cs to Window.cs (#652)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Animatable.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System.Text;
19
20 namespace Tizen.NUI
21 {
22
23     /// <summary>
24     /// Animatable.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class Animatable : BaseHandle
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30
31         /// <summary>
32         /// Create an instance of animatable.
33         /// </summary>
34         /// <since_tizen> 3 </since_tizen>
35         public Animatable() : this(NDalicPINVOKE.Handle_New(), true)
36         {
37             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38
39         }
40
41         internal Animatable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Handle_SWIGUpcast(cPtr), cMemoryOwn)
42         {
43             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
44         }
45
46         /// <summary>
47         /// Enumeration for Handle's capabilities that can be queried.
48         /// </summary>
49         /// <since_tizen> 3 </since_tizen>
50         public enum Capability
51         {
52             /// <summary>
53             /// Some objects support dynamic property creation at run-time.
54             /// New properties are registered by calling RegisterProperty() with an unused property name.
55             /// </summary>
56             /// <since_tizen> 3 </since_tizen>
57             DYNAMIC_PROPERTIES = 0x01
58         }
59
60         /// <summary>
61         /// Queries the name of a property.
62         /// </summary>
63         /// <param name="index">The index of the property.</param>
64         /// <returns>The name of the property.</returns>
65         /// <since_tizen> 3 </since_tizen>
66         public string GetPropertyName(int index)
67         {
68             string ret = NDalicPINVOKE.Handle_GetPropertyName(swigCPtr, index);
69             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
70             return ret;
71         }
72
73         /// <summary>
74         /// Queries the index of a property.
75         /// </summary>
76         /// <param name="name">The name of the property.</param>
77         /// <returns>The index of the property.</returns>
78         /// <since_tizen> 3 </since_tizen>
79         public int GetPropertyIndex(string name)
80         {
81             // Convert property string to be lowercase
82             StringBuilder sb = new StringBuilder(name);
83             sb[0] = (char)(sb[0] | 0x20);
84             string str = sb.ToString();
85
86             int ret = NDalicPINVOKE.Handle_GetPropertyIndex(swigCPtr, str);
87             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88             return ret;
89         }
90
91         /// <summary>
92         /// Queries whether a property can be writable.
93         /// </summary>
94         /// <param name="index">The index of the property.</param>
95         /// <returns>True if the property is writable.</returns>
96         /// <since_tizen> 3 </since_tizen>
97         public bool IsPropertyWritable(int index)
98         {
99             bool ret = NDalicPINVOKE.Handle_IsPropertyWritable(swigCPtr, index);
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101             return ret;
102         }
103
104         /// <summary>
105         /// whether a writable property can be the target of an animation.
106         /// </summary>
107         /// <param name="index">The index of the property.</param>
108         /// <returns>True if the property is animatable.</returns>
109         /// <since_tizen> 3 </since_tizen>
110         public bool IsPropertyAnimatable(int index)
111         {
112             bool ret = NDalicPINVOKE.Handle_IsPropertyAnimatable(swigCPtr, index);
113             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114             return ret;
115         }
116
117         /// <summary>
118         /// Queries the type of a property.
119         /// </summary>
120         /// <param name="index">The index of the property.</param>
121         /// <returns>The type of the property.</returns>
122         /// <since_tizen> 3 </since_tizen>
123         public PropertyType GetPropertyType(int index)
124         {
125             PropertyType ret = (PropertyType)NDalicPINVOKE.Handle_GetPropertyType(swigCPtr, index);
126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127             return ret;
128         }
129
130         /// <summary>
131         /// Sets the value of an existing property.
132         /// </summary>
133         /// <param name="index">The index of the property.</param>
134         /// <param name="propertyValue">The new value of the property.</param>
135         /// <since_tizen> 3 </since_tizen>
136         public void SetProperty(int index, PropertyValue propertyValue)
137         {
138             Tizen.NUI.Object.SetProperty(swigCPtr, index, propertyValue);
139         }
140
141         /// <summary>
142         /// Registers a new animatable property.
143         /// </summary>
144         /// <param name="name">The name of the property.</param>
145         /// <param name="propertyValue">The new value of the property.</param>
146         /// <returns>The type of the property.</returns>
147         /// <since_tizen> 3 </since_tizen>
148         public int RegisterProperty(string name, PropertyValue propertyValue)
149         {
150             int ret = NDalicPINVOKE.Handle_RegisterProperty__SWIG_0(swigCPtr, name, PropertyValue.getCPtr(propertyValue));
151             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152             return ret;
153         }
154
155         /// <summary>
156         /// Registers a new animatable property.
157         /// </summary>
158         /// <param name="name">The name of the property.</param>
159         /// <param name="propertyValue">The new value of the property.</param>
160         /// <param name="accessMode">The property access mode (writable, animatable etc).</param>
161         /// <returns>The type of the property.</returns>
162         /// <since_tizen> 3 </since_tizen>
163         public int RegisterProperty(string name, PropertyValue propertyValue, PropertyAccessMode accessMode)
164         {
165             int ret = NDalicPINVOKE.Handle_RegisterProperty__SWIG_1(swigCPtr, name, PropertyValue.getCPtr(propertyValue), (int)accessMode);
166             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167             return ret;
168         }
169
170         /// <summary>
171         /// Retrieves a property value.
172         /// </summary>
173         /// <param name="index">The index of the property.</param>
174         /// <returns>The property value.</returns>
175         /// <since_tizen> 3 </since_tizen>
176         public PropertyValue GetProperty(int index)
177         {
178             PropertyValue ret = Tizen.NUI.Object.GetProperty(swigCPtr, index);
179             return ret;
180         }
181
182         /// <summary>
183         /// Adds a property notification to this object.
184         /// </summary>
185         /// <param name="property">The name of the property.</param>
186         /// <param name="condition">The notification will be triggered when this condition is satisfied.</param>
187         /// <returns>A handle to the newly created PropertyNotification.</returns>
188         /// <since_tizen> 4 </since_tizen>
189         public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition)
190         {
191             PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.Handle_AddPropertyNotification__SWIG_0(swigCPtr, PropertyHelper.GetPropertyFromString(this, property).propertyIndex, PropertyCondition.getCPtr(condition)), true);
192             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193             return ret;
194         }
195
196         /// <summary>
197         /// Removes a property notification from this object.
198         /// </summary>
199         /// <param name="propertyNotification">The propertyNotification to be removed.</param>
200         /// <since_tizen> 4 </since_tizen>
201         public void RemovePropertyNotification(PropertyNotification propertyNotification)
202         {
203             NDalicPINVOKE.Handle_RemovePropertyNotification(swigCPtr, PropertyNotification.getCPtr(propertyNotification));
204             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205         }
206
207         /// <summary>
208         /// Removes a property notification from this object.
209         /// </summary>
210         /// <since_tizen> 4 </since_tizen>
211         public void RemovePropertyNotifications()
212         {
213             NDalicPINVOKE.Handle_RemovePropertyNotifications(swigCPtr);
214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215         }
216
217         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Animatable obj)
218         {
219             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
220         }
221
222         internal uint GetPropertyCount()
223         {
224             uint ret = NDalicPINVOKE.Handle_GetPropertyCount(swigCPtr);
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226             return ret;
227         }
228
229         internal PropertyNotification AddPropertyNotification(int index, int componentIndex, PropertyCondition condition)
230         {
231             PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.Handle_AddPropertyNotification__SWIG_1(swigCPtr, index, componentIndex, PropertyCondition.getCPtr(condition)), true);
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233             return ret;
234         }
235
236         internal void RemoveConstraints()
237         {
238             NDalicPINVOKE.Handle_RemoveConstraints__SWIG_0(swigCPtr);
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240         }
241
242         internal void RemoveConstraints(uint tag)
243         {
244             NDalicPINVOKE.Handle_RemoveConstraints__SWIG_1(swigCPtr, tag);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246         }
247
248         /// <summary>
249         /// To make the Animatable instance be disposed.
250         /// </summary>
251         /// <since_tizen> 3 </since_tizen>
252         protected override void Dispose(DisposeTypes type)
253         {
254             if (disposed)
255             {
256                 return;
257             }
258
259             if (type == DisposeTypes.Explicit)
260             {
261                 //Called by User
262                 //Release your own managed resources here.
263                 //You should release all of your own disposable objects here.
264
265             }
266
267             //Release your own unmanaged resources here.
268             //You should not access any managed member here except static instance.
269             //because the execution order of Finalizes is non-deterministic.
270
271             if (swigCPtr.Handle != global::System.IntPtr.Zero)
272             {
273                 if (swigCMemOwn)
274                 {
275                     swigCMemOwn = false;
276                     NDalicPINVOKE.delete_Handle(swigCPtr);
277                 }
278                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
279             }
280
281             base.Dispose(type);
282         }
283
284     }
285
286 }