private static RawFlowLayout OrientedFlowParent(Orientation orientation, string name, LayoutSize size, FlowLayoutStyle style, params LayoutNodeOrInstruction[] children) { var workableAreaStyle = new LayoutStyle(margin: style.Margin, alignment: style.Alignment); var workableArea = LayoutNode.NamelessOneOffParent(size, workableAreaStyle, LayoutNode.Leaf("workableArea", LayoutSize.StretchedBoth())).Bake().GetNode("workableArea"); var rows = new FlowLayoutRows(workableArea.Size, style, orientation); foreach (var item in children) { if (item.IsLayoutNode) { if (!rows.CanFitItemPerpendicular(item)) { break; } if (rows.CanFitItemAlongCurrentRow(item)) { rows.AddItemToCurrentRow(item); } else { rows.CreateNextRowAndAdd(item); } } else if (item.IsInstruction) { rows.ConsumeInstruction(item); } } return(new RawFlowLayout(name, size, workableAreaStyle, orientation, style, rows)); }
internal RawFlowLayout(string name, LayoutSize size, LayoutStyle workableAreaStyle, Orientation orientation, FlowLayoutStyle style, FlowLayoutRows rows) : base( LayoutNode.OneOffParent(name, size, workableAreaStyle, LayoutNode.OrientedParent(orientation.Opposite(), "rows", LayoutSize.Pixels(rows.UsedSize), new LayoutStyle(padding: style.PaddingBetweenRows), rows.GetLayoutNodesOfEachRow() ) )) { this.orientation = orientation; this.rowNodes = rows.GetLayoutNodesOfEachRow(); this.rowUsedSpace = rows.GetUsedSpaceOfEachRow(); }
/// <summary> /// This is only called by the static constructor methods. Most constructors ignore everything past "size" /// </summary> private LayoutNode(bool isBakable, LayoutNodeName name, LayoutSize size, Orientation orientation, LayoutStyle style, LayoutNode[] children) { IsBakable = isBakable; Name = name; Size = size; Orientation = orientation; if (children != null) { Children = children; } Style = style; }
public static RawLayout OrientedParent(Orientation orientation, string name, LayoutSize size, LayoutStyle style, params LayoutNode[] children) { if (orientation == Orientation.Horizontal) { return(HorizontalParent(name, size, style, children)); } else { return(VerticalParent(name, size, style, children)); } }
public static RawLayout OneOffParent(string name, LayoutSize size, LayoutStyle style, LayoutNode child) { // Horizontal/Vertical does not matter here return(HorizontalParent(name, size, style, child)); }
public static RawLayout NamelessOneOffParent(LayoutSize size, LayoutStyle style, LayoutNode child) { // Horizontal/Vertical does not matter here return(HorizontalParent("root", size, style, child)); }
public static LayoutNode NamelessHorizontalParent(LayoutSize size, LayoutStyle style, params LayoutNode[] children) { return(new RawLayout(new LayoutNode(true, LayoutNodeName.Nameless, size, Orientation.Horizontal, style, children))); }
public static RawLayout HorizontalParent(string name, LayoutSize size, LayoutStyle style, params LayoutNode[] children) { return(new RawLayout(new LayoutNode(true, name, size, Orientation.Horizontal, style, children))); }