コード例 #1
0
ファイル: HistoryView.cs プロジェクト: Cariaga/Git-for-Unity
        protected void BuildHistoryControl(int loadAhead, List <GitLogEntry> gitLogEntries)
        {
            if (HistoryControl == null)
            {
                HistoryControl = new HistoryControl();
            }

            HistoryControl.Load(loadAhead, gitLogEntries);
            if (!SelectedEntry.Equals(GitLogEntry.Default) &&
                SelectedEntry.CommitID != HistoryControl.SelectedGitLogEntry.CommitID)
            {
                SelectedEntry = GitLogEntry.Default;
            }
        }
コード例 #2
0
ファイル: HistoryView.cs プロジェクト: Cariaga/Git-for-Unity
        protected void DoHistoryGui(Rect rect, Action <GitLogEntry> historyControlRightClick = null,
                                    Action <ChangesTreeNode> changesTreeRightClick           = null)
        {
            if (HistoryControl != null)
            {
                var historyControlRect = new Rect(0f, 0f, Position.width, Position.height - rect.height);

                var requiresRepaint = HistoryControl.Render(historyControlRect,
                                                            singleClick: entry => {
                    SelectedEntry = entry;
                    BuildTreeChanges();
                },
                                                            doubleClick: entry => {
                },
                                                            rightClick: historyControlRightClick);

                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,
                                                          singleClick: node => { },
                                                          doubleClick: node => { },
                                                          rightClick: changesTreeRightClick);

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

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

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