Example #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));
        }
Example #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();
 }
Example #3
0
 /// <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;
 }
Example #4
0
 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));
     }
 }
Example #5
0
 public static RawLayout OneOffParent(string name, LayoutSize size, LayoutStyle style, LayoutNode child)
 {
     // Horizontal/Vertical does not matter here
     return(HorizontalParent(name, size, style, child));
 }
Example #6
0
 public static RawLayout NamelessOneOffParent(LayoutSize size, LayoutStyle style, LayoutNode child)
 {
     // Horizontal/Vertical does not matter here
     return(HorizontalParent("root", size, style, child));
 }
Example #7
0
 public static LayoutNode NamelessHorizontalParent(LayoutSize size, LayoutStyle style, params LayoutNode[] children)
 {
     return(new RawLayout(new LayoutNode(true, LayoutNodeName.Nameless, size, Orientation.Horizontal, style, children)));
 }
Example #8
0
 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)));
 }