Fix components issue 1216 (#1194) (#1203)
authorXianbing Teng <xb.teng@samsung.com>
Wed, 18 Dec 2019 06:33:54 +0000 (14:33 +0800)
committerJiyun Yang <ji.yang@samsung.com>
Wed, 18 Dec 2019 06:33:54 +0000 (15:33 +0900)
* [NUI] Fix text field fontfamily selector and color convert issue

* [NUI.Components] Fix tab item issue

* [NUI] Rename attribute file name to style

* [NUI.Components] Make OnUpdate of Button as hidden

25 files changed:
src/Tizen.NUI.Components/Controls/Button.cs
src/Tizen.NUI.Components/Controls/Control.cs
src/Tizen.NUI.Components/Controls/DropDown.cs
src/Tizen.NUI.Components/Controls/ImageControl.cs
src/Tizen.NUI.Components/Controls/InputField.cs
src/Tizen.NUI.Components/Controls/Tab.cs
src/Tizen.NUI.Components/Style/ButtonStyle.cs [moved from src/Tizen.NUI.Components/Attributes/ButtonAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/ControlStyle.cs [moved from src/Tizen.NUI.Components/Attributes/ControlStyle.cs with 100% similarity]
src/Tizen.NUI.Components/Style/DropDownStyle.cs [moved from src/Tizen.NUI.Components/Attributes/DropDownAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/ImageControlStyle.cs [moved from src/Tizen.NUI.Components/Attributes/ImageControlStyle.cs with 100% similarity]
src/Tizen.NUI.Components/Style/InputFieldStyle.cs [moved from src/Tizen.NUI.Components/Attributes/InputFieldAttributes.cs with 94% similarity]
src/Tizen.NUI.Components/Style/LoadingStyle.cs [moved from src/Tizen.NUI.Components/Attributes/LoadingAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/PaginationStyle.cs [moved from src/Tizen.NUI.Components/Attributes/PaginationAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/PopupStyle.cs [moved from src/Tizen.NUI.Components/Attributes/PopupAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/ProgressStyle.cs [moved from src/Tizen.NUI.Components/Attributes/ProgressAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/ScrollbarStyle.cs [moved from src/Tizen.NUI.Components/Attributes/ScrollbarAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/SliderStyle.cs [moved from src/Tizen.NUI.Components/Attributes/SliderAttributes.cs with 99% similarity]
src/Tizen.NUI.Components/Style/SwitchStyle.cs [moved from src/Tizen.NUI.Components/Attributes/SwitchAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/TabStyle.cs [moved from src/Tizen.NUI.Components/Attributes/TabAttributes.cs with 100% similarity]
src/Tizen.NUI.Components/Style/ToastStyle.cs [moved from src/Tizen.NUI.Components/Attributes/ToastAttributes.cs with 100% similarity]
src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs [moved from src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewAttributes.cs with 100% similarity]
src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs [moved from src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldAttributes.cs with 99% similarity]
src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs [moved from src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelAttributes.cs with 100% similarity]
src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs [moved from src/Tizen.NUI/src/public/BaseComponents/Style/ViewAttributes.cs with 100% similarity]
src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs

index f2ca4ae..c9efa03 100755 (executable)
@@ -584,7 +584,6 @@ namespace Tizen.NUI.Components
             {
                 if (buttonIcon != null)
                 {
-                    buttonIcon.Relayout -= OnIconRelayout;
                     Utility.Dispose(buttonIcon);
                 }
                 if (buttonText != null)
@@ -646,6 +645,7 @@ namespace Tizen.NUI.Components
             base.OnFocusGained();
             UpdateState();
         }
+
         /// <summary>
         /// 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.
         /// </summary>
@@ -741,7 +741,6 @@ namespace Tizen.NUI.Components
                 if (null == buttonIcon)
                 {
                     buttonIcon = new ImageControl();
-                    buttonIcon.Relayout += OnIconRelayout;
                     this.Add(buttonIcon);
                 }
 
@@ -762,6 +761,14 @@ namespace Tizen.NUI.Components
             return new ButtonStyle();
         }
 
+        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void OnUpdate()
+        {
+            base.OnUpdate();
+            UpdateUIContent();
+        }
+
         /// <summary>
         /// Update Button State.
         /// </summary>
index 6a9e174..fb6c543 100755 (executable)
@@ -84,7 +84,7 @@ namespace Tizen.NUI.Components
         private TapGestureDetector tapGestureDetector = new TapGestureDetector();
         private bool isFocused = false;
 
-        internal ImageView backgroundImage;
+        internal ImageView backgroundImage = new ImageView();
         internal ImageView shadowImage;
 
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -356,16 +356,12 @@ namespace Tizen.NUI.Components
                 }
 
                 shadowImage.ApplyStyle(controlStyle.Shadow);
-
-                if (null == backgroundImage)
-                {
-                    backgroundImage = new ImageView()
-                    {
-                        WidthResizePolicy = ResizePolicyType.FillToParent,
-                        HeightResizePolicy = ResizePolicyType.FillToParent,
-                    };
-                    this.Add(backgroundImage);
-                }
+            }
+            if (null != controlStyle.BackgroundImage)
+            {
+                backgroundImage.WidthResizePolicy = ResizePolicyType.FillToParent;
+                backgroundImage.HeightResizePolicy = ResizePolicyType.FillToParent;
+                this.Add(backgroundImage);
             }
         }
 
@@ -427,15 +423,6 @@ namespace Tizen.NUI.Components
         private void Initialize(string style)
         {
             ControlState = ControlStates.Normal;
-            if(null == backgroundImage)
-            {
-                backgroundImage = new ImageView()
-                {
-                    WidthResizePolicy = ResizePolicyType.FillToParent,
-                    HeightResizePolicy = ResizePolicyType.FillToParent,
-                };
-                this.Add(backgroundImage);
-            }
 
             RegisterDetectionOfSubstyleChanges();
 
index 419a0c4..cbd2ebf 100755 (executable)
@@ -390,9 +390,9 @@ namespace Tizen.NUI.Components
                 {
                     SetUpListContainer();
                 }
-                button.ApplyStyle(Style.Button);
-                headerText.ApplyStyle(Style.HeaderText);
-                listBackgroundImage.ApplyStyle(Style.ListBackgroundImage);
+                button.ApplyStyle(dropDownStyle.Button);
+                headerText.ApplyStyle(dropDownStyle.HeaderText);
+                listBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
                 UpdateDropDown();
             }
         }
@@ -1515,7 +1515,12 @@ namespace Tizen.NUI.Components
                     if (listItemData.CheckImageResourceUrl != null)
                     {
                         listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
-                        listItemView.CheckImageSize = listItemData.CheckImageSize;
+
+                        if (null != listItemData.CheckImageSize)
+                        {
+                            listItemView.CheckImageSize = listItemData.CheckImageSize;
+                        }
+
                         if (listItemView.CheckImageSize != null)
                         {
                             listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
index 18a017e..e104701 100755 (executable)
@@ -59,18 +59,6 @@ namespace Tizen.NUI.Components
             return imageControl.BorderSelector;
         });
 
-        /// <summary>
-        /// Control style.
-        /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        private ImageControlStyle imageControlStyle;
-
-        /// 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 new ImageControlStyle Style => imageControlStyle;
-
         internal ImageView imageView;
 
         /// <summary>
@@ -108,6 +96,10 @@ namespace Tizen.NUI.Components
             Initialize(style);
         }
 
+        /// 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 new ImageControlStyle Style => ViewStyle as ImageControlStyle;
+
         /// <summary>
         /// Override view's BackgroundImage.
         /// </summary>
@@ -176,6 +168,7 @@ namespace Tizen.NUI.Components
                     };
                     this.Add(imageView);
                 }
+                imageView.RaiseToTop();
             }
         }
 
