Exemple #1
0
        private void OnTreeGUI(Rect rect)
        {
            if (treeChanges != null)
            {
                treeChanges.FolderStyle                = Styles.Foldout;
                treeChanges.TreeNodeStyle              = Styles.TreeNode;
                treeChanges.ActiveTreeNodeStyle        = Styles.ActiveTreeNode;
                treeChanges.FocusedTreeNodeStyle       = Styles.FocusedTreeNode;
                treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;

                var treeRenderRect = treeChanges.Render(rect, treeScroll,
                                                        node => { },
                                                        node => { },
                                                        node => {
                    var menu = CreateContextMenu(node);
                    menu.ShowAsContext();
                });

                if (treeChanges.RequiresRepaint)
                {
                    Redraw();
                }

                GUILayout.Space(treeRenderRect.y - rect.y);
            }
        }
Exemple #2
0
        private void OnTreeGUI(Rect rect)
        {
            var initialRect = rect;

            if (treeChanges != null)
            {
                treeChanges.FolderStyle                = Styles.Foldout;
                treeChanges.TreeNodeStyle              = Styles.TreeNode;
                treeChanges.ActiveTreeNodeStyle        = Styles.ActiveTreeNode;
                treeChanges.FocusedTreeNodeStyle       = Styles.FocusedTreeNode;
                treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;

                rect = treeChanges.Render(initialRect, rect, scroll,
                                          node => { },
                                          node => {
                },
                                          node => {
                });

                if (treeChanges.RequiresRepaint)
                {
                    Redraw();
                }
            }

            GUILayout.Space(rect.y - initialRect.y);
        }
