示例#1
0
        void SetPositionsHorizontal(List <List <LayoutElementInfo> > group)
        {
            var startPosition = GetStartPosition();
            var position      = startPosition;
            var width         = Layout.UISize.x;

            GetRowsWidths(group);
            GetMaxColumnsWidths(group);

            var align = new Vector2(0, 0);

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

                for (int coord_y = 0; coord_y < group[coord_x].Count; coord_y++)
                {
                    element = group[coord_x][coord_y];
                    align   = GetAlignByWidth(element, MaxColumnsWidths[coord_y], row_cell_max_size, width - RowsWidths[coord_x]);

                    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.x += ((Layout.LayoutType == LayoutTypes.Compact)
                                                ? element.Width
                                                : MaxColumnsWidths[coord_y]) + Layout.Spacing.x;
                }
                position.x  = startPosition.x;
                position.y -= row_cell_max_size.y + Layout.Spacing.y;
            }
        }
示例#2
0
        /// <summary>
        /// Gets the user interface element position.
        /// </summary>
        /// <returns>The user interface position.</returns>
        /// <param name="ui">User interface.</param>
        /// <param name="position">Position.</param>
        /// <param name="align">Align.</param>
        static Vector2 GetUIPosition(LayoutElementInfo ui, Vector2 position, Vector2 align)
        {
            var pivot_fix_x = ui.Width * ui.Rect.pivot.x;
            var pivox_fix_y = ui.Height * ui.Rect.pivot.y;
            var new_x       = position.x + pivot_fix_x + align.x;
            var new_y       = position.y - ui.Height + pivox_fix_y - align.y;

            return(new Vector2(new_x, new_y));
        }
示例#3
0
 void ResizeElement(LayoutElementInfo element)
 {
     if (Layout.ChildrenWidth != ChildrenSize.DoNothing)
     {
         element.NewWidth = (maxWidth != -1) ? maxWidth : element.PreferredWidth;
     }
     if (Layout.ChildrenHeight != ChildrenSize.DoNothing)
     {
         element.NewHeight = (maxHeight != -1) ? maxHeight : element.PreferredHeight;
     }
 }
示例#4
0
        Vector2 GetAlignByHeight(LayoutElementInfo ui, float maxHeight, Vector2 cellMaxSize, float emptyHeight)
        {
            if (Layout.LayoutType == LayoutTypes.Compact)
            {
                return(new Vector2(
                           (cellMaxSize.x - ui.Width) * innerAligns[(int)Layout.InnerAlign],
                           emptyHeight * rowAligns[(int)Layout.RowAlign]
                           ));
            }
            else
            {
                var cell_align = groupPositions[(int)Layout.CellAlign];

                return(new Vector2(
                           (cellMaxSize.x - ui.Width) * (1 - cell_align.x),
                           (maxHeight - ui.Height) * cell_align.y
                           ));
            }
        }
示例#5
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;
            }
        }