private View targetView;
private BindableProperty targetBindableProperty;
}
+
+ internal static class SelectorHelper<T> where T : class, Tizen.NUI.ICloneable
+ {
+ /// <summary>
+ /// For the object type of T or Selector T, convert it to Selector T and return the cloned one.
+ /// Otherwise, return null. <br/>
+ /// </summary>
+ static internal Selector<T> Clone(object value)
+ {
+ var type = value?.GetType();
+
+ if (type == typeof(Selector<T>))
+ {
+ var result = new Selector<T>();
+ result.Clone((Selector<T>)value);
+ return result;
+ }
+
+ if (type == typeof(T))
+ {
+ var result = new Selector<T>();
+ result.Clone((T)value);
+ return result;
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// For the object type of T or Selector T, convert it to T and return the cloned one.
+ /// Otherwise, return null. <br/>
+ /// </summary>
+ static internal T Clone(object value, View view)
+ {
+ var type = value?.GetType();
+
+ if (type == typeof(T))
+ {
+ return (T)((T)value).Clone();
+ }
+
+ if (type == typeof(Selector<T>) && view != null)
+ {
+ Selector<T> selector = (Selector<T>)value;
+ T valueInState = selector.GetValue(view.ControlState);
+
+ return (T)valueInState?.Clone();
+ }
+
+ return null;
+ }
+ }
}
private Extents margin;
private float? weight;
+ private Selector<ImageShadow> imageShadow;
+
+ private Selector<Shadow> boxShadow;
+
static ViewStyle() {}
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
return viewStyle.backgroundImageBorderSelector;
});
+ /// A BindableProperty for ImageShadow
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty ImageShadowProperty = BindableProperty.Create(nameof(ImageShadow), typeof(Selector<ImageShadow>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var viewStyle = (ViewStyle)bindable;
+ viewStyle.imageShadow = SelectorHelper<ImageShadow>.Clone(newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var viewStyle = (ViewStyle)bindable;
+ return viewStyle.imageShadow;
+ });
+
+ /// A BindableProperty for BoxShadow
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty BoxShadowProperty = BindableProperty.Create(nameof(BoxShadow), typeof(Selector<ImageShadow>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var viewStyle = (ViewStyle)bindable;
+ viewStyle.boxShadow = SelectorHelper<Shadow>.Clone(newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var viewStyle = (ViewStyle)bindable;
+ return viewStyle.boxShadow;
+ });
+
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewStyle()
}
set => SetValue(BackgroundImageBorderSelectorProperty, value);
}
+
+ /// <summary>
+ /// Describes a shadow as an image for a View.
+ /// It is null by default.
+ /// </summary>
+ /// <remarks>
+ /// The mutually exclusive with "BoxShadow".
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Selector<ImageShadow> ImageShadow
+ {
+ get => (Selector<ImageShadow>)GetValue(ImageShadowProperty);
+ set => SetValue(ImageShadowProperty, value);
+ }
+
+ /// <summary>
+ /// Describes a box shaped shadow drawing for a View.
+ /// It is null by default.
+ /// </summary>
+ /// <remarks>
+ /// The mutually exclusive with "ImageShadow".
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Selector<Shadow> BoxShadow
+ {
+ get => (Selector<Shadow>)GetValue(BoxShadowProperty);
+ set => SetValue(BoxShadowProperty, value);
+ }
}
}
}
/// <summary>
- /// Describes a shadow as an image for View.
+ /// Describes a shadow as an image for a View.
/// It is null by default.
/// </summary>
/// <remarks>
/// The mutually exclusive with "BoxShadow".
- /// If it is not null, the "BoxShadow" property will be ignored.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public ImageShadow ImageShadow
{
get
{
- return (ImageShadow)GetValue(ImageShadowProperty);
+ var value = (ImageShadow)GetValue(ImageShadowProperty);
+ return value == null ? null : new ImageShadow(value, OnImageShadowChanged);
}
set
{
- value.OnPropertyChanged = OnImageShadowChanged;
SetValue(ImageShadowProperty, value);
NotifyPropertyChanged();
}
}
/// <summary>
- /// Describes a box shaped shadow drawing for View.
+ /// Describes a box shaped shadow drawing for a View.
/// It is null by default.
/// </summary>
/// <remarks>
/// The mutually exclusive with "ImageShadow".
- /// If the "ImageShadow" is not null, this property will be ignored.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public Shadow BoxShadow
{
get
{
- return (Shadow)GetValue(BoxShadowProperty);
+ var value = (Shadow)GetValue(BoxShadowProperty);
+ return value == null ? null : new Shadow(value, OnBoxShadowChanged);
}
set
{
- value.OnPropertyChanged = OnBoxShadowChanged;
SetValue(BoxShadowProperty, value);
NotifyPropertyChanged();
}
public static readonly BindableProperty ImageShadowProperty = BindableProperty.Create("ImageShadow", typeof(ImageShadow), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var view = (View)bindable;
- view.imageShadow = (ImageShadow)newValue;
+ view.imageShadow = SelectorHelper<ImageShadow>.Clone(newValue, view);
Tizen.NUI.Object.SetProperty(view.swigCPtr, Interop.ViewProperty.View_Property_SHADOW_get(), ImageShadow.ToPropertyValue(view.imageShadow));
},
defaultValueCreator: (bindable) =>
public static readonly BindableProperty BoxShadowProperty = BindableProperty.Create("BoxShadow", typeof(Shadow), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var view = (View)bindable;
- view.boxShadow = (Shadow)newValue;
- if (view.imageShadow == null)
- {
- Tizen.NUI.Object.SetProperty(view.swigCPtr, Interop.ViewProperty.View_Property_SHADOW_get(), Shadow.ToPropertyValue(view.boxShadow));
- }
+ view.boxShadow = SelectorHelper<Shadow>.Clone(newValue, view);
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, Interop.ViewProperty.View_Property_SHADOW_get(), Shadow.ToPropertyValue(view.boxShadow));
},
defaultValueCreator: (bindable) =>
{
--- /dev/null
+/*
+ * Copyright(c) 2020 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;
+
+namespace Tizen.NUI
+{
+
+ /// <summary>
+ /// The class that offer Clone method.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public interface ICloneable
+ {
+ /// <summary>
+ /// Clone object
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ object Clone();
+ }
+}
+
+
/// The Shadow composed of image for View
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class ImageShadow : TransformablePropertyMap
+ public class ImageShadow : TransformablePropertyMap, Tizen.NUI.ICloneable
{
private string url;
{
}
+ internal ImageShadow(ImageShadow other, PropertyChangedCallback callback = null) : base(other)
+ {
+ Url = other.Url;
+ Border = other.Border;
+ OnPropertyChanged = callback;
+ }
+
/// <summary>
/// Deep copy method
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- override public object Clone()
+ public object Clone()
{
return new ImageShadow() {
Offset = offset,
/// The platform provided shadow drawing for View
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class Shadow : TransformablePropertyMap
+ public class Shadow : TransformablePropertyMap, Tizen.NUI.ICloneable
{
private static readonly Color noColor = new Color(0, 0, 0, 0);
Color = defaultColor;
}
+ internal Shadow(Shadow other, PropertyChangedCallback callback = null) : base(other)
+ {
+ Color = other.Color;
+ BlurRadius = other.BlurRadius;
+ OnPropertyChanged = callback;
+ }
+
/// <summary>
/// The boolean conversion
/// </summary>
/// Deep copy method
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- override public object Clone()
+ public object Clone()
{
return new Shadow() {
Offset = offset,
abstract internal bool IsValid();
- /// <summary>
- /// Deep copy method
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- abstract public object Clone();
-
static internal PropertyValue ToPropertyValue(TransformablePropertyMap instance)
{
return (instance != null && instance.IsValid()) ? new PropertyValue(instance.propertyMap) : new PropertyValue();