[NUI] Add TextLabel, TextField, TextEditor style and theme. (#2838)
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 6 Apr 2021 04:13:31 +0000 (13:13 +0900)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Tue, 20 Apr 2021 06:13:00 +0000 (15:13 +0900)
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/Tizen.NUI/Tizen.NUI.csproj
src/Tizen.NUI/res/IoT_handler_center_downW.png [new file with mode: 0644]
src/Tizen.NUI/res/IoT_handler_downleftW.png [new file with mode: 0644]
src/Tizen.NUI/res/IoT_handler_downrightW.png [new file with mode: 0644]
src/Tizen.NUI/src/public/BaseComponents/Style/TextEditorStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs
src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs

index c7f1bf7..f8e126a 100644 (file)
     </ItemGroup>
   </Target>
 
+  <ItemGroup>
+    <None Update="res\*.png;res\*.svg">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+
 </Project>
\ No newline at end of file
diff --git a/src/Tizen.NUI/res/IoT_handler_center_downW.png b/src/Tizen.NUI/res/IoT_handler_center_downW.png
new file mode 100644 (file)
index 0000000..00b0c3b
Binary files /dev/null and b/src/Tizen.NUI/res/IoT_handler_center_downW.png differ
diff --git a/src/Tizen.NUI/res/IoT_handler_downleftW.png b/src/Tizen.NUI/res/IoT_handler_downleftW.png
new file mode 100644 (file)
index 0000000..d83bcc6
Binary files /dev/null and b/src/Tizen.NUI/res/IoT_handler_downleftW.png differ
diff --git a/src/Tizen.NUI/res/IoT_handler_downrightW.png b/src/Tizen.NUI/res/IoT_handler_downrightW.png
new file mode 100644 (file)
index 0000000..0e2bd14
Binary files /dev/null and b/src/Tizen.NUI/res/IoT_handler_downrightW.png differ
index 721082f..d2fefa1 100755 (executable)
@@ -99,6 +99,12 @@ namespace Tizen.NUI.BaseComponents
             propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).cursorWidth = (int?)newValue,
             defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).cursorWidth);
 
+        /// <summary> The bindable property of GrabHandleColor. </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        internal static readonly BindableProperty GrabHandleColorProperty = BindableProperty.Create(nameof(GrabHandleColor), typeof(Color), typeof(TextEditorStyle), null,
+            propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).grabHandleColor = (Color)newValue,
+            defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).grabHandleColor);
+
         /// <summary> The bindable property of GrabHandleImage. </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         internal static readonly BindableProperty GrabHandleImageProperty = BindableProperty.Create(nameof(GrabHandleImage), typeof(string), typeof(TextEditorStyle), String.Empty,
@@ -110,6 +116,18 @@ namespace Tizen.NUI.BaseComponents
         internal static readonly BindableProperty GrabHandlePressedImageProperty = BindableProperty.Create(nameof(GrabHandlePressedImage), typeof(string), typeof(TextEditorStyle), String.Empty, propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).grabHandlePressedImage = (string)newValue,
             defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).grabHandlePressedImage);
 
+        /// <summary> The bindable property of SelectionHandleImageLeft. </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        internal static readonly BindableProperty SelectionHandleImageLeftProperty = BindableProperty.Create(nameof(SelectionHandleImageLeft), typeof(PropertyMap), typeof(TextEditorStyle), null,
+            propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).selectionHandleImageLeft = (PropertyMap)newValue,
+            defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).selectionHandleImageLeft);
+
+        /// <summary> The bindable property of SelectionHandleImageRight. </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        internal static readonly BindableProperty SelectionHandleImageRightProperty = BindableProperty.Create(nameof(SelectionHandleImageRight), typeof(PropertyMap), typeof(TextEditorStyle), null,
+            propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).selectionHandleImageRight = (PropertyMap)newValue,
+            defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).selectionHandleImageRight);
+
         /// <summary> The bindable property of ScrollThreshold. </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         internal static readonly BindableProperty ScrollThresholdProperty = BindableProperty.Create(nameof(ScrollThreshold), typeof(float?), typeof(TextEditorStyle), null,