@@ -205,8 +198,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override ViewStyle GetViewStyle()
         {
-            imageControlStyle = new ImageControlStyle();
-            return imageControlStyle;
+            return new ImageControlStyle(); ;
         }
 
         private void Initialize(string style)
index 4427c8d..6dfa6c5 100755 (executable)
@@ -370,6 +370,50 @@ 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 override void ApplyStyle(ViewStyle viewStyle)
+        {
+            base.ApplyStyle(viewStyle);
+
+            InputFieldStyle inputFieldStyle = viewStyle as InputFieldStyle;
+
+            if (null != inputFieldStyle.BackgroundImageAttributes)
+            {
+                if (null == bgImage)
+                {
+                    bgImage = new ImageView()
+                    {
+                        WidthResizePolicy = ResizePolicyType.FillToParent,
+                        HeightResizePolicy = ResizePolicyType.FillToParent,
+                    };
+
+                    this.Add(bgImage);
+                }
+                bgImage.ApplyStyle(inputFieldStyle.BackgroundImageAttributes);
+            }
+            if (null != inputFieldStyle.InputBoxAttributes)
+            {
+                if (null == textField)
+                {
+                    textField = new TextField()
+                    {
+                        WidthResizePolicy = ResizePolicyType.Fixed,
+                        HeightResizePolicy = ResizePolicyType.Fixed,
+                        ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
+                        PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
+                        PositionUsesPivotPoint = true,
+                    };
+                    this.Add(textField);
+                    textField.FocusGained += OnTextFieldFocusGained;
+                    textField.FocusLost += OnTextFieldFocusLost;
+                    textField.TextChanged += OnTextFieldTextChanged;
+                    textField.KeyEvent += OnTextFieldKeyEvent;
+                }
+                textField.ApplyStyle(inputFieldStyle.InputBoxAttributes);
+            }
+        }
+
         /// <summary>
         /// Get Input Field attribues.
         /// </summary>
