using System.Collections.Generic; using Annulus; using Azimuth; using Glass; namespace Clave.Glass { /// /// Lays parts out side by side, each centred on the strip's height. /// public static class StripLayout { /// /// Returns the size of side by side with between them. /// public static Vector SizeOf(IReadOnlyList sizes, Scalar spacing) { var strip = new RectAggregator(new Vector(spacing, 0)); Scalar height = 0; foreach (Vector size in sizes) { strip.NewCol(size.X); height = Scalar.Max(height, size.Y); } return new Vector(strip.Rect.Width, height); } /// /// Gives each part its size from , left to right across the area. A part past the /// right edge is squeezed to what is left. /// public static void Arrange(IReadOnlyList parts, IReadOnlyList sizes, Rect area, Scalar spacing) { Rect remainder = area; for (int i = 0; i < parts.Count; ++i) { Rect column = remainder.NewCol(sizes[i].X, margin: spacing, shortfall: Shortfall.UseWhatIsLeft); column.Center(new Vector(column.Width, sizes[i].Y), Shortfall.UseWhatIsLeft); parts[i].Bounds = column; } } } }