private void DrawToolbar() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); Rect goToLineRect = GUILayoutUtility.GetRect(GitGUI.GetTempContent("Go To Line"), EditorStyles.toolbarButton); if (GUI.Button(goToLineRect, GitGUI.GetTempContent("Go To Line"), EditorStyles.toolbarButton)) { PopupWindow.Show(goToLineRect, new GoToLinePopup(GoToLine)); } if (GUILayout.Button(GitGUI.GetTempContent("Previous Change"), EditorStyles.toolbarButton)) { GoToPreviousChange(); } if (GUILayout.Button(GitGUI.GetTempContent("Next Change"), EditorStyles.toolbarButton)) { GoToNextChange(); } GUILayout.FlexibleSpace(); GUILayout.Label(GitGUI.GetTempContent(localPath)); if (GitGUI.LinkButtonLayout(gitOverlay.icons.donateSmall, GitGUI.Styles.IconButton)) { GitLinks.GoTo(GitLinks.Donate); } if (GitGUI.LinkButtonLayout(GitGUI.Contents.Help, GitGUI.Styles.IconButton)) { GitLinks.GoTo(GitLinks.DiffInspectorHelp); } EditorGUILayout.EndHorizontal(); }
private void OnGUI() { if (gitManager == null || !gitManager.IsValidRepo) { GitHistoryWindow.InvalidRepoGUI(gitManager); return; } Event current = Event.current; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); if (tabs != null) { for (int i = 0; i < tabs.Length; i++) { bool value = GUILayout.Toggle(tab == i, tabs[i].Name, EditorStyles.toolbarButton); if (value) { tab = i; } } } if (EditorGUI.EndChangeCheck()) { LoseFocus(); if (currentTab != null) { currentTab.OnFocus(); } } GUILayout.FlexibleSpace(); if (GitGUI.LinkButtonLayout(GitOverlay.icons.donateSmall, GitGUI.Styles.IconButton)) { GitLinks.GoTo(GitLinks.Donate); } if (GitGUI.LinkButtonLayout(GitGUI.Contents.Help, GitGUI.Styles.IconButton)) { GitLinks.GoTo(GitLinks.SettingsWindowHelp); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (gitManager.Repository != null) { Rect localRect = new Rect(0, 0, position.width, position.height - EditorGUIUtility.singleLineHeight * 1.6f); if (currentTab != null) { currentTab.OnGUI(localRect, current); } } EditorGUILayout.Space(); if (current.type == EventType.MouseDown) { LoseFocus(); } }
internal void DoCommit(RepositoryInformation repoInfo, GitDiffWindow window, ref Vector2 commitScroll) { var settings = window.GitDiffSettings; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (repoInfo.CurrentOperation == CurrentOperation.Merge) { GUILayout.Label(GitGUI.GetTempContent("Merge"), styles.mergeIndicator); } window.CommitMaximized = GUILayout.Toggle(window.CommitMaximized, GitGUI.GetTempContent(gitSettings.ReadFromFile ? "File Commit Message: (Read Only)" : "Commit Message: "), styles.commitMessageFoldoud, GUILayout.Width(gitSettings.ReadFromFile ? 210 : 116)); EditorGUI.BeginDisabledGroup(true); if (!window.CommitMaximized) { if (!gitSettings.ReadFromFile) { EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("Commit Message Field"); settings.commitMessage = EditorGUILayout.TextArea(settings.commitMessage, GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (EditorGUI.EndChangeCheck()) { window.SaveCommitMessage(); } } else { GUILayout.Label(GitGUI.GetTempContent(settings.commitMessageFromFile), GUI.skin.textArea, GUILayout.Height(EditorGUIUtility.singleLineHeight)); } } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); if (window.CommitMaximized) { commitScroll = EditorGUILayout.BeginScrollView(commitScroll, GUILayout.Height(window.CalculateCommitTextHeight())); if (!gitSettings.ReadFromFile) { EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("Commit Message Field"); string newCommitMessage = EditorGUILayout.TextArea(settings.commitMessage, GUILayout.ExpandHeight(true)); if (EditorGUI.EndChangeCheck()) { if ((Event.current.character == ' ' || Event.current.character == '\0') && !(commitMessageLastChar == ' ' || commitMessageLastChar == '\0')) { if (Undo.GetCurrentGroupName() == GitDiffWindow.CommitMessageUndoGroup) { Undo.IncrementCurrentGroup(); } } commitMessageLastChar = Event.current.character; Undo.RecordObject(window, GitDiffWindow.CommitMessageUndoGroup); settings.commitMessage = newCommitMessage; window.SaveCommitMessage(); } } else { GUILayout.Label(GitGUI.GetTempContent(settings.commitMessageFromFile), GUI.skin.textArea, GUILayout.ExpandHeight(true)); } EditorGUILayout.EndScrollView(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(GitGUI.GetTempContent("Commit"), styles.commitButton)) { GenericMenu commitMenu = new GenericMenu(); BuildCommitMenu(commitMenu, window); commitMenu.ShowAsContext(); } GitGUI.StartEnable(!gitSettings.ExternalsType.IsFlagSet(GitSettingsJson.ExternalsTypeEnum.Commit)); settings.emptyCommit = GUILayout.Toggle(settings.emptyCommit, GitGUI.GetTempContent("Empty Commit", "Commit the message only without changes")); EditorGUI.BeginChangeCheck(); settings.amendCommit = GUILayout.Toggle(settings.amendCommit, GitGUI.GetTempContent("Amend Commit", "Amend previous commit.")); if (EditorGUI.EndChangeCheck()) { if (settings.amendCommit) { window.AmmendCommit(); } } settings.prettify = GUILayout.Toggle(settings.prettify, GitGUI.GetTempContent("Prettify", "Prettify the commit message")); GitGUI.EndEnable(); GUILayout.FlexibleSpace(); if (GitGUI.LinkButtonLayout(gitOverlay.icons.donateSmall, GitGUI.Styles.IconButton)) { GitLinks.GoTo(GitLinks.Donate); } if (GitGUI.LinkButtonLayout(GitGUI.Contents.Help, GitGUI.Styles.IconButton)) { GitLinks.GoTo(GitLinks.DiffWindowHelp); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }