private object HandleKeyboard(object data) { RowsDrawer rowsDrawer = data as RowsDrawer; if (Event.current.type == EventType.KeyDown) { if (HQ.Settings.Get <ConsoleSettings>().inputsManager.Check("Navigation", ConsoleConstants.CloseLogCommand) == true) { if (rowsDrawer.rowsData.ContainsKey(this) == true) { rowsDrawer.rowsData.Remove(this); rowsDrawer.InvalidateViewHeight(); RowUtility.drawingWindow.Repaint(); } } else if (HQ.Settings.Get <ConsoleSettings>().inputsManager.Check("Navigation", ConsoleConstants.OpenLogCommand) == true) { if (rowsDrawer.rowsData.ContainsKey(this) == false) { rowsDrawer.rowsData.Add(this, true); rowsDrawer.InvalidateViewHeight(); RowUtility.drawingWindow.Repaint(); } } } return(null); }
/// <summary> /// Handles events to toggle Row from the selection. /// </summary> /// <param name="rowsDrawer">The drawer.</param> /// <param name="r">The area to work on.</param> /// <param name="streamIndex">Index from the RowsDrawer.rows[].</param> protected void HandleDefaultSelection(RowsDrawer rowsDrawer, Rect r, int streamIndex) { if (r.Contains(Event.current.mousePosition) == true) { // Focus on left click. if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { // Handle multi-selection. if (Event.current.control == true && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { rowsDrawer.currentVars.RemoveSelection(streamIndex); } else { if (Event.current.control == false) { rowsDrawer.currentVars.ClearSelection(); } rowsDrawer.currentVars.AddSelection(streamIndex); if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } } RowUtility.drawingWindow.Repaint(); Event.current.Use(); } } }
protected Rect DrawPreLogData(RowsDrawer rowsDrawer, Rect r) { LogSettings settings = HQ.Settings.Get <LogSettings>(); // Draw time. if (settings.displayTime == true) { Utility.content.text = this.log.time; r.width = settings.TimeStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.TimeStyle); r.x += r.width; } // Draw frame count. if (settings.displayFrameCount == true) { Utility.content.text = this.log.frameCount.ToString(); r.width = settings.TimeStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.TimeStyle); r.x += r.width; } // Draw rendered frame count. if (settings.displayRenderedFrameCount == true) { Utility.content.text = this.log.renderedFrameCount.ToString(); r.width = settings.TimeStyle.CalcSize(Utility.content).x; GUI.Label(r, Utility.content, settings.TimeStyle); r.x += r.width; } return(r); }
private Rect RowsDrawer_GlobalBeforeFoldout(RowsDrawer rowsDrawer, Rect r, int i, Row row) { if (HQ.Settings == null) { return(r); } ColorMarkersModuleSettings settings = HQ.Settings.Get <ColorMarkersModuleSettings>(); List <ColorMarker> markers = settings.colorMarkers; List <ColorBackground> stamps = settings.colorBackgrounds; for (int j = 0; j < this.coloredRows.Count; j++) { if (this.coloredRows[j].row == row) { if (this.coloredRows[j].i < stamps.Count) { EditorGUI.DrawRect(r, stamps[this.coloredRows[j].i].color); } return(r); } } for (int j = 0; j < markers.Count; j++) { if (markers[j].groupFilters.filters.Count > 0 && markers[j].groupFilters.Filter(row) == true) { EditorGUI.DrawRect(r, markers[j].backgroundColor); break; } } return(r); }
public override float GetHeight(RowsDrawer rowsDrawer) { LogSettings settings = HQ.Settings.Get <LogSettings>(); float height = settings.height; // An error occurred. if (this.error != null) { this.subHeight = settings.ContentStyle.CalcSize(new GUIContent(this.error)).y; } // Waiting for answer. else if (this.result == null) { this.subHeight = settings.ContentStyle.CalcSize(new GUIContent(this.log.file)).y; } // Answer received. else { this.subHeight = settings.ContentStyle.CalcSize(new GUIContent(this.result)).y; } height += this.subHeight; return(height); }
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(); } } }
/// <summary> /// Draws background when focus, even or odd. /// </summary> /// <param name="rowsDrawer">The drawer.</param> /// <param name="r">The area to work on.</param> /// <param name="streamIndex">Index from the RowsDrawer.rows[].</param> protected void DrawBackground(RowsDrawer rowsDrawer, Rect r, int streamIndex) { if (Event.current.type != EventType.Repaint) { return; } if (rowsDrawer.currentVars.IsSelected(streamIndex) == true) { if (EditorGUIUtility.keyboardControl != 0) { EditorGUI.DrawRect(r, HQ.Settings.Get <LogSettings>().selectedBackground * .8F); } else { EditorGUI.DrawRect(r, HQ.Settings.Get <LogSettings>().selectedBackground); } } else if ((streamIndex & 1) == 0) { EditorGUI.DrawRect(r, HQ.Settings.Get <LogSettings>().evenBackground); } else { EditorGUI.DrawRect(r, HQ.Settings.Get <LogSettings>().oddBackground); } }
public override float GetHeight(RowsDrawer rowsDrawer) { if (rowsDrawer.rowsData.ContainsKey(this) == true) { return(HQ.Settings.Get <LogSettings>().height + this.fieldsHeight); } return(HQ.Settings.Get <LogSettings>().height); }
public override float GetHeight(RowsDrawer rowsDrawer) { if (rowsDrawer.rowsData.ContainsKey(this) == true) { return(HQ.Settings.Get <LogSettings>().height + HQ.Settings.Get <StackTraceSettings>().height *this.Frames.Length); } return(HQ.Settings.Get <LogSettings>().height); }
public override float GetHeight(RowsDrawer rowsDrawer) { if (this.isOpened == true) { return(HQ.Settings.Get <LogSettings>().height + HQ.Settings.Get <StackTraceSettings>().height *this.Frames.Length); } return(HQ.Settings.Get <LogSettings>().height); }
public override float GetHeight(RowsDrawer rowsDrawer) { if (rowsDrawer.rowsData.ContainsKey(this) == true && this.root != null) { return(HQ.Settings.Get <LogSettings>().height + this.root.GetHeight()); } return(HQ.Settings.Get <LogSettings>().height); }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse) { LogSettings settings = HQ.Settings.Get <LogSettings>(); if (RemoteRow.LogPrefixHeight < 0F) { RemoteRow.LogPrefixHeight = settings.Style.CalcSize(RemoteRow.LogPrefix).x; } 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); this.HandleDefaultSelection(rowsDrawer, r, i); GUI.Label(r, this.log.condition, settings.Style); r.y += r.height; r.width = RemoteRow.LogPrefixHeight; // An error occurred. if (this.error != null) { GUI.Label(r, "<color=" + NGCLI.ErrorCommandColor + ">></color>", settings.Style); r.x += r.width; r.width = originWidth - r.x; r.height = this.subHeight; EditorGUI.SelectableLabel(r, this.error, settings.ContentStyle); } // Waiting for answer. else if (this.result == null) { GUI.Label(r, "<color=" + NGCLI.PendingCommandColor + ">></color>", settings.Style); r.x += r.width; r.width = originWidth - r.x; r.height = this.subHeight; // Use file to display the default value from RemoteCommand while waiting for the answer. EditorGUI.SelectableLabel(r, this.log.file, settings.ContentStyle); } // Answer received. else { GUI.Label(r, "<color=" + NGCLI.ReceivedCommandColor + ">></color>", settings.Style); r.x += r.width; r.width = originWidth - r.x; r.height = this.subHeight; EditorGUI.SelectableLabel(r, this.result, settings.ContentStyle); } }
public override float GetHeight(RowsDrawer rowsDrawer) { if (this.isOpened == false) { return(HQ.Settings.Get <LogSettings>().height); } else { return(HQ.Settings.Get <LogSettings>().height + this.fileLines.Count * HQ.Settings.Get <LogSettings>().height); } }
public StreamLog() { this.name = "New stream"; this.displayLog = true; this.displayWarning = true; this.displayError = true; this.displayException = true; this.addConsumedLog = false; this.consumeLog = false; this.rowsDrawer = new RowsDrawer(); this.groupFilters = new GroupFilters(); }
public static void ClearPreview() { if (RowUtility.previewLines == null) { return; } RowUtility.previewEditorWindow = null; RowUtility.previewLines = null; RowUtility.previewFrame = null; RowUtility.rowsDrawer.AfterAllRows -= RowUtility.DrawPreview; RowUtility.rowsDrawer = null; }
private void AppendColorsMenuItem(GenericMenu menu, RowsDrawer rowsDrawer, int streamIndex, Row row) { if (HQ.Settings == null) { return; } ColorMarkersModuleSettings settings = HQ.Settings.Get <ColorMarkersModuleSettings>(); for (int i = 0; i < settings.colorBackgrounds.Count; i++) { if (settings.colorBackgrounds[i].name != string.Empty) { menu.AddItem(new GUIContent(settings.nestedMenu == true ? "Colors/" + settings.colorBackgrounds[i].name : settings.colorBackgrounds[i].name), this.coloredRows.Exists((e) => e.i == i && e.row == row), this.ToggleColor, new object[] { rowsDrawer, streamIndex, row, i }); } } }
private void ToggleColor(object data) { object[] array = data as object[]; RowsDrawer rowsDrawer = array[0] as RowsDrawer; int consoleIndex = rowsDrawer[(int)array[1]]; Row row = array[2] as Row; int colorIndex = (int)array[3]; ColorMarkersModuleSettings settings = HQ.Settings.Get <ColorMarkersModuleSettings>(); List <ColorBackground> markers = settings.colorBackgrounds; ScrollbarInterests interests; if (this.rowsDrawerInterests.TryGetValue(rowsDrawer, out interests) == false) { interests = new ScrollbarInterests(); this.rowsDrawerInterests.Add(rowsDrawer, interests); } for (int j = 0; j < this.coloredRows.Count; j++) { if (this.coloredRows[j].row == row) { if (this.coloredRows[j].i == colorIndex) { interests.filterInterests.RemoveId(consoleIndex, 0F); this.coloredRows.RemoveAt(j); } else { interests.filterInterests.Add(8F + rowsDrawer.GetOffsetAtIndex(consoleIndex), markers[colorIndex].color, consoleIndex); this.coloredRows[j].i = colorIndex; } return; } } interests.filterInterests.Add(8F + rowsDrawer.GetOffsetAtIndex(consoleIndex), markers[colorIndex].color, consoleIndex); this.coloredRows.Add(new ColoredRow() { row = row, i = colorIndex }); }
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); }
private void CopyAllFullExplodedJSON(object _rowsDrawer) { RowsDrawer rowsDrawer = _rowsDrawer as RowsDrawer; StringBuilder buffer = Utility.GetBuffer(); rowsDrawer.currentVars.selectedLogs.Sort(); foreach (int streamIndex in rowsDrawer.currentVars.selectedLogs) { Row r = rowsDrawer.rows.GetRow(rowsDrawer[streamIndex]); buffer.AppendLine(r.Command(JSONRow.CopyFullExplodedJSONCommand, r).ToString()); } if (buffer.Length > Environment.NewLine.Length) { buffer.Length -= Environment.NewLine.Length; } EditorGUIUtility.systemCopyBuffer = (string)Utility.ReturnBuffer(buffer); }
/// <summary> /// Returns the current height of the <paramref name="row"/>. /// </summary> /// <param name="rowsDrawer">The drawer.</param> /// <param name="row"></param> /// <returns></returns> public abstract float GetHeight(RowsDrawer rowsDrawer);
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; } } }
/// <summary> /// </summary> /// <param name="rowsDrawer">The drawer.</param> /// <param name="rect">The area to work on.</param> /// <param name="streamIndex">Index from the RowsDrawer.rows[].</param> /// <param name="collapse">Defines if row should displayed its collapse label. Do not used it.</param> public abstract void DrawRow(RowsDrawer rowsDrawer, Rect rect, int streamIndex, bool?collapse);
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse) { }
public override float GetHeight(RowsDrawer rowsDrawer) { return(this.height); }
private void ArchiveFromContextMenu(GenericMenu menu, RowsDrawer rowsDrawer, int streamIndex, Row row) { LogNote log = this.GetLogFromRow(row); menu.AddItem(new GUIContent("Archive log"), log != null, this.ToggleRowFromArchive, row); }
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 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) { 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) { 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); } }