From: Jean-Philippe Bruyère Date: Fri, 18 Oct 2019 03:50:38 +0000 (+0200) Subject: move stretchedGo changes logic from Widget to GenericStack X-Git-Tag: v0.9.5-beta~137^2~7 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=163c8f4961765aedafd255f20335bbe87895a96b;p=jp%2Fcrow.git move stretchedGo changes logic from Widget to GenericStack --- diff --git a/Crow/src/Widgets/GenericStack.cs b/Crow/src/Widgets/GenericStack.cs index 7d1facf0..3e0a8cfb 100644 --- a/Crow/src/Widgets/GenericStack.cs +++ b/Crow/src/Widgets/GenericStack.cs @@ -157,16 +157,21 @@ namespace Crow case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { if (go.Width == Measure.Stretched) { - if (stretchedGO == null && Width != Measure.Fit) + if (stretchedGO == null && Width != Measure.Fit) { stretchedGO = go; - else if (stretchedGO != go) { + contentSize.Width -= go.LastSlots.Width; + } else if (stretchedGO != go) { go.Slot.Width = 0; go.Width = Measure.Fit; return; } + } else if (stretchedGO == go) { + stretchedGO = null; + contentSize.Width += go.Slot.Width; } else contentSize.Width += go.Slot.Width - go.LastSlots.Width; + adjustStretchedGo (LayoutingType.Width); if (Width == Measure.Fit) @@ -179,13 +184,17 @@ namespace Crow case LayoutingType.Height: if (Orientation == Orientation.Vertical) { if (go.Height == Measure.Stretched) { - if (stretchedGO == null && Height != Measure.Fit) + if (stretchedGO == null && Height != Measure.Fit) { stretchedGO = go; - else if (stretchedGO != go){ + contentSize.Height -= go.LastSlots.Height; + } else if (stretchedGO != go) { go.Slot.Height = 0; go.Height = Measure.Fit; return; } + } else if (stretchedGO == go) { + stretchedGO = null; + contentSize.Height += go.Slot.Height; } else contentSize.Height += go.Slot.Height - go.LastSlots.Height; diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 7fdec5a1..4fe87abe 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -316,7 +316,7 @@ namespace Crow /// widget inside the stack, which is never added to the contentSize, instead, its size /// is deducted from (parent.ClientRectangle - contentSize) /// - internal Size contentSize; + public Size contentSize; #endregion #region ILayoutable @@ -615,27 +615,9 @@ namespace Crow if (value < minimumSize.Width || (value > maximumSize.Width && maximumSize.Width > 0)) return; } - Measure old = width; width = value; NotifyValueChanged ("Width", width); - if (width == Measure.Stretched || old == Measure.Stretched) { - //NotifyValueChanged ("WidthPolicy", width.Policy); - //contentSize in Stacks are only update on childLayoutChange, and the single stretched - //child of the stack is not counted in contentSize, so when changing size policy of a child - //we should adapt contentSize - //TODO:check case when child become stretched, and another stretched item already exists. - GenericStack gs = Parent as GenericStack; - if (gs != null){ //TODO:check if I should test Group instead - if (gs.Orientation == Orientation.Horizontal) { - if (width == Measure.Stretched) - gs.contentSize.Width -= this.LastSlots.Width; - else - gs.contentSize.Width += this.LastSlots.Width; - } - } - } - - this.RegisterForLayouting (LayoutingType.Width); + RegisterForLayouting (LayoutingType.Width); } } /// @@ -656,23 +638,9 @@ namespace Crow if (value < minimumSize.Height || (value > maximumSize.Height && maximumSize.Height > 0)) return; } - Measure old = height; height = value; NotifyValueChanged ("Height", height); - if (height == Measure.Stretched || old == Measure.Stretched) { - //NotifyValueChanged ("HeightPolicy", HeightPolicy); - GenericStack gs = Parent as GenericStack; - if (gs != null){ //TODO:check if I should test Group instead - if (gs.Orientation == Orientation.Vertical) { - if (height == Measure.Stretched) - gs.contentSize.Height -= this.LastSlots.Height; - else - gs.contentSize.Height += this.LastSlots.Height; - } - } - } - - this.RegisterForLayouting (LayoutingType.Height); + RegisterForLayouting (LayoutingType.Height); } } ///