The CornerRadiusPolicy indicates whether the CornerRadius value is relative or absolute.
The default policy is absolute, which means the CornerRadius is an absolute float length.
If the policy is relative, the CornerRadius can have percentage value between 0.0f to 1.0f,
that is relative to the smaller of view's width and height.
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
return ret;
}
- internal override void UpdateCornerRadius(float value)
+ internal override void ApplyCornerRadius()
{
- base.UpdateCornerRadius(value);
+ base.ApplyCornerRadius();
UpdateImage(0, null);
}
private Selector<Color> backgroundColorSelector;
private Selector<Rectangle> backgroundImageBorderSelector;
private Selector<Color> colorSelector;
+ private VisualTransformPolicyType? cornerRadiusPolicy;
static ViewStyle() { }
}
/// <summary>
+ /// Whether the CornerRadius property value is relative (percentage [0.0f to 1.0f] of the view size) or absolute (in world units).
+ /// It is absolute by default.
+ /// When the policy is relative, the corner radius is relative to the smaller of the view's width and height.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public VisualTransformPolicyType? CornerRadiusPolicy
+ {
+ get => (VisualTransformPolicyType?)GetValue(CornerRadiusPolicyProperty);
+ set => SetValue(CornerRadiusPolicyProperty, value);
+ }
+
+ /// <summary>
/// The EnableControlState value of the View.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
return viewStyle.cornerRadius;
});
+ /// <summary> A BindableProperty for CornerRadiusPolicy </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty CornerRadiusPolicyProperty = BindableProperty.Create(nameof(CornerRadiusPolicy), typeof(VisualTransformPolicyType?), typeof(ViewStyle), null,
+ propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).cornerRadiusPolicy = (VisualTransformPolicyType?)newValue,
+ defaultValueCreator: (bindable) => ((ViewStyle)bindable).cornerRadiusPolicy
+ );
+
/// <summary>
/// EnableControlState property
/// </summary>
}
/// <summary>
+ /// Whether the CornerRadius property value is relative (percentage [0.0f to 1.0f] of the view size) or absolute (in world units).
+ /// It is absolute by default.
+ /// When the policy is relative, the corner radius is relative to the smaller of the view's width and height.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public VisualTransformPolicyType CornerRadiusPolicy
+ {
+ get => (VisualTransformPolicyType)GetValue(CornerRadiusPolicyProperty);
+ set => SetValue(CornerRadiusPolicyProperty, value);
+ }
+
+ /// <summary>
/// The current state of the view.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(nameof(CornerRadius), typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
{
var view = (View)bindable;
- view.UpdateCornerRadius((float)newValue);
+ (view.backgroundExtraData ?? (view.backgroundExtraData = new BackgroundExtraData())).CornerRadius = (float)newValue;
+ view.ApplyCornerRadius();
},
defaultValueCreator: (bindable) =>
{
});
/// <summary>
+ /// CornerRadiusPolicy Property
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty CornerRadiusPolicyProperty = BindableProperty.Create(nameof(CornerRadiusPolicy), typeof(VisualTransformPolicyType), typeof(View), VisualTransformPolicyType.Absolute, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ (view.backgroundExtraData ?? (view.backgroundExtraData = new BackgroundExtraData())).CornerRadiusPolicy = (VisualTransformPolicyType)newValue;
+ if (view.backgroundExtraData.CornerRadius != 0)
+ {
+ view.ApplyCornerRadius();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var view = (View)bindable;
+ return view.backgroundExtraData == null ? VisualTransformPolicyType.Absolute : view.backgroundExtraData.CornerRadiusPolicy;
+ });
+
+ /// <summary>
/// EnableControlState property
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
}
- internal virtual void UpdateCornerRadius(float value)
+ /// TODO open as a protected level
+ internal virtual void ApplyCornerRadius()
{
- if (value != 0)
- {
- (backgroundExtraData ?? (backgroundExtraData = new BackgroundExtraData())).CornerRadius = value;
- }
+ if (backgroundExtraData == null) return;
- Tizen.NUI.PropertyMap backgroundMap = new Tizen.NUI.PropertyMap();
+ // Apply to the background visual
+ PropertyMap backgroundMap = new PropertyMap();
PropertyValue background = Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.BACKGROUND);
- background?.Get(backgroundMap);
+ if (background.Get(backgroundMap) && !backgroundMap.Empty())
+ {
+ backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(backgroundExtraData.CornerRadius);
+ backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
+ Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.BACKGROUND, new PropertyValue(backgroundMap));
+ }
+ backgroundMap.Dispose();
+ background.Dispose();
- if (!backgroundMap.Empty())
+ // Apply to the shadow visual
+ PropertyMap shadowMap = new PropertyMap();
+ PropertyValue shadow = Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.SHADOW);
+ if (shadow.Get(shadowMap) && !shadowMap.Empty())
{
- backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(value);
- PropertyValue setValue = new Tizen.NUI.PropertyValue(backgroundMap);
- Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.BACKGROUND, setValue);
- setValue?.Dispose();
+ shadowMap[Visual.Property.CornerRadius] = new PropertyValue(backgroundExtraData.CornerRadius);
+ shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
+ Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, new PropertyValue(shadowMap));
}
- UpdateShadowCornerRadius(value);
- backgroundMap?.Dispose();
- background?.Dispose();
+ shadowMap.Dispose();
+ shadow.Dispose();
}
internal void UpdateStyle()
SizeModeFactor = new Vector3(x, y, z);
}
- private void UpdateShadowCornerRadius(float value)
- {
- // TODO Update corner radius property only whe DALi supports visual property update.
- PropertyMap map = new PropertyMap();
-
- PropertyValue shadowVal = Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.SHADOW);
- if (shadowVal.Get(map) && !map.Empty())
- {
- map[Visual.Property.CornerRadius] = new PropertyValue(value);
-
- PropertyValue setValue = new PropertyValue(map);
- Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, setValue);
- setValue?.Dispose();
- }
- map?.Dispose();
- shadowVal?.Dispose();
- }
-
private bool EmptyOnTouch(object target, TouchEventArgs args)
{
return false;
/// <summary></summary>
internal float CornerRadius { get; set; }
+ /// <summary>
+ /// Whether the CornerRadius value is relative (percentage [0.0f to 1.0f] of the view size) or absolute (in world units).
+ /// </summary>
+ internal VisualTransformPolicyType CornerRadiusPolicy { get; set; } = VisualTransformPolicyType.Absolute;
+
internal bool Empty()
{
return CornerRadius == 0 && Rectangle.IsNullOrZero(BackgroundImageBorder);
if (attachedView.CornerRadius > 0)
{
map[Visual.Property.CornerRadius] = new PropertyValue(attachedView.CornerRadius);
+ map[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)attachedView.CornerRadiusPolicy);
}
- map[Visual.Property.Transform] = GetTransformMap();
-
return new PropertyValue(map);
}
{
PropertyMap map = new PropertyMap();
+ map[Visual.Property.Transform] = GetTransformMap();
+
return map;
}
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly int CornerRadius = NDalic.VISUAL_PROPERTY_MIX_COLOR + 3;
+ /// <summary>
+ /// The corner radius policy of the visual.
+ /// Whether the corner radius value is relative (percentage [0.0f to 1.0f] of the visual size) or absolute (in world units).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly int CornerRadiusPolicy = NDalic.VISUAL_PROPERTY_MIX_COLOR + 4;
}
/// <summary>
Color = new Color(0.2f, 0.2f, 0.2f, 0.3f),
Offset = new Vector2(5, 5),
},
- CornerRadius = 26f,
+ CornerRadius = 0.5f,
+ CornerRadiusPolicy = VisualTransformPolicyType.Relative,
};
root.Add(control);
+
+ var animation = new Animation(2000);
+ animation.AnimateTo(control, "SizeWidth", 200, 0, 1000);
+ animation.AnimateTo(control, "SizeWidth", 100, 1000, 2000);
+ animation.Looping = true;
+ animation.Play();
}
public void Deactivate()