From 1d53ee1dab84d9d55d867ddc716f75403a3f3e23 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 21 Jul 2017 19:54:44 +0100 Subject: [PATCH] Adding PropertyMap and PropertyArray types to SetProperty Fixed Visual base property map getter to actually get the property. Enables addition of visuals via following setup in a CustomView: private VisualBase _imageVisual; [ScriptableProperty()] public PropertyMap ImageVisual { get { return _imageVisual.Creation; } set { _imageVisual = VisualFactory.Get().CreateVisual( value ); RegisterVisual( GetPropertyIndex("ImageVisual", _imageVisual ); } } Then in code, can use var imageVisual = new ImageVisual(); imageVisual.URL = value; imageVisual.AlphaMaskURL = _maskURL; imageVisual.MaskContentScale = 1.6f; imageVisual.CropToMask = true; ImageVisual = imageVisual.OutputVisualMap; Change-Id: If31703b1684db30d9ed319be62e8b091ee62cdbb Signed-off-by: David Steele --- src/Tizen.NUI/src/public/CustomViewRegistry.cs | 25 +++++++++++++++++++++---- src/Tizen.NUI/src/public/VisualBase.cs | 6 ++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Tizen.NUI/src/public/CustomViewRegistry.cs b/src/Tizen.NUI/src/public/CustomViewRegistry.cs index e20f0f5..0b5cc21 100755 --- a/src/Tizen.NUI/src/public/CustomViewRegistry.cs +++ b/src/Tizen.NUI/src/public/CustomViewRegistry.cs @@ -164,6 +164,8 @@ namespace Tizen.NUI { "Size", PropertyType.Vector2 }, { "Position",PropertyType.Vector3 }, { "Color", PropertyType.Vector4 }, + { "PropertyArray", PropertyType.Array }, + { "PropertyMap", PropertyType.Map }, // { "Matrix3", PropertyType.MATRIX3 }, commented out until we need to use Matrices from JSON // { "Matrix", PropertyType.MATRIX }, }; @@ -279,10 +281,8 @@ namespace Tizen.NUI // Cycle through each property in the class foreach (System.Reflection.PropertyInfo propertyInfo in viewType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)) { - if (propertyInfo.CanRead) { - IEnumerable ie_attrs = propertyInfo.GetCustomAttributes(); List li_attrs = new List(ie_attrs); System.Attribute[] attrs = li_attrs.ToArray(); @@ -356,7 +356,6 @@ namespace Tizen.NUI if (view != null) { System.Reflection.PropertyInfo propertyInfo = view.GetType().GetProperty(propertyName); - // We know the property name, we know it's type, we just need to convert from a DALi property value to native C# type System.Type type = propertyInfo.PropertyType; bool ok = false; @@ -453,9 +452,27 @@ namespace Tizen.NUI propertyInfo.SetValue(view, (Color)value); }; } + else if (type.Equals(typeof(PropertyMap))) + { + PropertyMap map = new PropertyMap(); + ok = propValue.Get(map); + if( ok ) + { + propertyInfo.SetValue( view, map ); + } + } + else if (type.Equals(typeof(PropertyArray))) + { + PropertyArray array = new PropertyArray(); + ok = propValue.Get(array); + if( ok ) + { + propertyInfo.SetValue( view, array ); + } + } else { - throw new global::System.InvalidOperationException("SetPropertyValue Unimplemented type for Property Value"); + throw new global::System.InvalidOperationException("SetPropertyValue Unimplemented type for Property Value for " + type.FullName ); } if (!ok) { diff --git a/src/Tizen.NUI/src/public/VisualBase.cs b/src/Tizen.NUI/src/public/VisualBase.cs index 42311b1..c360462 100755 --- a/src/Tizen.NUI/src/public/VisualBase.cs +++ b/src/Tizen.NUI/src/public/VisualBase.cs @@ -187,9 +187,11 @@ namespace Tizen.NUI /// public PropertyMap Creation { - set + get { - CreatePropertyMap(value); + PropertyMap map = new PropertyMap(); + CreatePropertyMap(map); + return map; } } internal void CreatePropertyMap(PropertyMap map) -- 2.7.4