@@ -194,14 +212,23 @@ namespace Tizen.NUI.BaseComponents
             propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).matchSystemLanguageDirection = (bool?)newValue,
             defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).matchSystemLanguageDirection);
 
+        /// <summary> The bindable property of FontStyleProperty. </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty FontStyleProperty = BindableProperty.Create(nameof(FontStyle), typeof(PropertyMap), typeof(TextEditorStyle), null,
+            propertyChanged: (bindable, oldValue, newValue) => ((TextEditorStyle)bindable).fontStyle = (PropertyMap)newValue,
+            defaultValueCreator: (bindable) => ((TextEditorStyle)bindable).fontStyle);
+
         private HorizontalAlignment? horizontalAlignment;
         private Vector4 secondaryCursorColor;
         private bool? enableCursorBlink;
         private float? cursorBlinkInterval;
         private float? cursorBlinkDuration;
         private int? cursorWidth;
+        private Color grabHandleColor;
         private string grabHandleImage;
         private string grabHandlePressedImage;
+        private PropertyMap selectionHandleImageLeft;
+        private PropertyMap selectionHandleImageRight;
         private float? scrollThreshold;
         private float? scrollSpeed;
         private Vector4 selectionHighlightColor;
@@ -222,6 +249,7 @@ namespace Tizen.NUI.BaseComponents
         private float? pointSize;
         private Color placeholderTextColor;
         private Vector4 primaryCursorColor;
+        private PropertyMap fontStyle;
 
         static TextEditorStyle() { }
 
@@ -305,6 +333,16 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// The GrabHandleColor property.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Color GrabHandleColor
+        {
+            get => (Color)GetValue(GrabHandleColorProperty);
+            set => SetValue(GrabHandleColorProperty, value);
+        }
+
+        /// <summary>
         /// The GrabHandleImage property.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -325,6 +363,26 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// The SelectionHandleImageLeft property.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap SelectionHandleImageLeft
+        {
+            get => (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
+            set => SetValue(SelectionHandleImageLeftProperty, value);
+        }
+
+        /// <summary>
+        /// The SelectionHandleImageRight property.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap SelectionHandleImageRight
+        {
+            get => (PropertyMap)GetValue(SelectionHandleImageRightProperty);
+            set => SetValue(SelectionHandleImageRightProperty, value);
+        }
+
+        /// <summary>
         /// The ScrollThreshold property.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -519,5 +577,15 @@ namespace Tizen.NUI.BaseComponents
             get => (Vector4)GetValue(PrimaryCursorColorProperty);
             set => SetValue(PrimaryCursorColorProperty, value);
         }
+
+        /// <summary>
+        /// The FontStyle property.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap FontStyle
+        {
+            get => (PropertyMap)GetValue(FontStyleProperty);
+            set => SetValue(FontStyleProperty, value);
+        }
     }
 }
index 95b190a..7a00eeb 100755 (executable)
@@ -219,6 +219,18 @@ namespace Tizen.NUI.BaseComponents
             var textFieldStyle = (TextFieldStyle)bindable;
             return textFieldStyle.cursorWidth;
         });
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty GrabHandleColorProperty = BindableProperty.Create(nameof(GrabHandleColor), typeof(Color), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            textFieldStyle.grabHandleColor = (Color)newValue;
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            return textFieldStyle.grabHandleColor;
+        });
         /// 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 GrabHandleImageProperty = BindableProperty.Create(nameof(GrabHandleImage), typeof(string), typeof(TextFieldStyle), String.Empty, propertyChanged: (bindable, oldValue, newValue) =>
