From: Jean-Philippe Bruyère Date: Thu, 15 Apr 2021 04:29:33 +0000 (+0200) Subject: GenericStack:override addChild to increment contenSize on child addition X-Git-Tag: v0.9.5-beta~26 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=dad50038e364dda92e2ab5d4790f2138ae5b3909;p=jp%2Fcrow.git GenericStack:override addChild to increment contenSize on child addition --- diff --git a/Crow/src/Widgets/GenericStack.cs b/Crow/src/Widgets/GenericStack.cs index d0b94f37..3b92a2d8 100644 --- a/Crow/src/Widgets/GenericStack.cs +++ b/Crow/src/Widgets/GenericStack.cs @@ -72,14 +72,22 @@ namespace Crow { foreach (Widget c in Children) { if (!c.IsVisible) continue; - c.Slot.X = d; + if (c.Slot.X != d) { + c.Slot.X = d; + c.OnLayoutChanges (LayoutingType.X); + c.LastSlots.X = c.Slot.X; + } d += c.Slot.Width + Spacing; } } else { foreach (Widget c in Children) { if (!c.IsVisible) continue; - c.Slot.Y = d; + if (c.Slot.Y != d) { + c.Slot.Y = d; + c.OnLayoutChanges (LayoutingType.Y); + c.LastSlots.Y = c.Slot.Y; + } d += c.Slot.Height + Spacing; } } @@ -135,7 +143,7 @@ namespace Crow { w.LayoutChanged += OnChildLayoutChanges; w.LastSlots.Height = w.Slot.Height; } - void adjustStretchedGo (LayoutingType lt) { + internal void adjustStretchedGo (LayoutingType lt) { if (stretchedGO == null) return; if (lt == LayoutingType.Width) @@ -214,6 +222,18 @@ namespace Crow { } #endregion + public override void AddChild (Widget child) { + base.AddChild (child); + if (Orientation == Orientation.Horizontal) { + if (child.Width == Measure.Stretched) + child.RegisterForLayouting (LayoutingType.Width); + else + contentSize.Width += child.LastSlots.Width; + }else if (child.Height == Measure.Stretched) + child.RegisterForLayouting (LayoutingType.Height); + else + contentSize.Height += child.LastSlots.Height; + } public override void RemoveChild (Widget child) { if (child != stretchedGO) { if (Orientation == Orientation.Horizontal)