diff --git a/Source/Editor/Options/VisualOptions.cs b/Source/Editor/Options/VisualOptions.cs index e0f0982f4..463dda590 100644 --- a/Source/Editor/Options/VisualOptions.cs +++ b/Source/Editor/Options/VisualOptions.cs @@ -106,28 +106,28 @@ namespace FlaxEditor.Options /// Gets or sets the output log text color. /// [DefaultValue(typeof(Color), "1,1,1,1")] - [EditorDisplay("Log", "Info Color"), EditorOrder(1500), Tooltip("The color used for info messages in the Debug and Output Log.")] + [EditorDisplay("Debug Log", "Info Color"), EditorOrder(1500), Tooltip("The color used for info messages in the Debug and Output Log.")] public Color LogInfoColor { get; set; } = Color.White; /// /// Gets or sets the output log text color for warnings /// [DefaultValue(typeof(Color), "1,1,0,1")] - [EditorDisplay("Log", "Warning Color"), EditorOrder(1501), Tooltip("The color used for warnings in the Debug and Output Log.")] + [EditorDisplay("Debug Log", "Warning Color"), EditorOrder(1501), Tooltip("The color used for warnings in the Debug and Output Log.")] public Color LogWarningColor { get; set; } = Color.Yellow; /// /// Gets or sets the output log text color for errors /// [DefaultValue(typeof(Color), "1,0,0,1")] - [EditorDisplay("Log", "Error Color"), EditorOrder(1502), Tooltip("The color used for errors in the Debug and Output Log.")] + [EditorDisplay("Debug Log", "Error Color"), EditorOrder(1502), Tooltip("The color used for errors in the Debug and Output Log.")] public Color LogErrorColor { get; set; } = Color.Red; /// - /// Gets or sets a value wether the Debug Log entry text color should use the set color. + /// Gets or sets a value whether the Debug Log entry text color should use the set color. /// [DefaultValue(true)] - [EditorDisplay("Log", "Color Debug Log Text"), EditorOrder(1503), Tooltip("Wether to use the set colors in the text of a Debug Log entry.")] + [EditorDisplay("Debug Log", "Color Debug Log Text"), EditorOrder(1503), Tooltip("Wether to use the set colors in the text of a Debug Log entry.")] public bool ColorDebugLogText = true; } } diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index 5b5abf1e2..5183b7454 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -77,11 +77,14 @@ namespace FlaxEditor.Windows public const float DefaultHeight = 32.0f; private DebugLogWindow _window; + private RichTextBox _richTextBox; public LogGroup Group; public LogEntryDescription Desc; public SpriteHandle Icon; public int LogCount = 1; + private Color Color => Group == LogGroup.Error ? _window._colorError : (Group == LogGroup.Warning ? _window._colorWarning : _window._colorInfo); + public LogEntry(DebugLogWindow window, ref LogEntryDescription desc) : base(0, 0, 120, DefaultHeight) { @@ -106,6 +109,24 @@ namespace FlaxEditor.Windows Icon = _window._iconError; break; } + + // Use Rich Text Box to display title if it contains any HTML tags + if (desc.Title.Contains('<') && desc.Title.Contains('>')) + { + _richTextBox = new RichTextBox + { + ClipText = false, + HasBorder = false, + BackgroundColor = Color.Transparent, + Text = desc.Title, + }; + if (_window._colorDebugLogText) + { + var style = _richTextBox.TextStyle; + style.Color = Color; + _richTextBox.TextStyle = style; + } + } } /// @@ -116,12 +137,10 @@ namespace FlaxEditor.Windows /// public override void Draw() { - base.Draw(); - - // Cache data var style = Style.Current; var index = IndexInParent; var clientRect = new Rectangle(Float2.Zero, Size); + var color = Color; // Background if (_window._selected == this) @@ -136,8 +155,6 @@ namespace FlaxEditor.Windows else if (index % 2 == 0) Render2D.FillRectangle(clientRect, style.Background * 0.9f); - var color = Group == LogGroup.Error ? _window._colorError : (Group == LogGroup.Warning ? _window._colorWarning : _window._colorInfo); - // Icon Render2D.DrawSprite(Icon, new Rectangle(8, 0, 32, 32), color); @@ -145,14 +162,37 @@ namespace FlaxEditor.Windows var textRect = new Rectangle(43, 2, clientRect.Width - 40, clientRect.Height - 10); Render2D.PushClip(ref clientRect); bool coloredText = _window._colorDebugLogText; - if (LogCount == 1) + if (_richTextBox != null) + { + Render2D.PushTransform(Matrix3x3.Translation2D(textRect.Location)); + _richTextBox.DrawSelf(); + Render2D.PopTransform(); + } + else { Render2D.DrawText(style.FontMedium, Desc.Title, textRect, coloredText ? color : style.Foreground); } - else if (LogCount > 1) + + // Adding log counter for collapsed logs + if (LogCount > 1) { - Render2D.DrawText(style.FontMedium, $"{Desc.Title} ({LogCount})", textRect, coloredText ? color : style.Foreground); + Float2 logCountPos = Float2.Zero; + if (_richTextBox != null) + { + var blocks = _richTextBox.TextBlocks; + if (blocks.Count != 0) + { + var block = blocks[^1]; + logCountPos = new Float2(block.Bounds.Right, block.Bounds.Top); + } + } + else + { + logCountPos.X = style.FontMedium.MeasureText(Desc.Title).X; + } + Render2D.DrawText(style.FontMedium, $" ({LogCount})", color, textRect.Location + logCountPos); } + Render2D.PopClip(); } @@ -291,6 +331,18 @@ namespace FlaxEditor.Windows base.OnMouseLeave(); } + + /// + public override void OnDestroy() + { + if (_richTextBox != null) + { + _richTextBox.OnDestroy(); + _richTextBox = null; + } + + base.OnDestroy(); + } } private readonly SplitPanel _split; diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs index 97e1d88a5..b83a89943 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs @@ -29,6 +29,11 @@ namespace FlaxEngine.GUI [HideInEditor] public ParseTextBlocksDelegate ParseTextBlocks; + /// + /// Gets the list of parsed text blocks. + /// + public List TextBlocks => _textBlocks; + /// /// Initializes a new instance of the class. ///