void DrawTypeRow(Type t) { // icon var iconRect = GUILayoutUtility.GetRect(IconSize, IconSize); var icon = backendIcons[t]; if (icon != null) { GUI.DrawTexture(iconRect, icon, ScaleMode.StretchToFill, true); } // title (if clicked, return the type and close the window) string titleText = BackendTypeUtil.GetTitle(t); if (t == selectedBackendType) { string color = EditorGUIUtility.isProSkin ? "white" : "grey"; titleText = string.Format("<color=\"{0}\">{1}</color>", color, titleText); } var titleContent = new GUIContent(titleText, null, BackendTypeUtil.GetDescription(t)); bool select = GUILayout.Button(titleContent, backendTitleStyle, GUILayout.Width(TitleWidth)); if (select) { OnSelectBackend(t); Close(); } // version string version = BackendTypeUtil.GetVersion(t); if (string.IsNullOrEmpty(version)) { version = string.Empty; } GUILayout.Label(version, GUILayout.Width(VersionWidth)); // doc URL (if clicked: open) string docURL = BackendTypeUtil.GetDocumentationURL(t); GUI.enabled = !string.IsNullOrEmpty(docURL); var docContent = new GUIContent(helpIcon, "Open documentation website"); bool openDoc = GUILayout.Button(docContent, GUIStyle.none, GUILayout.ExpandWidth(false)); if (openDoc) { Application.OpenURL(docURL); } GUI.enabled = true; GUILayout.FlexibleSpace(); }
internal void DrawToolbar() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); // target history navigation targetHistory.OnGUI(LoadHistoryState); // clear GUI.enabled = targetObjects != null; if (GUILayout.Button(clearButtonContent, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { Exec(() => SetTargetObjects(null)); } GUI.enabled = true; // re-create the workspace from targets GUI.enabled = targetObjects != null && targetObjects.Any(); if (GUILayout.Button(rebuildButtonContent, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { InitWorkspace(); } GUI.enabled = true; GUILayout.FlexibleSpace(); // backend selector string backendSelectText = (selectedBackendType != null) ? BackendTypeUtil.GetTitle(selectedBackendType) : "Select graph type"; var backendSelectContent = new GUIContent(backendSelectText, null, "Select graph type"); var backendSelectButtonRect = GUILayoutUtility.GetRect(backendSelectContent, EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)); if (GUI.Button(backendSelectButtonRect, backendSelectContent, EditorStyles.toolbarDropDown)) { var window = EditorWindow.CreateInstance <BackendSelectWindow>(); window.backendTypes = validBackendTypes.ToArray(); window.selectedBackendType = selectedBackendType; window.OnSelectBackend = (newSelection) => { // don't save constructed types (because we can't deserialize them yet) if (!newSelection.GetGenericArguments().Any()) { GUIUtil.SetPrefsBackendType(PrefsKeyDefaultBackend, newSelection); } SetBackend(newSelection); }; var size = new Vector2(340, 150); window.minSize = window.maxSize = size; window.ShowAsDropDown(GUIUtil.GUIToScreenRect(backendSelectButtonRect), size); } GUILayout.FlexibleSpace(); // workspace toolbar if (workspace != null) { workspace.OnToolbarGUI(); } GUILayout.FlexibleSpace(); // setttings menu if (GUILayout.Button(new GUIContent(SkinManager.GetSkin().settingsIcon, "Settings"), EditorStyles.toolbarButton, GUILayout.Width(25))) { SettingsMenu.Create(); } EditorGUILayout.EndHorizontal(); }