Exemple #1
0
        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));
        }
Exemple #2
0
 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();
 }