[NUI][API8] Add Constraint base + inhouse ResizePolicyType.KeepSizeFollowingParent...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / View.cs
index c513026..076db39 100755 (executable)
@@ -51,23 +51,27 @@ namespace Tizen.NUI.BaseComponents
         private Dictionary<TransitionCondition, TransitionList> _layoutTransitions;
         private int _widthPolicy = LayoutParamPolicies.WrapContent; // Layout width policy
         private int _heightPolicy = LayoutParamPolicies.WrapContent; // Layout height policy
+        private int _oldWidthPolicy = LayoutParamPolicies.MatchParent; // // Store Layout width to compare against later
+        private int _oldHeightPolicy = LayoutParamPolicies.MatchParent; // Store Layout height to compare against later
         private float _weight = 0.0f; // Weighting of child View in a Layout
         private MeasureSpecification _measureSpecificationWidth; // Layout width and internal Mode
         private MeasureSpecification _measureSpecificationHeight; // Layout height and internal Mode
         private bool _backgroundImageSynchronosLoading = false;
         private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
         private string[] transitionNames;
-        private Rectangle backgroundImageBorder;
-
-        private ImageShadow imageShadow;
-
-        private Shadow boxShadow;
+        private bool controlStatePropagation = false;
+        private ViewStyle viewStyle;
+        private bool themeChangeSensitive = false;
 
         internal Size2D sizeSetExplicitly = new Size2D(); // Store size set by API, will be used in place of NaturalSize if not set.
+        internal BackgroundExtraData backgroundExtraData;
+
+        // List of constraint
+        private Constraint widthConstraint = null;
+        private Constraint heightConstraint = null;
 
         static View() {}
 
-        private ViewStyle viewStyle;
         /// 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 ViewStyle ViewStyle
@@ -94,9 +98,8 @@ namespace Tizen.NUI.BaseComponents
 
         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public View(ViewStyle viewStyle) : this(Interop.View.View_New(), true)
+        public View(ViewStyle viewStyle) : this(Interop.View.View_New(), true, viewStyle)
         {
-            this.ViewStyle.CopyFrom(viewStyle);
         }
 
         /// <summary>
@@ -118,11 +121,16 @@ namespace Tizen.NUI.BaseComponents
             {
                 SetVisible(false);
             }
+
+            backgroundExtraData = uiControl.backgroundExtraData == null ? null : new BackgroundExtraData(uiControl.backgroundExtraData);
         }
 
         internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown)
         {
-            this.ViewStyle.CopyFrom(viewStyle);
+            if (!ThemeManager.ThemeApplied) return;
+
+            if (viewStyle == null) UpdateStyle(); // Use style in the current theme
+            else ApplyStyle(viewStyle.Clone());   // Use given style
         }
 
         internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.View.View_SWIGUpcast(cPtr), cMemoryOwn)
@@ -151,38 +159,52 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-        internal delegate void ControlStateChangesDelegate(View obj, ControlStates state);
-        internal event ControlStateChangesDelegate ControlStateChangeEvent;
+        /// <summary>
+        /// The event that is triggered when the View's ControlState is changed.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<ControlStateChangedEventArgs> ControlStateChangedEvent;
 
-        private ControlStates controlStates;
+        internal event EventHandler<ControlStateChangedEventArgs> ControlStateChangeEventInternal;
+
+        private ControlState controlStates = ControlState.Normal;
         /// <summary>
         /// Get/Set the control state.
         /// </summary>
-        /// <since_tizen> 6 </since_tizen>
         /// 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 ControlStates ControlState
+        public ControlState ControlState
         {
             get
             {
                 return controlStates;
             }
-            set
+            protected set
             {
-                if (controlStates != value)
+                if (controlStates == value)
                 {
-                    controlStates = value;
+                    return;
+                }
 
-                    ControlStateChangeEvent?.Invoke(this, value);
+                var prevState = controlStates;
 
-                    if (true == OnControlStateChanged(value))
+                controlStates = value;
+
+                var changeInfo = new ControlStateChangedEventArgs(prevState, value);
+
+                ControlStateChangeEventInternal?.Invoke(this, changeInfo);
+
+                if (controlStatePropagation)
+                {
+                    foreach (View child in Children)
                     {
-                        foreach (View child in Children)
-                        {
-                            child.ControlState = value;
-                        }
+                        child.ControlState = value;
                     }
                 }
+
+                OnControlStateChanged(changeInfo);
+
+                ControlStateChangedEvent?.Invoke(this, changeInfo);
             }
         }
 
