Adding PropertyMap and PropertyArray types to SetProperty
authorDavid Steele <david.steele@samsung.com>
Fri, 21 Jul 2017 18:54:44 +0000 (19:54 +0100)
committerDavid Steele <david.steele@samsung.com>
Fri, 28 Jul 2017 16:51:04 +0000 (17:51 +0100)
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 <david.steele@samsung.com>
src/Tizen.NUI/src/public/CustomViewRegistry.cs
src/Tizen.NUI/src/public/VisualBase.cs

index e20f0f5..0b5cc21 100755 (executable)
@@ -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<Attribute> ie_attrs = propertyInfo.GetCustomAttributes<Attribute>();
                     List<Attribute> li_attrs = new List<Attribute>(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)
                 {
index 42311b1..c360462 100755 (executable)
@@ -187,9 +187,11 @@ namespace Tizen.NUI
         /// </summary>
         public PropertyMap Creation
         {
-            set
+            get
             {
-                CreatePropertyMap(value);
+                PropertyMap map = new PropertyMap();
+                CreatePropertyMap(map);
+                return map;
             }
         }
         internal void CreatePropertyMap(PropertyMap map)