@@ -552,37 +596,27 @@ namespace Tizen.NUI.Components
                 throw new Exception("Fail to get the InputField attributes.");
             }
 
-            bgImage = new ImageView();
             if (null == bgImage)
             {
-                throw new Exception("Fail to create background image.");
-            }
-
-            textField = new TextField();
-            if (null == textField)
-            {
-                throw new Exception("Fail to create text field.");
-            }
+                bgImage = new ImageView()
+                {
+                    WidthResizePolicy = ResizePolicyType.FillToParent,
+                    HeightResizePolicy = ResizePolicyType.FillToParent,
+                };
 
-            if (null != inputFieldAttrs.BackgroundImageAttributes)
-            {
-                bgImage.WidthResizePolicy = ResizePolicyType.FillToParent;
-                bgImage.HeightResizePolicy = ResizePolicyType.FillToParent;
-                bgImage.ParentOrigin = Tizen.NUI.ParentOrigin.Center;
-                bgImage.PivotPoint = Tizen.NUI.PivotPoint.Center;
-                bgImage.PositionUsesPivotPoint = true;
                 this.Add(bgImage);
             }
-
-            if (null != inputFieldAttrs.InputBoxAttributes)
+            if (null == textField)
             {
-                textField.WidthResizePolicy = ResizePolicyType.Fixed;
-                textField.HeightResizePolicy = ResizePolicyType.Fixed;
-                textField.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft;
-                textField.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft;
-                textField.PositionUsesPivotPoint = true;
+                textField = new TextField()
+                {
+                    WidthResizePolicy = ResizePolicyType.Fixed,
+                    HeightResizePolicy = ResizePolicyType.Fixed,
+                    ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
+                    PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
+                    PositionUsesPivotPoint = true,
+                };
                 this.Add(textField);
-
                 textField.FocusGained += OnTextFieldFocusGained;
                 textField.FocusLost += OnTextFieldFocusLost;
                 textField.TextChanged += OnTextFieldTextChanged;
index e8873d5..279b732 100755 (executable)
@@ -483,7 +483,7 @@ namespace Tizen.NUI.Components
                 {
                     for (int i = 0; i < totalNum; i++)
                     {
-                        preW = (itemList[i].NaturalSize2D != null ? itemList[i].NaturalSize2D.Width : 0);
+                        preW = (itemList[i].TextItem.NaturalSize2D != null ? itemList[i].TextItem.NaturalSize2D.Width : 0);
                         itemList[i].Position2D.X = preX;
                         itemList[i].Size2D.Width = preW;
                         preX = itemList[i].Position2D.X + preW + itemSpace;
@@ -77,11 +77,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public ImageViewStyle BackgroundImageAttributes
-        {
-            get;
-            set;
-        }
+        public ImageViewStyle BackgroundImageAttributes { get; set; }
 
         /// <summary>
         /// Gets or sets input box attributes of input field.
@@ -89,11 +85,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public TextFieldStyle InputBoxAttributes
-        {
-            get;
-            set;
-        }
+        public TextFieldStyle InputBoxAttributes { get; set; }
 
         /// <summary>
         /// Gets or sets space.
@@ -101,11 +93,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public int? Space
-        {
-            get;
-            set;
-        } 
+        public int? Space { get; set; } 
 
         /// <summary>
         /// Attributes's clone function.
@@ -33,7 +33,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create("IndicatorType", typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
-            var instance = (Tizen.NUI.Components.SliderStyle)bindable;
+            var instance = (SliderStyle)bindable;
             if (newValue != null)
             {
                 instance.privateIndicatorType = (IndicatorType)newValue;
@@ -107,7 +107,7 @@ 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 FontFamilySelectorProperty = BindableProperty.Create("FontFamily", typeof(Selector<string>), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        public static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector<string>), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var textFieldStyle = (TextFieldStyle)bindable;
             if (null == textFieldStyle.fontFamilySelector)
index f084ccb..8fad3fb 100755 (executable)
@@ -262,7 +262,9 @@ namespace Tizen.NUI.BaseComponents
             var textField = (TextField)bindable;
             if (newValue != null)
             {
-                Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+                Color color = (Color)newValue;
+                Vector4 vector = new Vector4(color.R, color.G, color.B, color.A);
+                Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT_COLOR, new Tizen.NUI.PropertyValue(vector));
             }
         },
         defaultValueCreator: (bindable) =>
@@ -313,7 +315,9 @@ namespace Tizen.NUI.BaseComponents
             var textField = (TextField)bindable;
             if (newValue != null)
             {
-                Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PRIMARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+                Color color = (Color)newValue;
+                Vector4 vector = new Vector4(color.R, color.G, color.B, color.A);
+                Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PRIMARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue(vector));
             }
         },
         defaultValueCreator: (bindable) =>