@@ -212,6 +234,7 @@ namespace Tizen.NUI.BaseComponents
 
         /// <summary>
         /// The StyleName, type string.
+        /// The value indicates DALi style name defined in json theme file.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         public string StyleName
@@ -228,6 +251,23 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// The KeyInputFocus, type bool.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool KeyInputFocus
+        {
+            get
+            {
+                return (bool)GetValue(KeyInputFocusProperty);
+            }
+            set
+            {
+                SetValue(KeyInputFocusProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
         /// The mutually exclusive with "backgroundImage" and "background" type Vector4.
         /// </summary>
         /// <remarks>
@@ -244,6 +284,11 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(BackgroundColorProperty, value);
+                if (selectorData != null)
+                {
+                    selectorData.BackgroundImage.Reset(this);
+                    selectorData.BackgroundColor.UpdateIfNeeds(this, value);
+                }
                 NotifyPropertyChanged();
             }
         }
@@ -261,6 +306,11 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(BackgroundImageProperty, value);
+                if (selectorData != null)
+                {
+                    selectorData.BackgroundColor.Reset(this);
+                    selectorData.BackgroundImage.UpdateIfNeeds(this, value);
+                }
                 NotifyPropertyChanged();
             }
         }
@@ -279,6 +329,7 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(BackgroundImageBorderProperty, value);
+                selectorData?.BackgroundImageBorder.UpdateIfNeeds(this, value);
                 NotifyPropertyChanged();
             }
         }
@@ -305,6 +356,9 @@ namespace Tizen.NUI.BaseComponents
         /// It is null by default.
         /// </summary>
         /// <remarks>
+        /// Getter returns copied instance of current shadow.
+        /// </remarks>
+        /// <remarks>
         /// The mutually exclusive with "BoxShadow".
         /// </remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -312,12 +366,16 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                var value = (ImageShadow)GetValue(ImageShadowProperty);
-                return value == null ? null : new ImageShadow(value, OnImageShadowChanged);
+                return (ImageShadow)GetValue(ImageShadowProperty);
             }
             set
             {
                 SetValue(ImageShadowProperty, value);
+                if (selectorData != null)
+                {
+                    selectorData.BoxShadow.Reset(this);
+                    selectorData.ImageShadow.UpdateIfNeeds(this, value);
+                }
                 NotifyPropertyChanged();
             }
         }
@@ -327,6 +385,9 @@ namespace Tizen.NUI.BaseComponents
         /// It is null by default.
         /// </summary>
         /// <remarks>
+        /// Gettter returns copied instance of current shadow.
+        /// </remarks>
+        /// <remarks>
         /// The mutually exclusive with "ImageShadow".
         /// </remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -334,12 +395,36 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                var value = (Shadow)GetValue(BoxShadowProperty);
