private Size internalSize = null;
private Size2D internalSize2D = null;
private int layoutCount = 0;
+ private ControlState propagatableControlStates = ControlState.All;
static View()
{
{
foreach (View child in Children)
{
- child.ControlState = value;
+ ControlState allowed = child.PropagatableControlStates;
+ if (allowed.Contains(ControlState.All))
+ {
+ child.ControlState = value;
+ }
+ else
+ {
+ ControlState newControlState = child.ControlState;
+
+ if (allowed.Contains(ControlState.Normal))
+ {
+ if (value.Contains(ControlState.Normal))
+ {
+ newControlState += ControlState.Normal;
+ }
+ else
+ {
+ newControlState -= ControlState.Normal;
+ }
+ }
+
+ if (allowed.Contains(ControlState.Disabled))
+ {
+ if (value.Contains(ControlState.Disabled))
+ {
+ newControlState += ControlState.Disabled;
+ }
+ else
+ {
+ newControlState -= ControlState.Disabled;
+ }
+ }
+
+ if (allowed.Contains(ControlState.Selected))
+ {
+ if (value.Contains(ControlState.Selected))
+ {
+ newControlState += ControlState.Selected;
+ }
+ else
+ {
+ newControlState -= ControlState.Selected;
+ }
+ }
+
+ if (allowed.Contains(ControlState.Pressed))
+ {
+ if (value.Contains(ControlState.Pressed))
+ {
+ newControlState += ControlState.Pressed;
+ }
+ else
+ {
+ newControlState -= ControlState.Pressed;
+ }
+ }
+
+ if (allowed.Contains(ControlState.Focused))
+ {
+ if (value.Contains(ControlState.Focused))
+ {
+ newControlState += ControlState.Focused;
+ }
+ else
+ {
+ newControlState -= ControlState.Focused;
+ }
+ }
+
+ if (allowed.Contains(ControlState.Other))
+ {
+ if (value.Contains(ControlState.Other))
+ {
+ newControlState += ControlState.Other;
+ }
+ else
+ {
+ newControlState -= ControlState.Other;
+ }
+ }
+
+ if (child.ControlState != newControlState)
+ child.ControlState = newControlState;
+ }
}
}
}
/// <summary>
+ /// The ControlStates can propagate from the parent.
+ /// Listed ControlStates will be accepted propagation of the parent ControlState changes
+ /// if parent view EnableControlState is true.
+ /// <see cref="EnableControlState"/>.
+ /// Default is ControlState.All, so every ControlStates will be propagated from the parent.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ControlState PropagatableControlStates
+ {
+ get
+ {
+ return (ControlState)GetValue(PropagatableControlStatesProperty);
+ }
+ set
+ {
+ SetValue(PropagatableControlStatesProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+
+ private ControlState InternalPropagatableControlStates
+ {
+ get => propagatableControlStates;
+ set => propagatableControlStates = value;
+ }
+
+ /// <summary>
/// By default, it is false in View, true in Control.
/// Note that if the value is true, the View will be a touch receptor.
/// </summary>
});
/// <summary>
+ /// PropagatableControlStatesProperty
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty PropagatableControlStatesProperty = BindableProperty.Create(nameof(PropagatableControlStates), typeof(ControlState), typeof(View), ControlState.All, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Tizen.NUI.BaseComponents.View)bindable;
+ if (newValue != null)
+ {
+ instance.InternalPropagatableControlStates = (ControlState)newValue;
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Tizen.NUI.BaseComponents.View)bindable;
+ return instance.InternalPropagatableControlStates;
+ });
+
+ /// <summary>
/// GrabTouchAfterLeaveProperty
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
testView.Dispose();
}
+ [Test]
+ [Category("P1")]
+ [Description("Get value test for View.PropagatableControlStates")]
+ [Property("SPEC", "Tizen.NUI.BaseComponents.View.PropagatableControlStates")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "sh10233.lee@samsung.com")]
+ public void PropagatableControlStates_GET_SET_VALUE()
+ {
+ /* TEST CODE */
+ View testView = new View();
+
+ Assert.AreEqual(ControlState.All, testView.PropagatableControlStates, "View PropagatableControlStates should be ControlState.All by default");
+
+ testView.PropagatableControlStates = ControlState.Disabled + ControlState.Selected;
+
+ Assert.AreEqual(ControlState.Disabled + ControlState.Selected, testView.PropagatableControlStates, "View PropagatableControlStates should be ControlState.All by default");
+
+ testView.Dispose();
+ }
+
+
+ [Test]
+ [Category("P1")]
+ [Description("Update value test for View.PropagatableControlStates")]
+ [Property("SPEC", "Tizen.NUI.BaseComponents.View.PropagatableControlStates")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "sh10233.lee@samsung.com")]
+ public void PropagatableControlStates_UPDATE_VALUE()
+ {
+ /* TEST CODE */
+ View parentView = new View();
+ View testView = new View();
+
+ testView.PropagatableControlStates = ControlState.Disabled;
+
+ parentView.Add(testView);
+ parentView.EnableControlStatePropagation = true;
+ parentView.EnableControlState = true;
+ testView.EnableControlState = true;
+
+ Assert.AreEqual(ControlState.Normal, testView.ControlState, "View ControlStates should be ControlState.Normal by default");
+
+ parentView.IsEnabled = false;
+
+ Assert.AreEqual(true, testView.ControlState.Contains(ControlState.Disabled), "View ControlStates should be ControlState.Disabled by parentView propagation");
+
+ testView.PropagatableControlStates -= ControlState.Disabled;
+
+ parentView.IsEnabled = true;
+
+ Assert.AreEqual(true, testView.ControlState.Contains(ControlState.Disabled), "View ControlStates should be ControlState.Disabled as parentView propagation blocked");
+
+ testView.Dispose();
+ }
}
}
check.Sensitive = false;
item.Icon = check;
}
- if (extra) item.Extra = new RadioButton();
+ if (extra)
+ {
+ item.Extra = new RadioButton();
+ // This will makes RadioButton only propagatable Disabled and Pressed state from it's parent view.
+ // Selected, Focused, Other will work as standalone in RadioButton.
+ item.Extra.PropagatableControlStates = ControlState.Disabled + ControlState.Pressed;
+ }
return item;
}