[NUI] Re-structuring NUI by classifying modules
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Animation / 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 using System.ComponentModel;
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
30         /// <summary>
31         /// Create an instance of animatable.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         public Animatable() : this(Interop.Handle.New(), true)
35         {
36             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
37
38         }
39
40         internal Animatable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Handle.Upcast(cPtr), cMemoryOwn)
41         {
42         }
43
44         /// <summary>
45         /// Enumeration for Handle's capabilities that can be queried.
46         /// </summary>
47         /// <since_tizen> 3 </since_tizen>
48         public enum Capability
49         {
50             /// <summary>
51             /// Some objects support dynamic property creation at run-time.
52             /// New properties are registered by calling RegisterProperty() with an unused property name.
53             /// </summary>
54             /// <since_tizen> 3 </since_tizen>
55             DYNAMIC_PROPERTIES = 0x01
56         }
57
58         /// <summary>
59         /// Queries the name of a property.
60         /// </summary>
61         /// <param name="index">The index of the property.</param>
62         /// <returns>The name of the property.</returns>
63         /// <since_tizen> 3 </since_tizen>
64         public string GetPropertyName(int index)
65         {
66             string ret = Interop.Handle.GetPropertyName(SwigCPtr, index);
67             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68             return ret;
69         }
70
71         /// <summary>
72         /// Queries the index of a property.
73         /// </summary>
74         /// <param name="name">The name of the property.</param>
75         /// <returns>The index of the property.</returns>
76         /// <since_tizen> 3 </since_tizen>
77         public int GetPropertyIndex(string name)
78         {
79             // Convert property string to be lowercase
80             StringBuilder sb = new StringBuilder(name);
81             sb[0] = (char)(sb[0] | 0x20);
82             string str = sb.ToString();
83
84             int ret = Interop.Handle.GetPropertyIndex(SwigCPtr, str);
85             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             return ret;
87         }
88
89         /// <summary>
90         /// Queries whether a property can be writable.
91         /// </summary>
92         /// <param name="index">The index of the property.</param>
93         /// <returns>True if the property is writable.</returns>
94         /// <since_tizen> 3 </since_tizen>
95         public bool IsPropertyWritable(int index)
96         {
97             bool ret = Interop.Handle.IsPropertyWritable(SwigCPtr, index);
98             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99             return ret;
100         }
101
102         /// <summary>
103         /// whether a writable property can be the target of an animation.
104         /// </summary>
105         /// <param name="index">The index of the property.</param>
106         /// <returns>True if the property is animatable.</returns>
107         /// <since_tizen> 3 </since_tizen>
108         public bool IsPropertyAnimatable(int index)
109         {
110             bool ret = Interop.Handle.IsPropertyAnimatable(SwigCPtr, index);
111             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112             return ret;
113         }
114
115         /// <summary>
116         /// Queries the type of a property.
117         /// </summary>
118         /// <param name="index">The index of the property.</param>
119         /// <returns>The type of the property.</returns>
120         /// <since_tizen> 3 </since_tizen>
121         public PropertyType GetPropertyType(int index)
122         {
123             PropertyType ret = (PropertyType)Interop.Handle.GetPropertyType(SwigCPtr, index);
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         /// <summary>
129         /// Sets the value of an existing property.
130         /// </summary>
131         /// <param name="index">The index of the property.</param>
132         /// <param name="propertyValue">The new value of the property.</param>
133         /// <since_tizen> 3 </since_tizen>
134         public void SetProperty(int index, PropertyValue propertyValue)
135         {
136             Tizen.NUI.Object.SetProperty(SwigCPtr, index, propertyValue);
137         }
138
139         /// <summary>
140         /// Registers a new animatable property.
141         /// </summary>
142         /// <param name="name">The name of the property.</param>
143         /// <param name="propertyValue">The new value of the property.</param>
144         /// <returns>The type of the property.</returns>
145         /// <since_tizen> 3 </since_tizen>
146         public int RegisterProperty(string name, PropertyValue propertyValue)
147         {
148             int ret = Interop.Handle.RegisterProperty(SwigCPtr, name, PropertyValue.getCPtr(propertyValue));
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150             return ret;
151         }
152
153         /// <summary>
154         /// Registers a new animatable property.
155         /// </summary>
156         /// <param name="name">The name of the property.</param>
157         /// <param name="propertyValue">The new value of the property.</param>
158         /// <param name="accessMode">The property access mode (writable, animatable etc).</param>
159         /// <returns>The type of the property.</returns>
160         /// <since_tizen> 3 </since_tizen>
161         public int RegisterProperty(string name, PropertyValue propertyValue, PropertyAccessMode accessMode)
162         {
163             int ret = Interop.Handle.RegisterProperty(SwigCPtr, name, PropertyValue.getCPtr(propertyValue), (int)accessMode);
164             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165             return ret;
166         }
167
168         /// <summary>
169         /// Retrieves a property value.
170         /// </summary>
171         /// <param name="index">The index of the property.</param>
172         /// <returns>The property value.</returns>
173         /// <since_tizen> 3 </since_tizen>
174         public PropertyValue GetProperty(int index)
175         {
176             PropertyValue ret = Tizen.NUI.Object.GetProperty(SwigCPtr, index);
177             return ret;
178         }
179
180         /// <summary>
181         /// Adds a property notification to this object.
182         /// </summary>
183         /// <param name="property">The name of the property.</param>
184         /// <param name="condition">The notification will be triggered when this condition is satisfied.</param>
185         /// <returns>A handle to the newly created PropertyNotification.</returns>
186         /// <since_tizen> 4 </since_tizen>
187         public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition)
188         {
189             Property properties = PropertyHelper.GetPropertyFromString(this, property);
190             PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, properties.propertyIndex, PropertyCondition.getCPtr(condition)), true);
191             properties.Dispose();
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             Interop.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             Interop.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 = Interop.HandleInternal.HandleGetPropertyCount(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(Interop.Handle.AddPropertyNotification(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             Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr);
239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240         }
241
242         internal void RemoveConstraints(uint tag)
243         {
244             Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr, tag);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246         }
247
248         /// This will not be public opened.
249         [EditorBrowsable(EditorBrowsableState.Never)]
250         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
251         {
252             Interop.Handle.DeleteHandle(swigCPtr);
253         }
254     }
255 }