/// <summary> /// Group the specified elements. /// </summary> /// <param name="elements">Elements.</param> /// <param name="baseLength">Base length (width or height).</param> /// <param name="layout">Layout.</param> /// <param name="resultedGroup">Result</param> public static void Group(List <LayoutElementInfo> elements, float baseLength, EasyLayout layout, List <List <LayoutElementInfo> > resultedGroup) { if (elements.Count == 0) { return; } if (layout.Stacking == Stackings.Horizontal) { GroupHorizontal(elements, baseLength, layout, resultedGroup); } else { GroupVertical(elements, baseLength, layout, resultedGroup); } var rows = resultedGroup.Count; var columns = rows > 0 ? resultedGroup.Max(x => x.Count) : 0; if ((layout.CompactConstraint == CompactConstraints.MaxRowCount) && (rows > layout.ConstraintCount)) { resultedGroup.Clear(); EasyLayoutGrid.GroupByRows(elements, layout, resultedGroup); } else if ((layout.CompactConstraint == CompactConstraints.MaxColumnCount) && (columns > layout.ConstraintCount)) { resultedGroup.Clear(); EasyLayoutGrid.GroupByColumns(elements, layout, resultedGroup); } }
/// <summary> /// Group the specified uiElements. /// </summary> /// <param name="uiElements">User interface elements.</param> /// <param name="baseLength">Base length (width or size).</param> /// <param name="layout">Layout.</param> /// <param name="resultedGroup">Result</param> public static void Group(List <LayoutElementInfo> uiElements, float baseLength, EasyLayout layout, List <List <LayoutElementInfo> > resultedGroup) { if (layout.GridConstraint == GridConstraints.Flexible) { EasyLayoutGrid.GroupFlexible(uiElements, baseLength, layout, resultedGroup); } else if (layout.GridConstraint == GridConstraints.FixedRowCount) { EasyLayoutGrid.GroupByRows(uiElements, layout, resultedGroup); } else if (layout.GridConstraint == GridConstraints.FixedColumnCount) { EasyLayoutGrid.GroupByColumns(uiElements, layout, resultedGroup); } }
void GroupUIElements() { uiElementsGroup.Clear(); var base_length = Stacking == Stackings.Horizontal ? rectTransform.rect.width : rectTransform.rect.height; base_length -= (Stacking == Stackings.Horizontal) ? (GetMarginLeft() + GetMarginRight()) : (GetMarginTop() + GetMarginBottom()); var ui_elements = GetUIElements(); if (LayoutType == LayoutTypes.Compact) { EasyLayoutCompact.Group(ui_elements, base_length, this, uiElementsGroup); } else { EasyLayoutGrid.Group(ui_elements, base_length, this, uiElementsGroup); } if (!TopToBottom) { uiElementsGroup.Reverse(); } if (RightToLeft) { uiElementsGroup.ForEach(ReverseList); } CalculateSize(); Resizer.ResizeGroup(uiElementsGroup); foreach (var block in uiElementsGroup.ToArray()) { block.ForEach(x => x.ApplyResize()); } }
List <List <RectTransform> > GroupUIElements() { var base_length = GetLength(rectTransform, false); base_length -= (Stacking == Stackings.Horizontal) ? (GetMarginLeft() + GetMarginRight()) : (GetMarginTop() + GetMarginBottom()); var ui_elements = GetUIElements(); var group = (LayoutType == LayoutTypes.Compact) ? EasyLayoutCompact.Group(ui_elements, base_length, this) : EasyLayoutGrid.Group(ui_elements, base_length, this); if (Stacking == Stackings.Vertical) { group = Transpose(group); } if (!TopToBottom) { group.Reverse(); } if (RightToLeft) { group.ForEach(ReverseList); } var width = rectTransform.rect.width - (GetMarginLeft() + GetMarginRight()); var height = rectTransform.rect.height - (GetMarginTop() + GetMarginBottom()); if (LayoutType == LayoutTypes.Grid) { if (ChildrenWidth == ChildrenSize.FitContainer) { ResizeColumnWidthToFit(width, group); } if (ChildrenHeight == ChildrenSize.FitContainer) { ResizeRowHeightToFit(height, group); } } else { if (Stacking == Stackings.Horizontal) { if (ChildrenWidth == ChildrenSize.FitContainer) { ResizeWidthToFit(width, group); } if (ChildrenHeight == ChildrenSize.FitContainer) { ResizeRowHeightToFit(height, group); } } else { if (ChildrenHeight == ChildrenSize.FitContainer) { ResizeHeightToFit(height, group); } if (ChildrenWidth == ChildrenSize.FitContainer) { ResizeColumnWidthToFit(width, group); } } } return(group); }
List <List <RectTransform> > GroupUIElements() { var base_length = GetLength(rectTransform, false); base_length -= (Stacking == Stackings.Horizontal) ? (GetMarginLeft() + GetMarginRight()) : (GetMarginTop() + GetMarginBottom()); var ui_elements = GetUIElements(); ClearUIElementsGroup(); if (LayoutType == LayoutTypes.Compact) { EasyLayoutCompact.Group(ui_elements, base_length, this, uiElementsGroup); if (Stacking == Stackings.Vertical) { uiElementsGroup = EasyLayoutUtilites.Transpose(uiElementsGroup); } } else { GridConstraintCount = Mathf.Max(1, GridConstraintCount); if (GridConstraint == GridConstraints.Flexible) { EasyLayoutGrid.GroupFlexible(ui_elements, base_length, this, uiElementsGroup); } else if (GridConstraint == GridConstraints.FixedRowCount) { if (Stacking == Stackings.Vertical) { EasyLayoutGrid.GroupByRowsVertical(ui_elements, this, GridConstraintCount, uiElementsGroup); } else { EasyLayoutGrid.GroupByRowsHorizontal(ui_elements, this, GridConstraintCount, uiElementsGroup); } } else if (GridConstraint == GridConstraints.FixedColumnCount) { if (Stacking == Stackings.Vertical) { EasyLayoutGrid.GroupByColumnsVertical(ui_elements, this, GridConstraintCount, uiElementsGroup); } else { EasyLayoutGrid.GroupByColumnsHorizontal(ui_elements, this, GridConstraintCount, uiElementsGroup); } } } if (!TopToBottom) { uiElementsGroup.Reverse(); } if (RightToLeft) { uiElementsGroup.ForEach(ReverseList); } var width = rectTransform.rect.width - (GetMarginLeft() + GetMarginRight()); var height = rectTransform.rect.height - (GetMarginTop() + GetMarginBottom()); if (LayoutType == LayoutTypes.Grid) { if (ChildrenWidth == ChildrenSize.FitContainer) { EasyLayoutUtilites.ResizeColumnWidthToFit(width, uiElementsGroup, Spacing.x, PaddingInner.Left + PaddingInner.Right); } if (ChildrenHeight == ChildrenSize.FitContainer) { EasyLayoutUtilites.ResizeRowHeightToFit(height, uiElementsGroup, Spacing.y, PaddingInner.Top + PaddingInner.Bottom); } } else { if (Stacking == Stackings.Horizontal) { if (ChildrenWidth == ChildrenSize.FitContainer) { EasyLayoutUtilites.ResizeWidthToFit(width, uiElementsGroup, Spacing.x); } if (ChildrenHeight == ChildrenSize.FitContainer) { EasyLayoutUtilites.ResizeRowHeightToFit(height, uiElementsGroup, Spacing.y, PaddingInner.Top + PaddingInner.Bottom); } } else { if (ChildrenHeight == ChildrenSize.FitContainer) { EasyLayoutUtilites.ResizeHeightToFit(height, uiElementsGroup, Spacing.y); } if (ChildrenWidth == ChildrenSize.FitContainer) { EasyLayoutUtilites.ResizeColumnWidthToFit(width, uiElementsGroup, Spacing.x, PaddingInner.Left + PaddingInner.Right); } } } return(uiElementsGroup); }