void DrawGitFileLogsPanel() { foreach (var log in logs) { GUIStyle style = (log.Sha1 == _selectedSha1) ? EditorHelper.BoxDarkStyle : EditorHelper.BoxLightStyle; var rect = EditorGUILayout.BeginHorizontal(style); if (GUILayout.Button("checkout", GUILayout.Width(80)) && EditorUtility.DisplayDialog("Checkout Entry?", "Are you sure you want to checkout this entry?", "Yes", "No")) { Git.Checkout(file, log.Sha1); window.Close(); } GUILayout.Label(log.Sha1, GUILayout.Width(70)); GUILayout.Label(log.Message); GUILayout.Label(string.Format("{0} by {1}", log.Date.ToString("MM-dd HH:mm"), log.User), EditorHelper.RightLabelStyle, GUILayout.Width(140)); if (GUILayout.Button("diff", GUILayout.Width(60))) { if (_selectedSha1 != log.Sha1) { _requiredRepaint = true; _selectedSha1 = log.Sha1; } Git.InvokeDiffTool(file, log.Sha1); } EditorGUILayout.EndHorizontal(); GUILayout.Space(-EditorGUIUtility.standardVerticalSpacing); if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition)) { if (_selectedSha1 != log.Sha1) { _requiredRepaint = true; _selectedSha1 = log.Sha1; } } } }
void DrawLogsPanel() { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Recent Logs", EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); // -------------------------------------------------------------------------------------------- var rect = EditorGUILayout.BeginHorizontal("TextArea", GUILayout.Height(_logsAreaHeight)); _logsAreaScrollPos = EditorGUILayout.BeginScrollView(_logsAreaScrollPos); EditorGUILayout.BeginVertical(); foreach (var log in _logs) { GUIStyle style = (_currentLog != null && log.Sha1 == _currentLog.Sha1) ? EditorHelper.BoxDarkStyle : EditorHelper.BoxLightStyle; var area = EditorGUILayout.BeginHorizontal(style); GUILayout.Label(log.Sha1, GUILayout.Width(70)); GUILayout.Label(log.Message); GUILayout.Label(string.Format("{0} by {1}", log.Date.ToString("MM-dd HH:mm"), log.User), GUILayout.Width(140)); EditorGUILayout.EndHorizontal(); GUILayout.Space(-EditorGUIUtility.standardVerticalSpacing); if (Event.current.type == EventType.MouseDown && area.Contains(Event.current.mousePosition)) { if (_currentLog == null || _currentLog.Sha1 != log.Sha1) { _repaintRequired = true; _logFiles = Git.GetHeadFiles(log.Sha1); _currentLogFile = null; _currentLog = log; } } } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); // -------------------------------------------------------------------------------------------- _isResizing = EditorHelper.DrawHorizontalResizerAfterRect(rect, ref _logsAreaHeight); _logsAreaHeight = Mathf.Min(_logsAreaHeight, position.height - 200f); // -------------------------------------------------------------------------------------------- EditorGUILayout.BeginHorizontal(); GUILayout.Label("Log Files", GUILayout.Width(80)); if (!_repaintRequired && _currentLog != null) { GUILayout.Label(string.Format("{0} by {1} : {2}", _currentLog.Date.ToString("MM-dd HH:mm"), _currentLog.User, _currentLog.Message)); } EditorGUILayout.EndHorizontal(); GUILayout.Space(2); // -------------------------------------------------------------------------------------------- EditorGUILayout.BeginHorizontal("TextArea"); _logFilesAreaScrollPos = EditorGUILayout.BeginScrollView(_logFilesAreaScrollPos); EditorGUILayout.BeginVertical(); if (!_repaintRequired && _currentLog != null) { int safeId = 0; foreach (var file in _logFiles) { if (++safeId > 50) { break; } GUIStyle style = (_currentLogFile == file.Path) ? EditorHelper.BoxDarkStyle : EditorHelper.BoxLightStyle; var area = EditorGUILayout.BeginHorizontal(style); if (GUILayout.Button("checkout", GUILayout.Width(80)) && EditorUtility.DisplayDialog("Checkout Entry?", "Are you sure you want to checkout this entry?", "Yes", "No")) { Git.Checkout(file, _currentLog.Sha1); } GUILayout.Label(file.Path, GUILayout.MaxWidth(position.width - 220), GUILayout.ExpandWidth(true)); if (GUILayout.Button("diff", GUILayout.Width(60))) { if (_currentLogFile != file.Path) { _repaintRequired = true; _currentLogFile = file.Path; } Git.InvokeDiffTool(file.Path, _currentLog.Sha1); } EditorGUILayout.EndHorizontal(); GUILayout.Space(-EditorGUIUtility.standardVerticalSpacing); if (Event.current.type == EventType.MouseDown && area.Contains(Event.current.mousePosition)) { if (_currentLogFile != file.Path) { _repaintRequired = true; _currentLogFile = file.Path; } } } } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); }