From 9b9d61c199ef7bec4a04f5c315a2e3ea2f75042f Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Mon, 4 Sep 2017 15:21:34 +0100 Subject: Adding Property Notification support Moving Property files from internal to public Creating helper class to be used when animatables provide properties as strings not indexes. Animatables can now connect to Notify and use the defined conditional functions Change-Id: Iac5d5e7b6ced6df9d2b651d36559f223e5a06fdc --- Tizen.NUI/src/internal/NDalic.cs | 42 ----- Tizen.NUI/src/internal/PropertyCondition.cs | 100 ---------- Tizen.NUI/src/internal/PropertyHelper.cs | 40 ++++ Tizen.NUI/src/internal/PropertyNotification.cs | 239 ------------------------ Tizen.NUI/src/internal/PropertyNotifySignal.cs | 148 --------------- Tizen.NUI/src/public/Animatable.cs | 8 +- Tizen.NUI/src/public/Animation.cs | 55 +----- Tizen.NUI/src/public/PropertyCondition.cs | 155 ++++++++++++++++ Tizen.NUI/src/public/PropertyNotification.cs | 242 +++++++++++++++++++++++++ Tizen.NUI/src/public/PropertyNotifySignal.cs | 151 +++++++++++++++ 10 files changed, 598 insertions(+), 582 deletions(-) delete mode 100755 Tizen.NUI/src/internal/PropertyCondition.cs create mode 100755 Tizen.NUI/src/internal/PropertyHelper.cs delete mode 100755 Tizen.NUI/src/internal/PropertyNotification.cs delete mode 100755 Tizen.NUI/src/internal/PropertyNotifySignal.cs create mode 100755 Tizen.NUI/src/public/PropertyCondition.cs create mode 100755 Tizen.NUI/src/public/PropertyNotification.cs create mode 100755 Tizen.NUI/src/public/PropertyNotifySignal.cs diff --git a/Tizen.NUI/src/internal/NDalic.cs b/Tizen.NUI/src/internal/NDalic.cs index b9b3ce3..13697ac 100755 --- a/Tizen.NUI/src/internal/NDalic.cs +++ b/Tizen.NUI/src/internal/NDalic.cs @@ -187,48 +187,6 @@ namespace Tizen.NUI return ret; } - public static PropertyCondition LessThanCondition(float arg) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.LessThanCondition(arg), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public static PropertyCondition GreaterThanCondition(float arg) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.GreaterThanCondition(arg), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public static PropertyCondition InsideCondition(float arg0, float arg1) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.InsideCondition(arg0, arg1), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public static PropertyCondition OutsideCondition(float arg0, float arg1) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.OutsideCondition(arg0, arg1), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public static PropertyCondition StepCondition(float stepAmount, float initialValue) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_0(stepAmount, initialValue), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public static PropertyCondition StepCondition(float stepAmount) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_1(stepAmount), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - public static int WEIGHT { get diff --git a/Tizen.NUI/src/internal/PropertyCondition.cs b/Tizen.NUI/src/internal/PropertyCondition.cs deleted file mode 100755 index 278349f..0000000 --- a/Tizen.NUI/src/internal/PropertyCondition.cs +++ /dev/null @@ -1,100 +0,0 @@ -/** 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. -* -*/ - -namespace Tizen.NUI -{ - - internal class PropertyCondition : BaseHandle - { - private global::System.Runtime.InteropServices.HandleRef swigCPtr; - - internal PropertyCondition(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyCondition_SWIGUpcast(cPtr), cMemoryOwn) - { - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); - } - - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyCondition obj) - { - return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; - } - - protected override void Dispose(DisposeTypes type) - { - if (disposed) - { - return; - } - - if (type == DisposeTypes.Explicit) - { - //Called by User - //Release your own managed resources here. - //You should release all of your own disposable objects here. - - } - - //Release your own unmanaged resources here. - //You should not access any managed member here except static instance. - //because the execution order of Finalizes is non-deterministic. - - if (swigCPtr.Handle != global::System.IntPtr.Zero) - { - if (swigCMemOwn) - { - swigCMemOwn = false; - NDalicPINVOKE.delete_PropertyCondition(swigCPtr); - } - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); - } - - base.Dispose(type); - } - - - public PropertyCondition() : this(NDalicPINVOKE.new_PropertyCondition__SWIG_0(), true) - { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public PropertyCondition(PropertyCondition handle) : this(NDalicPINVOKE.new_PropertyCondition__SWIG_1(PropertyCondition.getCPtr(handle)), true) - { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public PropertyCondition Assign(PropertyCondition rhs) - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyCondition_Assign(swigCPtr, PropertyCondition.getCPtr(rhs)), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public uint GetArgumentCount() - { - uint ret = NDalicPINVOKE.PropertyCondition_GetArgumentCount(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public float GetArgument(uint index) - { - float ret = NDalicPINVOKE.PropertyCondition_GetArgument(swigCPtr, index); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - } - -} diff --git a/Tizen.NUI/src/internal/PropertyHelper.cs b/Tizen.NUI/src/internal/PropertyHelper.cs new file mode 100755 index 0000000..e2b6311 --- /dev/null +++ b/Tizen.NUI/src/internal/PropertyHelper.cs @@ -0,0 +1,40 @@ +/** 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. +* +*/ + +namespace Tizen.NUI +{ + internal static class PropertyHelper + { + /// + /// Returns a Property if stringProperty is a valid index + /// + internal static Property GetPropertyFromString(Animatable handle, string stringProperty) + { + /// Convert property string to be lowercase + string str1 = stringProperty.Substring(0, 1); + string str2 = stringProperty.Substring(1); + string str = str1.ToLower() + str2; + + Property property = new Property(handle, str); + if (property.propertyIndex == Property.INVALID_INDEX) + { + throw new System.ArgumentException("string property is invalid"); + } + + return property; + } + } +} diff --git a/Tizen.NUI/src/internal/PropertyNotification.cs b/Tizen.NUI/src/internal/PropertyNotification.cs deleted file mode 100755 index 50dc344..0000000 --- a/Tizen.NUI/src/internal/PropertyNotification.cs +++ /dev/null @@ -1,239 +0,0 @@ -/** 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. -* -*/ - -namespace Tizen.NUI -{ - - using System; - using System.Runtime.InteropServices; - - - internal class PropertyNotification : BaseHandle - { - private global::System.Runtime.InteropServices.HandleRef swigCPtr; - - internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn) - { - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); - } - - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj) - { - return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; - } - - protected override void Dispose(DisposeTypes type) - { - if (disposed) - { - return; - } - - if (type == DisposeTypes.Explicit) - { - //Called by User - //Release your own managed resources here. - //You should release all of your own disposable objects here. - - } - - //Release your own unmanaged resources here. - //You should not access any managed member here except static instance. - //because the execution order of Finalizes is non-deterministic. - - if (swigCPtr.Handle != global::System.IntPtr.Zero) - { - if (swigCMemOwn) - { - swigCMemOwn = false; - NDalicPINVOKE.delete_PropertyNotification(swigCPtr); - } - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); - } - - base.Dispose(type); - } - - /** - * @brief Event arguments that passed via Notify signal - * - */ - public class NotifyEventArgs : EventArgs - { - private PropertyNotification _propertyNotification; - - /** - * @brief PropertyNotification - is the PropertyNotification handle that has the notification properties. - * - */ - public PropertyNotification PropertyNotification - { - get - { - return _propertyNotification; - } - set - { - _propertyNotification = value; - } - } - } - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification); - private DaliEventHandler _propertyNotificationNotifyEventHandler; - private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate; - - /** - * @brief Event for Notified signal which can be used to subscribe/unsubscribe the event handler - * (in the type of NotifyEventHandler-DaliEventHandler) provided by the user. - * Notified signal is emitted when the notification upon a condition of the property being met, has occurred. - */ - public event DaliEventHandler Notified - { - add - { - lock (this) - { - // Restricted to only one listener - if (_propertyNotificationNotifyEventHandler == null) - { - _propertyNotificationNotifyEventHandler += value; - - _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify); - this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate); - } - } - } - - remove - { - lock (this) - { - if (_propertyNotificationNotifyEventHandler != null) - { - this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate); - } - - _propertyNotificationNotifyEventHandler -= value; - } - } - } - - // Callback for PropertyNotification NotifySignal - private void OnPropertyNotificationNotify(IntPtr propertyNotification) - { - NotifyEventArgs e = new NotifyEventArgs(); - e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification); - - if (_propertyNotificationNotifyEventHandler != null) - { - //here we send all data to user event handlers - _propertyNotificationNotifyEventHandler(this, e); - } - } - - public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr) - { - PropertyNotification ret = new PropertyNotification(cPtr, false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - - public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true) - { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public static PropertyNotification DownCast(BaseHandle handle) - { - PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification; - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true) - { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public PropertyNotification Assign(PropertyNotification rhs) - { - PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public PropertyCondition GetCondition() - { - PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public Animatable GetTarget() - { - Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public int GetTargetProperty() - { - int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public void SetNotifyMode(PropertyNotification.NotifyMode mode) - { - NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public PropertyNotification.NotifyMode GetNotifyMode() - { - PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public bool GetNotifyResult() - { - bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public PropertyNotifySignal NotifySignal() - { - PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public enum NotifyMode - { - Disabled, - NotifyOnTrue, - NotifyOnFalse, - NotifyOnChanged - } - - } - -} diff --git a/Tizen.NUI/src/internal/PropertyNotifySignal.cs b/Tizen.NUI/src/internal/PropertyNotifySignal.cs deleted file mode 100755 index 59e96cb..0000000 --- a/Tizen.NUI/src/internal/PropertyNotifySignal.cs +++ /dev/null @@ -1,148 +0,0 @@ -/** 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. -* -*/ - -namespace Tizen.NUI -{ - - internal class PropertyNotifySignal : global::System.IDisposable - { - private global::System.Runtime.InteropServices.HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal PropertyNotifySignal(global::System.IntPtr cPtr, bool cMemoryOwn) - { - swigCMemOwn = cMemoryOwn; - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); - } - - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotifySignal obj) - { - return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; - } - - //A Flag to check who called Dispose(). (By User or DisposeQueue) - private bool isDisposeQueued = false; - //A Flat to check if it is already disposed. - protected bool disposed = false; - - - ~PropertyNotifySignal() - { - if (!isDisposeQueued) - { - isDisposeQueued = true; - DisposeQueue.Instance.Add(this); - } - } - - public void Dispose() - { - //Throw excpetion if Dispose() is called in separate thread. - if (!Window.IsInstalled()) - { - throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread."); - } - - if (isDisposeQueued) - { - Dispose(DisposeTypes.Implicit); - } - else - { - Dispose(DisposeTypes.Explicit); - System.GC.SuppressFinalize(this); - } - } - - protected virtual void Dispose(DisposeTypes type) - { - if (disposed) - { - return; - } - - if (type == DisposeTypes.Explicit) - { - //Called by User - //Release your own managed resources here. - //You should release all of your own disposable objects here. - - } - - //Release your own unmanaged resources here. - //You should not access any managed member here except static instance. - //because the execution order of Finalizes is non-deterministic. - - if (swigCPtr.Handle != global::System.IntPtr.Zero) - { - if (swigCMemOwn) - { - swigCMemOwn = false; - NDalicPINVOKE.delete_PropertyNotifySignal(swigCPtr); - } - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); - } - - disposed = true; - } - - - public bool Empty() - { - bool ret = NDalicPINVOKE.PropertyNotifySignal_Empty(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public uint GetConnectionCount() - { - uint ret = NDalicPINVOKE.PropertyNotifySignal_GetConnectionCount(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public void Connect(System.Delegate func) - { - System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); - { - NDalicPINVOKE.PropertyNotifySignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - } - - public void Disconnect(System.Delegate func) - { - System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); - { - NDalicPINVOKE.PropertyNotifySignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - } - - public void Emit(PropertyNotification arg) - { - NDalicPINVOKE.PropertyNotifySignal_Emit(swigCPtr, PropertyNotification.getCPtr(arg)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - public PropertyNotifySignal() : this(NDalicPINVOKE.new_PropertyNotifySignal(), true) - { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - } - -} diff --git a/Tizen.NUI/src/public/Animatable.cs b/Tizen.NUI/src/public/Animatable.cs index 578477f..b5c056e 100755 --- a/Tizen.NUI/src/public/Animatable.cs +++ b/Tizen.NUI/src/public/Animatable.cs @@ -137,9 +137,9 @@ namespace Tizen.NUI return ret; } - internal PropertyNotification AddPropertyNotification(int index, PropertyCondition condition) + public PropertyNotification AddPropertyNotification(string property, PropertyCondition condition) { - PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.Handle_AddPropertyNotification__SWIG_0(swigCPtr, index, PropertyCondition.getCPtr(condition)), true); + PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.Handle_AddPropertyNotification__SWIG_0(swigCPtr, PropertyHelper.GetPropertyFromString(this, property).propertyIndex, PropertyCondition.getCPtr(condition)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -151,13 +151,13 @@ namespace Tizen.NUI return ret; } - internal void RemovePropertyNotification(PropertyNotification propertyNotification) + public void RemovePropertyNotification(PropertyNotification propertyNotification) { NDalicPINVOKE.Handle_RemovePropertyNotification(swigCPtr, PropertyNotification.getCPtr(propertyNotification)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal void RemovePropertyNotifications() + public void RemovePropertyNotifications() { NDalicPINVOKE.Handle_RemovePropertyNotifications(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); diff --git a/Tizen.NUI/src/public/Animation.cs b/Tizen.NUI/src/public/Animation.cs index ba4e606..312ad08 100755 --- a/Tizen.NUI/src/public/Animation.cs +++ b/Tizen.NUI/src/public/Animation.cs @@ -458,15 +458,7 @@ namespace Tizen.NUI /// The alpha function to apply public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null) { - string _str1 = property.Substring(0, 1); - string _str2 = property.Substring(1); - string _str = _str1.ToLower() + _str2; - - Property _prop = new Property(target, _str); - if (_prop.propertyIndex == Property.INVALID_INDEX) - { - throw new System.ArgumentException("second argument string property is invalid parameter!"); - } + Property _prop = PropertyHelper.GetPropertyFromString(target, property); PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex); if(propertyType.Equals(PropertyType.Float)) @@ -502,15 +494,7 @@ namespace Tizen.NUI /// The alpha function to apply public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null) { - string _str1 = property.Substring(0, 1); - string _str2 = property.Substring(1); - string _str = _str1.ToLower() + _str2; - - Property _prop = new Property(target, _str); - if (_prop.propertyIndex == Property.INVALID_INDEX) - { - throw new System.ArgumentException("second argument string property is invalid parameter!"); - } + Property _prop = PropertyHelper.GetPropertyFromString(target, property); PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex); if(propertyType.Equals(PropertyType.Float)) @@ -546,15 +530,7 @@ namespace Tizen.NUI /// The alpha function to apply public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null) { - string _str1 = property.Substring(0, 1); - string _str2 = property.Substring(1); - string _str = _str1.ToLower() + _str2; - - Property _prop = new Property(target, _str); - if (_prop.propertyIndex == Property.INVALID_INDEX) - { - throw new System.ArgumentException("second argument string property is invalid parameter!"); - } + Property _prop = PropertyHelper.GetPropertyFromString(target, property); PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex); if(propertyType.Equals(PropertyType.Float)) @@ -591,15 +567,7 @@ namespace Tizen.NUI /// The alpha function to apply public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null) { - string _str1 = property.Substring(0, 1); - string _str2 = property.Substring(1); - string _str = _str1.ToLower() + _str2; - - Property _prop = new Property(target, _str); - if (_prop.propertyIndex == Property.INVALID_INDEX) - { - throw new System.ArgumentException("second argument string property is invalid parameter!"); - } + Property _prop = PropertyHelper.GetPropertyFromString(target, property); PropertyType propertyType = target.GetPropertyType(_prop.propertyIndex); if(propertyType.Equals(PropertyType.Float)) @@ -636,11 +604,8 @@ namespace Tizen.NUI /// The alpha function to apply public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null) { - string _str1 = property.Substring(0, 1); - string _str2 = property.Substring(1); - string _str = _str1.ToLower() + _str2; + Property _prop = PropertyHelper.GetPropertyFromString(target, property); - Property _prop = new Property(target, _str); if (_prop.propertyIndex == Property.INVALID_INDEX) { throw new System.ArgumentException("second argument string property is invalid parameter!"); @@ -669,15 +634,7 @@ namespace Tizen.NUI /// The alpha function to apply public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null) { - string _str1 = property.Substring(0, 1); - string _str2 = property.Substring(1); - string _str = _str1.ToLower() + _str2; - - Property _prop = new Property(target, _str); - if (_prop.propertyIndex == Property.INVALID_INDEX) - { - throw new System.ArgumentException("second argument string property is invalid parameter!"); - } + Property _prop = PropertyHelper.GetPropertyFromString(target, property); Tizen.NUI.TimePeriod time = new Tizen.NUI.TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)); if (alphaFunction != null) diff --git a/Tizen.NUI/src/public/PropertyCondition.cs b/Tizen.NUI/src/public/PropertyCondition.cs new file mode 100755 index 0000000..4fc3f66 --- /dev/null +++ b/Tizen.NUI/src/public/PropertyCondition.cs @@ -0,0 +1,155 @@ +/** 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. +* +*/ + +namespace Tizen.NUI +{ + /// + /// A condition that can be evaluated on a Property Value + /// + public class PropertyCondition : BaseHandle + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal PropertyCondition(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyCondition_SWIGUpcast(cPtr), cMemoryOwn) + { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyCondition obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + protected override void Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (swigCPtr.Handle != global::System.IntPtr.Zero) + { + if (swigCMemOwn) + { + swigCMemOwn = false; + NDalicPINVOKE.delete_PropertyCondition(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + base.Dispose(type); + } + + + public PropertyCondition() : this(NDalicPINVOKE.new_PropertyCondition__SWIG_0(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Retrieves the arguments that this condition uses. + /// + public uint GetArgumentCount() + { + uint ret = NDalicPINVOKE.PropertyCondition_GetArgumentCount(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + /// + /// Retrieves the arguments that this condition uses + /// + public float GetArgument(uint index) + { + float ret = NDalicPINVOKE.PropertyCondition_GetArgument(swigCPtr, index); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// LessThan condition compares whether property is less than arg. + /// + public static PropertyCondition LessThan(float arg) + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.LessThanCondition(arg), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// GreaterThan condition compares whether property is greater than arg. + /// + public static PropertyCondition GreaterThan(float arg) + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.GreaterThanCondition(arg), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Inside condition compares whether property is greater than arg0 and less than arg1. + /// + public static PropertyCondition Inside(float arg0, float arg1) + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.InsideCondition(arg0, arg1), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Outside condition compares whether property is less than arg0 or greater than arg1 + /// + public static PropertyCondition Outside(float arg0, float arg1) + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.OutsideCondition(arg0, arg1), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Detects when a property changes by stepAmount from initialValue, in both positive and negative directions. This will continue checking for multiples of stepAmount. + /// + public static PropertyCondition Step(float stepAmount, float initialValue) + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_0(stepAmount, initialValue), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Receives notifications as a property goes above/below the inputted values. Values must be ordered and can be either ascending or descending. + /// + public static PropertyCondition Step(float stepAmount) + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.StepCondition__SWIG_1(stepAmount), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + } + +} diff --git a/Tizen.NUI/src/public/PropertyNotification.cs b/Tizen.NUI/src/public/PropertyNotification.cs new file mode 100755 index 0000000..3b0fc65 --- /dev/null +++ b/Tizen.NUI/src/public/PropertyNotification.cs @@ -0,0 +1,242 @@ +/** 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. +* +*/ + +namespace Tizen.NUI +{ + + using System; + using System.Runtime.InteropServices; + + /// + /// Issues a notification upon a condition of the property being met. + /// See PropertyCondition for available defined conditions. + /// + public class PropertyNotification : BaseHandle + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn) + { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + protected override void Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (swigCPtr.Handle != global::System.IntPtr.Zero) + { + if (swigCMemOwn) + { + swigCMemOwn = false; + NDalicPINVOKE.delete_PropertyNotification(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + base.Dispose(type); + } + + /** + * @brief Event arguments that passed via Notify signal + * + */ + public class NotifyEventArgs : EventArgs + { + private PropertyNotification _propertyNotification; + + /** + * @brief PropertyNotification - is the PropertyNotification handle that has the notification properties. + * + */ + public PropertyNotification PropertyNotification + { + get + { + return _propertyNotification; + } + set + { + _propertyNotification = value; + } + } + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification); + private DaliEventHandler _propertyNotificationNotifyEventHandler; + private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate; + + /** + * @brief Event for Notified signal which can be used to subscribe/unsubscribe the event handler + * (in the type of NotifyEventHandler-DaliEventHandler) provided by the user. + * Notified signal is emitted when the notification upon a condition of the property being met, has occurred. + */ + public event DaliEventHandler Notified + { + add + { + lock (this) + { + // Restricted to only one listener + if (_propertyNotificationNotifyEventHandler == null) + { + _propertyNotificationNotifyEventHandler += value; + + _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify); + this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate); + } + } + } + + remove + { + lock (this) + { + if (_propertyNotificationNotifyEventHandler != null) + { + this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate); + } + + _propertyNotificationNotifyEventHandler -= value; + } + } + } + + // Callback for PropertyNotification NotifySignal + private void OnPropertyNotificationNotify(IntPtr propertyNotification) + { + NotifyEventArgs e = new NotifyEventArgs(); + e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification); + + if (_propertyNotificationNotifyEventHandler != null) + { + //here we send all data to user event handlers + _propertyNotificationNotifyEventHandler(this, e); + } + } + + public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr) + { + PropertyNotification ret = new PropertyNotification(cPtr, false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + + public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public static PropertyNotification DownCast(BaseHandle handle) + { + PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification; + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public PropertyNotification Assign(PropertyNotification rhs) + { + PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public PropertyCondition GetCondition() + { + PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public Animatable GetTarget() + { + Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public int GetTargetProperty() + { + int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void SetNotifyMode(PropertyNotification.NotifyMode mode) + { + NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public PropertyNotification.NotifyMode GetNotifyMode() + { + PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public bool GetNotifyResult() + { + bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public PropertyNotifySignal NotifySignal() + { + PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public enum NotifyMode + { + Disabled, + NotifyOnTrue, + NotifyOnFalse, + NotifyOnChanged + } + + } + +} diff --git a/Tizen.NUI/src/public/PropertyNotifySignal.cs b/Tizen.NUI/src/public/PropertyNotifySignal.cs new file mode 100755 index 0000000..4919007 --- /dev/null +++ b/Tizen.NUI/src/public/PropertyNotifySignal.cs @@ -0,0 +1,151 @@ +/** 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. +* +*/ + +namespace Tizen.NUI +{ + + /// + /// Signal connection class for PropertyNotification + /// + public class PropertyNotifySignal : global::System.IDisposable + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal PropertyNotifySignal(global::System.IntPtr cPtr, bool cMemoryOwn) + { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotifySignal obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + + //A Flag to check who called Dispose(). (By User or DisposeQueue) + private bool isDisposeQueued = false; + //A Flat to check if it is already disposed. + protected bool disposed = false; + + + ~PropertyNotifySignal() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + public void Dispose() + { + //Throw excpetion if Dispose() is called in separate thread. + if (!Window.IsInstalled()) + { + throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread."); + } + + if (isDisposeQueued) + { + Dispose(DisposeTypes.Implicit); + } + else + { + Dispose(DisposeTypes.Explicit); + System.GC.SuppressFinalize(this); + } + } + + protected virtual void Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (swigCPtr.Handle != global::System.IntPtr.Zero) + { + if (swigCMemOwn) + { + swigCMemOwn = false; + NDalicPINVOKE.delete_PropertyNotifySignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + disposed = true; + } + + + public bool Empty() + { + bool ret = NDalicPINVOKE.PropertyNotifySignal_Empty(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint GetConnectionCount() + { + uint ret = NDalicPINVOKE.PropertyNotifySignal_GetConnectionCount(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Connect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + NDalicPINVOKE.PropertyNotifySignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Disconnect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + NDalicPINVOKE.PropertyNotifySignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Emit(PropertyNotification arg) + { + NDalicPINVOKE.PropertyNotifySignal_Emit(swigCPtr, PropertyNotification.getCPtr(arg)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public PropertyNotifySignal() : this(NDalicPINVOKE.new_PropertyNotifySignal(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + } + +} -- cgit v1.2.3