2using System.Collections.Generic;
3using System.Threading.Tasks;
13 private readonly List<Padding> currentRow =
new List<Padding>();
14 private readonly List<Tuple<float, float, Padding[]>> rows =
new List<Tuple<float, float, Padding[]>>();
16 private readonly
float limitWidth;
20 private float maxWidth = 0;
21 private float maxHeight = 0;
37 this.session = Session;
38 this.limitWidth = WidthLimit;
50 float Width = Element.Width ?? 0;
51 float Height = Element.Height ?? 0;
53 if (this.x + Width > this.limitWidth)
56 this.currentRow.Add(
new Padding(Element, 0, 0));
59 if (Height > this.maxHeight)
60 this.maxHeight = Height;
62 return Task.CompletedTask;
70 if (this.currentRow.Count > 0)
72 this.rows.Add(
new Tuple<
float,
float,
Padding[]>(this.x, this.maxHeight, this.currentRow.ToArray()));
73 this.currentRow.Clear();
74 this.y += this.maxHeight;
76 if (this.x > this.maxWidth)
92 foreach (Tuple<
float,
float,
Padding[]> Row
in this.rows)
94 foreach (
Padding P
in Row.Item3)
99 P.OffsetX -= Element.Left ?? 0;
100 P.OffsetY -= Element.Top ?? 0;
121 foreach (Tuple<
float,
float,
Padding[]> Row
in this.rows)
123 foreach (
Padding P
in Row.Item3)
124 P.
Distribute(
null, Row.Item2,
this.session, SetPosition);
134 List<Padding> Result =
new List<Padding>();
136 float Y = this.verticalDirection == VerticalDirection.TopDown ? 0 : this.y;
139 foreach (Tuple<
float,
float,
Padding[]> Row
in this.rows)
141 Diff = this.maxWidth - Row.Item1;
142 switch (this.horizontalAlignment)
149 X = this.maxWidth - Diff;
156 X = this.maxWidth - Diff / 2;
170 foreach (
Padding P
in Row.Item3)
172 float Width = P.Element.Width ?? 0;
189 return Result.ToArray();
Lays out elements flexibly, first horizontally, then vertically.
void Distribute(bool SetPosition)
Distributes cells in layout.
void Flush()
Flushes any waiting elements int he layout pipeline.
Padding[] Align()
Aligns cells and returns an array of padded cells.
float TotHeight
Total height of layout
Task Add(ILayoutElement Element)
Adds a cell to the layout.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
float TotWidth
Total width of layout
FlexibleHorizontalCells(Variables Session, float WidthLimit, HorizontalDirection HorizontalDirection, VerticalDirection VerticalDirection, HorizontalAlignment HorizontalAlignment)
Lays out elements flexibly, first horizontally, then vertically.
Provides padding for a layout element in a group contruct.
Task Distribute(float? MaxWidth, float? MaxHeight, Variables Session, bool SetPosition)
Aligns a measured cell
ILayoutElement Element
Embedded element
Basic interface for cell layout objects.
Base interface for all layout elements.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
HorizontalDirection
Horizontal ordering
VerticalDirection
Vertical ordering
HorizontalAlignment
Horizontal alignment