public static void GoToLine(ILogContentGetter log, LogEntry logEntry, bool focus) { // Prefer using instanceID as much as possible, more reliable. // Try to reach the object, it might not be a TextAsset. if (logEntry.instanceID != 0) { string path = AssetDatabase.GetAssetPath(logEntry.instanceID); if (string.IsNullOrEmpty(path) == false) { Object sourceFile = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)); if (sourceFile != null) { RowUtility.GoToFileLine(path, logEntry.line, focus); return; } } } // Go to the first reachable frame. for (int j = 0; j < log.Frames.Length; j++) { if (log.Frames[j].fileExist == true) { RowUtility.GoToFileLine(log.Frames[j].fileName, log.Frames[j].line, focus); break; } } }
public static void PreviewStackFrame(RowsDrawer rowsDrawer, Rect r, Frame frame) { if (frame.fileExist == true && RowUtility.previewFrame != frame) { try { RowUtility.previewLines = ConsoleUtility.files.GetFile(frame.fileName); RowUtility.rowsDrawer = rowsDrawer; RowUtility.previewFrame = frame; RowUtility.previewRect = r; FilesWatcher.Watch(frame.fileName); RowUtility.previewEditorWindow = RowUtility.drawingWindow; RowUtility.rowsDrawer.AfterAllRows -= RowUtility.DrawPreview; RowUtility.rowsDrawer.AfterAllRows += RowUtility.DrawPreview; } catch (Exception ex) { InternalNGDebug.LogException(ex); RowUtility.ClearPreview(); } } }
private object HandleKeyboard(object data) { RowsDrawer rowsDrawer = data as RowsDrawer; if (Event.current.type == EventType.KeyDown) { InputsManager inputsManager = HQ.Settings.Get <ConsoleSettings>().inputsManager; if (inputsManager.Check("Navigation", ConsoleConstants.CloseLogCommand) == true) { if (rowsDrawer.rowsData.ContainsKey(this) == true) { rowsDrawer.rowsData.Remove(this); rowsDrawer.InvalidateViewHeight(); RowUtility.drawingWindow.Repaint(); RowUtility.ClearPreview(); } } else if (inputsManager.Check("Navigation", ConsoleConstants.OpenLogCommand) == true) { if (rowsDrawer.rowsData.ContainsKey(this) == false) { rowsDrawer.rowsData.Add(this, true); rowsDrawer.InvalidateViewHeight(); RowUtility.drawingWindow.Repaint(); RowUtility.ClearPreview(); } } else if (inputsManager.Check("Navigation", ConsoleConstants.GoToLineCommand) == true && rowsDrawer.currentVars.CountSelection == 1 && this.Frames.Length > 0) { string fileName = this.Frames[0].fileName; int line = this.Frames[0].line; bool focus = (Event.current.modifiers & HQ.Settings.Get <LogSettings>().forceFocusOnModifier) != 0; RowUtility.GoToFileLine(fileName, line, focus); RowUtility.drawingWindow.Repaint(); Event.current.Use(); } } return(null); }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int streamIndex, bool?collapse) { if (this.isParsed == false) { this.ParseLog(); } float originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth; LogSettings settings = HQ.Settings.Get <LogSettings>(); // Draw highlight. r.x = 0F; r.width = originWidth; r.height = settings.height; this.DrawBackground(rowsDrawer, r, streamIndex); r.width = 16F; EditorGUI.DrawRect(r, JSONRow.FoldColor); bool isOpened = rowsDrawer.rowsData.ContainsKey(this); EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, isOpened, ""); if (EditorGUI.EndChangeCheck() == true) { if (isOpened == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } isOpened = !isOpened; rowsDrawer.InvalidateViewHeight(); } r.x = r.width; r.width = originWidth - r.x; // Handle mouse inputs. if (r.Contains(Event.current.mousePosition) == true) { // Toggle on middle click. if (Event.current.type == EventType.MouseDown && Event.current.button == 2) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { if (Event.current.control == false) { rowsDrawer.currentVars.ClearSelection(); } rowsDrawer.currentVars.AddSelection(streamIndex); if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } } if (isOpened == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } isOpened = !isOpened; rowsDrawer.InvalidateViewHeight(); Event.current.Use(); } // Show menu on right click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(LC.G("CopyLine")), false, rowsDrawer.MenuCopyLine, this); menu.AddItem(new GUIContent(LC.G("CopyActualExplodedJSON")), false, this.CopyAllActualExplodedJSON, rowsDrawer); menu.AddItem(new GUIContent(LC.G("CopyFullExplodedJSON")), false, this.CopyAllFullExplodedJSON, rowsDrawer); menu.AddItem(new GUIContent(LC.G("ViewJSON")), false, this.ViewJSON); if (string.IsNullOrEmpty(this.StackTrace) == false) { menu.AddItem(new GUIContent(LC.G("CopyStackTrace")), false, rowsDrawer.MenuCopyStackTrace, this); } menu.AddItem(new GUIContent("Advance Copy Shift+C"), false, rowsDrawer.OpenAdvanceCopy); if (rowsDrawer.currentVars.CountSelection >= 2) { menu.AddItem(new GUIContent(LC.G("ExportSelection")), false, rowsDrawer.MenuExportSelection, this); } if (RowsDrawer.GlobalLogContextMenu != null) { RowsDrawer.GlobalLogContextMenu(menu, rowsDrawer, streamIndex, this); } if (rowsDrawer.LogContextMenu != null) { rowsDrawer.LogContextMenu(menu, this); } menu.ShowAsContext(); Event.current.Use(); } // Focus on right click down. else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { // Handle multi-selection. if (Event.current.control == true) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } } else { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.ClearSelection(); rowsDrawer.currentVars.AddSelection(streamIndex); } rowsDrawer.FitFocusedLogInScreen(streamIndex); } Event.current.Use(); } // Focus on left click. else if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { // Set the selection to the log's object if available. if (this.log.instanceID != 0 && (Event.current.modifiers & settings.selectObjectOnModifier) != 0) { Selection.activeInstanceID = this.log.instanceID; } // Go to line if force focus is available. else if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { RowUtility.GoToLine(this, this.log, true); } // Handle multi-selection. if (Event.current.control == true && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { rowsDrawer.currentVars.RemoveSelection(streamIndex); } else { if (Event.current.shift == true) { rowsDrawer.currentVars.WrapSelection(streamIndex); } else if (Event.current.control == false) { if (settings.alwaysDisplayLogContent == false && rowsDrawer.currentVars.CountSelection != 1) { rowsDrawer.bodyRect.height -= rowsDrawer.currentVars.rowContentHeight + ConsoleConstants.RowContentSplitterHeight; } else { // Reset last click when selection changes. if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { RowUtility.LastClickTime = 0; } } rowsDrawer.currentVars.ClearSelection(); } if (Event.current.shift == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } GUI.FocusControl(null); Event.current.Use(); } } // Handle normal behaviour on left click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { // Go to line on double click. if (RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup && RowUtility.LastClickIndex == streamIndex && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } RowUtility.GoToLine(this, this.log, focus); } // Ping on simple click. else if (this.log.instanceID != 0) { EditorGUIUtility.PingObject(this.log.instanceID); } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; RowUtility.LastClickIndex = streamIndex; RowUtility.drawingWindow.Repaint(); Event.current.Use(); } } r = this.DrawPreLogData(rowsDrawer, r); r.width = originWidth - r.x; GUI.Label(r, this.firstLine, settings.Style); if (isOpened == true) { if (this.root == null) { this.ParseJSON(); } r.y += r.height; r.x = 16F; r.width = originWidth - 16F; r.height = this.root.GetHeight(); EditorGUI.BeginChangeCheck(); this.root.Draw(r); if (EditorGUI.EndChangeCheck() == true) { rowsDrawer.InvalidateViewHeight(); } if (Event.current.type == EventType.MouseMove) { this.editor.Repaint(); } } }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse) { LogSettings settings = HQ.Settings.Get <LogSettings>(); float originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth; // Draw highlight. r.x = 0F; r.width = originWidth; r.height = settings.height; this.DrawBackground(rowsDrawer, r, i); r.x += 2F; r.width = 16F; bool lastValue = this.isOpened; Color foldoutColor = this.hasError == true ? ConsoleConstants.ErrorFoldoutColor : ConsoleConstants.WarningFoldoutColor; using (BgColorContentRestorer.Get(foldoutColor)) { this.isOpened = EditorGUI.Foldout(r, this.isOpened, ""); } if (lastValue != this.isOpened) { GUI.FocusControl(null); rowsDrawer.InvalidateViewHeight(); } r.x -= 2F; r.width = 3F; EditorGUI.DrawRect(r, foldoutColor); r.width = 16F; r.x += r.width; r.width = originWidth - r.width; this.HandleDefaultSelection(rowsDrawer, r, i); // Toggle on middle-click. if (r.Contains(Event.current.mousePosition) == true && Event.current.type == EventType.MouseDown && Event.current.button == 2) { this.isOpened = !this.isOpened; rowsDrawer.InvalidateViewHeight(); Event.current.Use(); } else if (r.Contains(Event.current.mousePosition) == true && Event.current.type == EventType.MouseUp && Event.current.button == 0) { if (string.IsNullOrEmpty(this.file) == false && RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } if (this.lastGoToFile < this.fileLines.Count) { RowUtility.GoToFileLine(this.file, this.fileLines[this.lastGoToFile].line, focus); ++this.lastGoToFile; if (this.lastGoToFile >= this.fileLines.Count) { this.lastGoToFile = 0; } } else { this.lastGoToFile = 0; } } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; } GUI.Label(r, this.error + " (" + this.fileLines.Count + ")", settings.Style); r.y += settings.height; if (this.isOpened == true) { for (int j = 0; j < this.fileLines.Count; j++) { r.x = 0F; r.width = originWidth; if (Event.current.type == EventType.Repaint && this.selectedSubRow == j && rowsDrawer.currentVars.CountSelection > 0 && rowsDrawer.currentVars.GetSelection(0) == i) { EditorGUI.DrawRect(r, CompileRow.SubRowHighlightColor); } // Handle mouse inputs per log. if (r.Contains(Event.current.mousePosition) == true) { // Toggle on middle click. if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (string.IsNullOrEmpty(this.file) == false && RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } RowUtility.GoToFileLine(this.fileLines[j].file, this.fileLines[j].line, focus); } else { rowsDrawer.currentVars.ClearSelection(); rowsDrawer.currentVars.AddSelection(i); this.selectedSubRow = j; this.log.condition = this.fileLines[j].message; } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; Event.current.Use(); } } // Handle inputs. if (this.fileLines[j].line > 0) { Utility.content.text = this.fileLines[j].line.ToString(); r.width = settings.Style.CalcSize(Utility.content).x; GUI.Label(r, Utility.Color(Utility.content.text, HQ.Settings.Get <StackTraceSettings>().lineColor), settings.Style); r.x += r.width; } r.width = originWidth - r.x; GUI.Label(r, this.fileLines[j].message, settings.Style); r.y += settings.height; } } }
private static void DrawPreview(Rect bodyRect) { Rect r = RowUtility.previewRect; r.x += bodyRect.x; r.y += bodyRect.y; // Out of window. if (EditorWindow.mouseOverWindow != RowUtility.previewEditorWindow) { RowUtility.ClearPreview(); return; } // Out of stacktrace. //else if (Event.current.type == EventType.MouseMove) if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == false) { RowUtility.ClearPreview(); return; } if (RowUtility.previewFrame.line <= RowUtility.previewLines.Length) { StackTraceSettings stackTrace = HQ.Settings.Get <StackTraceSettings>(); float maxWidth = float.MinValue; r.x = Event.current.mousePosition.x + stackTrace.previewOffset.x; r.y = Event.current.mousePosition.y + stackTrace.previewOffset.y; r.width = RowUtility.previewRect.width; r.height = stackTrace.previewHeight; for (int i = RowUtility.previewFrame.line - stackTrace.previewLinesBeforeStackFrame - 1, max = Mathf.Min(RowUtility.previewFrame.line + stackTrace.previewLinesAfterStackFrame, RowUtility.previewLines.Length); i < max; i++) { Utility.content.text = RowUtility.previewLines[i]; Vector2 size = stackTrace.PreviewSourceCodeStyle.CalcSize(Utility.content); if (size.x > maxWidth) { maxWidth = size.x; } } r.width = maxWidth; for (int i = RowUtility.previewFrame.line - stackTrace.previewLinesBeforeStackFrame - 1, max = Mathf.Min(RowUtility.previewFrame.line + stackTrace.previewLinesAfterStackFrame, RowUtility.previewLines.Length); i < max; i++) { if (Event.current.type == EventType.Repaint) { if (i + 1 != RowUtility.previewFrame.line) { EditorGUI.DrawRect(r, stackTrace.previewSourceCodeBackgroundColor); } else { EditorGUI.DrawRect(r, stackTrace.previewSourceCodeMainLineBackgroundColor); } } GUI.Label(r, RowUtility.previewLines[i], stackTrace.PreviewSourceCodeStyle); r.y += r.height; } RowUtility.drawingWindow.Repaint(); } }
private static void GoToLine(Rect r, Frame frame) { StackTraceSettings stackTrace = HQ.Settings.Get <StackTraceSettings>(); if (Event.current.button == 0 && frame.fileExist == true) { // Ping folder on click + modifiers. if ((Event.current.modifiers & stackTrace.pingFolderOnModifier) != 0) { int i = frame.frameString.LastIndexOf(' ') + 1; Utility.content.text = frame.frameString.Substring(0, i); var v = stackTrace.Style.CalcSize(Utility.content); StringBuilder buffer = Utility.GetBuffer(); if (Event.current.mousePosition.x >= v.x) { int i2 = frame.frameString.IndexOf('/', i + 1); // Skip Assets folder. string folder = frame.frameString.Substring(i, i2 - i).Split('>')[1]; Utility.content.text += folder; v = stackTrace.Style.CalcSize(Utility.content); if (Event.current.mousePosition.x > v.x) { i = i2; buffer.Append(folder); while (Event.current.mousePosition.x >= v.x) { i2 = frame.frameString.IndexOf('/', i + 1); if (i2 == -1) { break; } folder = frame.frameString.Substring(i, i2 - i); buffer.Append(folder); Utility.content.text += folder; v = stackTrace.Style.CalcSize(Utility.content); i = i2; } EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(buffer.ToString(), typeof(Object))); } } Utility.RestoreBuffer(buffer); } // Or go to line. else { bool focus = (Event.current.modifiers & HQ.Settings.Get <LogSettings>().forceFocusOnModifier) != 0; RowUtility.GoToFileLine(frame.fileName, frame.line, focus); Event.current.Use(); } } }
private static void AddFilter(object data) { RowUtility.AddFrameFilter(data as string); }
public static Rect DrawStackTrace(ILogContentGetter log, RowsDrawer rowsDrawer, Rect r, int i, Row row) { StackTraceSettings settings = HQ.Settings.Get <StackTraceSettings>(); float width = r.width; // Substract viewRect to avoid scrollbar. r.height = settings.height; // Display the stack trace. int j = 0; foreach (var frame in log.Frames) { // Hide invisible frames. if (r.y - rowsDrawer.currentVars.scrollbar.Offset > rowsDrawer.bodyRect.height) { break; } r.x = 0F; r.width = width - 16F; GUI.SetNextControlName("SF" + i + j); if (GUI.Button(r, frame.frameString, settings.Style) == true) { if (RowUtility.CheckLowestRowGoToLineAllowed(j) == true) { GUI.FocusControl("SF" + i + j); r.y -= rowsDrawer.currentVars.scrollbar.Offset; RowUtility.GoToLine(r, frame); r.y += rowsDrawer.currentVars.scrollbar.Offset; } } // Handle hover overflow. if (r.y - rowsDrawer.currentVars.scrollbar.Offset + r.height > rowsDrawer.bodyRect.height) { r.height = rowsDrawer.bodyRect.height - r.y + rowsDrawer.currentVars.scrollbar.Offset; } if (Event.current.type == EventType.MouseMove && r.Contains(Event.current.mousePosition) == true) { r.y -= rowsDrawer.currentVars.scrollbar.Offset; RowUtility.PreviewStackFrame(rowsDrawer, r, frame); r.y += rowsDrawer.currentVars.scrollbar.Offset; } r.x = r.width; r.width = 16F; if (GUI.Button(r, "+", settings.Style) == true) { StackTraceSettings stackTrace = HQ.Settings.Get <StackTraceSettings>(); GenericMenu menu = new GenericMenu(); if (frame.raw == null) { InternalNGDebug.LogError("The frame stack is invalid." + Environment.NewLine + frame); } menu.AddItem(new GUIContent("Set as Category"), false, RowUtility.SetAsCategory, frame.raw); string f = RowUtility.GetFilterNamespace(frame.raw); if (f != null) { if (stackTrace.filters.Contains(f) == false) { menu.AddItem(new GUIContent("Skip Namespace \"" + f + "\""), false, RowUtility.AddFilter, f); } else { menu.AddDisabledItem(new GUIContent("Skip Namespace \"" + f + "\"")); } } f = RowUtility.GetFilterClass(frame.raw); if (f != null) { if (stackTrace.filters.Contains(f) == false) { menu.AddItem(new GUIContent("Skip Class \"" + f + "\""), false, RowUtility.AddFilter, f); } else { menu.AddDisabledItem(new GUIContent("Skip Class \"" + f + "\"")); } } f = RowUtility.GetFilterMethod(frame.raw); if (f != null) { if (stackTrace.filters.Contains(f) == false) { menu.AddItem(new GUIContent("Skip Method \"" + f + "\""), false, RowUtility.AddFilter, f); } else { menu.AddDisabledItem(new GUIContent("Skip Method \"" + f + "\"")); } } menu.AddItem(new GUIContent("Manage filters"), false, RowUtility.GoToSettings); menu.ShowAsContext(); } ++j; r.y += r.height; } return(r); }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int streamIndex, bool?collapse) { LogSettings settings = HQ.Settings.Get <LogSettings>(); float originWidth = r.width - rowsDrawer.verticalScrollbarWidth /* + rowsDrawer.currentVars.scrollX*/; // Draw highlight. //r.x = rowsDrawer.currentVars.scrollX; r.width = originWidth; r.height = settings.height; this.DrawBackground(rowsDrawer, r, streamIndex); // Handle row events. if (r.Contains(Event.current.mousePosition) == true) { if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag) { if (Event.current.type == EventType.MouseDrag && Utility.position2D != Vector2.zero && DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null && (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance) { Utility.position2D = Vector2.zero; DragAndDrop.StartDrag("Drag Object"); } if (rowsDrawer.RowHovered != null) { r.y -= rowsDrawer.currentVars.scrollbar.Offset; rowsDrawer.RowHovered(r, this); r.y += rowsDrawer.currentVars.scrollbar.Offset; } } else if (Event.current.type == EventType.MouseDown) { if (rowsDrawer.RowClicked != null) { r.y -= rowsDrawer.currentVars.scrollbar.Offset; rowsDrawer.RowClicked(r, this); r.y += rowsDrawer.currentVars.scrollbar.Offset; } } } //r.x = 0F; if (RowsDrawer.GlobalBeforeFoldout != null) { //r.width = originWidth - r.x; r = RowsDrawer.GlobalBeforeFoldout(rowsDrawer, r, streamIndex, this); } if (rowsDrawer.BeforeFoldout != null) { r.width = originWidth - r.x; r = rowsDrawer.BeforeFoldout(r, streamIndex, this); } // The drag position needs to be often reset. To ensure no drag start. if (Event.current.type == EventType.MouseUp) { Utility.position2D = Vector2.zero; } if (Event.current.type == EventType.MouseDown) { Utility.position2D = Vector2.zero; if (Event.current.button == 0 && r.Contains(Event.current.mousePosition) == true) { Utility.position2D = Event.current.mousePosition; if (this.log.instanceID != 0) { DragAndDrop.objectReferences = new Object[] { EditorUtility.InstanceIDToObject(this.log.instanceID) }; DragAndDrop.SetGenericData(Utility.DragObjectDataName, this.log.instanceID); } } } Color foldoutColor = Color.white; bool isDefaultLog = false; if ((this.log.mode & Mode.ScriptingException) != 0) { if (HQ.Settings.Get <GeneralSettings>().differentiateException == false) { foldoutColor = ConsoleConstants.ErrorFoldoutColor; } else { foldoutColor = ConsoleConstants.ExceptionFoldoutColor; } } else if ((this.log.mode & (Mode.ScriptCompileError | Mode.ScriptingError | Mode.Fatal | Mode.Error | Mode.Assert | Mode.AssetImportError | Mode.ScriptingAssertion)) != 0) { foldoutColor = ConsoleConstants.ErrorFoldoutColor; } else if ((this.log.mode & (Mode.ScriptCompileWarning | Mode.ScriptingWarning | Mode.AssetImportWarning)) != 0) { foldoutColor = ConsoleConstants.WarningFoldoutColor; } else { isDefaultLog = true; } bool isOpened = rowsDrawer.rowsData.ContainsKey(this); // Draw foldout. r.x += 2F; r.width = 16F; EditorGUI.BeginDisabledGroup(this.HasStackTrace == false); { using (BgColorContentRestorer.Get(!isDefaultLog, foldoutColor)) { EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, (bool)isOpened, ""); if (EditorGUI.EndChangeCheck() == true) { if (isOpened == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } isOpened = !isOpened; GUI.FocusControl(null); rowsDrawer.InvalidateViewHeight(); } } r.x -= 2F; r.width = 3F; if (isDefaultLog == false) { EditorGUI.DrawRect(r, foldoutColor); } r.width = 16F; } EditorGUI.EndDisabledGroup(); r.x = r.width; if (this.log.instanceID != 0) { if (this.icon == null) { this.icon = Utility.GetIcon(this.log.instanceID); if (this.icon == null) { this.icon = InternalEditorUtility.GetIconForFile(this.log.file); } } if (icon != null) { r.width = settings.height; GUI.DrawTexture(r, icon); r.x += r.width; } } if (RowsDrawer.GlobalBeforeLog != null) { r.width = originWidth - r.x; r = RowsDrawer.GlobalBeforeLog(r, streamIndex, this); } if (rowsDrawer.BeforeLog != null) { r.width = originWidth - r.x; r = rowsDrawer.BeforeLog(r, streamIndex, this); } r.width = originWidth - r.x; // Handle mouse inputs. if (r.Contains(Event.current.mousePosition) == true) { // Toggle on middle click. if (Event.current.type == EventType.MouseDown && Event.current.button == 2) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { if (Event.current.control == false) { rowsDrawer.currentVars.ClearSelection(); } rowsDrawer.currentVars.AddSelection(streamIndex); if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } GUI.FocusControl(null); } if (rowsDrawer.rowsData.ContainsKey(this) == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } //this.isOpened = !this.isOpened; rowsDrawer.InvalidateViewHeight(); Event.current.Use(); } // Show menu on right click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(LC.G("CopyLine")), false, rowsDrawer.MenuCopyLine, this); menu.AddItem(new GUIContent(LC.G("CopyLog")), false, rowsDrawer.MenuCopyLog, this); if (string.IsNullOrEmpty(this.StackTrace) == false) { menu.AddItem(new GUIContent(LC.G("CopyStackTrace")), false, rowsDrawer.MenuCopyStackTrace, this); } menu.AddItem(new GUIContent("Advance Copy Shift+C"), false, rowsDrawer.OpenAdvanceCopy); if (rowsDrawer.currentVars.CountSelection >= 2) { menu.AddItem(new GUIContent(LC.G("ExportSelection")), false, rowsDrawer.MenuExportSelection, this); } if (RowsDrawer.GlobalLogContextMenu != null) { RowsDrawer.GlobalLogContextMenu(menu, rowsDrawer, streamIndex, this); } if (rowsDrawer.LogContextMenu != null) { rowsDrawer.LogContextMenu(menu, this); } menu.ShowAsContext(); Event.current.Use(); } // Focus on right click down. else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { // Handle multi-selection. if (Event.current.control == true) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } } else { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.ClearSelection(); rowsDrawer.currentVars.AddSelection(streamIndex); } rowsDrawer.FitFocusedLogInScreen(streamIndex); GUI.FocusControl(null); } Event.current.Use(); } // Focus on left click. else if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { // Set the selection to the log's object if available. if (this.log.instanceID != 0 && (Event.current.modifiers & settings.selectObjectOnModifier) != 0) { Selection.activeInstanceID = this.log.instanceID; } // Go to line if force focus is available. else if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { RowUtility.GoToLine(this, this.log, true); } // Handle multi-selection. if (Event.current.control == true && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { rowsDrawer.currentVars.RemoveSelection(streamIndex); } else { if (Event.current.shift == true) { rowsDrawer.currentVars.WrapSelection(streamIndex); } else if (Event.current.control == false) { if (settings.alwaysDisplayLogContent == false && rowsDrawer.currentVars.CountSelection != 1) { rowsDrawer.bodyRect.height -= rowsDrawer.currentVars.rowContentHeight + ConsoleConstants.RowContentSplitterHeight; } else { // Reset last click when selection changes. if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { RowUtility.LastClickTime = 0; } } rowsDrawer.currentVars.ClearSelection(); } if (Event.current.shift == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } GUI.FocusControl(null); Event.current.Use(); } } // Handle normal behaviour on left click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { // Go to line on double click. if (RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup && RowUtility.LastClickIndex == streamIndex && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } RowUtility.GoToLine(this, this.log, focus); } // Ping on simple click. else if (this.log.instanceID != 0) { EditorGUIUtility.PingObject(this.log.instanceID); } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; RowUtility.LastClickIndex = streamIndex; GUI.FocusControl(null); RowUtility.drawingWindow.Repaint(); Event.current.Use(); } } r = this.DrawPreLogData(rowsDrawer, r); r.width = originWidth - r.x; this.DrawLog(r, streamIndex); r = this.DrawCollapseLabel(r, collapse); if (RowsDrawer.GlobalAfterLog != null) { r = RowsDrawer.GlobalAfterLog(r, streamIndex, this); } if (rowsDrawer.AfterLog != null) { r = rowsDrawer.AfterLog(r, streamIndex, this); } r.y += r.height; if (isOpened == true) { r.x = 0F; r.width = originWidth; RowUtility.DrawStackTrace(this, rowsDrawer, r, streamIndex, this); } }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse) { if (this.instanceIDs == null) { this.ParseCondition(); } LogSettings log = HQ.Settings.Get <LogSettings>(); float originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth; // Draw highlight. r.x = 0F; r.width = originWidth; r.height = log.height; this.DrawBackground(rowsDrawer, r, i); if (Event.current.type == EventType.MouseDrag && Utility.position2D != Vector2.zero && DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null && (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance) { DragAndDrop.StartDrag("Drag Object"); Event.current.Use(); } r.width = 16F; EditorGUI.DrawRect(r, Color.cyan); bool lastValue = this.isOpened; this.isOpened = EditorGUI.Foldout(r, this.isOpened, ""); if (lastValue != this.isOpened) { rowsDrawer.InvalidateViewHeight(); } r.x = r.width; r.width = originWidth - r.x; r = this.DrawPreLogData(rowsDrawer, r); r.width = originWidth - r.x; // Draw contexts. for (int j = 0; j < this.instanceIDs.Length; j++) { Texture2D icon = null; r.width = log.height; if (this.instanceIDs[j] != 0) { icon = Utility.GetIcon(this.instanceIDs[j]); if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true) { if (Event.current.button == 0) { Utility.position2D = Event.current.mousePosition; DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[] { EditorUtility.InstanceIDToObject(this.instanceIDs[j]) }; DragAndDrop.SetGenericData(Utility.DragObjectDataName, this.instanceIDs[j]); if (RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup || (Event.current.modifiers & log.selectObjectOnModifier) != 0) { Selection.activeInstanceID = this.instanceIDs[j]; } else { EditorGUIUtility.PingObject(this.instanceIDs[j]); } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; } else if (Event.current.button == 1) { Selection.activeInstanceID = this.instanceIDs[j]; } } } if (icon != null) { GUI.DrawTexture(r, icon); } else { EditorGUI.DrawRect(r, Color.black); } if (r.Contains(Event.current.mousePosition) == true) { r.x += r.width; r.width = originWidth - r.x; Object context = null; if (this.instanceIDs[j] != 0) { context = EditorUtility.InstanceIDToObject(this.instanceIDs[j]); } if (context != null) { EditorGUI.LabelField(r, context.ToString()); } else { EditorGUI.LabelField(r, LC.G("MultiContextsRow_ObjectNotAvailable")); } RowUtility.drawingWindow.Repaint(); } r.x += r.width + MultiContextsRow.Spacing; } r.x = 0F; r.width = originWidth; this.HandleDefaultSelection(rowsDrawer, r, i); if (this.isOpened == true) { r.x = 0F; r.y += r.height; r.width = originWidth; r = RowUtility.DrawStackTrace(this, rowsDrawer, r, i, this); } }