From eff4e447d261798c5ab3a2f9b50303eaecf0b9e8 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Fri, 16 Dec 2022 19:11:13 +0900 Subject: [PATCH] [NUI] Fix FlexLayout OnMeasure to calculate size correctly Previously, the measured size of FlexLayout with WrapContent could be calculated like MatchParent. The above issue happened in the following case. Tizen.NUI.Components.DialogPage.ShowAlertDialog("Title", "Message", null); To resolve the above issue without breaking backward compatibility, FlexLayout OnMeasure has been fixed to use ResolveSizeAndState() instead of GetDefaultSize() when calculating the measured size. To test the issue, showing a dialog without action button case has been added to Tizen.NUI.StyleGuide. --- src/Tizen.NUI/src/public/Layouting/FlexLayout.cs | 12 ++++++++++-- .../Examples/DialogAndAlertDialogExample.cs | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs b/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs index e5c19cb..1a5e7c9 100755 --- a/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs +++ b/src/Tizen.NUI/src/public/Layouting/FlexLayout.cs @@ -773,8 +773,16 @@ namespace Tizen.NUI NUILog.Debug("FlexLayout OnMeasure width:" + flexLayoutWidth.AsRoundedValue() + " height:" + flexLayoutHeight.AsRoundedValue()); - SetMeasuredDimensions(GetDefaultSize(flexLayoutWidth, widthMeasureSpec), - GetDefaultSize(flexLayoutHeight, heightMeasureSpec)); + // If flexLayoutWidth or flexLayoutHeight is 0, + // then the measured width or height can be assigned with parent's width or height. + // e.g. Let flexLayoutHeight be 0. + // Let heightMeasureSpec.Mode be AtMost. + // Then GetDefaultSize(flexLayoutHeight, heightMeasureSpec) returns the parent's height. + // Not to break backward compatibility of GetDefaultSize(), ResolveSizeAndState() is used instead. + Tizen.NUI.MeasuredSize widthMeasuredSize = ResolveSizeAndState(flexLayoutWidth, widthMeasureSpec, Tizen.NUI.MeasuredSize.StateType.MeasuredSizeOK); + Tizen.NUI.MeasuredSize heightMeasuredSize = ResolveSizeAndState(flexLayoutHeight, heightMeasureSpec, Tizen.NUI.MeasuredSize.StateType.MeasuredSizeOK); + + SetMeasuredDimensions(widthMeasuredSize, heightMeasuredSize); } /// diff --git a/test/Tizen.NUI.StyleGuide/Examples/DialogAndAlertDialogExample.cs b/test/Tizen.NUI.StyleGuide/Examples/DialogAndAlertDialogExample.cs index 6f00a9a..085a56f 100644 --- a/test/Tizen.NUI.StyleGuide/Examples/DialogAndAlertDialogExample.cs +++ b/test/Tizen.NUI.StyleGuide/Examples/DialogAndAlertDialogExample.cs @@ -26,7 +26,7 @@ namespace Tizen.NUI.StyleGuide internal class DialogAndAlertDialogExample : ContentPage, IExample { private View rootContent; - private Button buttonOneAction, buttonTwoAction, buttonNoTitle, buttonNoMessage; + private Button buttonNoAction, buttonOneAction, buttonTwoAction, buttonNoTitle, buttonNoMessage; public void Activate() { @@ -63,6 +63,19 @@ namespace Tizen.NUI.StyleGuide }, }; + buttonNoAction = new Button + { + Name = "buttonNoAction", + Text = "Show AlertDialog without button", + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + rootContent.Add(buttonNoAction); + + buttonNoAction.Clicked += (s, e) => + { + DialogPage.ShowAlertDialog("Title", "Message", null); + }; + buttonOneAction = new Button { Name = "buttonOneAction", -- 2.7.4