-                return value == null ? null : new Shadow(value, OnBoxShadowChanged);
+                return (Shadow)GetValue(BoxShadowProperty);
             }
             set
             {
                 SetValue(BoxShadowProperty, value);
+                if (selectorData != null)
+                {
+                    selectorData.ImageShadow.Reset(this);
+                    selectorData.BoxShadow.UpdateIfNeeds(this, value);
+                }
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
+        /// The radius for the rounded corners of the View.
+        /// This will rounds background and shadow edges.
+        /// Note that, an image background (or shadow) may not have rounded corners if it uses a Border property.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public float CornerRadius
+        {
+            get
+            {
+                return (float)GetValue(CornerRadiusProperty);
+            }
+            set
+            {
+                SetValue(CornerRadiusProperty, value);
+                selectorData?.CornerRadius.UpdateIfNeeds(this, value);
                 NotifyPropertyChanged();
             }
         }
@@ -414,6 +499,7 @@ namespace Tizen.NUI.BaseComponents
         /// If all items in the container set this property, their sizes will be proportional to the specified flex factor.<br />
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        [Obsolete("Deprecated in API8, will be removed in API10.")]
         public float Flex
         {
             get
@@ -432,6 +518,7 @@ namespace Tizen.NUI.BaseComponents
         /// The alignment of the flex item along the cross axis, which, if set, overides the default alignment for all items in the container.<br />
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        [Obsolete("Deprecated in API8, will be removed in API10.")]
         public int AlignSelf
         {
             get
@@ -453,6 +540,7 @@ namespace Tizen.NUI.BaseComponents
         /// The property cascade chaining set is possible. For example, this (view.FlexMargin.X = 0.1f;) is possible.
         /// </remarks>
         /// <since_tizen> 3 </since_tizen>
+        [Obsolete("Deprecated in API8, will be removed in API10.")]
         public Vector4 FlexMargin
         {
             get
@@ -654,6 +742,43 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Whether the children of this view can be focusable by keyboard navigation. If user sets this to false, the children of this actor view will not be focused.
+        /// Note : Default value is true.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool FocusableChildren
+        {
+            set
+            {
+                SetValue(FocusableChildrenProperty, value);
+                NotifyPropertyChanged();
+            }
+            get
+            {
+                return (bool)GetValue(FocusableChildrenProperty);
+            }
+        }
+
+        /// <summary>
+        /// Whether this view can focus by touch.
+        /// If Focusable is false, FocusableInTouch is disabled.
+        /// If you want to have focus on touch, you need to set both Focusable and FocusableInTouch settings to true.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool FocusableInTouch
+        {
+            set
+            {
+                SetValue(FocusableInTouchProperty, value);
+                NotifyPropertyChanged();
+            }
+            get
+            {
+                return (bool)GetValue(FocusableInTouchProperty);
+            }
+        }
+
+        /// <summary>
         ///  Retrieves the position of the view.<br />
         ///  The coordinates are relative to the view's parent.<br />
         /// </summary>
@@ -682,7 +807,16 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 Size2D temp = (Size2D)GetValue(Size2DProperty);
-                return new Size2D(OnSize2DChanged, temp.Width, temp.Height);
+                int width = temp.Width;
+                int height = temp.Height;
+
+                if (this.Layout == null)
+                {
+                    if (width < 0) { width = 0; }
+                    if (height < 0) { height = 0; }
+                }
+
+                return new Size2D(OnSize2DChanged, width, height);
             }
             set
             {
@@ -694,6 +828,7 @@ namespace Tizen.NUI.BaseComponents
                 MeasureSpecificationHeight = new MeasureSpecification(new LayoutLength(value.Height), MeasureSpecification.ModeType.Exactly);
                 _widthPolicy = value.Width;
                 _heightPolicy = value.Height;
+                
                 _layout?.RequestLayout();
                 NotifyPropertyChanged();
             }
@@ -725,6 +860,7 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(OpacityProperty, value);
+                selectorData?.Opacity.UpdateIfNeeds(this, value);
                 NotifyPropertyChanged();
             }
         }
@@ -769,7 +905,7 @@ namespace Tizen.NUI.BaseComponents
 
         /// <summary>
         /// Determines whether the pivot point should be used to determine the position of the view.
-        /// This is true by default.
+        /// This is false by default.
         /// </summary>
         /// <remarks>If false, then the top-left of the view is used for the position.
         /// Setting this to false will allow scaling or rotation around the pivot point without affecting the view's position.
@@ -857,6 +993,10 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(SiblingOrderProperty, value);
+
+                LayoutGroup layout = Layout as LayoutGroup;
+                layout?.ChangeLayoutSiblingOrder(value);
+
                 NotifyPropertyChanged();
             }
         }
@@ -964,7 +1104,6 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(SizeWidthProperty, value);
-                WidthSpecification = (int)Math.Ceiling(value);
                 NotifyPropertyChanged();
             }
         }
@@ -987,7 +1126,6 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(SizeHeightProperty, value);
-                HeightSpecification = (int)Math.Ceiling(value);
                 NotifyPropertyChanged();
             }
         }
@@ -1447,28 +1585,6 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(WidthResizePolicyProperty, value);
-                // Match ResizePolicy to new Layouting.
-                // Parent relative policies can not be mapped at this point as parent size unknown.
-                switch (value)
-                {
-                    case ResizePolicyType.UseNaturalSize:
-                    {
-                        WidthSpecification = LayoutParamPolicies.WrapContent;
-                        break;
-                    }
-                    case ResizePolicyType.FillToParent:
-                    {
-                        WidthSpecification = LayoutParamPolicies.MatchParent;
-                        break;
-                    }
-                    case ResizePolicyType.FitToChildren:
-                    {
-                        WidthSpecification = LayoutParamPolicies.WrapContent;
-                        break;
-                    }
-                    default:
-                        break;
-                }
                 NotifyPropertyChanged();
             }
         }
