No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DrawGuiModeSwitcher.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEditor;
  2. using UnityEditor.IMGUI.Controls;
  3. using UnityEngine;
  4. using Unity.PlasticSCM.Editor.Views.PendingChanges;
  5. namespace Unity.PlasticSCM.Editor
  6. {
  7. internal static class DrawGuiModeSwitcher
  8. {
  9. internal static void ForMode(
  10. bool isGluonMode,
  11. WorkspaceWindow workspaceWindow,
  12. TreeView changesTreeView,
  13. EditorWindow editorWindow)
  14. {
  15. GUI.enabled = !workspaceWindow.IsOperationInProgress();
  16. EditorGUI.BeginChangeCheck();
  17. GuiMode currentMode = isGluonMode ?
  18. GuiMode.GluonMode : GuiMode.DeveloperMode;
  19. GuiMode selectedMode = (GuiMode)EditorGUILayout.EnumPopup(
  20. currentMode,
  21. EditorStyles.toolbarDropDown,
  22. GUILayout.Width(100));
  23. if (EditorGUI.EndChangeCheck())
  24. {
  25. SwitchGuiModeIfUserWants(
  26. workspaceWindow, currentMode, selectedMode,
  27. changesTreeView, editorWindow);
  28. }
  29. GUI.enabled = true;
  30. }
  31. static void SwitchGuiModeIfUserWants(
  32. WorkspaceWindow workspaceWindow,
  33. GuiMode currentMode, GuiMode selectedMode,
  34. TreeView changesTreeView,
  35. EditorWindow editorWindow)
  36. {
  37. if (currentMode == selectedMode)
  38. return;
  39. bool userConfirmed = SwitchModeConfirmationDialog.SwitchMode(
  40. currentMode == GuiMode.GluonMode, editorWindow);
  41. if (!userConfirmed)
  42. return;
  43. bool isGluonMode = selectedMode == GuiMode.GluonMode;
  44. workspaceWindow.UpdateWorkspaceForMode(
  45. isGluonMode, workspaceWindow);
  46. PendingChangesTreeHeaderState.SetMode(
  47. changesTreeView.multiColumnHeader.state,
  48. isGluonMode);
  49. }
  50. enum GuiMode
  51. {
  52. DeveloperMode,
  53. GluonMode
  54. }
  55. }
  56. }