A game about forced loneliness, made by TACStudios
1using System;
2using UnityEditor.TestTools.TestRunner.GUI.Controls;
3using UnityEngine;
4
5namespace UnityEditor.TestTools.TestRunner.GUI
6{
7 internal static class TestRunnerGUI
8 {
9 private static Styles s_Styles;
10 private static Styles Style => s_Styles ?? (s_Styles = new Styles());
11
12 internal static void TestPlatformSelectionDropDown(ISelectionDropDownContentProvider contentProvider)
13 {
14 var text = Style.TestPlatformButtonString;
15 for (int i = 0; i < contentProvider.Count; i++)
16 {
17 if (contentProvider.IsSelected(i))
18 {
19 text += " " + contentProvider.GetName(i);
20 break;
21 }
22 }
23
24 var content = new GUIContent(text);
25 SelectionDropDown(contentProvider, content, GUILayout.Width(EditorStyles.toolbarDropDown.CalcSize(content).x));
26 }
27
28 internal static void CategorySelectionDropDown(ISelectionDropDownContentProvider contentProvider)
29 {
30 SelectionDropDown(contentProvider, Style.CategoryButtonContent, GUILayout.Width(Style.CategoryButtonWidth));
31 }
32
33 private static void SelectionDropDown(ISelectionDropDownContentProvider listContentProvider, GUIContent buttonContent,
34 params GUILayoutOption[] options)
35 {
36 var rect = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, Styles.DropdownButton, options);
37 if (!EditorGUI.DropdownButton(rect, buttonContent, FocusType.Passive, Styles.DropdownButton))
38 {
39 return;
40 }
41
42 var selectionDropDown = new SelectionDropDown(listContentProvider);
43 PopupWindow.Show(rect, selectionDropDown);
44 }
45
46 private class Styles
47 {
48 public static readonly GUIStyle DropdownButton = EditorStyles.toolbarDropDown;
49 public readonly string TestPlatformButtonString = "Run Location:";
50 public readonly GUIContent CategoryButtonContent = new GUIContent("Category");
51 public readonly float CategoryButtonWidth;
52
53 public Styles()
54 {
55 CategoryButtonWidth = DropdownButton.CalcSize(CategoryButtonContent).x;
56 }
57 }
58 }
59}