2 * Copyright(c) 2017 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.
17 using System.ComponentModel;
26 /// <since_tizen> 3 </since_tizen>
27 public class Animatable : BaseHandle
31 /// Create an instance of animatable.
33 /// <since_tizen> 3 </since_tizen>
34 public Animatable() : this(Interop.Handle.New(), true)
36 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
40 internal Animatable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
45 /// Enumeration for Handle's capabilities that can be queried.
47 /// <since_tizen> 3 </since_tizen>
48 public enum Capability
51 /// Some objects support dynamic property creation at run-time.
52 /// New properties are registered by calling RegisterProperty() with an unused property name.
54 /// <since_tizen> 3 </since_tizen>
55 DYNAMIC_PROPERTIES = 0x01
59 /// Queries the name of a property.
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)
66 string ret = Interop.Handle.GetPropertyName(SwigCPtr, index);
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 /// Queries the index of a property.
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)
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();
84 int ret = Interop.Handle.GetPropertyIndex(SwigCPtr, str);
85 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90 /// Queries whether a property can be writable.
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)
97 bool ret = Interop.Handle.IsPropertyWritable(SwigCPtr, index);
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103 /// whether a writable property can be the target of an animation.
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)
110 bool ret = Interop.Handle.IsPropertyAnimatable(SwigCPtr, index);
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 /// Queries the type of a property.
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)
123 PropertyType ret = (PropertyType)Interop.Handle.GetPropertyType(SwigCPtr, index);
124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129 /// Sets the value of an existing property.
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)
136 Tizen.NUI.Object.SetProperty(SwigCPtr, index, propertyValue);
140 /// Sets the value of an existing property.
142 /// <param name="name">The index of the property.</param>
143 /// <param name="propertyValue">The new value of the property.</param>
144 /// This will not be public opened.
145 [EditorBrowsable(EditorBrowsableState.Never)]
146 public void SetProperty(string name, PropertyValue propertyValue)
148 var propertyName = LowerFirstLetter(name);
149 Property property = new Property(this, propertyName);
150 if (property.propertyIndex == Property.InvalidIndex)
152 Tizen.Log.Error("NUI", "Invalid property name\n");
156 Tizen.NUI.Object.SetProperty(SwigCPtr, property.propertyIndex, propertyValue);
162 /// Registers a new animatable property.
164 /// <param name="name">The name of the property.</param>
165 /// <param name="propertyValue">The new value of the property.</param>
166 /// <returns>The type of the property.</returns>
167 /// <since_tizen> 3 </since_tizen>
168 public int RegisterProperty(string name, PropertyValue propertyValue)
170 int ret = Interop.Handle.RegisterProperty(SwigCPtr, name, PropertyValue.getCPtr(propertyValue));
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 /// Registers a new animatable property.
178 /// <param name="name">The name of the property.</param>
179 /// <param name="propertyValue">The new value of the property.</param>
180 /// <param name="accessMode">The property access mode (writable, animatable etc).</param>
181 /// <returns>The type of the property.</returns>
182 /// <since_tizen> 3 </since_tizen>
183 public int RegisterProperty(string name, PropertyValue propertyValue, PropertyAccessMode accessMode)
185 int ret = Interop.Handle.RegisterProperty(SwigCPtr, name, PropertyValue.getCPtr(propertyValue), (int)accessMode);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 /// Retrieves a property value.
193 /// <param name="index">The index of the property.</param>
194 /// <returns>The property value.</returns>
195 /// <since_tizen> 3 </since_tizen>
196 public PropertyValue GetProperty(int index)
198 PropertyValue ret = Tizen.NUI.Object.GetProperty(SwigCPtr, index);
203 /// Adds a property notification to this object.
205 /// <param name="property">The name of the property.</param>
206 /// <param name="condition">The notification will be triggered when this condition is satisfied.</param>
207 /// <returns>A handle to the newly created PropertyNotification.</returns>
208 /// <since_tizen> 4 </since_tizen>
209 public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition)
211 Property properties = PropertyHelper.GetPropertyFromString(this, property);
212 PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, properties.propertyIndex, PropertyCondition.getCPtr(condition)), true);
213 properties.Dispose();
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// Removes a property notification from this object.
221 /// <param name="propertyNotification">The propertyNotification to be removed.</param>
222 /// <since_tizen> 4 </since_tizen>
223 public void RemovePropertyNotification(PropertyNotification propertyNotification)
225 Interop.Handle.RemovePropertyNotification(SwigCPtr, PropertyNotification.getCPtr(propertyNotification));
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 /// Removes a property notification from this object.
232 /// <since_tizen> 4 </since_tizen>
233 public void RemovePropertyNotifications()
235 Interop.Handle.RemovePropertyNotifications(SwigCPtr);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 internal uint GetPropertyCount()
241 uint ret = Interop.HandleInternal.HandleGetPropertyCount(SwigCPtr);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 internal PropertyNotification AddPropertyNotification(int index, int componentIndex, PropertyCondition condition)
248 PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, index, componentIndex, PropertyCondition.getCPtr(condition)), true);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 internal void RemoveConstraints()
255 Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr);
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259 internal void RemoveConstraints(uint tag)
261 Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr, tag);
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 private static string LowerFirstLetter(string original)
267 StringBuilder sb = new StringBuilder(original);
268 sb[0] = (char)(sb[0] | 0x20);
269 return sb.ToString();
272 /// This will not be public opened.
273 [EditorBrowsable(EditorBrowsableState.Never)]
274 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
276 Interop.Handle.DeleteHandle(swigCPtr);