@@ -1486,28 +1602,6 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(HeightResizePolicyProperty, value);
-                // Match ResizePolicy to new Layouting.
-                // Parent relative policies can not be mapped at this point as parent size unknown.
-                switch (value)
-                {
-                    case ResizePolicyType.UseNaturalSize:
-                    {
-                        HeightSpecification = LayoutParamPolicies.WrapContent;
-                        break;
-                    }
-                    case ResizePolicyType.FillToParent:
-                    {
-                        HeightSpecification = LayoutParamPolicies.MatchParent;
-                        break;
-                    }
-                    case ResizePolicyType.FitToChildren:
-                    {
-                        HeightSpecification = LayoutParamPolicies.WrapContent;
-                        break;
-                    }
-                    default:
-                        break;
-                }
                 NotifyPropertyChanged();
             }
         }
@@ -1576,7 +1670,7 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 // If View has a Layout then padding in stored in the base Layout class
-                if (Layout !=null)
+                if (Layout != null)
                 {
                     return Layout.Padding;
                 }
@@ -1590,7 +1684,7 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 Extents padding = value;
-                if (Layout !=null)
+                if (Layout != null)
                 {
                     // Layout set so store Padding in LayoutItem instead of in View.
                     // If View stores the Padding value then Legacy Size Negotiation will overwrite
@@ -1598,15 +1692,14 @@ namespace Tizen.NUI.BaseComponents
                     Layout.Padding = value;
                     // If Layout is a LayoutItem then it could be a View that handles it's own padding.
                     // Let the View keeps it's padding.  Still store Padding in Layout to reduce code paths.
-                    if( Layout.GetType() != typeof(LayoutItem)) // If a Layout container of some kind.
+                    if (typeof(LayoutGroup).IsAssignableFrom(Layout.GetType())) // If a Layout container of some kind.
                     {
-                        padding =  new Extents(0,0,0,0); // Reset value stored in View.
+                        padding = new Extents(0, 0, 0, 0); // Reset value stored in View.
                     }
-                    _layout?.RequestLayout();
                 }
+
                 SetValue(PaddingProperty, padding);
                 NotifyPropertyChanged();
-                _layout?.RequestLayout();
             }
         }
 
@@ -1659,10 +1752,6 @@ namespace Tizen.NUI.BaseComponents
                 // MATCH_PARENT spec + parent container size can be used to limit
                 if (_layout != null)
                 {
-                    // Note: it only works if minimum size is >= than natural size.
-                    // To force the size it should be done through the width&height spec or Size2D.
-                    _layout.MinimumHeight = new Tizen.NUI.LayoutLength(value.Width);
-                    _layout.MinimumWidth = new Tizen.NUI.LayoutLength(value.Height);
                     _layout.RequestLayout();
                 }
                 SetValue(MaximumSizeProperty, value);
@@ -1769,10 +1858,6 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 SetValue(SizeProperty, value);
-                // Set Specification so when layouts measure this View it matches the value set here.
-                // All Views are currently Layouts.
-                WidthSpecification = (int)Math.Ceiling(value.Width);
-                HeightSpecification = (int)Math.Ceiling(value.Height);
                 NotifyPropertyChanged();
             }
         }
@@ -1798,7 +1883,7 @@ namespace Tizen.NUI.BaseComponents
                 if (basehandle is Layer layer)
                 {
                     ret = new View(Layer.getCPtr(layer).Handle, false);
-                    NUILog.Error("This Parent property is deprecated, shoud do not be used");
+                    NUILog.Error("This Parent property is deprecated, should do not be used");
                 }
                 else
                 {
@@ -1908,23 +1993,21 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 _widthPolicy = value;
-                if (_widthPolicy >= 0)
+                if( _oldWidthPolicy != _widthPolicy )
                 {
-                    _measureSpecificationWidth = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
-
-                    if(_heightPolicy>=0) // Policy an exact value
-                    {
-                        Size2D.Width = _widthPolicy;
-                    }
-                    else
+                    if (_widthPolicy >= 0)
                     {
-                        // Store _heightPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
-                        // Size2D height will store the specification value (negative number) this will then be applied to the
-                        // HeightSpecification when the Size2D callback is invoked.
-                        Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                        _measureSpecificationWidth = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
+
+                        if(_heightPolicy>=0) // Policy an exact value
+                        {
+                            // Create Size2D only both _widthPolicy and _heightPolicy are set.
+                            Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                        }
                     }
+                    _layout?.RequestLayout();
+                    _oldWidthPolicy = _widthPolicy;
                 }
-                _layout?.RequestLayout();
             }
         }
 
