/*
* Copyright(c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System.ComponentModel;
using System.Text;
namespace Tizen.NUI
{
///
/// Animatable.
///
/// 3
public class Animatable : BaseHandle
{
///
/// Create an instance of animatable.
///
/// 3
public Animatable() : this(Interop.Handle.New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal Animatable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
}
///
/// Enumeration for Handle's capabilities that can be queried.
///
/// 3
public enum Capability
{
///
/// Some objects support dynamic property creation at run-time.
/// New properties are registered by calling RegisterProperty() with an unused property name.
///
/// 3
DYNAMIC_PROPERTIES = 0x01
}
///
/// Queries the name of a property.
///
/// The index of the property.
/// The name of the property.
/// 3
public string GetPropertyName(int index)
{
string ret = Interop.Handle.GetPropertyName(SwigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Queries the index of a property.
///
/// The name of the property.
/// The index of the property.
/// 3
public int GetPropertyIndex(string name)
{
// Convert property string to be lowercase
StringBuilder sb = new StringBuilder(name);
sb[0] = (char)(sb[0] | 0x20);
string str = sb.ToString();
int ret = Interop.Handle.GetPropertyIndex(SwigCPtr, str);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Queries whether a property can be writable.
///
/// The index of the property.
/// True if the property is writable.
/// 3
public bool IsPropertyWritable(int index)
{
bool ret = Interop.Handle.IsPropertyWritable(SwigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// whether a writable property can be the target of an animation.
///
/// The index of the property.
/// True if the property is animatable.
/// 3
public bool IsPropertyAnimatable(int index)
{
bool ret = Interop.Handle.IsPropertyAnimatable(SwigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Queries the type of a property.
///
/// The index of the property.
/// The type of the property.
/// 3
public PropertyType GetPropertyType(int index)
{
PropertyType ret = (PropertyType)Interop.Handle.GetPropertyType(SwigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Sets the value of an existing property.
///
/// The index of the property.
/// The new value of the property.
/// 3
public void SetProperty(int index, PropertyValue propertyValue)
{
Tizen.NUI.Object.SetProperty(SwigCPtr, index, propertyValue);
}
///
/// Sets the value of an existing property.
///
/// The index of the property.
/// The new value of the property.
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetProperty(string name, PropertyValue propertyValue)
{
var propertyName = LowerFirstLetter(name);
Property property = new Property(this, propertyName);
if (property.propertyIndex == Property.InvalidIndex)
{
Tizen.Log.Error("NUI", "Invalid property name\n");
}
else
{
Tizen.NUI.Object.SetProperty(SwigCPtr, property.propertyIndex, propertyValue);
}
property.Dispose();
}
///
/// Registers a new animatable property.
///
/// The name of the property.
/// The new value of the property.
/// The type of the property.
/// 3
public int RegisterProperty(string name, PropertyValue propertyValue)
{
int ret = Interop.Handle.RegisterProperty(SwigCPtr, name, PropertyValue.getCPtr(propertyValue));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Registers a new animatable property.
///
/// The name of the property.
/// The new value of the property.
/// The property access mode (writable, animatable etc).
/// The type of the property.
/// 3
public int RegisterProperty(string name, PropertyValue propertyValue, PropertyAccessMode accessMode)
{
int ret = Interop.Handle.RegisterProperty(SwigCPtr, name, PropertyValue.getCPtr(propertyValue), (int)accessMode);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Retrieves a property value.
///
/// The index of the property.
/// The property value.
/// 3
public PropertyValue GetProperty(int index)
{
PropertyValue ret = Tizen.NUI.Object.GetProperty(SwigCPtr, index);
return ret;
}
///
/// Adds a property notification to this object.
///
/// The name of the property.
/// The notification will be triggered when this condition is satisfied.
/// A handle to the newly created PropertyNotification.
/// 4
public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition)
{
Property properties = PropertyHelper.GetPropertyFromString(this, property);
PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, properties.propertyIndex, PropertyCondition.getCPtr(condition)), true);
properties.Dispose();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Removes a property notification from this object.
///
/// The propertyNotification to be removed.
/// 4
public void RemovePropertyNotification(PropertyNotification propertyNotification)
{
Interop.Handle.RemovePropertyNotification(SwigCPtr, PropertyNotification.getCPtr(propertyNotification));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Removes a property notification from this object.
///
/// 4
public void RemovePropertyNotifications()
{
Interop.Handle.RemovePropertyNotifications(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal uint GetPropertyCount()
{
uint ret = Interop.HandleInternal.HandleGetPropertyCount(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal PropertyNotification AddPropertyNotification(int index, int componentIndex, PropertyCondition condition)
{
PropertyNotification ret = new PropertyNotification(Interop.Handle.AddPropertyNotification(SwigCPtr, index, componentIndex, PropertyCondition.getCPtr(condition)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void RemoveConstraints()
{
Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal void RemoveConstraints(uint tag)
{
Interop.HandleInternal.HandleRemoveConstraints(SwigCPtr, tag);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
private static string LowerFirstLetter(string original)
{
StringBuilder sb = new StringBuilder(original);
sb[0] = (char)(sb[0] | 0x20);
return sb.ToString();
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.Handle.DeleteHandle(swigCPtr);
}
}
}