aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-06-07 11:42:04 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-06-07 11:42:05 +0200
commit18e9dca6ea12f3f01a28c08f4b596268d0322a4f (patch)
treee59d9d645b0cc09eca7e656ad790fde3a0f1ae7f /src
parentd54616114dc1a3a3ca269e067c62fda2cde70202 (diff)
Allow on child in stack to have streatching size, to occupy remaining
space if stack size is fixed or stretched. Usefull in the case of spinner for example.
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GenericStack.cs47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index 5759bac4..63a70ad3 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -110,12 +110,55 @@ namespace go
if ((layoutType & (int)LayoutingType.PositionChildren) > 0)
Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);
+
}
public override void UpdateLayout (LayoutingType layoutType)
{
- if (layoutType == LayoutingType.PositionChildren)
+ if (layoutType == LayoutingType.PositionChildren) {
+ //allow 1 child to have size to 0 if stack has fixed or streched size,
+ //this child will occupy remaining space
+ if (Orientation == Orientation.Horizontal) {
+ if (Width >= 0) {
+ GraphicObject[] gobjs = Children.Where (c => c.Width == 0).ToArray();
+ if (gobjs.Length > 1)
+ throw new Exception ("Only one child in stack may have size to stretched");
+ else if (gobjs.Length == 1) {
+ int sz = Children.Except (gobjs).Sum (g => g.Slot.Width);
+ if (sz < Slot.Width) {
+ gobjs [0].Slot.Width = Slot.Width - sz - Spacing;
+ int idx = Children.IndexOf (gobjs [0]);
+ if (idx > 0 && idx < Children.Count - 1)
+ gobjs [0].Slot.Width -= Spacing;
+
+ if (gobjs [0].LastSlots.Width != gobjs [0].Slot.Width) {
+ gobjs [0].bmp = null;
+ gobjs [0].LastSlots.Width = gobjs [0].Slot.Width;
+ }
+ }
+ }
+ }
+ } else {
+ if (Height >= 0) {
+ GraphicObject[] gobjs = Children.Where (c => c.Height == 0).ToArray();
+ if (gobjs.Length > 1)
+ throw new Exception ("Only one child in stack may have size to stretched");
+ else if (gobjs.Length == 1) {
+ int sz = Children.Except (gobjs).Sum (g => g.Slot.Height);
+ if (sz < Slot.Height) {
+ gobjs [0].Slot.Height = Slot.Height - sz;
+ int idx = Children.IndexOf (gobjs [0]);
+ if (idx > 0 && idx < Children.Count - 1)
+ gobjs [0].Slot.Height -= Spacing;
+ if (gobjs [0].LastSlots.Height != gobjs [0].Slot.Height) {
+ gobjs [0].bmp = null;
+ gobjs [0].LastSlots.Height = gobjs [0].Slot.Height;
+ }
+ }
+ }
+ }
+ }
ComputeChildrenPositions ();
- else
+ }else
base.UpdateLayout(layoutType);
}
#endregion