@@ -1941,24 +2024,22 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 _heightPolicy = value;
-                if (_heightPolicy >= 0)
+                if( _oldHeightPolicy != _heightPolicy )
                 {
-                    _measureSpecificationHeight = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
-
-                    if(_widthPolicy>=0) // Policy an exact value
+                    if (_heightPolicy >= 0)
                     {
-                        Size2D.Height = _heightPolicy;
-                    }
-                    else
-                    {
-                        // Store widthPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
-                        // Size2D height will store the specification value (negative number) this will then be applied to the
-                        // HeightSpecification when the Size2D callback is invoked.
-                        Size2D = new Size2D(_widthPolicy,_heightPolicy);
-                    }
+                        _measureSpecificationHeight = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
 
+                        if(_widthPolicy>=0) // Policy an exact value
+                        {
+                            // Create Size2D only both _widthPolicy and _heightPolicy are set.
+                            Size2D = new Size2D(_widthPolicy,_heightPolicy);
+                        }
+
+                    }
+                    _layout?.RequestLayout();
+                    _oldHeightPolicy = _heightPolicy;
                 }
-               _layout?.RequestLayout();
             }
         }
 
@@ -2054,13 +2135,14 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
-                GetProperty(Interop.ActorProperty.Actor_Property_COLOR_get()).Get(temp);
+                Color temp = (Color)GetValue(ColorProperty);
                 return new Color(OnColorChanged, temp.R, temp.G, temp.B, temp.A);
             }
             set
             {
-                SetColor(value);
+                SetValue(ColorProperty, value);
+                selectorData?.Color.UpdateIfNeeds(this, value);
+                NotifyPropertyChanged();
             }
         }
 
@@ -2082,7 +2164,6 @@ namespace Tizen.NUI.BaseComponents
                     return;
                 }
 
-                Log.Info("NUI", "Setting Layout on:" + Name + "\n");
                 layoutingDisabled = false;
                 layoutSet = true;
 
@@ -2091,11 +2172,14 @@ namespace Tizen.NUI.BaseComponents
                 if (value?.Owner != null)
                 {
                     // Previous owner of the layout gets a default layout as a replacement.
-                    value.Owner.Layout = new LayoutGroup();
+                    value.Owner.Layout = new AbsoluteLayout();
 
                     // Copy Margin and Padding to replacement LayoutGroup.
-                    value.Owner.Layout.Margin = value.Margin;
-                    value.Owner.Layout.Padding = value.Padding;
+                    if (value.Owner.Layout != null)
+                    {
+                        value.Owner.Layout.Margin = value.Margin;
+                        value.Owner.Layout.Padding = value.Padding;
+                    }
                 }
 
                 // Copy Margin and Padding to new layout being set or restore padding and margin back to
@@ -2120,24 +2204,28 @@ namespace Tizen.NUI.BaseComponents
                 else
                 {
                     // First Layout to be added to the View hence copy
-
                     // Do not try to set Margins or Padding on a null Layout (when a layout is being removed from a View)
-                    if (value !=null)
+                    if (value != null)
                     {
-                        if (Margin.Top != 0 || Margin.Bottom !=0 || Margin.Start !=0 || Margin.End != 0)
+                        if (Margin.Top != 0 || Margin.Bottom != 0 || Margin.Start != 0 || Margin.End != 0)
                         {
                             // If View already has a margin set then store it in Layout instead.
                             value.Margin = Margin;
-                            SetValue(MarginProperty, new Extents(0,0,0,0));
+                            SetValue(MarginProperty, new Extents(0, 0, 0, 0));
                             NotifyPropertyChanged();
                         }
 
-                        if (Padding.Top != 0 || Padding.Bottom !=0 || Padding.Start !=0 || Padding.End != 0)
+                        if (Padding.Top != 0 || Padding.Bottom != 0 || Padding.Start != 0 || Padding.End != 0)
                         {
                             // If View already has a padding set then store it in Layout instead.
                             value.Padding = Padding;
-                            SetValue(PaddingProperty, new Extents(0,0,0,0));
-                            NotifyPropertyChanged();
+                            // If Layout is a LayoutItem then it could be a View that handles it's own padding.
+                            // Let the View keeps it's padding.  Still store Padding in Layout to reduce code paths.
+                            if (typeof(LayoutGroup).IsAssignableFrom(value.GetType())) // If a Layout container of some kind.
+                            {
+                                SetValue(PaddingProperty, new Extents(0, 0, 0, 0));
+                                NotifyPropertyChanged();
+                            }
                         }
                     }
                 }
