public static LayoutNode Spacer(Point size) { return(new LayoutNode(false, LayoutNodeName.Nameless, LayoutSize.Pixels(size), /*Ignored params:*/ Orientation.Horizontal, LayoutStyle.Empty, null)); }
public static LayoutNode NamelessLeaf(LayoutSize size) { return(new LayoutNode(true, LayoutNodeName.Nameless, size, /*Ignored params:*/ Orientation.Horizontal, LayoutStyle.Empty, null)); }
public static LayoutNode Leaf(string name, LayoutSize size) { return(new LayoutNode(true, name, size, /*Ignored params:*/ Orientation.Horizontal, LayoutStyle.Empty, null)); }
public void ConsumeInstruction(FlowLayoutInstruction instruction) { if (instruction == FlowLayoutInstruction.Linebreak) { if (HasRoomForAnotherRow(LayoutNode.NamelessLeaf(LayoutSize.Pixels(0, 0)))) { AddNewRow(); } } }
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)); } }
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; }
private static LayoutSize FlexParentSize(Orientation orientation, FlexLayoutStyle style, LayoutNode[] children) { var totalPadding = (children.Length - 1) * style.InnerStyle.Padding; var totalAlongMargin = style.InnerStyle.Margin.AxisValue(orientation.ToAxis()) * 2; var totalPerpendicularMargin = style.InnerStyle.Margin.AxisValue(orientation.Opposite().ToAxis()) * 2; var measuredAlongSize = 0; var largestPerpendicularSize = 0; foreach (var child in children) { measuredAlongSize += child.Size.GetValueFromOrientation(orientation).ActualSize; largestPerpendicularSize = Math.Max(largestPerpendicularSize, child.Size.GetValueFromOrientation(orientation.Opposite()).ActualSize); } var alongSize = measuredAlongSize + totalAlongMargin + totalPadding; var perpendicularSize = largestPerpendicularSize + totalPerpendicularMargin; if (style.MinAlongSize.HasValue) { alongSize = Math.Max(alongSize, style.MinAlongSize.Value); } if (style.MinPerpendicularSize.HasValue) { perpendicularSize = Math.Max(perpendicularSize, style.MinPerpendicularSize.Value); } if (orientation == Orientation.Horizontal) { return(LayoutSize.Pixels(alongSize, perpendicularSize)); } else { return(LayoutSize.Pixels(perpendicularSize, alongSize)); } }
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)); }
public static RawFlowLayout VerticalFlowParent(string name, LayoutSize size, FlowLayoutStyle style, params LayoutNodeOrInstruction[] children) { return(OrientedFlowParent(Orientation.Vertical, 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 LayoutNode StretchedSpacer() { return(new LayoutNode(false, LayoutNodeName.Nameless, LayoutSize.StretchedBoth(), Orientation.Horizontal, LayoutStyle.Empty, null)); }
/// <summary> /// Returns a LayoutNode just like this one with the same children, only resized /// </summary> /// <param name="newSize"></param> /// <returns></returns> public RawLayout GetResized(Point newSize) { return(new RawLayout(new LayoutNode(IsBakable, Name, LayoutSize.Pixels(newSize.X, newSize.Y), Orientation, 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))); }
public LayoutNode GetLayoutNode(string rowNodeName) { var size = Orientation.GetPointFromAlongPerpendicular(AvailableAlongSize, UsedPerpendicularSize); return(LayoutNode.OrientedParent(Orientation, rowNodeName, LayoutSize.Pixels(size), RowStyle, Content.ToArray())); }
public Point GetMeasuredSize(LayoutSize size) { return(new Point(MeasureEdge(size.Width), MeasureEdge(size.Height))); }