public void Draw(AssetList assetList, float width)
 {
     BuildReportTool.Options.FileFilterDisplay displayType = BuildReportTool.Options.GetOptionFileFilterDisplay();
     switch (displayType)
     {
     case BuildReportTool.Options.FileFilterDisplay.DropDown:
         DrawFiltersAsDropDown(assetList, width);
         break;
     case BuildReportTool.Options.FileFilterDisplay.Buttons:
         DrawFiltersAsButtons(assetList, width);
         break;
     }
 }
 void DrawFiltersAsDropDown(AssetList assetList, float width)
 {
     GUILayout.BeginHorizontal();
     GUILayout.Space(17);
     GUILayout.Label("Filter: ");
     _selectedFilterIdx = EditorGUILayout.Popup(_selectedFilterIdx, assetList.Labels, "Popup", GUILayout.Width(250));
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
 }
        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();
        }
        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();
        }
Exemple #5
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;
		}
        void DrawFiltersAsDropDown(AssetList assetList, float width)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(3);
            GUILayout.Label("Filter: ", BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

            _selectedFilterIdx = EditorGUILayout.Popup(_selectedFilterIdx, assetList.Labels,
                BuildReportTool.Window.Settings.FILE_FILTER_POPUP_STYLE_NAME);
            GUILayout.EndHorizontal();
        }