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 /// Retrieves the latest rendered frame value of the property.
205 /// <param name="index">The index of the property.</param>
206 /// <returns>The property value.</returns>
207 [EditorBrowsable(EditorBrowsableState.Never)]
208 public PropertyValue GetCurrentProperty(int index)
210 PropertyValue ret = Tizen.NUI.Object.GetCurrentProperty(SwigCPtr, index);
215 /// Adds a property notification to this object.
217 /// <param name="property">The name of the property.</param>
218 /// <param name="condition">The notification will be triggered when this condition is satisfied.</param>
219 /// <returns>A handle to the newly created PropertyNotification.</returns>
220 /// <since_tizen> 4 </since_tizen>
221 public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition)
223 Property properties = PropertyHelper.GetPropertyFromString(this, property);
224 PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, properties.PropertyIndex, PropertyCondition.getCPtr(condition)), true);
225 properties.Dispose();
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 /// Removes a property notification from this object.
233 /// <param name="propertyNotification">The propertyNotification to be removed.</param>
234 /// <since_tizen> 4 </since_tizen>
235 public void RemovePropertyNotification(PropertyNotification propertyNotification)
237 Interop.Handle.RemovePropertyNotification(SwigCPtr, PropertyNotification.getCPtr(propertyNotification));
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// Removes a property notification from this object.
244 /// <since_tizen> 4 </since_tizen>
245 public void RemovePropertyNotifications()
247 Interop.Handle.RemovePropertyNotifications(SwigCPtr);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 internal uint GetPropertyCount()
253 uint ret = Interop.HandleInternal.HandleGetPropertyCount(SwigCPtr);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 internal PropertyNotification AddPropertyNotification(int index, int componentIndex, PropertyCondition condition)
260 PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, index, componentIndex, PropertyCondition.getCPtr(condition)), true);
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 internal void RemoveConstraints()
267 Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271 internal void RemoveConstraints(uint tag)
273 Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr, tag);
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 private static string LowerFirstLetter(string original)
279 StringBuilder sb = new StringBuilder(original);
280 sb[0] = (char)(sb[0] | 0x20);
281 return sb.ToString();
284 /// This will not be public opened.
285 [EditorBrowsable(EditorBrowsableState.Never)]
286 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
288 Interop.Handle.DeleteHandle(swigCPtr);