public void Init(Rect rect, AudioProfilerClipViewBackend backend) { if (this.m_HeaderStyle == null) { this.m_HeaderStyle = new GUIStyle("OL title"); } this.m_HeaderStyle.alignment = TextAnchor.MiddleLeft; if (this.m_TreeView == null) { this.m_Backend = backend; if (this.m_TreeViewState.columnWidths == null) { int num = AudioProfilerClipInfoHelper.GetLastColumnIndex() + 1; this.m_TreeViewState.columnWidths = new float[num]; for (int i = 0; i < num; i++) { this.m_TreeViewState.columnWidths[i] = (i != 0) ? ((i != 2) ? ((float)80) : ((float)110)) : ((float)300); } } this.m_TreeView = new TreeViewController(this.m_EditorWindow, this.m_TreeViewState); ITreeViewGUI gui = new AudioProfilerClipViewGUI(this.m_TreeView); ITreeViewDataSource data = new AudioProfilerDataSource(this.m_TreeView, this.m_Backend); this.m_TreeView.Init(rect, data, gui, null); this.m_ColumnHeader = new AudioProfilerClipViewColumnHeader(this.m_TreeViewState, this.m_Backend); this.m_ColumnHeader.columnWidths = this.m_TreeViewState.columnWidths; this.m_ColumnHeader.minColumnWidth = 30f; this.m_TreeView.selectionChangedCallback = (Action <int[]>)Delegate.Combine(this.m_TreeView.selectionChangedCallback, new Action <int[]>(this.OnTreeSelectionChanged)); } }
public void OnGUI(Rect rect, bool allowSorting, GUIStyle headerStyle) { GUI.BeginClip(rect); float num = -this.m_TreeViewState.scrollPos.x; int lastColumnIndex = AudioProfilerClipInfoHelper.GetLastColumnIndex(); for (int i = 0; i <= lastColumnIndex; i++) { Rect position = new Rect(num, 0f, this.columnWidths[i], rect.height - 1f); num += this.columnWidths[i]; Rect position2 = new Rect(num - this.dragWidth / 2f, 0f, 3f, rect.height); float x = EditorGUI.MouseDeltaReader(position2, true).x; if (x != 0f) { this.columnWidths[i] += x; this.columnWidths[i] = Mathf.Max(this.columnWidths[i], this.minColumnWidth); } string text = this.headers[i]; if (allowSorting && i == this.m_TreeViewState.selectedColumn) { text += ((!this.m_TreeViewState.sortByDescendingOrder) ? " ▲" : " ▼"); } GUI.Box(position, text, headerStyle); if (allowSorting && Event.current.type == EventType.MouseDown && position.Contains(Event.current.mousePosition)) { this.m_TreeViewState.SetSelectedColumn(i); this.m_Backend.UpdateSorting(); } if (Event.current.type == EventType.Repaint) { EditorGUIUtility.AddCursorRect(position2, MouseCursor.SplitResizeLeftRight); } } GUI.EndClip(); }
protected override void OnContentGUI(Rect rect, int row, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging) { if (Event.current.type == EventType.Repaint) { GUIStyle gUIStyle = (!useBoldFont) ? TreeViewGUI.Styles.lineStyle : TreeViewGUI.Styles.lineBoldStyle; gUIStyle.alignment = TextAnchor.MiddleLeft; gUIStyle.padding.left = 0; int num = 2; base.OnContentGUI(new Rect(rect.x, rect.y, this.columnWidths[0] - (float)num, rect.height), row, item, label, selected, focused, useBoldFont, isPinging); rect.x += this.columnWidths[0] + (float)num; AudioProfilerClipView.AudioProfilerClipTreeViewItem audioProfilerClipTreeViewItem = item as AudioProfilerClipView.AudioProfilerClipTreeViewItem; for (int i = 1; i < this.columnWidths.Length; i++) { rect.width = this.columnWidths[i] - (float)(2 * num); gUIStyle.alignment = TextAnchor.MiddleRight; gUIStyle.Draw(rect, AudioProfilerClipInfoHelper.GetColumnString(audioProfilerClipTreeViewItem.info, (AudioProfilerClipInfoHelper.ColumnIndices)i), false, false, selected, focused); Handles.color = Color.black; Handles.DrawLine(new Vector3(rect.x - (float)num + 1f, rect.y, 0f), new Vector3(rect.x - (float)num + 1f, rect.y + rect.height, 0f)); rect.x += this.columnWidths[i]; } gUIStyle.alignment = TextAnchor.MiddleLeft; } }