Ejemplo n.º 1
0
        void SetPositionsVertical(List <List <RectTransform> > group, Vector2 startPosition, Vector2 groupSize)
        {
            var position = startPosition;

            group = EasyLayoutUtilites.Transpose(group);
            GetColumnsHeights(group, ColumnsHeights);
            GetMaxRowsHeights(group, MaxRowsHeights);

            var align = new Vector2(0, 0);

            for (int coord_y = 0; coord_y < group.Count; coord_y++)
            {
                var column_cell_max_size = GetMaxCellSize(group[coord_y]);

                for (int coord_x = 0; coord_x < group[coord_y].Count; coord_x++)
                {
                    currentUIElement = group[coord_y][coord_x];

                    align = GetAlignByHeight(currentUIElement, MaxRowsHeights[coord_x], column_cell_max_size, groupSize.y - ColumnsHeights[coord_y]);

                    var new_position = GetUIPosition(currentUIElement, position, align);
                    if (currentUIElement.localPosition.x != new_position.x || currentUIElement.localPosition.y != new_position.y)
                    {
                        currentUIElement.localPosition = new_position;
                    }

                    position.y -= ((LayoutType == LayoutTypes.Compact)
                                                ? EasyLayoutUtilites.ScaledHeight(currentUIElement)
                                                : MaxRowsHeights[coord_x]) + Spacing.y;
                }
                position.y  = startPosition.y;
                position.x += column_cell_max_size.x + Spacing.x;
            }
        }
Ejemplo n.º 2
0
        void ShrinkHeightToFit(float height, List <List <LayoutElementInfo> > group)
        {
            var transposed_group = EasyLayoutUtilites.Transpose(group);

            for (int i = 0; i < transposed_group.Count; i++)
            {
                ShrinkToFit(height, transposed_group[i], Layout.Spacing.y, RectTransform.Axis.Vertical);
            }
        }
Ejemplo n.º 3
0
        void GetMaxRowsHeights(List <List <RectTransform> > group, List <float> heights)
        {
            heights.Clear();
            var transposed_group = EasyLayoutUtilites.Transpose(group);

            for (int i = 0; i < transposed_group.Count; i++)
            {
                heights.Add(GetMaxRowHeight(transposed_group[i]));
            }
        }
Ejemplo n.º 4
0
        void SetPositionsVertical(List <List <LayoutElementInfo> > group)
        {
            var start_position = GetStartPosition();
            var position       = start_position;
            var height         = Layout.UISize.y;

            GetMaxRowsHeights(group);

            group = EasyLayoutUtilites.Transpose(group);
            GetColumnsHeights(group);

            var align = new Vector2(0, 0);

            for (int coord_y = 0; coord_y < group.Count; coord_y++)
            {
                var column_cell_max_size = GetMaxCellSize(group[coord_y]);

                for (int coord_x = 0; coord_x < group[coord_y].Count; coord_x++)
                {
                    element = group[coord_y][coord_x];

                    align = GetAlignByHeight(element, MaxRowsHeights[coord_x], column_cell_max_size, height - ColumnsHeights[coord_y]);

                    var new_position = GetUIPosition(element, position, align);
                    if (element.Rect.localPosition.x != new_position.x || element.Rect.localPosition.y != new_position.y)
                    {
                        element.Rect.localPosition = new_position;
                    }

                    position.y -= ((Layout.LayoutType == LayoutTypes.Compact)
                                                ? element.Height
                                                : MaxRowsHeights[coord_x]) + Layout.Spacing.y;
                }
                position.y  = start_position.y;
                position.x += column_cell_max_size.x + Layout.Spacing.x;
            }
        }
Ejemplo n.º 5
0
        void ResizeColumnWidthToFit(float width, List <List <LayoutElementInfo> > group)
        {
            var transposed_group = EasyLayoutUtilites.Transpose(group);

            ResizeToFit(width, transposed_group, Layout.Spacing.x, RectTransform.Axis.Horizontal);
        }
Ejemplo n.º 6
0
        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);
        }