From fe1c839694f27744b6406bcad19b716ea1ccbc04 Mon Sep 17 00:00:00 2001 From: zhouleonlei <56956725+zhouleonlei@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:04:45 +0800 Subject: [PATCH] [NUI] Made the value of Size be consistent with Specification (#1646) --- src/Tizen.NUI/src/public/BaseComponents/View.cs | 52 +-------------------- .../public/BaseComponents/ViewBindableProperty.cs | 53 +++++++++++++++++++++- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 54e0dee..7e97380 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -1053,7 +1053,6 @@ namespace Tizen.NUI.BaseComponents set { SetValue(SizeWidthProperty, value); - WidthSpecification = (int)Math.Ceiling(value); NotifyPropertyChanged(); } } @@ -1076,7 +1075,6 @@ namespace Tizen.NUI.BaseComponents set { SetValue(SizeHeightProperty, value); - HeightSpecification = (int)Math.Ceiling(value); NotifyPropertyChanged(); } } @@ -1536,28 +1534,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(); } } @@ -1575,28 +1551,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(); } } @@ -1665,7 +1619,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; } @@ -1854,10 +1808,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(); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index 277be24..c9ee212 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -763,6 +763,7 @@ namespace Tizen.NUI.BaseComponents if (newValue != null) { Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)newValue)); + view.WidthSpecification = (int)System.Math.Ceiling((float)newValue); } }, defaultValueCreator: (bindable) => @@ -783,6 +784,7 @@ namespace Tizen.NUI.BaseComponents if (newValue != null) { Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)newValue)); + view.HeightSpecification = (int)System.Math.Ceiling((float)newValue); } }, defaultValueCreator: (bindable) => @@ -1126,6 +1128,28 @@ namespace Tizen.NUI.BaseComponents if (newValue != null) { Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.WIDTH_RESIZE_POLICY, new Tizen.NUI.PropertyValue((int)newValue)); + // Match ResizePolicy to new Layouting. + // Parent relative policies can not be mapped at this point as parent size unknown. + switch ((ResizePolicyType)newValue) + { + case ResizePolicyType.UseNaturalSize: + { + view.WidthSpecification = LayoutParamPolicies.WrapContent; + break; + } + case ResizePolicyType.FillToParent: + { + view.WidthSpecification = LayoutParamPolicies.MatchParent; + break; + } + case ResizePolicyType.FitToChildren: + { + view.WidthSpecification = LayoutParamPolicies.WrapContent; + break; + } + default: + break; + } } }, defaultValueCreator: (bindable) => @@ -1149,6 +1173,28 @@ namespace Tizen.NUI.BaseComponents if (newValue != null) { Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.HEIGHT_RESIZE_POLICY, new Tizen.NUI.PropertyValue((int)newValue)); + // Match ResizePolicy to new Layouting. + // Parent relative policies can not be mapped at this point as parent size unknown. + switch ((ResizePolicyType)newValue) + { + case ResizePolicyType.UseNaturalSize: + { + view.HeightSpecification = LayoutParamPolicies.WrapContent; + break; + } + case ResizePolicyType.FillToParent: + { + view.HeightSpecification = LayoutParamPolicies.MatchParent; + break; + } + case ResizePolicyType.FitToChildren: + { + view.HeightSpecification = LayoutParamPolicies.WrapContent; + break; + } + default: + break; + } } }, defaultValueCreator: (bindable) => @@ -1256,7 +1302,12 @@ namespace Tizen.NUI.BaseComponents var view = (View)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE, new Tizen.NUI.PropertyValue((Size)newValue)); + Size size = (Size)newValue; + Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE, new Tizen.NUI.PropertyValue(size)); + // Set Specification so when layouts measure this View it matches the value set here. + // All Views are currently Layouts. + view.WidthSpecification = (int)System.Math.Ceiling(size.Width); + view.HeightSpecification = (int)System.Math.Ceiling(size.Height); } }, defaultValueCreator: (bindable) => -- 2.7.4