aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-10-18 05:50:38 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-10-18 05:50:38 +0200
commit0cc6450b9bb90609867ce9cc56084f86857fc3ef (patch)
tree23514acc776f6ba5536f6e6e77a6233590e81cff
parent2bd92636704c0a9a30bacadd6170ddfa747dee90 (diff)
move stretchedGo changes logic from Widget to GenericStack
-rw-r--r--Crow/src/Widgets/GenericStack.cs17
-rw-r--r--Crow/src/Widgets/Widget.cs38
2 files changed, 16 insertions, 39 deletions
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)
/// </summary>
- 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);
}
}
/// <summary>
@@ -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);
}
}
/// <summary>