public static void DrawHeaders( Rect rect, GUITableState tableState, List <TableColumn> columns, float currentX, float currentY) { tableState.RightClickMenu(columns, rect); for (int i = 0; i < columns.Count; i++) { TableColumn column = columns[i]; if (!tableState.columnVisible [i]) { continue; } string columnName = column.title; if (tableState.sortByColumnIndex == i) { if (tableState.sortIncreasing) { columnName += " " + '\u25B2'.ToString(); } else { columnName += " " + '\u25BC'.ToString(); } } GUI.enabled = true; tableState.ResizeColumn(i, currentX, rect); GUI.enabled = column.entry.enabledTitle; if (GUI.Button(new Rect(currentX, currentY, tableState.columnSizes[i] + 4, EditorGUIUtility.singleLineHeight), columnName, EditorStyles.miniButtonMid) && column.entry.isSortable) { if (tableState.sortByColumnIndex == i && tableState.sortIncreasing) { tableState.sortIncreasing = false; } else if (tableState.sortByColumnIndex == i && !tableState.sortIncreasing) { tableState.sortByColumnIndex = -1; } else { tableState.sortByColumnIndex = i; tableState.sortIncreasing = true; } } currentX += tableState.columnSizes[i] + 4f; } }
public static void DrawHeaders( Rect rect, GUITableState tableState, List <TableColumn> columns, float currentX, float currentY, bool rotated = false) { tableState.RightClickMenu(columns, rect); for (int i = 0; i < columns.Count; i++) { TableColumn column = columns[i]; if (!tableState.columnVisible [i]) { continue; } string columnName = column.entry.title; if (tableState.sortByColumnIndex == i) { if (tableState.sortIncreasing) { columnName += " " + '\u25B2'.ToString(); } else { columnName += " " + '\u25BC'.ToString(); } } GUI.enabled = true; if (!rotated) { tableState.ResizeColumn(columns, i, currentX, rect); } GUI.enabled = column.entry.enabledTitle; Rect headerRect = new Rect(currentX, currentY, tableState.absoluteColumnSizes[i] + 4, EditorGUIUtility.singleLineHeight); GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButtonMid); Matrix4x4 matrix = GUI.matrix; if (rotated) { Vector2 pivot = new Vector2(headerRect.center.x, headerRect.center.y); GUIUtility.RotateAroundPivot(-45f, pivot); buttonStyle.normal.background = null; buttonStyle.active.background = null; buttonStyle.alignment = TextAnchor.MiddleLeft; headerRect = new Rect(headerRect.center.x - 10f, headerRect.min.y, buttonStyle.CalcSize(new GUIContent(columnName)).x, headerRect.height); } if (GUI.Button(headerRect, columnName, buttonStyle) && column.entry.isSortable) { if (tableState.sortByColumnIndex == i && tableState.sortIncreasing) { tableState.sortIncreasing = false; } else if (tableState.sortByColumnIndex == i && !tableState.sortIncreasing) { tableState.sortByColumnIndex = -1; } else { tableState.sortByColumnIndex = i; tableState.sortIncreasing = true; } } if (rotated) { GUI.matrix = matrix; } currentX += tableState.absoluteColumnSizes[i] + 4f; } }