From: Jiyun Yang Date: Thu, 21 Jan 2021 11:45:05 +0000 (+0900) Subject: [NUI] Support selector for PixelSize in TextLabelStyle and TextEditorStyle (#2539) X-Git-Tag: accepted/tizen/unified/20210219.040944~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f833d1dedadb337ecc2a57345078c5d0ad24250;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Support selector for PixelSize in TextLabelStyle and TextEditorStyle (#2539) Signed-off-by: Jiyun Yang --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index 5669eda..36934d5 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -438,15 +438,15 @@ namespace Tizen.NUI.BaseComponents }); /// 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 PixelSizeProperty = BindableProperty.Create(nameof(PixelSize), typeof(float?), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty PixelSizeSelectorProperty = BindableProperty.Create("PixelSizeSelector", typeof(float?), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - textFieldStyle.pixelSize = (float?)newValue; + textFieldStyle.pixelSizeSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { var textFieldStyle = (TextFieldStyle)bindable; - return textFieldStyle.pixelSize; + return textFieldStyle.pixelSizeSelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -511,7 +511,7 @@ namespace Tizen.NUI.BaseComponents private string emboss; private string inputEmboss; private string inputOutline; - private float? pixelSize; + private Selector pixelSizeSelector; private bool? enableSelection; private bool? ellipsis; private bool? matchSystemLanguageDirection; @@ -792,10 +792,10 @@ namespace Tizen.NUI.BaseComponents /// 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 float? PixelSize + public Selector PixelSize { - get => (float?)GetValue(PixelSizeProperty); - set => SetValue(PixelSizeProperty, value); + get => (Selector)GetValue(PixelSizeSelectorProperty) ?? (pixelSizeSelector = new Selector()); + set => SetValue(PixelSizeSelectorProperty, value); } /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs index 3aff814..93014b0 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs @@ -200,15 +200,13 @@ namespace Tizen.NUI.BaseComponents }); /// 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 PixelSizeProperty = BindableProperty.Create(nameof(PixelSize), typeof(float?), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty PixelSizeSelectorProperty = BindableProperty.Create("PixelSizeSelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textLabelStyle = (TextLabelStyle)bindable; - textLabelStyle.pixelSize = (float?)newValue; + ((TextLabelStyle)bindable).pixelSizeSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textLabelStyle = (TextLabelStyle)bindable; - return textLabelStyle.pixelSize; + return ((TextLabelStyle)bindable).pixelSizeSelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -303,7 +301,7 @@ namespace Tizen.NUI.BaseComponents private float? autoScrollGap; private float? lineSpacing; private string emboss; - private float? pixelSize; + private Selector pixelSizeSelector; private bool? ellipsis; private float? autoScrollLoopDelay; private AutoScrollStopMode? autoScrollStopMode; @@ -433,10 +431,10 @@ namespace Tizen.NUI.BaseComponents /// 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 float? PixelSize + public Selector PixelSize { - get => (float?)GetValue(PixelSizeProperty); - set => SetValue(PixelSizeProperty, value); + get => (Selector)GetValue(PixelSizeSelectorProperty) ?? (pixelSizeSelector = new Selector()); + set => SetValue(PixelSizeSelectorProperty, value); } /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index ffcaf94..3e3e942 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -1047,6 +1047,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(PixelSizeProperty, value); + selectorData?.PixelSize.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs index 899d86a..3900053 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs @@ -1021,6 +1021,16 @@ namespace Tizen.NUI.BaseComponents var textField = (TextField)bindable; return textField.SelectorData.PointSize.Get(textField); }); + internal static readonly BindableProperty PixelSizeSelectorProperty = BindableProperty.Create("PixelSizeSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.PixelSize.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.PixelSize.Get(textField); + }); internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => { var textField = (TextField)bindable; diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs index 7a9c513..5445aaa 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs @@ -27,6 +27,7 @@ namespace Tizen.NUI.BaseComponents public TriggerableSelector FontFamily { get; } = new TriggerableSelector(TextField.FontFamilyProperty); public TriggerableSelector TextColor { get; } = new TriggerableSelector(TextField.TextColorProperty, GetTextColor); public TriggerableSelector PointSize { get; } = new TriggerableSelector(TextField.PointSizeProperty); + public TriggerableSelector PixelSize { get; } = new TriggerableSelector(TextField.PixelSizeProperty); public TriggerableSelector TranslatablePlaceholderText { get; } = new TriggerableSelector(TextField.TranslatablePlaceholderTextProperty); public TriggerableSelector PlaceholderTextColor { get; } = new TriggerableSelector(TextField.PlaceholderTextColorProperty, delegate (View view) { @@ -55,6 +56,7 @@ namespace Tizen.NUI.BaseComponents FontFamily.Reset(view); TextColor.Reset(view); PointSize.Reset(view); + PixelSize.Reset(view); TranslatablePlaceholderText.Reset(view); PlaceholderTextColor.Reset(view); PrimaryCursorColor.Reset(view); diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 377f482..2dd25be 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -734,6 +734,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(PixelSizeProperty, value); + selectorData?.PixelSize.UpdateIfNeeds(this, value); NotifyPropertyChangedAndRequestLayout(); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs index 7627794..014265a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs @@ -606,6 +606,17 @@ namespace Tizen.NUI.BaseComponents var textLabel = (TextLabel)bindable; return textLabel.SelectorData.TextShadow.Get(textLabel); }); + + internal static readonly BindableProperty PixelSizeSelectorProperty = BindableProperty.Create("PixelSizeSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + ((TextLabel)bindable).SelectorData.PixelSize.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.PixelSize.Get(textLabel); + }); #endregion } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs index 8834f1c..5f78bec 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs @@ -27,6 +27,7 @@ namespace Tizen.NUI.BaseComponents public TriggerableSelector FontFamily { get; } = new TriggerableSelector(TextLabel.FontFamilyProperty); public TriggerableSelector TextColor { get; } = new TriggerableSelector(TextLabel.TextColorProperty, GetTextColor); public TriggerableSelector PointSize { get; } = new TriggerableSelector(TextLabel.PointSizeProperty); + public TriggerableSelector PixelSize { get; } = new TriggerableSelector(TextLabel.PixelSizeProperty); public TriggerableSelector TextShadow { get; } = new TriggerableSelector(TextLabel.TextShadowProperty); public virtual void Reset(View view) @@ -36,6 +37,7 @@ namespace Tizen.NUI.BaseComponents FontFamily.Reset(view); TextColor.Reset(view); PointSize.Reset(view); + PixelSize.Reset(view); TextShadow.Reset(view); } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index d0a197c..ad9d73f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -1370,10 +1370,8 @@ namespace Tizen.NUI.BaseComponents private void InitializeStyle(ViewStyle style) { - if (!ThemeManager.ThemeApplied) return; - - if (style == null) UpdateStyle(); // Use style in the current theme - else ApplyStyle(style.Clone()); // Use given style + if (style != null) ApplyStyle(style.Clone()); // Use given style + else if (ThemeManager.ThemeApplied) UpdateStyle(); // Use style in the current theme } } }