/// <summary> /// Applies layout changes to a given box and its children. /// </summary> public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var node = level.BranchRoot; if (node.State.NumberOfSiblings <= MaxGroups * 2) { base.ApplyVerticalLayout(state, level); return; } if (node.Level == 0) { node.State.SiblingsRowV = new Dimensions(node.State.Top, node.State.Bottom); } if (node.AssistantsRoot != null) { // assistants root has to be initialized with main node's exterior node.AssistantsRoot.State.CopyExteriorFrom(node.State); LayoutAlgorithm.VerticalLayout(state, node.AssistantsRoot); } var adapter = new SingleFishboneLayoutAdapter(node); while (adapter.NextGroup()) { LayoutAlgorithm.VerticalLayout(state, adapter.SpecialRoot); } }
/// <summary> /// Applies layout changes to a given box and its children. /// </summary> public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var node = level.BranchRoot; if (node.Level == 0) { throw new InvalidOperationException("Should never be invoked on root node"); } var prevRowBottom = node.State.SiblingsRowV.To; var maxOnLeft = MaxOnLeft(node); for (var i = 0; i < maxOnLeft; i++) { var spacing = i == 0 ? ParentChildSpacing : SiblingSpacing; var child = node.Children[i]; var frame = child.State; frame.MoveTo(frame.Left, prevRowBottom + spacing); var rowExterior = new Dimensions(frame.Top, frame.Bottom); var i2 = i + maxOnLeft; if (i2 < node.State.NumberOfSiblings) { var child2 = node.Children[i2]; var frame2 = child2.State; frame2.MoveTo(frame2.Left, prevRowBottom + spacing); if (frame2.Bottom > frame.Bottom) { frame.MoveTo(frame.Left, frame2.CenterV - frame.Size.Height / 2); } else if (frame2.Bottom < frame.Bottom) { frame2.MoveTo(frame2.Left, frame.CenterV - frame2.Size.Height / 2); } frame2.BranchExterior = new Rect(frame2.TopLeft, frame2.Size); rowExterior += new Dimensions(frame2.Top, frame2.Bottom); frame2.SiblingsRowV = rowExterior; LayoutAlgorithm.VerticalLayout(state, child2); prevRowBottom = frame2.BranchExterior.Bottom; } frame.BranchExterior = new Rect(frame.TopLeft, frame.Size); frame.SiblingsRowV = rowExterior; LayoutAlgorithm.VerticalLayout(state, child); prevRowBottom = Math.Max(prevRowBottom, frame.BranchExterior.Bottom); } }
/// <summary> /// Applies layout changes to a given box and its children. /// </summary> public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var node = level.BranchRoot; if (node.Level == 0) { node.State.SiblingsRowV = new Dimensions( node.State.Top, node.State.Bottom); } if (node.AssistantsRoot != null) { // assistants root has to be initialized with main node's exterior node.AssistantsRoot.State.CopyExteriorFrom(node.State); LayoutAlgorithm.VerticalLayout(state, node.AssistantsRoot); } if (node.State.NumberOfSiblings == 0) { return; } var siblingsRowExterior = Dimensions.MinMax(); var top = node.AssistantsRoot == null ? node.State.SiblingsRowV.To + ParentChildSpacing : node.State.BranchExterior.Bottom + ParentChildSpacing; for (var i = 0; i < node.State.NumberOfSiblings; i++) { var child = node.Children[i]; var rect = child.State; child.State.MoveTo(0, top); child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size); siblingsRowExterior += new Dimensions(top, top + rect.Size.Height); } siblingsRowExterior = new Dimensions(siblingsRowExterior.From, siblingsRowExterior.To); for (var i = 0; i < node.State.NumberOfSiblings; i++) { var child = node.Children[i]; child.State.SiblingsRowV = siblingsRowExterior; // re-enter layout algorithm for child branch LayoutAlgorithm.VerticalLayout(state, child); } }
public override void ApplyVerticalLayout(LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var prevRowBottom = RealRoot.AssistantsRoot?.State.BranchExterior.Bottom ?? SpecialRoot.State.SiblingsRowV.To; for (var i = 0; i < Iterator.MaxOnLeft; i++) { var spacing = i == 0 ? ParentChildSpacing : SiblingSpacing; var child = SpecialRoot.Children[i]; var frame = child.State; frame.MoveTo(frame.Left, prevRowBottom + spacing); var rowExterior = new Dimensions(frame.Top, frame.Bottom); var i2 = i + Iterator.MaxOnLeft; if (i2 < Iterator.Count) { var child2 = SpecialRoot.Children[i2]; var frame2 = child2.State; frame2.MoveTo(frame2.Left, prevRowBottom + spacing); if (frame2.Bottom > frame.Bottom) { frame.MoveTo(frame.Left, frame2.CenterV - frame.Size.Height / 2); } else if (frame2.Bottom < frame.Bottom) { frame2.MoveTo(frame2.Left, frame.CenterV - frame2.Size.Height / 2); } frame2.BranchExterior = new Rect(frame2.TopLeft, frame2.Size); rowExterior += new Dimensions(frame2.Top, frame2.Bottom); frame2.SiblingsRowV = rowExterior; LayoutAlgorithm.VerticalLayout(state, child2); prevRowBottom = frame2.BranchExterior.Bottom; } frame.BranchExterior = new Rect(frame.TopLeft, frame.Size); frame.SiblingsRowV = rowExterior; LayoutAlgorithm.VerticalLayout(state, child); prevRowBottom = Math.Max(prevRowBottom, frame.BranchExterior.Bottom); } }
/// <summary> /// Applies layout changes to a given box and its children. /// </summary> public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var node = level.BranchRoot; if (node.Level == 0) { node.State.SiblingsRowV = new Dimensions(node.State.Top, node.State.Bottom); } if (node.AssistantsRoot != null) { // assistants root has to be initialized with main node's exterior node.AssistantsRoot.State.CopyExteriorFrom(node.State); LayoutAlgorithm.VerticalLayout(state, node.AssistantsRoot); } var prevRowExterior = new Dimensions( node.State.SiblingsRowV.From, node.AssistantsRoot == null ? node.State.SiblingsRowV.To : node.State.BranchExterior.Bottom); for (var row = 0; row < node.State.NumberOfSiblings; row++) { // first, compute var child = node.Children[row]; var rect = child.State; var top = prevRowExterior.To + (row == 0 ? ParentChildSpacing : SiblingSpacing); child.State.MoveTo(rect.Left, top); child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size); var rowExterior = new Dimensions(top, top + rect.Size.Height); child = node.Children[row]; child.State.SiblingsRowV = rowExterior; // re-enter layout algorithm for child branch LayoutAlgorithm.VerticalLayout(state, child); var childBranchBottom = child.State.BranchExterior.Bottom; prevRowExterior = new Dimensions(rowExterior.From, Math.Max(childBranchBottom, rowExterior.To)); } }
/// <summary> /// Applies layout changes to a given box and its children. /// </summary> public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var node = level.BranchRoot; if (node.State.NumberOfSiblings <= MaxSiblingsPerRow) { // fall back to linear layout, only have one row of boxes base.ApplyVerticalLayout(state, level); return; } if (node.Level == 0) { node.State.SiblingsRowV = new Dimensions(node.State.Top, node.State.Bottom); } if (node.AssistantsRoot != null) { // assistants root has to be initialized with main node's exterior node.AssistantsRoot.State.CopyExteriorFrom(node.State); LayoutAlgorithm.VerticalLayout(state, node.AssistantsRoot); } var prevRowExterior = new Dimensions( node.State.SiblingsRowV.From, node.AssistantsRoot == null ? node.State.SiblingsRowV.To : node.State.BranchExterior.Bottom); for (var row = 0; row < node.State.NumberOfSiblingRows; row++) { var siblingsRowExterior = Dimensions.MinMax(); var spacing = row == 0 ? ParentChildSpacing : SiblingSpacing; // first, compute var from = row * node.State.NumberOfSiblingColumns; var to = Math.Min(from + node.State.NumberOfSiblingColumns, node.State.NumberOfSiblings); for (var i = from; i < to; i++) { var child = node.Children[i]; if (child.Element.IsSpecial) { // skip vertical spacers for now continue; } var rect = child.State; var top = prevRowExterior.To + spacing; child.State.MoveTo(rect.Left, top); child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size); siblingsRowExterior += new Dimensions(top, top + rect.Size.Height); } siblingsRowExterior = new Dimensions(siblingsRowExterior.From, siblingsRowExterior.To); var siblingsBottom = double.MinValue; for (var i = from; i < to; i++) { var child = node.Children[i]; child.State.SiblingsRowV = siblingsRowExterior; // re-enter layout algorithm for child branch LayoutAlgorithm.VerticalLayout(state, child); siblingsBottom = Math.Max(siblingsBottom, child.State.BranchExterior.Bottom); } prevRowExterior = new Dimensions(siblingsRowExterior.From, Math.Max(siblingsBottom, siblingsRowExterior.To)); // now assign size to the vertical spacer, if any var spacerIndex = from + node.State.NumberOfSiblingColumns / 2; if (spacerIndex < node.State.NumberOfSiblings) { // in the last row, spacer should only extend to the siblings row bottom, // because main vertical carrier does not go below last row // and thus cannot conflict with branches of children of the last row var spacerBottom = row == node.State.NumberOfSiblingRows - 1 ? node.Children[spacerIndex - 1].State.SiblingsRowV.To : prevRowExterior.To; var spacer = node.Children[spacerIndex].State; spacer.AdjustSpacer( 0, prevRowExterior.From, ParentConnectorShield, spacerBottom - prevRowExterior.From); } } }
/// <summary> /// Applies layout changes to a given box and its children. /// </summary> public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level) { var node = level.BranchRoot; if (node.Level == 0) { node.State.SiblingsRowV = new Dimensions( node.State.Top, node.State.Bottom); } if (node.State.NumberOfSiblings == 0) { return; } var siblingsRowExterior = Dimensions.MinMax(); if (Orientation == StackOrientation.SingleRowHorizontal) { var top = node.AssistantsRoot == null ? node.State.SiblingsRowV.To + ParentChildSpacing : node.State.BranchExterior.Bottom + ParentChildSpacing; for (var i = 0; i < node.State.NumberOfSiblings; i++) { var child = node.Children[i]; var rect = child.State; child.State.MoveTo(0, top); child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size); siblingsRowExterior += new Dimensions(top, top + rect.Size.Height); } siblingsRowExterior = new Dimensions(siblingsRowExterior.From, siblingsRowExterior.To); for (var i = 0; i < node.State.NumberOfSiblings; i++) { var child = node.Children[i]; child.State.SiblingsRowV = siblingsRowExterior; // re-enter layout algorithm for child branch LayoutAlgorithm.VerticalLayout(state, child); } } else if (Orientation == StackOrientation.SingleColumnVertical) { var prevRowExterior = new Dimensions( node.State.SiblingsRowV.From, node.State.SiblingsRowV.To); for (var row = 0; row < node.State.NumberOfSiblings; row++) { // first, compute var child = node.Children[row]; var rect = child.State; var top = prevRowExterior.To + (row == 0 ? ParentChildSpacing : SiblingSpacing); child.State.MoveTo(rect.Left, top); child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size); var rowExterior = new Dimensions(top, top + rect.Size.Height); child = node.Children[row]; child.State.SiblingsRowV = rowExterior; // re-enter layout algorithm for child branch LayoutAlgorithm.VerticalLayout(state, child); var childBranchBottom = child.State.BranchExterior.Bottom; prevRowExterior = new Dimensions(rowExterior.From, Math.Max(childBranchBottom, rowExterior.To)); } } }