Exemple #3
0
        public override void OnGUI()
        {
            // History toolbar
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                GUILayout.FlexibleSpace();

                if (hasRemote)
                {
                    EditorGUI.BeginDisabledGroup(currentRemoteName == null);
                    {
                        // Fetch button
                        var fetchClicked = GUILayout.Button(FetchButtonText, Styles.HistoryToolbarButtonStyle);
                        if (fetchClicked)
                        {
                            Fetch();
                        }

                        // Pull button
                        var pullButtonText = statusBehind > 0 ? String.Format(PullButtonCount, statusBehind) : PullButton;
                        var pullClicked    = GUILayout.Button(pullButtonText, Styles.HistoryToolbarButtonStyle);

                        if (pullClicked &&
                            EditorUtility.DisplayDialog(PullConfirmTitle,
                                                        String.Format(PullConfirmDescription, currentRemoteName),
                                                        PullConfirmYes,
                                                        PullConfirmCancel)
                            )
                        {
                            Pull();
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    // Push button
                    EditorGUI.BeginDisabledGroup(currentRemoteName == null || statusBehind != 0);
                    {
                        var pushButtonText = statusAhead > 0 ? String.Format(PushButtonCount, statusAhead) : PushButton;
                        var pushClicked    = GUILayout.Button(pushButtonText, Styles.HistoryToolbarButtonStyle);

                        if (pushClicked &&
                            EditorUtility.DisplayDialog(PushConfirmTitle,
                                                        String.Format(PushConfirmDescription, currentRemoteName),
                                                        PushConfirmYes,
                                                        PushConfirmCancel)
                            )
                        {
                            Push();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                else
                {
                    // Publishing a repo
                    var publishedClicked = GUILayout.Button(PublishButton, Styles.HistoryToolbarButtonStyle);
                    if (publishedClicked)
                    {
                        PopupWindow.OpenWindow(PopupWindow.PopupViewType.PublishView);
                    }
                }
            }
            GUILayout.EndHorizontal();

            var rect = GUILayoutUtility.GetLastRect();

            if (historyControl != null)
            {
                var historyControlRect = new Rect(0f, 0f, Position.width, Position.height - rect.height);

                var requiresRepaint = historyControl.Render(historyControlRect,
                                                            entry => {
                    selectedEntry = entry;
                    BuildTree();
                },
                                                            entry => { },
                                                            entry => { });

                if (requiresRepaint)
                {
                    Redraw();
                }
            }

            if (!selectedEntry.Equals(GitLogEntry.Default))
            {
                // Top bar for scrolling to selection or clearing it
                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                {
                    if (GUILayout.Button(CommitDetailsTitle, Styles.HistoryToolbarButtonStyle))
                    {
                        historyControl.ScrollTo(historyControl.SelectedIndex);
                    }
                    if (GUILayout.Button(ClearSelectionButton, Styles.HistoryToolbarButtonStyle, GUILayout.ExpandWidth(false)))
                    {
                        selectedEntry = GitLogEntry.Default;
                        historyControl.SelectedIndex = -1;
                    }
                }
                GUILayout.EndHorizontal();

                // Log entry details - including changeset tree (if any changes are found)
                detailsScroll = GUILayout.BeginScrollView(detailsScroll, GUILayout.Height(250));
                {
                    HistoryDetailsEntry(selectedEntry);

                    GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
                    GUILayout.Label("Files changed", EditorStyles.boldLabel);
                    GUILayout.Space(-5);

                    rect = GUILayoutUtility.GetLastRect();
                    GUILayout.BeginHorizontal(Styles.HistoryFileTreeBoxStyle);
                    GUILayout.BeginVertical();
                    {
                        var borderLeft      = Styles.Label.margin.left;
                        var treeControlRect = new Rect(rect.x + borderLeft, rect.y, Position.width - borderLeft * 2, Position.height - rect.height + Styles.CommitAreaPadding);
                        var treeRect        = Rect.zero;
                        if (treeChanges != null)
                        {
                            treeChanges.FolderStyle                = Styles.Foldout;
                            treeChanges.TreeNodeStyle              = Styles.TreeNode;
                            treeChanges.ActiveTreeNodeStyle        = Styles.ActiveTreeNode;
                            treeChanges.FocusedTreeNodeStyle       = Styles.FocusedTreeNode;
                            treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;

                            treeRect = treeChanges.Render(treeControlRect, detailsScroll,
                                                          node => { },
                                                          node => {
                            },
                                                          node => {
                            });

                            if (treeChanges.RequiresRepaint)
                            {
                                Redraw();
                            }
                        }

                        GUILayout.Space(treeRect.y - treeControlRect.y);
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();

                    GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
                }
                GUILayout.EndScrollView();
            }
        }
        public override void OnGUI()
        {
            var rect = GUILayoutUtility.GetLastRect();

            if (historyControl != null)
            {
                var historyControlRect = new Rect(0f, 0f, Position.width, Position.height - rect.height);

                var requiresRepaint = historyControl.Render(historyControlRect,
                                                            entry => {
                    selectedEntry = entry;
                    BuildTree();
                },
                                                            entry => { }, entry => {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Revert"), false, RevertCommit);
                    menu.ShowAsContext();
                });

                if (requiresRepaint)
                {
                    Redraw();
                }
            }

            DoProgressGUI();

            if (!selectedEntry.Equals(GitLogEntry.Default))
            {
                // Top bar for scrolling to selection or clearing it
                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                {
                    if (GUILayout.Button(CommitDetailsTitle, Styles.ToolbarButtonStyle))
                    {
                        historyControl.ScrollTo(historyControl.SelectedIndex);
                    }
                    if (GUILayout.Button(ClearSelectionButton, Styles.ToolbarButtonStyle, GUILayout.ExpandWidth(false)))
                    {
                        selectedEntry = GitLogEntry.Default;
                        historyControl.SelectedIndex = -1;
                    }
                }
                GUILayout.EndHorizontal();

                // Log entry details - including changeset tree (if any changes are found)
                detailsScroll = GUILayout.BeginScrollView(detailsScroll, GUILayout.Height(250));
                {
                    HistoryDetailsEntry(selectedEntry);

                    GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
                    GUILayout.Label("Files changed", EditorStyles.boldLabel);
                    GUILayout.Space(-5);

                    rect = GUILayoutUtility.GetLastRect();
                    GUILayout.BeginHorizontal(Styles.HistoryFileTreeBoxStyle);
                    GUILayout.BeginVertical();
                    {
                        var borderLeft      = Styles.Label.margin.left;
                        var treeControlRect = new Rect(rect.x + borderLeft, rect.y, Position.width - borderLeft * 2, Position.height - rect.height + Styles.CommitAreaPadding);
                        var treeRect        = new Rect(0f, 0f, 0f, 0f);
                        if (treeChanges != null)
                        {
                            treeChanges.FolderStyle                = Styles.Foldout;
                            treeChanges.TreeNodeStyle              = Styles.TreeNode;
                            treeChanges.ActiveTreeNodeStyle        = Styles.ActiveTreeNode;
                            treeChanges.FocusedTreeNodeStyle       = Styles.FocusedTreeNode;
                            treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;

                            treeRect = treeChanges.Render(treeControlRect, detailsScroll,
                                                          node => { },
                                                          node => {
                            },
                                                          node => {
                            });

                            if (treeChanges.RequiresRepaint)
                            {
                                Redraw();
                            }
                        }

                        GUILayout.Space(treeRect.y - treeControlRect.y);
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();

                    GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
                }
                GUILayout.EndScrollView();
            }
        }