@@ -243,6 +255,30 @@ namespace Tizen.NUI.BaseComponents
             var textFieldStyle = (TextFieldStyle)bindable;
             return textFieldStyle.grabHandlePressedImage;
         });
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty SelectionHandleImageLeftProperty = BindableProperty.Create(nameof(SelectionHandleImageLeft), typeof(PropertyMap), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            textFieldStyle.selectionHandleImageLeft = (PropertyMap)newValue;
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            return textFieldStyle.selectionHandleImageLeft;
+        });
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty SelectionHandleImageRightProperty = BindableProperty.Create(nameof(SelectionHandleImageRight), typeof(PropertyMap), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            textFieldStyle.selectionHandleImageRight = (PropertyMap)newValue;
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            return textFieldStyle.selectionHandleImageRight;
+        });
         /// 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 ScrollThresholdProperty = BindableProperty.Create(nameof(ScrollThreshold), typeof(float?), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
@@ -447,6 +483,18 @@ namespace Tizen.NUI.BaseComponents
             var textFieldStyle = (TextFieldStyle)bindable;
             return textFieldStyle.matchSystemLanguageDirection;
         });
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty FontStyleProperty = BindableProperty.Create(nameof(FontStyle), typeof(PropertyMap), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            textFieldStyle.fontStyle = (PropertyMap)newValue;
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textFieldStyle = (TextFieldStyle)bindable;
+            return textFieldStyle.fontStyle;
+        });
 
         private string placeholderText;
         private string placeholderTextFocused;
@@ -459,8 +507,11 @@ namespace Tizen.NUI.BaseComponents
         private float? cursorBlinkInterval;
         private float? cursorBlinkDuration;
         private int? cursorWidth;
+        private Color grabHandleColor;
         private string grabHandleImage;
         private string grabHandlePressedImage;
+        private PropertyMap selectionHandleImageLeft;
+        private PropertyMap selectionHandleImageRight;
         private float? scrollThreshold;
         private float? scrollSpeed;
         private Vector4 selectionHighlightColor;
@@ -483,6 +534,7 @@ namespace Tizen.NUI.BaseComponents
         private Selector<float?> pointSizeSelector;
         private Selector<Vector4> placeholderTextColorSelector;
         private Selector<Vector4> primaryCursorColorSelector;
+        private PropertyMap fontStyle;
 
         static TextFieldStyle() { }
 
@@ -594,6 +646,14 @@ namespace Tizen.NUI.BaseComponents
             set => SetValue(CursorWidthProperty, value);
         }
 
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Color GrabHandleColor
+        {
+            get => (Color)GetValue(GrabHandleColorProperty);
+            set => SetValue(GrabHandleColorProperty, value);
+        }
+
         /// 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 string GrabHandleImage
@@ -609,7 +669,20 @@ namespace Tizen.NUI.BaseComponents
             get => (string)GetValue(GrabHandlePressedImageProperty);
             set => SetValue(GrabHandlePressedImageProperty, value);
         }
-
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap SelectionHandleImageLeft
+        {
+            get => (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
+            set => SetValue(SelectionHandleImageLeftProperty, value);
+        }
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap SelectionHandleImageRight
+        {
+            get => (PropertyMap)GetValue(SelectionHandleImageRightProperty);
+            set => SetValue(SelectionHandleImageRightProperty, value);
+        }
         /// 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? ScrollThreshold
@@ -797,5 +870,13 @@ namespace Tizen.NUI.BaseComponents
             }
             set => SetValue(PrimaryCursorColorSelectorProperty, value);
         }
+
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap FontStyle
+        {
+            get => (PropertyMap)GetValue(FontStyleProperty);
+            set => SetValue(FontStyleProperty, value);
+        }
     }
 }
