示例#1
0
 public static LayoutNode Spacer(Point size)
 {
     return(new LayoutNode(false, LayoutNodeName.Nameless, LayoutSize.Pixels(size),
                           /*Ignored params:*/
                           Orientation.Horizontal,
                           LayoutStyle.Empty,
                           null));
 }
示例#2
0
 public void ConsumeInstruction(FlowLayoutInstruction instruction)
 {
     if (instruction == FlowLayoutInstruction.Linebreak)
     {
         if (HasRoomForAnotherRow(LayoutNode.NamelessLeaf(LayoutSize.Pixels(0, 0))))
         {
             AddNewRow();
         }
     }
 }
示例#3
0
        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));
            }
        }
示例#4
0
        public LayoutNode GetLayoutNode(string rowNodeName)
        {
            var size = Orientation.GetPointFromAlongPerpendicular(AvailableAlongSize, UsedPerpendicularSize);

            return(LayoutNode.OrientedParent(Orientation, rowNodeName, LayoutSize.Pixels(size), RowStyle, Content.ToArray()));
        }
示例#5
0
 /// <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)));
 }
示例#6
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();
 }