@@ -2183,15 +2271,11 @@ namespace Tizen.NUI.BaseComponents
             set
             {
                 _backgroundImageSynchronosLoading = value;
-                string bgUrl = "";
-                int visualType = 0;
-                Background.Find(Visual.Property.Type)?.Get(out visualType);
-                if (visualType == (int)Visual.Type.Image)
-                {
-                    Background.Find(ImageVisualProperty.URL)?.Get(out bgUrl);
-                }
 
-                if (bgUrl.Length != 0)
+                string bgUrl = null;
+                Background.Find(ImageVisualProperty.URL)?.Get(out bgUrl);
+
+                if (!string.IsNullOrEmpty(bgUrl))
                 {
                     PropertyMap bgMap = this.Background;
                     bgMap.Add("synchronousLoading", new PropertyValue(_backgroundImageSynchronosLoading));
@@ -2231,130 +2315,118 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// Get Style, it is abstract function and must be override.
+        /// Enable/Disable ControlState propagation for children.
+        /// It is false by default.
+        /// If the View needs to share ControlState with descendants, please set it true.
+        /// Please note that, changing the value will also changes children's EnableControlStatePropagation value recursively.
         /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual ViewStyle GetViewStyle()
+        public bool EnableControlStatePropagation
         {
-            return new ViewStyle();
+            get => controlStatePropagation;
+            set
+            {
+                controlStatePropagation = value;
+
+                foreach (View child in Children)
+                {
+                    child.EnableControlStatePropagation = value;
+                }
+            }
         }
 
-        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        /// <summary>
+        /// If this property is set to true, the View can have a touch related ControlState (such as Pressed) when touch.
+        /// By default, it is false in View, true in Control.
+        /// Note that if the value is true, the View will be a touch receptor.
+        /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual bool OnControlStateChanged(ControlStates currentState)
-        {
-            //If need to apply the state to all child, return true;
-            return true;
-        }
-        internal static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector<string>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
-        {
-            var view = (View)bindable;
-            view.backgroundImageSelector.Clone((Selector<string>)newValue);
-        },
-        defaultValueCreator: (bindable) =>
-        {
-            var view = (View)bindable;
-            return view.backgroundImageSelector;
-        });
-        private TriggerableSelector<string> _backgroundImageSelector;
-        private TriggerableSelector<string> backgroundImageSelector
+        public bool EnableControlState
         {
             get
             {
-                if (null == _backgroundImageSelector)
-                {
-                    _backgroundImageSelector = new TriggerableSelector<string>(this, BackgroundImageProperty);
-                }
-                return _backgroundImageSelector;
+                return (bool)GetValue(EnableControlStateProperty);
+            }
+            set
+            {
+                SetValue(EnableControlStateProperty, value);
             }
         }
-        internal static readonly BindableProperty BackgroundColorSelectorProperty = BindableProperty.Create("BackgroundColorSelector", typeof(Selector<Color>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
-        {
-            var view = (View)bindable;
-            view.backgroundColorSelector.Clone((Selector<Color>)newValue);
-        },
-        defaultValueCreator: (bindable) =>
-        {
-            var view = (View)bindable;
-            return view.backgroundColorSelector;
-        });
-        private TriggerableSelector<Color> _backgroundColorSelector;
-        private TriggerableSelector<Color> backgroundColorSelector
+
+         /// <summary>
+        /// Whether the actor grab all touches even if touch leaves its boundary.
+        /// </summary>
+        /// <returns>true, if it grab all touch after start</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool GrabTouchAfterLeave
         {
             get
             {
-                if (null == _backgroundColorSelector)
-                {
-                    _backgroundColorSelector = new TriggerableSelector<Color>(this, BackgroundColorProperty);
-                }
-                return _backgroundColorSelector;
+                bool temp = false;
+                GetProperty(View.Property.CaptureAllTouchAfterStart).Get(out temp);
+                return temp;
+            }
+            set
+            {
+                SetProperty(View.Property.CaptureAllTouchAfterStart, new Tizen.NUI.PropertyValue(value));
+                NotifyPropertyChanged();
             }
         }
-        internal static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector<Rectangle>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
-        {
-            var view = (View)bindable;
-            view.backgroundImageBorderSelector.Clone((Selector<Rectangle>)newValue);
-        },
-        defaultValueCreator: (bindable) =>
+
+        /// <summary>
+        /// If the value is true, the View will change its style as the theme changes.
+        /// It is false by default, but turned to true when setting StyleName (by setting property or using specified constructor).
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool ThemeChangeSensitive
         {
-            var view = (View)bindable;
-            return view.backgroundImageBorderSelector;
-        });
-        private TriggerableSelector<Rectangle> _backgroundImageBorderSelector;
-        private TriggerableSelector<Rectangle> backgroundImageBorderSelector
+            get => (bool)GetValue(ThemeChangeSensitiveProperty);
+            set => SetValue(ThemeChangeSensitiveProperty, value);
+        }
+
+        /// <summary>
+        /// Get Style, it is abstract function and must be override.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        // TODO: It should be deprecated. please use CreateViewStyle instead.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual ViewStyle GetViewStyle()
         {
-            get
-            {
-                if (null == _backgroundImageBorderSelector)
-                {
-                    _backgroundImageBorderSelector = new TriggerableSelector<Rectangle>(this, BackgroundImageBorderProperty);
-                }
-                return _backgroundImageBorderSelector;
-            }
+            return CreateViewStyle();
         }
