aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/GenericStack.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-17 00:53:59 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-17 00:53:59 +0100
commita8a5562df0358b314197f3685fc7622ecfd307d0 (patch)
tree02cdd70b6b0f999dd2a2eab7bf8018da03ffdd9f /src/GraphicObjects/GenericStack.cs
parent61d1d07d37a5cc9d6ae1c4fcc333ec8ae644aca3 (diff)
splitted measure with fault checking, changing default template sizing to 0, lots of bugs.
Diffstat (limited to 'src/GraphicObjects/GenericStack.cs')
-rw-r--r--src/GraphicObjects/GenericStack.cs57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index bbbc52ec..2a1da6c3 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -52,34 +52,43 @@ namespace Crow
else
layoutType &= (~LayoutingType.Y);
}
- protected override Size measureRawSize ()
+ protected override int measureRawSize (LayoutingType lt)
{
- Size tmp = new Size ();
-
- if (Orientation == Orientation.Horizontal) {
- foreach (GraphicObject c in Children) {
- if (!c.Visible)
- continue;
- tmp.Width += c.Slot.Width + Spacing;
- tmp.Height = Math.Max (tmp.Height, Math.Max(c.Slot.Bottom, c.Slot.Height));
- }
- if (tmp.Width > 0)
- tmp.Width -= Spacing;
- } else {
- foreach (GraphicObject c in Children) {
- if (!c.Visible)
- continue;
- tmp.Width = Math.Max (tmp.Width, Math.Max(c.Slot.Right, c.Slot.Width));
- tmp.Height += c.Slot.Height + Spacing;
+ int tmp = 0;
+ switch (lt) {
+ case LayoutingType.Width:
+ if (Orientation == Orientation.Horizontal) {
+ if (Children.Count > 0) {
+ foreach (GraphicObject c in Children) {
+ if (!c.Visible)
+ continue;
+ if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return -1;
+ tmp += c.Slot.Width + Spacing;
+ }
+ tmp -= Spacing;
+ }
+ break;
+ }
+ return base.measureRawSize (lt);
+ case LayoutingType.Height:
+ if (Orientation == Orientation.Vertical) {
+ if (Children.Count > 0) {
+ foreach (GraphicObject c in Children) {
+ if (!c.Visible)
+ continue;
+ if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ return -1;
+ tmp += c.Slot.Height + Spacing;
+ }
+ tmp -= Spacing;
+ }
+ break;
}
- if (tmp.Height > 0)
- tmp.Height -= Spacing;
+ return base.measureRawSize (lt);
}
- tmp.Width += 2 * Margin;
- tmp.Height += 2 * Margin;
-
- return tmp;
+ return tmp + 2 * Margin;
}
public virtual void ComputeChildrenPositions()
{