コード例 #1
0
        private void MainGUI()
        {
            RepositoryInformation repoInfo = gitManager.Repository.Info;

            GUILayout.BeginArea(CommitRect);
            gitDiffWindowCommitRenderer.DoCommit(repoInfo, this, ref commitScroll);
            GUILayout.EndArea();

            toolbarRenderer.DoDiffToolbar(DiffToolbarRect, this, ref filter);

            if (diffWindowStatusList == null)
            {
                if (gitSettings.AnimationType.HasFlag(GitSettingsJson.AnimationTypeEnum.Loading))
                {
                    Repaint();
                }
                GitGUI.DrawLoading(new Rect(0, 0, position.width, position.height), GitGUI.GetTempContent(GetStatusBuildingState()));
            }
            else
            {
                DoDiffScroll(Event.current);
            }


            editoSerializedObject.ApplyModifiedProperties();

            if (Event.current.type == EventType.MouseDown)
            {
                GUIUtility.keyboardControl = 0;
                GUI.FocusControl(null);
            }
        }
コード例 #2
0
        internal static void InvalidRepoGUI(GitManager gitManager)
        {
            if (gitManager == null)
            {
                Rect initilizingRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                GitGUI.DrawLoading(new Rect(initilizingRect.x, initilizingRect.y, initilizingRect.width, initilizingRect.height), GitGUI.GetTempContent("Initializing..."));
                return;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box(GitGUI.GetTempContent("Not a GIT Repository"), "NotificationBackground");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            //initialization tips
            EditorGUILayout.HelpBox("If you have an existing remote repository and want to clone it, you will have to do so outside of the editor.", MessageType.Info);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = gitManager != null;
            if (GUILayout.Button(GitGUI.GetTempContent("Create"), GitGUI.Styles.LargeButton, GUILayout.Height(32), GUILayout.Width(128)))
            {
                if (EditorUtility.DisplayDialog("Initialize Repository", "Are you sure you want to initialize a Repository for your project", "Yes", "Cancel"))
                {
                    if (gitManager != null && !gitManager.IsValidRepo)
                    {
                        gitManager.InitilizeRepositoryAndRecompile();
                    }
                    GUIUtility.ExitGUI();
                    return;
                }
            }
            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
コード例 #3
0
        private void OnGUI()
        {
            InitStyles();

            if (isBinary)
            {
                EditorGUILayout.HelpBox("File Is Binary", MessageType.Warning);
                return;
            }

            if (changeSections == null)
            {
                if (GitManager.Repository != null)
                {
                    var commit = string.IsNullOrEmpty(commitSha) ? null : GitManager.Repository.Lookup <Commit>(commitSha);
                    BuildChangeSections(commit);
                }
                GitGUI.DrawLoading(position, new GUIContent("Loading Changes"));
                Repaint();
                return;
            }

            if (changeSections.Count <= 0)
            {
                EditorGUILayout.HelpBox("No Difference", MessageType.Info);
                return;
            }

            float toolbarHeight = ((GUIStyle)"Toolbar").fixedHeight;
            float difHeight     = position.height - toolbarHeight;

            EditorGUILayout.BeginHorizontal("Toolbar");
            Rect goToLineRect = GUILayoutUtility.GetRect(new GUIContent("Go To Line"), "toolbarbutton");

            if (GUI.Button(goToLineRect, new GUIContent("Go To Line"), "toolbarbutton"))
            {
                PopupWindow.Show(goToLineRect, new GoToLinePopup(GoToLine));
            }
            if (GUILayout.Button(new GUIContent("Previous Change"), "toolbarbutton"))
            {
                GoToPreviousChange();
            }
            if (GUILayout.Button(new GUIContent("Next Change"), "toolbarbutton"))
            {
                GoToNextChange();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            Rect resizeRect          = new Rect(position.width * otherFileWindowWidth - 3, toolbarHeight, 6, difHeight);
            Rect indexFileRect       = new Rect(position.width * otherFileWindowWidth + (resizeRect.width / 2), toolbarHeight, position.width * (1 - otherFileWindowWidth) - (resizeRect.width / 2), difHeight);
            Rect otherFileScrollRect = new Rect(0, toolbarHeight, position.width * otherFileWindowWidth - (resizeRect.width / 2), difHeight);

            if (Event.current.type == EventType.MouseDown && otherFileScrollRect.Contains(Event.current.mousePosition))
            {
                selectedFile = FileType.OtherFile;
                Repaint();
            }
            else if (Event.current.type == EventType.MouseDown && indexFileRect.Contains(Event.current.mousePosition))
            {
                selectedFile = FileType.IndexFile;
                Repaint();
            }

            GUI.Box(resizeRect, GUIContent.none);

            if (Event.current.type == EventType.MouseUp)
            {
                isResizingFileWindow = false;
            }
            if (Event.current.type == EventType.MouseDown && resizeRect.Contains(Event.current.mousePosition))
            {
                isResizingFileWindow = true;
            }

            if (isResizingFileWindow)
            {
                otherFileWindowWidth = Mathf.Clamp(Event.current.mousePosition.x / position.width, 0.1f, 0.9f);
                EditorGUIUtility.AddCursorRect(position, MouseCursor.ResizeHorizontal);
                Repaint();
            }
            else
            {
                EditorGUIUtility.AddCursorRect(resizeRect, MouseCursor.ResizeHorizontal);
            }

            GUI.Box(otherFileScrollRect, GUIContent.none, "AS TextArea");
            GUI.Box(indexFileRect, GUIContent.none, "AS TextArea");

            DrawBlobs(false, otherFileScrollRect, indexFileRect);
            DrawBlobs(true, indexFileRect, otherFileScrollRect);

            if (selectedFile == FileType.IndexFile)
            {
                GUI.Box(indexFileRect, GUIContent.none, "TL SelectionButton PreDropGlow");
            }
            else
            {
                GUI.Box(otherFileScrollRect, GUIContent.none, "TL SelectionButton PreDropGlow");
            }
        }
コード例 #4
0
        private void DoHistoryScrollRect(Rect rect, RepositoryInformation info)
        {
            if (loadingCommits != null && !loadingCommits.IsDone)
            {
                Repaint();
                GitGUI.DrawLoading(rect, GitGUI.GetTempContent("Loading Commit History"));
                return;
            }

            Event current = Event.current;

            GUI.Box(new Rect(14, rect.y + 2, 2, rect.height), GUIContent.none, styles.historyLine);

            //behind,ahead and merge checking

            bool displayWarnningBox = DoWarningBoxValidate(info, selectedBranch);

            //commit layout
            if (current.type == EventType.Layout)
            {
                GitProfilerProxy.BeginSample("Git History Window Scroll Rect GUI Layout", this);
                Rect lastCommitRect = new Rect(32, commitSpacing, Mathf.Max(rect.width - 24, 512) - 32, 0);

                if (displayWarnningBox)
                {
                    warningBoxRect    = new Rect(lastCommitRect.x, lastCommitRect.y, lastCommitRect.width, helpBoxHeight);
                    lastCommitRect.y += helpBoxHeight + commitSpacing;
                }

                for (int i = 0; i < cachedCommits.Length; i++)
                {
                    lastCommitRect = LayoutCommit(lastCommitRect, cachedCommits[i]);
                    if (i < commitRects.Length)
                    {
                        commitRects[i] = lastCommitRect;
                    }
                }

                historyScrollContentsRect         = new Rect(0, 0, lastCommitRect.width + 32, lastCommitRect.y + lastCommitRect.height + commitSpacing * 2);
                historyScrollContentsRect.height += EditorGUIUtility.singleLineHeight * 3;
                GitProfilerProxy.EndSample();
            }
            else
            {
                GitProfilerProxy.BeginSample("Git History Window Scroll Rect GUI Other", this);
                historyScroll = GUI.BeginScrollView(rect, historyScroll, historyScrollContentsRect);

                if (displayWarnningBox)
                {
                    DoWarningBox(warningBoxRect, info, selectedBranch);
                }

                for (int i = 0; i < cachedCommits.Length; i++)
                {
                    if (i < commitRects.Length)
                    {
                        DoCommit(commitRects[i], rect, cachedCommits[i]);
                    }
                }

                Rect commitsCountRect = new Rect(32, historyScrollContentsRect.height - EditorGUIUtility.singleLineHeight * 4, historyScrollContentsRect.width - 64, EditorGUIUtility.singleLineHeight);

                GUI.Label(commitsCountRect, GitGUI.GetTempContent(cachedCommits.Length + " / " + maxCommitsCount), EditorStyles.centeredGreyMiniLabel);

                Rect resetRect    = new Rect(historyScrollContentsRect.width / 2, historyScrollContentsRect.height - EditorGUIUtility.singleLineHeight * 3, 64, EditorGUIUtility.singleLineHeight);
                Rect loadMoreRect = new Rect(historyScrollContentsRect.width / 2 - 64, historyScrollContentsRect.height - EditorGUIUtility.singleLineHeight * 3, 64, EditorGUIUtility.singleLineHeight);
                if (GUI.Button(loadMoreRect, GitGUI.IconContent("ol plus", "More", "Show more commits."), styles.loadMoreCommitsBtn))
                {
                    maxCommitsCount += CommitsPerExpand;
                    StartUpdateChaches(cachedStatus);
                }
                GitGUI.StartEnable(maxCommitsCount != MaxFirstCommitCount);
                if (GUI.Button(resetRect, GitGUI.GetTempContent("Reset", "Reset the number of commits show."), styles.resetCommitsBtn))
                {
                    if (MaxFirstCommitCount < maxCommitsCount)
                    {
                        maxCommitsCount = MaxFirstCommitCount;
                        Array.Resize(ref cachedCommits, maxCommitsCount);
                    }
                    else
                    {
                        maxCommitsCount = MaxFirstCommitCount;
                        StartUpdateChaches(cachedStatus);
                    }
                }
                GitGUI.EndEnable();
                GUI.EndScrollView();
                GitProfilerProxy.EndSample();
            }
        }
コード例 #5
0
ファイル: GitDiffInspector.cs プロジェクト: Amitkapadi/UniGit
        private void OnGUI()
        {
            InitStyles();

            if (isBinary)
            {
                EditorGUILayout.HelpBox("File Is Binary", MessageType.Warning);
                return;
            }

            if (changeSections == null)
            {
                if (gitManager.Repository != null)
                {
                    var commit = string.IsNullOrEmpty(commitSha) ? null : gitManager.Repository.Lookup <Commit>(commitSha);
                    BuildChangeSections(commit);
                }
                GitGUI.DrawLoading(new Rect(0, 0, position.width, position.height), GitGUI.GetTempContent("Loading Changes"));
                Repaint();
                return;
            }

            if (changeSections.Count <= 0)
            {
                EditorGUILayout.HelpBox("No Difference", MessageType.Info);
                return;
            }

            if (animationTween == null)
            {
                animationTween = gitAnimation.StartManualAnimation(AnimationDuration, this, out animationTime, GitSettingsJson.AnimationTypeEnum.DiffInspector);
            }

            float toolbarHeight = EditorStyles.toolbar.fixedHeight;
            float difHeight     = position.height - toolbarHeight;

            DrawToolbar();

            Rect resizeRect          = new Rect(position.width * otherFileWindowWidth - 3, toolbarHeight, 6, difHeight);
            Rect indexFileRect       = new Rect(position.width * otherFileWindowWidth + (resizeRect.width / 2), toolbarHeight, position.width * (1 - otherFileWindowWidth) - (resizeRect.width / 2), difHeight);
            Rect otherFileScrollRect = new Rect(0, toolbarHeight, position.width * otherFileWindowWidth - (resizeRect.width / 2), difHeight);

            gitAnimation.Update(animationTween, ref animationTime);
            float animTime = GitAnimation.ApplyEasing(animationTween.Percent);

            if (Event.current.type == EventType.MouseDown && otherFileScrollRect.Contains(Event.current.mousePosition))
            {
                selectedFile = FileType.OtherFile;
                Repaint();
            }
            else if (Event.current.type == EventType.MouseDown && indexFileRect.Contains(Event.current.mousePosition))
            {
                selectedFile = FileType.IndexFile;
                Repaint();
            }

            GUI.Box(resizeRect, GUIContent.none);

            if (Event.current.type == EventType.MouseUp)
            {
                isResizingFileWindow = false;
            }
            if (Event.current.type == EventType.MouseDown && resizeRect.Contains(Event.current.mousePosition))
            {
                isResizingFileWindow = true;
            }

            if (isResizingFileWindow)
            {
                otherFileWindowWidth = Mathf.Clamp(Event.current.mousePosition.x / position.width, 0.1f, 0.9f);
                EditorGUIUtility.AddCursorRect(position, MouseCursor.ResizeHorizontal);
                Repaint();
            }
            else
            {
                EditorGUIUtility.AddCursorRect(resizeRect, MouseCursor.ResizeHorizontal);
            }

            GUI.Box(otherFileScrollRect, GUIContent.none, EditorStyles.textArea);
            GUI.Box(indexFileRect, GUIContent.none, EditorStyles.textArea);

            DrawBlobs(false, otherFileScrollRect, indexFileRect);
            DrawBlobs(true, indexFileRect, otherFileScrollRect);

            if (selectedFile == FileType.IndexFile)
            {
                GUI.Box(indexFileRect, GUIContent.none, GitGUI.Styles.SelectionBoxGlow);
            }
            else
            {
                GUI.Box(otherFileScrollRect, GUIContent.none, GitGUI.Styles.SelectionBoxGlow);
            }

            GUI.color = new Color(1, 1, 1, Mathf.Lerp(0, 1, animTime));
            GUI.Box(new Rect(0, 0, position.width, position.height - toolbarHeight), GUIContent.none);
            GUI.color = Color.white;
        }