コード例 #1
0
        public void CheckState(List <TableColumn> columns, GUITableEntry tableEntry, float availableWidth)
        {
            if (tableEntry.defaultColumnWidth > 0f)
            {
                columns.ForEach(c => { if (c.entry.defaultWidth == 0f)
                                       {
                                           c.entry.defaultWidth = tableEntry.defaultColumnWidth;
                                       }
                                });
            }

            if (columnSizes == null || columnSizes.Count != columns.Count)
            {
                columnSizes = columns.Select((column) => column.GetDefaultWidth()).ToList();
            }
            if (columnVisible == null || columnVisible.Count != columns.Count)
            {
                columnVisible = columns.Select((column) => column.entry.visibleByDefault).ToList();
            }
            if (totalWidth < availableWidth && !isBeingResized)
            {
                List <int> expandableColumns = new List <int> ();
                for (int i = 0; i < columns.Count; i++)
                {
                    if (columns[i].entry.expandWidth && columnSizes[i] < columns[i].entry.maxWidth)
                    {
                        expandableColumns.Add(i);
                    }
                }
                float addWidth = (availableWidth - totalWidth) / expandableColumns.Count;
                foreach (int i in expandableColumns)
                {
                    columnSizes[i] += addWidth;
                }
            }

            absoluteColumnSizes = columnSizes.Select((columnSize, i) =>
                                                     Mathf.Clamp(
                                                         columns[i].entry.relative ? columnSize * GUIHelpers.GetViewWidth() : columnSize,
                                                         columns[i].entry.minWidth,
                                                         columns[i].entry.maxWidth))
                                  .ToList();

            if (reorderableList != null)
            {
                reorderableList.draggable = sortByColumnIndex < 0;
            }
        }