index 799639c..e0bb5ca 100755 (executable)
@@ -289,6 +289,18 @@ namespace Tizen.NUI.BaseComponents
         {
             return ((TextLabelStyle)bindable).textShadow;
         });
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty FontStyleProperty = BindableProperty.Create(nameof(FontStyle), typeof(PropertyMap), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var textLabelStyle = (TextLabelStyle)bindable;
+            textLabelStyle.fontStyle = (PropertyMap)newValue;
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var textLabelStyle = (TextLabelStyle)bindable;
+            return textLabelStyle.fontStyle;
+        });
 
         private bool? multiLine;
         private HorizontalAlignment? horizontalAlignment;
@@ -313,6 +325,7 @@ namespace Tizen.NUI.BaseComponents
         private Selector<Color> textColorSelector;
         private Selector<float?> pointSizeSelector;
         private Selector<TextShadow> textShadow;
+        private PropertyMap fontStyle;
 
         static TextLabelStyle() { }
 
@@ -527,5 +540,13 @@ namespace Tizen.NUI.BaseComponents
             get => (Selector<TextShadow>)GetValue(TextShadowProperty);
             set => SetValue(TextShadowProperty, value);
         }
+
+        /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyMap FontStyle
+        {
+            get => (PropertyMap)GetValue(FontStyleProperty);
+            set => SetValue(FontStyleProperty, value);
+        }
     }
 }
index 09082b7..1981ba2 100644 (file)
@@ -32,27 +32,48 @@ namespace Tizen.NUI
                 Version = DefaultVersion,
             };
 
-            // // TODO Add a TextLabelStyle style to the theme if need.
-            // // This is an example of text label style.
-            // theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextLabel", new TextLabelStyle()
-            // {
-            //     PixelSize = 10,
-            //     TextColor = Color.Red,
-            // });
+            // TextLabel style.
+            theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextLabel", new TextLabelStyle()
+            {
+                FontFamily = "BreezeSans",
+                PixelSize = 32,
+                TextColor = new Color(0.00f, 0.05f, 0.17f, 1),
+                FontStyle = new PropertyMap().Add("weight", new PropertyValue("light")),
+            });
 
-            // // TODO Add a TextFieldStyle to the theme if need.
-            // // This is an example of text filed style.
-            // theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextField", new TextFieldStyle()
-            // {
-            //     //...
-            // });
+            // TextField style.
+            theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextField", new TextFieldStyle()
+            {
+                FontFamily = "BreezeSans",
+                PixelSize = 32,
+                TextColor = new Color(0.00f, 0.05f, 0.17f, 1),
+                FontStyle = new PropertyMap().Add("weight", new PropertyValue("regular")),
+                PrimaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
+                SecondaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
+                CursorWidth = 3,
+                SelectionHighlightColor = new Vector4(0.17f, 0.37f, 0.72f, 0.20f),
+                GrabHandleColor = new Color(0.08f, 0.45f, 0.90f, 1),
+                GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png",
+                SelectionHandleImageLeft = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downleftW.png")),
+                SelectionHandleImageRight = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downrightW.png")),
+            });
 
-            // // TODO Add a TextEditorStyle to the theme if need.
-            // // This is an example of text filed style.
-            // theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextEditor", new TextEditorStyle()
-            // {
-            //     //...
-            // });
+            // TextEditor style.
+            theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextEditor", new TextEditorStyle()
+            {
+                FontFamily = "BreezeSans",
+                PixelSize = 32,
+                TextColor = new Color(0.00f, 0.05f, 0.17f, 1),
+                FontStyle = new PropertyMap().Add("weight", new PropertyValue("regular")),
+                PrimaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
+                SecondaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
+                CursorWidth = 3,
+                SelectionHighlightColor = new Vector4(0.17f, 0.37f, 0.72f, 0.20f),
+                GrabHandleColor = new Color(0.08f, 0.45f, 0.90f, 1),
+                GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png",
+                SelectionHandleImageLeft = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downleftW.png")),
+                SelectionHandleImageRight = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downrightW.png")),
+            });
 
             return theme;
         }