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(); if (isPublished) { EditorGUI.BeginDisabledGroup(currentRemote == null); { // Fetch button var fetchClicked = GUILayout.Button(FetchButtonText, Styles.HistoryToolbarButtonStyle); if (fetchClicked) { Fetch(); } // Pull button var pullButtonText = statusBehind > 0 ? String.Format(PullButtonCount, statusBehind) : PullButton; var pullClicked = GUILayout.Button(pullButtonText, Styles.HistoryToolbarButtonStyle); if (pullClicked && EditorUtility.DisplayDialog(PullConfirmTitle, String.Format(PullConfirmDescription, currentRemote), PullConfirmYes, PullConfirmCancel) ) { Pull(); } } EditorGUI.EndDisabledGroup(); // Push button EditorGUI.BeginDisabledGroup(currentRemote == null || statusBehind != 0); { var pushButtonText = statusAhead > 0 ? String.Format(PushButtonCount, statusAhead) : PushButton; var pushClicked = GUILayout.Button(pushButtonText, Styles.HistoryToolbarButtonStyle); if (pushClicked && EditorUtility.DisplayDialog(PushConfirmTitle, String.Format(PushConfirmDescription, currentRemote), PushConfirmYes, PushConfirmCancel) ) { Push(); } } EditorGUI.EndDisabledGroup(); } else { // Publishing a repo EditorGUI.BeginDisabledGroup(!Platform.Keychain.Connections.Any()); { var publishedClicked = GUILayout.Button(PublishButton, Styles.HistoryToolbarButtonStyle); if (publishedClicked) { PopupWindow.Open(PopupWindow.PopupViewType.PublishView); } } EditorGUI.EndDisabledGroup(); } } 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(); } } }
private void SignIn(object obj) { PopupWindow.Open(PopupWindow.PopupViewType.AuthenticationView); }