Example #1
0
		bool DrawFiltersAsDropDown(AssetList assetList, float width)
		{
			var changed = false;
			GUILayout.BeginHorizontal();
			GUILayout.Space(3);
			GUILayout.Label("Filter: ", BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);
			if (assetList != null && assetList.Labels != null && assetList.Labels.Length > 0)
			{
				var newSelectedFilterIdx = EditorGUILayout.Popup(_selectedFilterIdx, assetList.Labels,
					BuildReportTool.Window.Settings.FILE_FILTER_POPUP_STYLE_NAME);

				if (newSelectedFilterIdx != _selectedFilterIdx)
				{
					_selectedFilterIdx = newSelectedFilterIdx;
					assetList.SortIfNeeded(this);
					changed = true;
				}
			}

			GUILayout.EndHorizontal();

			return changed;
		}
Example #2
0
		bool DrawFiltersAsButtons(AssetList assetList, float width)
		{
			var changed = false;
			GUILayout.BeginHorizontal();

			float overallWidth = 0;


			var styleToUse = GetStyleToUse(assetList.All.Length, _selectedFilterIdx, 0);
			var label = "All (" + assetList.All.Length.ToString() + ")";

			var widthToAdd = GUI.skin.GetStyle(styleToUse).CalcSize(new GUIContent(label)).x;

			overallWidth += widthToAdd;

			if (GUILayout.Button(label, styleToUse))
			{
				_selectedFilterIdx = 0;
				assetList.SortIfNeeded(this);
				changed = true;
			}

			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.ToString() + ")";

					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;
						assetList.SortIfNeeded(this);
						changed = true;
					}
				}

				styleToUse = GetStyleToUse(assetList.PerCategory[assetList.PerCategory.Length - 1].Length,
					_selectedFilterIdx, assetList.PerCategory.Length);

				label = string.Format("Unknown ({0})",
					assetList.PerCategory[assetList.PerCategory.Length - 1].Length.ToString());
				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;
					assetList.SortIfNeeded(this);
					changed = true;
				}
			}

			GUILayout.EndHorizontal();
			return changed;
		}