* Fix ControlState propagation to false.
* Fix typo in class name : ControlStateChagedInfo -> ControlStateChangedInfo
* Enhance ControlStateChangeInfo to have InputMethod property.
* Remove combined ControlState handling in Selector: It needs to be well-designed first.
* Fix test/Tizen.NUI.Samples compile errors.
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
if (isEnabled)
{
- // Normal
- targetState = ControlStates.Normal;
+ if (isPressed)
+ {
+ // Pressed
+ targetState = ControlStates.Pressed;
+ }
+ else
+ {
+ // Normal
+ targetState = ControlStates.Normal;
- // Selected
- targetState |= (IsSelected ? ControlStates.Selected : 0);
+ // Selected
+ targetState |= (IsSelected ? ControlStates.Selected : 0);
- // Pressed, PressedSelected, Focused, SelectedFocused
- targetState |= (isPressed ? ControlStates.Pressed : (IsFocused ? ControlStates.Focused : 0));
+ // Focused, SelectedFocused
+ targetState |= (IsFocused ? ControlStates.Focused : 0);
+ }
}
else
{
CreateComponents();
+ EnableControlStatePropagation = true;
+
if (ButtonOverlayImage != null)
{
Add(ButtonOverlayImage);
{
CreateThumb();
}
+
+ EnableControlStatePropagation = true;
}
private void Initialize()
VerticalAlignment = VerticalAlignment.Center
};
Add(TextItem);
+
+ EnableControlStatePropagation = true;
}
internal int Index
return SelectedFocused != null ? SelectedFocused : (Selected != null ? Selected : Other);
default:
{
- // Handle combined states
- if ((int)(state & ControlStates.Selected) != 0 && Selected != null)
- {
- return Selected;
- }
- else if ((int)(state & ControlStates.Pressed) != 0 && Pressed != null)
- {
- return Pressed;
- }
+ // TODO Handle combined states
return Other;
}
}
{
targetView = view;
targetBindableProperty = bindableProperty;
- view.ControlStateChangeEvent += OnViewControlState;
+ view.ControlStateChangeEventInternal += OnViewControlState;
}
/// <summary>
}
}
- private void OnViewControlState(View obj, View.ControlStateChagedInfo controlStateChangedInfo)
+ private void OnViewControlState(View obj, View.ControlStateChangedInfo controlStateChangedInfo)
{
if (null != obj && null != GetValue(controlStateChangedInfo.CurrentState))
{
if (hadMultiValue != HasMultiValue())
{
- if (hadMultiValue) view.ControlStateChangeEvent -= controlStateChanged;
- else view.ControlStateChangeEvent += controlStateChanged;
+ if (hadMultiValue) view.ControlStateChangeEventInternal -= controlStateChanged;
+ else view.ControlStateChangeEventInternal += controlStateChanged;
}
}
{
if (HasMultiValue())
{
- view.ControlStateChangeEvent -= controlStateChanged;
+ view.ControlStateChangeEventInternal -= controlStateChanged;
}
selector = null;
}
TextShadow = instance;
}
- private void OnControlStateChangedForShadow(View obj, ControlStateChagedInfo controlStateChangedInfo)
+ private void OnControlStateChangedForShadow(View obj, ControlStateChangedInfo controlStateChangedInfo)
{
UpdateTextShadowVisual();
}
private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
private string[] transitionNames;
private BackgroundExtraData backgroundExtraData;
+ private bool controlStatePropagation = false;
internal Size2D sizeSetExplicitly = new Size2D(); // Store size set by API, will be used in place of NaturalSize if not set.
}
}
- internal delegate void ControlStateChangesDelegate(View obj, ControlStateChagedInfo controlStateChangedInfo);
- internal event ControlStateChangesDelegate ControlStateChangeEvent;
+ /// <summary>
+ /// The delegate for ControlState changed event.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public delegate void ControlStateChangesDelegate(View obj, ControlStateChangedInfo controlStateChangedInfo);
+
+ /// <summary>
+ /// The event that is triggered when the View's ControlState is changed.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event ControlStateChangesDelegate ControlStateChangeEvent;
+
+ internal event ControlStateChangesDelegate ControlStateChangeEventInternal;
private ControlStates controlStates;
/// <summary>
controlStates = state;
- var changeInfo = new ControlStateChagedInfo(prevState, state, touchInfo);
+ var changeInfo = new ControlStateChangedInfo(prevState, state, ControlStateChangedInfo.InputMethodType.Touch, touchInfo);
- ControlStateChangeEvent?.Invoke(this, changeInfo);
+ ControlStateChangeEventInternal?.Invoke(this, changeInfo);
+
+ OnControlStateChanged(changeInfo);
- if (OnControlStateChanged(changeInfo))
+ if (controlStatePropagation)
{
foreach (View child in Children)
{
}
}
+ ControlStateChangeEvent?.Invoke(this, changeInfo);
+
return true;
}
}
/// <summary>
+ /// Enable/Disable ControlState propagation for children.
+ /// It is false by default.
+ /// If the View needs to share ControlState with descendants, please set it true.
+ /// Please note that, changing the value will also changes children's EnableControlStatePropagation value recursively.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool EnableControlStatePropagation
+ {
+ get => controlStatePropagation;
+ set
+ {
+ controlStatePropagation = value;
+
+ foreach (View child in Children)
+ {
+ child.EnableControlStatePropagation = value;
+ }
+ }
+ }
+
+ /// <summary>
/// Get Style, it is abstract function and must be override.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// Called after the View's ControlStates changed.
/// </summary>
/// <param name="controlStateChangedInfo">The information including state changed variables.</param>
- /// <return>True if it needs to apply the state to children recursively.</return>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual bool OnControlStateChanged(ControlStateChagedInfo controlStateChangedInfo)
+ protected virtual void OnControlStateChanged(ControlStateChangedInfo controlStateChangedInfo)
{
- //If need to apply the state to all child, return true;
- return true;
}
internal static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector<string>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
/// <summary>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class ControlStateChagedInfo
+ public class ControlStateChangedInfo
{
/// <summary>
/// The previous control state.
/// </summary>
- public ControlStateChagedInfo(ControlStates previousState, ControlStates currentState, Touch touch)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ControlStateChangedInfo(ControlStates previousState, ControlStates currentState, InputMethodType inputMethod, object inputData)
{
PreviousState = previousState;
CurrentState = currentState;
- Touch = touch;
+ InputMethod = inputMethod;
+ InputData = inputData;
}
/// <summary>
/// The previous control state.
/// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public ControlStates PreviousState { get; }
/// <summary>
/// The current control state.
/// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public ControlStates CurrentState { get; }
/// <summary>
- /// The touch information in case the state has changed by touching.
+ /// Indicates the input method that triggered this change.
/// </summary>
- /// <remarks>
- /// The value is null if it is not the case.
- /// </remarks>
- public Touch Touch { get; }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public InputMethodType InputMethod { get; }
+
+ /// <summary>
+ /// The input method data in detail.
+ ///
+ /// The type of data depends on the InputMethod,
+ /// ---------------------------------------
+ /// InputMethod | Typep of InputData
+ /// ---------------------------------------
+ /// None | (null)
+ /// Touch | Tizen.NUI.Touch
+ /// Key | Tizen.NUI.Key
+ /// ---------------------------------------
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public object InputData { get; }
+
+ /// <summary>
+ /// List of input method that can trigger ControlStates change.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum InputMethodType
+ {
+ /// <summary>
+ /// ControlState has changed without user input.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None,
+
+ /// <summary>
+ /// ControlState has changed by a touch.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Touch,
+
+ /// <summary>
+ /// ControlState has changed by key input.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Key,
+ }
}
private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
SizeModeFactor = new Vector3(x, y, z);
}
- private void OnControlStateChangedForShadow(View obj, ControlStateChagedInfo controlStateChangedInfo)
+ private void OnControlStateChangedForShadow(View obj, ControlStateChangedInfo controlStateChangedInfo)
{
var boxShadowSelector = (Selector<Shadow>)GetValue(BoxShadowSelectorProperty);
private void UpdateShadow(ShadowBase shadow, bool needToListenStateChanged)
{
- ControlStateChangeEvent -= OnControlStateChangedForShadow;
+ ControlStateChangeEventInternal -= OnControlStateChangedForShadow;
if (shadow == null)
{
if (needToListenStateChanged)
{
- ControlStateChangeEvent += OnControlStateChangedForShadow;
+ ControlStateChangeEventInternal += OnControlStateChangedForShadow;
}
}
- private void OnControlStateChangedForCornerRadius(View obj, ControlStateChagedInfo controlStateChangedInfo)
+ private void OnControlStateChangedForCornerRadius(View obj, ControlStateChangedInfo controlStateChangedInfo)
{
var selector = (Selector<float?>)GetValue(CornerRadiusSelectorProperty);
private void UpdateCornerRadius(float value, bool needToListenStateChanged)
{
- ControlStateChangeEvent -= OnControlStateChangedForCornerRadius;
+ ControlStateChangeEventInternal -= OnControlStateChangedForCornerRadius;
if (needToListenStateChanged)
{
- ControlStateChangeEvent += OnControlStateChangedForCornerRadius;
+ ControlStateChangeEventInternal += OnControlStateChangedForCornerRadius;
}
if (value != 0)
createText[1].Dispose();
createText[1] = null;
- window.Remove(root);
+ NUIApplication.GetDefaultWindow().Remove(root);
root.Dispose();
}
}
<ProjectReference Include="../../../src/Tizen.System.SystemSettings/Tizen.System.SystemSettings.csproj" />
<ProjectReference Include="../../../src/Tizen.NUI/Tizen.NUI.csproj" />
<ProjectReference Include="../../../src/Tizen.NUI.Components/Tizen.NUI.Components.csproj" />
+ <ProjectReference Include="../../../src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj" />
</ItemGroup>
</Project>