public static IView Open(Action <bool> onClose = null) { PublishWindow publishWindow = GetWindow <PublishWindow>(true); if (onClose != null) { publishWindow.OnClose += onClose; } publishWindow.minSize = publishWindow.maxSize = new Vector2(300, 250); publishWindow.Show(); return(publishWindow); }
public void OnEmbeddedGUI() { // History toolbar GUILayout.BeginHorizontal(EditorStyles.toolbar); { // Target indicator / clear button EditorGUI.BeginDisabledGroup(historyTarget == null); { if (GUILayout.Button( historyTarget == null ? HistoryFocusAll : String.Format(HistoryFocusSingle, historyTarget.name), Styles.HistoryToolbarButtonStyle) ) { historyTarget = null; Refresh(); } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); var isPublished = Repository.CurrentRemote.HasValue; if (isPublished) { GUI.enabled = currentRemote != null; var fetchClicked = GUILayout.Button(FetchButtonText, Styles.HistoryToolbarButtonStyle); GUI.enabled = true; if (fetchClicked) { Fetch(); } // Pull / Push buttons var pullButtonText = statusBehind > 0 ? String.Format(PullButtonCount, statusBehind) : PullButton; GUI.enabled = currentRemote != null; var pullClicked = GUILayout.Button(pullButtonText, Styles.HistoryToolbarButtonStyle); GUI.enabled = true; if (pullClicked && EditorUtility.DisplayDialog(PullConfirmTitle, String.Format(PullConfirmDescription, currentRemote), PullConfirmYes, PullConfirmCancel) ) { Pull(); } var pushButtonText = statusAhead > 0 ? String.Format(PushButtonCount, statusAhead) : PushButton; GUI.enabled = currentRemote != null && statusBehind == 0; var pushClicked = GUILayout.Button(pushButtonText, Styles.HistoryToolbarButtonStyle); GUI.enabled = true; if (pushClicked && EditorUtility.DisplayDialog(PushConfirmTitle, String.Format(PushConfirmDescription, currentRemote), PushConfirmYes, PushConfirmCancel) ) { Push(); } } else { // Publishing a repo GUI.enabled = Platform.Keychain.Connections.Any(); var publishedClicked = GUILayout.Button(PublishButton, Styles.HistoryToolbarButtonStyle); if (publishedClicked) { PublishWindow.Open(); } GUI.enabled = true; } } GUILayout.EndHorizontal(); // When history scroll actually changes, store time value of topmost visible entry. This is the value we use to reposition scroll on log update - not the pixel value. if (history.Any()) { listID = GUIUtility.GetControlID(FocusType.Keyboard); // Only update time scroll var lastScroll = scroll; scroll = GUILayout.BeginScrollView(scroll); if (lastScroll != scroll && !updated) { scrollTime = history[historyStartIndex].Time; scrollOffset = scroll.y - historyStartIndex * EntryHeight; useScrollTime = true; } // Handle only the selected range of history items - adding spacing for the rest var start = Mathf.Max(0, historyStartIndex - HistoryExtraItemCount); var stop = Mathf.Min(historyStopIndex + HistoryExtraItemCount, history.Count); GUILayout.Space(start * EntryHeight); for (var index = start; index < stop; ++index) { if (HistoryEntry(history[index], GetEntryState(index), selectionIndex == index)) { newSelectionIndex = index; GUIUtility.keyboardControl = listID; } } GUILayout.Space((history.Count - stop) * EntryHeight); // Keyboard control if (GUIUtility.keyboardControl == listID && Event.current.type == EventType.KeyDown) { var change = 0; if (Event.current.keyCode == KeyCode.DownArrow) { change = 1; } else if (Event.current.keyCode == KeyCode.UpArrow) { change = -1; } if (change != 0) { newSelectionIndex = (selectionIndex + change) % history.Count; if (newSelectionIndex < historyStartIndex || newSelectionIndex > historyStopIndex) { ScrollTo(newSelectionIndex, (Position.height - Position.height * MaxChangelistHeightRatio - 30f - EntryHeight) * -.5f); } Event.current.Use(); } } } else { GUILayout.BeginScrollView(scroll); } GUILayout.EndScrollView(); // Selection info if (selectionIndex >= 0 && history.Count > selectionIndex) { var selection = history[selectionIndex]; // Top bar for scrolling to selection or clearing it GUILayout.BeginHorizontal(EditorStyles.toolbar); { if (GUILayout.Button(CommitDetailsTitle, Styles.HistoryToolbarButtonStyle)) { ScrollTo(selectionIndex); } if (GUILayout.Button(ClearSelectionButton, Styles.HistoryToolbarButtonStyle, GUILayout.ExpandWidth(false))) { newSelectionIndex = -2; } } GUILayout.EndHorizontal(); // Log entry details - including changeset tree (if any changes are found) if (changesetTree.Entries.Any()) { detailsScroll = GUILayout.BeginScrollView(detailsScroll, GUILayout.Height(250)); { HistoryDetailsEntry(selection); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); GUILayout.Label("Files changed", EditorStyles.boldLabel); GUILayout.Space(-5); GUILayout.BeginHorizontal(Styles.HistoryFileTreeBoxStyle); { changesetTree.OnGUI(); } GUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); } GUILayout.EndScrollView(); } else { detailsScroll = GUILayout.BeginScrollView(detailsScroll, GUILayout.Height(246)); HistoryDetailsEntry(selection); GUILayout.EndScrollView(); } } // Handle culling and selection changes at the end of the last GUI frame if (Event.current.type == EventType.Repaint) { CullHistory(); updated = false; if (newSelectionIndex >= 0 || newSelectionIndex == -2) { selectionIndex = newSelectionIndex == -2 ? -1 : newSelectionIndex; newSelectionIndex = -1; detailsScroll = Vector2.zero; if (selectionIndex >= 0) { changesetTree.UpdateEntries(history[selectionIndex].Changes); } Redraw(); } } }