Пример #1
0
        private void InitTabVisuals(int tabIndex, GitSettingsTab tabData, VisualElement tabVisualElement, ToolbarButton toolbarButton)
        {
            tabVisualElement.style.display  = tabIndex == 0 ? DisplayStyle.Flex : DisplayStyle.None;
            tabVisualElement.style.position = Position.Absolute;
            tabVisualElement.style.top      = 0;
            tabVisualElement.style.right    = 0;
            tabVisualElement.style.left     = 0;
            tabVisualElement.style.bottom   = 0;
            settingsTabsElement.Add(tabVisualElement);

            toolbarButton.text     = tabData.Name.text;
            toolbarButton.userData = tabIndex;
            toolbarButton.SetEnabled(tabIndex != 0);

            toolbarButton.clickable.clicked += () =>
            {
                if (this.tab != tabIndex)
                {
                    lastTabIndex = this.tab;
                    toolbarButtons[this.tab].SetEnabled(true);
                    this.tab = tabIndex;
                    toolbarButtons[tabIndex].SetEnabled(false);
                    animationTween = gitAnimation.StartAnimation(AnimationDuration, this,
                                                                 GitSettingsJson.AnimationTypeEnum.Settings);
                }
            };
        }
Пример #2
0
 public void Init(string localPath)
 {
     InitStyles();
     this.localPath   = localPath;
     synataxHighlight = localPath.EndsWith(".cs");
     BuildChangeSections(null);
     LoadAsset(localPath);
     ScrollToFirstChange();
     animationTween = null;
 }
Пример #3
0
 public void Init(string localPath, Commit oldCommit, Commit newCommit)
 {
     InitStyles();
     this.localPath   = localPath;
     synataxHighlight = localPath.EndsWith(".cs");
     commitSha        = oldCommit.Sha;
     BuildChangeSections(oldCommit, newCommit);
     LoadAsset(localPath);
     ScrollToFirstChange();
     animationTween = null;
 }
Пример #4
0
 private void Construct(InjectionHelper parentInjectionHelper, GitAnimation gitAnimation)
 {
     this.gitAnimation = gitAnimation;
     injectionHelper.SetParent(parentInjectionHelper);
     injectionHelper.Bind <GitSettingsTab>().To <GitGeneralSettingsTab>();
     injectionHelper.Bind <GitSettingsTab>().To <GitExternalsSettingsTab>();
     injectionHelper.Bind <GitSettingsTab>().To <GitRemotesSettingsTab>();
     injectionHelper.Bind <GitSettingsTab>().To <GitBranchesSettingsTab>();
     injectionHelper.Bind <GitSettingsTab>().To <GitLFSSettingsTab>();
     injectionHelper.Bind <GitSettingsTab>().To <GitSecuritySettingsTab>();
     animationTween = GitAnimation.Empty;
 }
Пример #5
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(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;
        }