Esempio n. 1
0
        private void OnTreeGUI(Rect rect)
        {
            var treeRenderRect = new Rect(0f, 0f, 0f, 0f);

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

                treeRemotes.FolderStyle                = Styles.Foldout;
                treeRemotes.TreeNodeStyle              = Styles.TreeNode;
                treeRemotes.ActiveTreeNodeStyle        = Styles.ActiveTreeNode;
                treeRemotes.FocusedTreeNodeStyle       = Styles.FocusedTreeNode;
                treeRemotes.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;

                var treeHadFocus = treeLocals.SelectedNode != null;

                treeRenderRect = treeLocals.Render(rect, scroll,
                                                   node => { },
                                                   node => {
                    if (node.IsFolder)
                    {
                        return;
                    }

                    if (node.IsActive)
                    {
                        return;
                    }

                    SwitchBranch(node.Path);
                },
                                                   node => {
                    if (node.IsFolder)
                    {
                        return;
                    }

                    var menu = CreateContextMenuForLocalBranchNode(node);
                    menu.ShowAsContext();
                });

                if (treeHadFocus && treeLocals.SelectedNode == null)
                {
                    treeRemotes.Focus();
                }
                else if (!treeHadFocus && treeLocals.SelectedNode != null)
                {
                    treeRemotes.Blur();
                }

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

                treeHadFocus = treeRemotes.SelectedNode != null;

                treeRenderRect.y += Styles.TreePadding;

                var treeRemoteDisplayRect = new Rect(rect.x, treeRenderRect.y, rect.width, rect.height);
                treeRenderRect = treeRemotes.Render(treeRemoteDisplayRect, scroll,
                                                    node => { },
                                                    node => {
                    if (node.IsFolder)
                    {
                        return;
                    }

                    CheckoutRemoteBranch(node.Path);
                },
                                                    node => {
                    if (node.IsFolder)
                    {
                        return;
                    }

                    var menu = CreateContextMenuForRemoteBranchNode(node);
                    menu.ShowAsContext();
                });

                if (treeHadFocus && treeRemotes.SelectedNode == null)
                {
                    treeLocals.Focus();
                }
                else if (!treeHadFocus && treeRemotes.SelectedNode != null)
                {
                    treeLocals.Blur();
                }

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

            GUILayout.Space(treeRenderRect.y - rect.y);
        }
Esempio n. 2
0
        private void OnTreeGUI(Rect rect)
        {
            UpdateTreeStyles();

            var initialRect  = rect;
            var treeHadFocus = treeLocals.SelectedNode != null;

            rect = treeLocals.Render(initialRect, rect, scroll,
                                     node => { },
                                     node => {
                if (node.IsFolder)
                {
                    return;
                }

                if (node.IsActive)
                {
                    return;
                }

                SwitchBranch(node.Name);
            },
                                     node => {
                if (node.IsFolder)
                {
                    return;
                }

                var menu = CreateContextMenuForLocalBranchNode(node);
                menu.ShowAsContext();
            });

            if (treeHadFocus && treeLocals.SelectedNode == null)
            {
                treeRemotes.Focus();
            }
            else if (!treeHadFocus && treeLocals.SelectedNode != null)
            {
                treeRemotes.Blur();
            }

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

            treeHadFocus = treeRemotes.SelectedNode != null;

            rect.y += Styles.TreePadding;

            rect = treeRemotes.Render(initialRect, rect, scroll,
                                      node => { },
                                      node => {
                if (node.IsFolder)
                {
                    return;
                }

                CheckoutRemoteBranch(node.Name);
            },
                                      node => {
                if (node.IsFolder)
                {
                    return;
                }

                var menu = CreateContextMenuForRemoteBranchNode(node);
                menu.ShowAsContext();
            });

            if (treeHadFocus && treeRemotes.SelectedNode == null)
            {
                treeLocals.Focus();
            }
            else if (!treeHadFocus && treeRemotes.SelectedNode != null)
            {
                treeLocals.Blur();
            }

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

            //Debug.LogFormat("reserving: {0} {1} {2}", rect.y - initialRect.y, rect.y, initialRect.y);
            GUILayout.Space(rect.y - initialRect.y);
        }