-        internal static readonly BindableProperty OpacitySelectorProperty = BindableProperty.Create("OpacitySelector", typeof(Selector<float?>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
+
+        /// <summary>
+        /// Create Style, it is abstract function and must be override.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual ViewStyle CreateViewStyle()
         {
-            var view = (View)bindable;
-            view.opacitySelector.Clone((Selector<float?>)newValue);
-        },
-        defaultValueCreator: (bindable) =>
+            return new ViewStyle();
+        }
+
+        /// <summary>
+        /// Called after the View's ControlStates changed.
+        /// </summary>
+        /// <param name="controlStateChangedInfo">The information including state changed variables.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual void OnControlStateChanged(ControlStateChangedEventArgs controlStateChangedInfo)
         {
-            var view = (View)bindable;
-            return view.opacitySelector;
-        });
-        private TriggerableSelector<float?> _opacitySelector;
-        private TriggerableSelector<float?> opacitySelector
+        }
+
+        /// <summary>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual void OnThemeChanged(object sender, ThemeChangedEventArgs e)
         {
-            get
-            {
-                if (null == _opacitySelector)
-                {
-                    _opacitySelector = new TriggerableSelector<float?>(this, OpacityProperty);
-                }
-                return _opacitySelector;
-            }
+            UpdateStyle();
         }
 
         /// 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 virtual void ApplyStyle(ViewStyle viewStyle)
         {
-            if (null == viewStyle)
-            {
-                return;
-            }
-
-            if (this.viewStyle == viewStyle)
-            {
-                return;
-            }
-
-            if (null != this.viewStyle)
-            {
-                simpleBinding.Clear();
-            }
+            if (null == viewStyle || this.viewStyle == viewStyle) return;
 
             this.viewStyle = viewStyle;
 
@@ -2374,7 +2446,7 @@ namespace Tizen.NUI.BaseComponents
                     BindableProperty viewProperty;
                     bindablePropertyOfView.TryGetValue(keyValuePair.Key, out viewProperty);
 
-                    if (null != viewProperty)
+                    if (null != viewProperty && viewProperty != StyleNameProperty)
                     {
                         object value = viewStyle.GetValue(keyValuePair.Value);
 
@@ -2382,15 +2454,9 @@ namespace Tizen.NUI.BaseComponents
                         {
                             SetValue(viewProperty, value);
                         }
-
-                        simpleBinding.Bind(viewStyle, keyValuePair.Value, this, viewProperty, BindingDirection.TwoWay);
                     }
                 }
             }
         }
-
-        /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        private BundledPipe simpleBinding = new BundledPipe();
     }
 }