[NUI] Fix LinearLayout to update max height and width correctly
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 19 Apr 2022 05:25:38 +0000 (14:25 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Thu, 21 Apr 2022 10:39:37 +0000 (19:39 +0900)
commitf49655713258a3677dd8eade3cb5dc9ac8debf0e
tree776630c478086096e7a59e87b55b6b9061d1566e
parent4202b63ffbe6deef6d6fcd96c13da558f7967540
[NUI] Fix LinearLayout to update max height and width correctly

Horizontal oriented LinearLayout decides max height among children.
Vertical oriented LinearLayout decides max width among children.

Previously, the max height and width might be calculated before all
children sizes were measured.
So the max height and width might be calculated with children's previous
height and width.

Now, the max height and width should be calculated after all children
sizes are measured.
So the max height and width are calculated with children's current
height and width.

e.g. problem case
var window = NUIApplication.GetDefaultWindow();

var parent = new View()
{
    Layout = new LinearLayout(),
    WidthSpecification = LayoutParamPolicies.MatchParent,
    HeightSpecification = LayoutParamPolicies.WrapContent,
    BackgroundColor = Color.Red,
};
window.Add(parent);

var child = new View()
{
    WidthSpecification = LayoutParamPolicies.MatchParent,
    HeightSpecification = 200,
    BackgroundColor = Color.Blue,
};
parent.Add(child);

var timer = new Timer(1000);
timer.Tick += (object sender, Timer.TickEventArgs args) =>
{
    child.HeightSpecification = 100;
    return false;
};
timer.Start();
src/Tizen.NUI/src/public/Layouting/LinearLayout.cs