forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeViewTest.cs
More file actions
171 lines (157 loc) · 4.62 KB
/
Copy pathTreeViewTest.cs
File metadata and controls
171 lines (157 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Profiling;
namespace UnityEditor.TreeViewExamples
{
internal class TreeViewTest
{
private BackendData m_BackendData;
private TreeViewController m_TreeView;
private EditorWindow m_EditorWindow;
private bool m_Lazy;
private TreeViewColumnHeader m_ColumnHeader;
private GUIStyle m_HeaderStyle;
private GUIStyle m_HeaderStyleRightAligned;
public TreeViewTest(EditorWindow editorWindow, bool lazy)
{
this.m_EditorWindow = editorWindow;
this.m_Lazy = lazy;
}
public int GetNumItemsInData()
{
return this.m_BackendData.IDCounter;
}
public int GetNumItemsInTree()
{
LazyTestDataSource lazyTestDataSource = this.m_TreeView.data as LazyTestDataSource;
int result;
if (lazyTestDataSource != null)
{
result = lazyTestDataSource.itemCounter;
}
else
{
TestDataSource testDataSource = this.m_TreeView.data as TestDataSource;
if (testDataSource != null)
{
result = testDataSource.itemCounter;
}
else
{
result = -1;
}
}
return result;
}
public void Init(Rect rect, BackendData backendData)
{
if (this.m_TreeView == null)
{
this.m_BackendData = backendData;
TreeViewState treeViewState = new TreeViewState();
treeViewState.columnWidths = new float[]
{
250f,
90f,
93f,
98f,
74f,
78f
};
this.m_TreeView = new TreeViewController(this.m_EditorWindow, treeViewState);
ITreeViewGUI gui = new TestGUI(this.m_TreeView);
ITreeViewDragging dragging = new TestDragging(this.m_TreeView, this.m_BackendData);
ITreeViewDataSource data;
if (this.m_Lazy)
{
data = new LazyTestDataSource(this.m_TreeView, this.m_BackendData);
}
else
{
data = new TestDataSource(this.m_TreeView, this.m_BackendData);
}
this.m_TreeView.Init(rect, data, gui, dragging);
this.m_ColumnHeader = new TreeViewColumnHeader();
this.m_ColumnHeader.columnWidths = treeViewState.columnWidths;
this.m_ColumnHeader.minColumnWidth = 30f;
TreeViewColumnHeader expr_DA = this.m_ColumnHeader;
expr_DA.columnRenderer = (Action<int, Rect>)Delegate.Combine(expr_DA.columnRenderer, new Action<int, Rect>(this.OnColumnRenderer));
}
}
private void OnColumnRenderer(int column, Rect rect)
{
if (this.m_HeaderStyle == null)
{
this.m_HeaderStyle = new GUIStyle(EditorStyles.toolbarButton);
this.m_HeaderStyle.padding.left = 4;
this.m_HeaderStyle.alignment = TextAnchor.MiddleLeft;
this.m_HeaderStyleRightAligned = new GUIStyle(EditorStyles.toolbarButton);
this.m_HeaderStyleRightAligned.padding.right = 4;
this.m_HeaderStyleRightAligned.alignment = TextAnchor.MiddleRight;
}
string[] array = new string[]
{
"Name",
"Date Modified",
"Size",
"Kind",
"Author",
"Platform",
"Faster",
"Slower"
};
GUI.Label(rect, array[column], (column % 2 != 0) ? this.m_HeaderStyleRightAligned : this.m_HeaderStyle);
}
public void OnGUI(Rect rect)
{
int controlID = GUIUtility.GetControlID(FocusType.Keyboard, rect);
Rect rect2 = new Rect(rect.x, rect.y, rect.width, 17f);
Rect screenRect = new Rect(rect.x, rect.yMax - 20f, rect.width, 20f);
GUI.Label(rect2, "", EditorStyles.toolbar);
this.m_ColumnHeader.OnGUI(rect2);
Profiler.BeginSample("TREEVIEW");
rect.y += rect2.height;
rect.height -= rect2.height + screenRect.height;
this.m_TreeView.OnEvent();
this.m_TreeView.OnGUI(rect, controlID);
Profiler.EndSample();
GUILayout.BeginArea(screenRect, this.GetHeader(), EditorStyles.helpBox);
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
this.m_BackendData.m_RecursiveFindParentsBelow = GUILayout.Toggle(this.m_BackendData.m_RecursiveFindParentsBelow, GUIContent.Temp("Recursive"), new GUILayoutOption[0]);
if (GUILayout.Button("Ping", EditorStyles.miniButton, new GUILayoutOption[0]))
{
int num = this.GetNumItemsInData() / 2;
this.m_TreeView.Frame(num, true, true);
this.m_TreeView.SetSelection(new int[]
{
num
}, false);
}
if (GUILayout.Button("Frame", EditorStyles.miniButton, new GUILayoutOption[0]))
{
int num2 = this.GetNumItemsInData() / 10;
this.m_TreeView.Frame(num2, true, false);
this.m_TreeView.SetSelection(new int[]
{
num2
}, false);
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
private string GetHeader()
{
return string.Concat(new object[]
{
(!this.m_Lazy) ? "FULL: " : "LAZY: ",
"GUI items: ",
this.GetNumItemsInTree(),
" (data items: ",
this.GetNumItemsInData(),
")"
});
}
}
}