void DrawFiltersAsButtons(AssetList assetList, float width)
{
string styleToUse;
GUILayout.BeginHorizontal();
float overallWidth = 0;
float widthToAdd = 0;
string label = "";
styleToUse = GetStyleToUse(assetList.All.Length, _selectedFilterIdx, 0);
label = "All (" + assetList.All.Length + ")";
widthToAdd = GUI.skin.GetStyle(styleToUse).CalcSize(new GUIContent(label)).x;
overallWidth += widthToAdd;
if (GUILayout.Button(label, styleToUse))
{
_selectedFilterIdx = 0;
}
if (overallWidth >= width)
{
overallWidth = 0;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
}
if (assetList.PerCategory != null && assetList.PerCategory.Length >= _fileFilters.Length)
{
for (int n = 0, len = _fileFilters.Length; n < len; ++n)
{
styleToUse = GetStyleToUse(assetList.PerCategory[n].Length, _selectedFilterIdx, n+1);
label = _fileFilters[n].Label + " (" + assetList.PerCategory[n].Length + ")";
widthToAdd = GUI.skin.GetStyle(styleToUse).CalcSize(new GUIContent(label)).x;
if (overallWidth + widthToAdd >= width)
{
overallWidth = 0;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
}
overallWidth += widthToAdd;
if (GUILayout.Button(label, styleToUse))
{
_selectedFilterIdx = n+1;
}
}
styleToUse = GetStyleToUse(assetList.PerCategory[assetList.PerCategory.Length-1].Length, _selectedFilterIdx, assetList.PerCategory.Length);
label = "Unknown (" + assetList.PerCategory[assetList.PerCategory.Length-1].Length + ")";
widthToAdd = GUI.skin.GetStyle(styleToUse).CalcSize(new GUIContent(label)).x;
if (overallWidth + widthToAdd >= width)
{
overallWidth = 0;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
}
if (GUILayout.Button(label, styleToUse))
{
_selectedFilterIdx = assetList.PerCategory.Length;
}
}
GUILayout.EndHorizontal();
}