From 87a8c6c4d1a529dfcf933a2a9364c91a95baf7d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sat, 17 Mar 2018 04:28:49 +0100 Subject: [PATCH] go.UpdateLayout position improvment --- src/GraphicObjects/GenericStack.cs | 12 ++++----- src/GraphicObjects/GraphicObject.cs | 38 +++++++++-------------------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 9bf1944a..2653d420 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -267,11 +267,11 @@ namespace Crow else adjustStretchedGo (LayoutingType.Height); } -// public override void LayoutingDiscardCheck (LayoutingType lt) -// { -// if ((lt == LayoutingType.Height && _orientation == Orientation.Horizontal) || -// (lt == LayoutingType.Width && _orientation == Orientation.Vertical)) -// base.LayoutingDiscardCheck (lt); -// } + public override void LayoutingDiscardCheck (LayoutingType lt) + { + if ((lt == LayoutingType.Height && _orientation == Orientation.Horizontal) || + (lt == LayoutingType.Width && _orientation == Orientation.Vertical)) + base.LayoutingDiscardCheck (lt); + } } } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 1147f208..d1ae13c9 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1500,22 +1500,15 @@ namespace Crow case LayoutingType.X: if (Visible) { if (Left == 0) { - - if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || - RegisteredLayoutings.HasFlag (LayoutingType.Width)) - return false; - - switch (HorizontalAlignment) { - case HorizontalAlignment.Left: + if (HorizontalAlignment == HorizontalAlignment.Left) Slot.X = 0; - break; - case HorizontalAlignment.Right: + else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || + RegisteredLayoutings.HasFlag (LayoutingType.Width)) + return false; + else if (HorizontalAlignment == HorizontalAlignment.Right) Slot.X = Parent.ClientRectangle.Width - Slot.Width; - break; - case HorizontalAlignment.Center: + else if (HorizontalAlignment == HorizontalAlignment.Center) Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2; - break; - } } else Slot.X = Left; } else @@ -1533,22 +1526,15 @@ namespace Crow case LayoutingType.Y: if (Visible) { if (Top == 0) { - - if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || - RegisteredLayoutings.HasFlag (LayoutingType.Height)) - return false; - - switch (VerticalAlignment) { - case VerticalAlignment.Top://this could be processed even if parent Height is not known + if (VerticalAlignment == VerticalAlignment.Top) Slot.Y = 0; - break; - case VerticalAlignment.Bottom: + else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || + RegisteredLayoutings.HasFlag (LayoutingType.Height)) + return false; + else if (VerticalAlignment == VerticalAlignment.Bottom) Slot.Y = Parent.ClientRectangle.Height - Slot.Height; - break; - case VerticalAlignment.Center: + else if (VerticalAlignment == VerticalAlignment.Center) Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2; - break; - } } else Slot.Y = Top; } else -- 2.47.3