[NUI] Support selector for PixelSize in TextLabelStyle and TextEditorStyle (#2539)
authorJiyun Yang <ji.yang@samsung.com>
Thu, 21 Jan 2021 11:45:05 +0000 (20:45 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Tue, 26 Jan 2021 08:27:40 +0000 (17:27 +0900)
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs
src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs

index 5669eda..36934d5 100755 (executable)
@@ -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<float?>)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<float?> 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<float?> PixelSize
         {
-            get => (float?)GetValue(PixelSizeProperty);
-            set => SetValue(PixelSizeProperty, value);
+            get => (Selector<float?>)GetValue(PixelSizeSelectorProperty) ?? (pixelSizeSelector = new Selector<float?>());
+            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.
index 3aff814..93014b0 100755 (executable)
@@ -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<float?>), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
-            var textLabelStyle = (TextLabelStyle)bindable;
-            textLabelStyle.pixelSize = (float?)newValue;
+            ((TextLabelStyle)bindable).pixelSizeSelector = ((Selector<float?>)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<float?> 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<float?> PixelSize
         {
-            get => (float?)GetValue(PixelSizeProperty);
-            set => SetValue(PixelSizeProperty, value);
+            get => (Selector<float?>)GetValue(PixelSizeSelectorProperty) ?? (pixelSizeSelector = new Selector<float?>());
+            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.
index ffcaf94..3e3e942 100755 (executable)
@@ -1047,6 +1047,7 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(PixelSizeProperty, value);
+                selectorData?.PixelSize.UpdateIfNeeds(this, value);
                 NotifyPropertyChanged();
             }
         }
index 899d86a..3900053 100755 (executable)
@@ -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<float?>), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textField = (TextField)bindable;
+            textField.SelectorData.PixelSize.Update(textField, (Selector<float?>)newValue, true);
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textField = (TextField)bindable;
+            return textField.SelectorData.PixelSize.Get(textField);
+        });
         internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector<Color>), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var textField = (TextField)bindable;
index 7a9c513..5445aaa 100755 (executable)
@@ -27,6 +27,7 @@ namespace Tizen.NUI.BaseComponents
         public TriggerableSelector<string> FontFamily { get; } = new TriggerableSelector<string>(TextField.FontFamilyProperty);
         public TriggerableSelector<Color> TextColor { get; } = new TriggerableSelector<Color>(TextField.TextColorProperty, GetTextColor);
         public TriggerableSelector<float?> PointSize { get; } = new TriggerableSelector<float?>(TextField.PointSizeProperty);
+        public TriggerableSelector<float?> PixelSize { get; } = new TriggerableSelector<float?>(TextField.PixelSizeProperty);
         public TriggerableSelector<string> TranslatablePlaceholderText { get; } = new TriggerableSelector<string>(TextField.TranslatablePlaceholderTextProperty);
         public TriggerableSelector<Vector4> PlaceholderTextColor { get; } = new TriggerableSelector<Vector4>(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);
index 377f482..2dd25be 100755 (executable)
@@ -734,6 +734,7 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(PixelSizeProperty, value);
+                selectorData?.PixelSize.UpdateIfNeeds(this, value);
                 NotifyPropertyChangedAndRequestLayout();
             }
         }
index 7627794..014265a 100755 (executable)
@@ -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<float?>), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textLabel = (TextLabel)bindable;
+            ((TextLabel)bindable).SelectorData.PixelSize.Update(textLabel, (Selector<float?>)newValue, true);
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textLabel = (TextLabel)bindable;
+            return textLabel.SelectorData.PixelSize.Get(textLabel);
+        });
         #endregion
 
     }
index 8834f1c..5f78bec 100755 (executable)
@@ -27,6 +27,7 @@ namespace Tizen.NUI.BaseComponents
         public TriggerableSelector<string> FontFamily { get; } = new TriggerableSelector<string>(TextLabel.FontFamilyProperty);
         public TriggerableSelector<Color> TextColor { get; } = new TriggerableSelector<Color>(TextLabel.TextColorProperty, GetTextColor);
         public TriggerableSelector<float?> PointSize { get; } = new TriggerableSelector<float?>(TextLabel.PointSizeProperty);
+        public TriggerableSelector<float?> PixelSize { get; } = new TriggerableSelector<float?>(TextLabel.PixelSizeProperty);
         public TriggerableSelector<TextShadow> TextShadow { get; } = new TriggerableSelector<TextShadow>(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);
         }
 
index d0a197c..ad9d73f 100755 (executable)
@@ -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
         }
     }
 }