From 3c767a0864ddb0aac89933f7df57b0ff4498ea5e Mon Sep 17 00:00:00 2001 From: "everLEEst(SangHyeon Lee)" Date: Fri, 18 Mar 2022 01:05:41 -0700 Subject: [PATCH] [NUI] Modify IsEnabled pre-built classes and style --- .../Controls/Button.Internal.cs | 2 - src/Tizen.NUI.Components/Controls/Button.cs | 4 -- src/Tizen.NUI.Components/Controls/Progress.cs | 45 ++++------------------ .../RecyclerView/Item/RecyclerViewItem.Internal.cs | 9 ++++- .../Controls/RecyclerView/Item/RecyclerViewItem.cs | 27 ++++--------- .../Controls/Slider.Internal.cs | 1 - src/Tizen.NUI.Components/Controls/Slider.cs | 44 ++++----------------- src/Tizen.NUI.Components/Style/ButtonStyle.cs | 20 +++------- .../Style/RecyclerViewItemStyle.cs | 23 ----------- .../src/public/BaseComponents/Style/ViewStyle.cs | 11 ++++++ .../Style/ViewStyleBindableProperty.cs | 13 +++++++ 11 files changed, 61 insertions(+), 138 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/Button.Internal.cs b/src/Tizen.NUI.Components/Controls/Button.Internal.cs index e61b52d..73dd5aa 100644 --- a/src/Tizen.NUI.Components/Controls/Button.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Button.Internal.cs @@ -186,13 +186,11 @@ namespace Tizen.NUI.Components return base.HandleControlStateOnTouch(touch); } - /// [EditorBrowsable(EditorBrowsableState.Never)] protected override void OnEnabled(bool enabled) { base.OnEnabled(enabled); - //Sensitive = false; UpdateState(); } diff --git a/src/Tizen.NUI.Components/Controls/Button.cs b/src/Tizen.NUI.Components/Controls/Button.cs index ce2f576..8a9573e 100755 --- a/src/Tizen.NUI.Components/Controls/Button.cs +++ b/src/Tizen.NUI.Components/Controls/Button.cs @@ -66,10 +66,6 @@ namespace Tizen.NUI.Components /// 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 static readonly BindableProperty IsEnabledProperty = View.IsEnabledProperty; - - /// 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 static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) => { var instance = (Button)bindable; diff --git a/src/Tizen.NUI.Components/Controls/Progress.cs b/src/Tizen.NUI.Components/Controls/Progress.cs index ed2e763..0dcd1d2 100755 --- a/src/Tizen.NUI.Components/Controls/Progress.cs +++ b/src/Tizen.NUI.Components/Controls/Progress.cs @@ -131,26 +131,6 @@ namespace Tizen.NUI.Components return instance.state; }); - /// - /// IsEnabledProperty - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Progress), true, propertyChanged: (bindable, oldValue, newValue) => - { - var instance = (Progress)bindable; - if (newValue != null) - { - bool newEnabled = (bool)newValue; - if (instance.isEnabled != newEnabled) - { - instance.isEnabled = newEnabled; - instance.Sensitive = newEnabled; - instance.UpdateStates(); - } - } - }, - defaultValueCreator: (bindable) => ((Progress)bindable).isEnabled); - /// This needs to be considered more if public-open is necessary. private ProgressStatusType state = ProgressStatusType.Determinate; @@ -165,7 +145,6 @@ namespace Tizen.NUI.Components private float currentValue = 0; private float bufferValue = 0; private Animation indeterminateAnimation = null; - bool isEnabled = true; static Progress() { } /// @@ -490,22 +469,6 @@ namespace Tizen.NUI.Components } } - /// - /// Flag to decide enable or disable in Progress. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEnabled - { - get - { - return (bool)GetValue(IsEnabledProperty); - } - set - { - SetValue(IsEnabledProperty, value); - } - } - /// [EditorBrowsable(EditorBrowsableState.Never)] public override void OnInitialize() @@ -781,6 +744,14 @@ namespace Tizen.NUI.Components } } + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnEnabled(bool enabled) + { + base.OnEnabled(enabled); + UpdateStates(); + } + private void Initialize() { AccessibilityHighlightable = true; diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.Internal.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.Internal.cs index abbff85..4c29a5b 100755 --- a/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.Internal.cs @@ -203,11 +203,18 @@ namespace Tizen.NUI.Components { MeasureChild(); LayoutChild(); + } - Sensitive = IsEnabled; + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnEnabled(bool enabled) + { + base.OnEnabled(enabled); + UpdateState(); } + /// FIXME!! This has to be done in Element or View class. /// [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs index 9a32bab..775d8f1 100755 --- a/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs @@ -30,20 +30,7 @@ namespace Tizen.NUI.Components /// Property of boolean Enable flag. /// /// 9 - public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(RecyclerViewItem), true, propertyChanged: (bindable, oldValue, newValue) => - { - var instance = (RecyclerViewItem)bindable; - if (newValue != null) - { - bool newEnabled = (bool)newValue; - if (instance.isEnabled != newEnabled) - { - instance.isEnabled = newEnabled; - instance.UpdateState(); - } - } - }, - defaultValueCreator: (bindable) => ((RecyclerViewItem)bindable).isEnabled); + public static readonly BindableProperty IsEnabledProperty = View.IsEnabledProperty; /// /// Property of boolean Selected flag. @@ -93,7 +80,6 @@ namespace Tizen.NUI.Components private bool isSelected = false; private bool isSelectable = true; - private bool isEnabled = true; private RecyclerViewItemStyle ItemStyle => ViewStyle as RecyclerViewItemStyle; static RecyclerViewItem() { } @@ -157,8 +143,11 @@ namespace Tizen.NUI.Components /// 9 public bool IsEnabled { - get => (bool)GetValue(IsEnabledProperty); - set => SetValue(IsEnabledProperty, value); + get => base.IsEnabled; + set + { + base.IsEnabled = value; + } } /// @@ -262,7 +251,7 @@ namespace Tizen.NUI.Components } /// - /// Called when the control loses key input focus. + /// Called when the control loses key input focus. /// Should be overridden by derived classes if they need to customize /// what happens when the focus is lost. /// @@ -286,7 +275,7 @@ namespace Tizen.NUI.Components if (viewStyle != null) { //Extension = RecyclerViewItemStyle.CreateExtension(); - //FIXME : currently padding and margin are not applied by ApplyStyle automatically as missing binding features. + //FIXME : currently padding and margin are not applied by ApplyStyle automatically as missing binding features. Padding = new Extents(viewStyle.Padding); Margin = new Extents(viewStyle.Margin); } diff --git a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs index c391769..50530c2 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs @@ -95,7 +95,6 @@ namespace Tizen.NUI.Components bool isFocused = false; bool isPressed = false; - bool isEnabled = true; private void Initialize() { diff --git a/src/Tizen.NUI.Components/Controls/Slider.cs b/src/Tizen.NUI.Components/Controls/Slider.cs index 522a536..c030ac0 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.cs @@ -190,26 +190,6 @@ namespace Tizen.NUI.Components } ); - /// - /// IsEnabledProperty - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Slider), true, propertyChanged: (bindable, oldValue, newValue) => - { - var instance = (Slider)bindable; - if (newValue != null) - { - bool newEnabled = (bool)newValue; - if (instance.isEnabled != newEnabled) - { - instance.isEnabled = newEnabled; - instance.Sensitive = newEnabled; - instance.UpdateValue(); - } - } - }, - defaultValueCreator: (bindable) => ((Slider)bindable).isEnabled); - static Slider() { } /// @@ -1277,22 +1257,6 @@ namespace Tizen.NUI.Components } } - /// - /// Flag to decide enable or disable in Slider. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEnabled - { - get - { - return (bool)GetValue(IsEnabledProperty); - } - set - { - SetValue(IsEnabledProperty, value); - } - } - private Extents spaceBetweenTrackAndIndicator { get @@ -1700,6 +1664,14 @@ namespace Tizen.NUI.Components UpdateValue(); } + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnEnabled(bool enabled) + { + base.OnEnabled(enabled); + UpdateValue(); + } + private void CalculateCurrentValueByGesture(float offset) { currentSlidedOffset += offset; diff --git a/src/Tizen.NUI.Components/Style/ButtonStyle.cs b/src/Tizen.NUI.Components/Style/ButtonStyle.cs index 1b97275..31b3662 100755 --- a/src/Tizen.NUI.Components/Style/ButtonStyle.cs +++ b/src/Tizen.NUI.Components/Style/ButtonStyle.cs @@ -53,18 +53,6 @@ namespace Tizen.NUI.Components }); /// 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 static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool?), typeof(ButtonStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - var buttonStyle = (ButtonStyle)bindable; - buttonStyle.isEnabled = (bool?)newValue; - }, - defaultValueCreator: (bindable) => - { - var buttonStyle = (ButtonStyle)bindable; - return buttonStyle.isEnabled; - }); - /// 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 static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(Button.IconOrientation?), typeof(ButtonStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var buttonStyle = (ButtonStyle)bindable; @@ -116,7 +104,6 @@ namespace Tizen.NUI.Components private bool? isSelectable; private bool? isSelected; - private bool? isEnabled; private Button.IconOrientation? iconRelativeOrientation; private Extents iconPadding; private Extents textPadding; @@ -186,8 +173,11 @@ namespace Tizen.NUI.Components /// 8 public bool? IsEnabled { - get => (bool?)GetValue(IsEnabledProperty); - set => SetValue(IsEnabledProperty, value); + get => (bool?)base.IsEnabled; + set + { + base.IsEnabled = value; + } } /// diff --git a/src/Tizen.NUI.Components/Style/RecyclerViewItemStyle.cs b/src/Tizen.NUI.Components/Style/RecyclerViewItemStyle.cs index 5d0b3bc..b1ee754 100755 --- a/src/Tizen.NUI.Components/Style/RecyclerViewItemStyle.cs +++ b/src/Tizen.NUI.Components/Style/RecyclerViewItemStyle.cs @@ -52,22 +52,9 @@ namespace Tizen.NUI.Components var RecyclerViewItemStyle = (RecyclerViewItemStyle)bindable; return RecyclerViewItemStyle.isSelected; }); - /// 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 static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool?), typeof(RecyclerViewItemStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - var RecyclerViewItemStyle = (RecyclerViewItemStyle)bindable; - RecyclerViewItemStyle.isEnabled = (bool?)newValue; - }, - defaultValueCreator: (bindable) => - { - var RecyclerViewItemStyle = (RecyclerViewItemStyle)bindable; - return RecyclerViewItemStyle.isEnabled; - }); private bool? isSelectable; private bool? isSelected; - private bool? isEnabled; static RecyclerViewItemStyle() { } @@ -108,16 +95,6 @@ namespace Tizen.NUI.Components set => SetValue(IsSelectedProperty, value); } - /// - /// Flag to decide RecyclerViewItem can be selected or not. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool? IsEnabled - { - get => (bool?)GetValue(IsEnabledProperty); - set => SetValue(IsEnabledProperty, value); - } - /// [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs index 6ea7ad4..829b770 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs @@ -53,6 +53,7 @@ namespace Tizen.NUI.BaseComponents private float? borderlineWidth; private Color borderlineColor; private float? borderlineOffset; + private bool? isEnabled; private Selector imageShadow; private Selector boxShadow; @@ -498,6 +499,16 @@ namespace Tizen.NUI.BaseComponents set => SetValue(ThemeChangeSensitiveProperty, value); } + /// + /// Flag to decide View can be enabled user interaction or not. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool? IsEnabled + { + get => (bool?)GetValue(IsEnabledProperty); + set => SetValue(IsEnabledProperty, value); + } + /// /// Allow null properties when merging it into other Theme. diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs index 46ed3a6..bf754cd 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs @@ -427,5 +427,18 @@ namespace Tizen.NUI.BaseComponents propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).themeChangeSensitive = (bool?)newValue, defaultValueCreator: (bindable) => ((ViewStyle)bindable).themeChangeSensitive ); + + /// 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 static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + var buttonStyle = (ViewStyle)bindable; + buttonStyle.isEnabled = (bool?)newValue; + }, + defaultValueCreator: (bindable) => + { + var buttonStyle = (ViewStyle)bindable; + return buttonStyle.isEnabled; + }); } } -- 2.7.4