aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-04-15 06:29:33 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-04-15 06:29:33 +0200
commitdad50038e364dda92e2ab5d4790f2138ae5b3909 (patch)
treeab86977d4ec0708e2c93efbde41ea07ae4a70a63
parent412e93ade521562145cf602cd340c4485fa15e37 (diff)
GenericStack:override addChild to increment contenSize on child addition
-rw-r--r--Crow/src/Widgets/GenericStack.cs26
1 files changed, 23 insertions, 3 deletions
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)