Ejemplo n.º 1
0
        private void OnGUI()
        {
            if (!GitManager.IsValidRepo)
            {
                GitHistoryWindow.InvalidRepoGUI();
                return;
            }

            Event current = Event.current;

            EditorGUILayout.BeginHorizontal("Toolbar");
            EditorGUI.BeginChangeCheck();
            bool value = GUILayout.Toggle(tab == SettingTabEnum.General, GitGUI.GetTempContent("General"), "toolbarbutton");

            if (value)
            {
                tab = SettingTabEnum.General;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Externals, GitGUI.GetTempContent("Externals"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Externals;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Remotes, GitGUI.GetTempContent("Remotes"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Remotes;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Branches, GitGUI.GetTempContent("Branches"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Branches;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.LFS, GitGUI.GetTempContent("LFS"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.LFS;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Security, GitGUI.GetTempContent("Security"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Security;
            }
            if (EditorGUI.EndChangeCheck())
            {
                LoseFocus();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            if (GitManager.Repository != null)
            {
                switch (tab)
                {
                case SettingTabEnum.Remotes:
                    DoRemotes(current);
                    break;

                case SettingTabEnum.Externals:
                    DoExternals(current);
                    break;

                case SettingTabEnum.Branches:
                    DoBranches(current);
                    break;

                case SettingTabEnum.LFS:
                    DoLFS(current);
                    break;

                case SettingTabEnum.Security:
                    DoSecurity(current);
                    break;

                default:
                    DoGeneral(current);
                    break;
                }
            }

            EditorGUILayout.Space();

            if (current.type == EventType.MouseDown)
            {
                LoseFocus();
            }
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            if (!GitManager.IsValidRepo)
            {
                GitHistoryWindow.InvalidRepoGUI();
                return;
            }

            Event current = Event.current;

            EditorGUILayout.BeginHorizontal("Toolbar");
            EditorGUI.BeginChangeCheck();
            bool value = GUILayout.Toggle(tab == SettingTabEnum.General, GitGUI.GetTempContent("General"), "toolbarbutton");

            if (value)
            {
                tab = SettingTabEnum.General;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Externals, GitGUI.GetTempContent("Externals", "External Programs Helpers"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Externals;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Remotes, GitGUI.GetTempContent("Remotes", "Remote Repositories"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Remotes;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Branches, GitGUI.GetTempContent("Branches"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Branches;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.LFS, GitGUI.GetTempContent("LFS", "Git Large File Storage (beta)"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.LFS;
            }
            value = GUILayout.Toggle(tab == SettingTabEnum.Security, GitGUI.GetTempContent("Security"), "toolbarbutton");
            if (value)
            {
                tab = SettingTabEnum.Security;
            }
            if (EditorGUI.EndChangeCheck())
            {
                LoseFocus();
                if (currentTab != null)
                {
                    currentTab.OnFocus();
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.IconContent("_Help"), "IconButton"))
            {
                GoToHelp();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            if (GitManager.Repository != null)
            {
                Rect localRect = new Rect(0, 0, position.width, position.height - EditorGUIUtility.singleLineHeight * 1.6f);
                if (currentTab != null)
                {
                    currentTab.OnGUI(localRect, current);
                }
            }
            EditorGUILayout.Space();

            if (current.type == EventType.MouseDown)
            {
                LoseFocus();
            }
        }