From aa59a6faf7f8a3c9b075ae402f57f0f23290efaf Mon Sep 17 00:00:00 2001 From: Zode Date: Wed, 11 Jun 2025 17:46:37 +0300 Subject: [PATCH 1/3] Extract function to lessen repeat code for debug group buttons, add shift functionality to quick toggle others. --- Source/Editor/Windows/DebugLogWindow.cs | 45 +++++++++++++++---------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index fd6b333ef..d0680c3c0 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -352,24 +352,12 @@ namespace FlaxEditor.Windows editor.Options.Apply(editor.Options.Options); }).SetAutoCheck(true).LinkTooltip("Performs auto pause on error"); toolstrip.AddSeparator(); - _groupButtons[0] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Error32, () => - { - UpdateLogTypeVisibility(LogGroup.Error, _groupButtons[0].Checked); - editor.Options.Options.Interface.DebugLogShowErrorMessages = _groupButtons[0].Checked; - editor.Options.Apply(editor.Options.Options); - }).SetAutoCheck(true).LinkTooltip("Shows/hides error messages"); - _groupButtons[1] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Warning32, () => - { - UpdateLogTypeVisibility(LogGroup.Warning, _groupButtons[1].Checked); - editor.Options.Options.Interface.DebugLogShowWarningMessages = _groupButtons[1].Checked; - editor.Options.Apply(editor.Options.Options); - }).SetAutoCheck(true).LinkTooltip("Shows/hides warning messages"); - _groupButtons[2] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Info32, () => - { - UpdateLogTypeVisibility(LogGroup.Info, _groupButtons[2].Checked); - editor.Options.Options.Interface.DebugLogShowInfoMessages = _groupButtons[2].Checked; - editor.Options.Apply(editor.Options.Options); - }).SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); + _groupButtons[0] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Error32, () => { OnGroupButtonPressed(0); }) + .SetAutoCheck(true).LinkTooltip("Shows/hides error messages"); + _groupButtons[1] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Warning32, () => { OnGroupButtonPressed(1); }) + .SetAutoCheck(true).LinkTooltip("Shows/hides warning messages"); + _groupButtons[2] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Info32, () => { OnGroupButtonPressed(2); }) + .SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); UpdateCount(); // Split panel @@ -418,6 +406,27 @@ namespace FlaxEditor.Windows OnEditorOptionsChanged(Editor.Options.Options); } + private void OnGroupButtonPressed(int index) + { + UpdateLogTypeVisibility((LogGroup)index, _groupButtons[index].Checked); + if(Input.GetKey(KeyboardKeys.Shift)) + { + for(int i = 0; i < (int)LogGroup.Max; i++) + { + if(i == index) + continue; + + _groupButtons[i].Checked = !_groupButtons[index].Checked; + UpdateLogTypeVisibility((LogGroup)i, _groupButtons[i].Checked); + } + } + + Editor.Options.Options.Interface.DebugLogShowErrorMessages = _groupButtons[0].Checked; + Editor.Options.Options.Interface.DebugLogShowWarningMessages = _groupButtons[1].Checked; + Editor.Options.Options.Interface.DebugLogShowInfoMessages = _groupButtons[2].Checked; + Editor.Options.Apply(Editor.Options.Options); + } + private void OnEditorOptionsChanged(EditorOptions options) { _timestampsFormats = options.Interface.DebugLogTimestampsFormat; From 00055ef66329437d044ea290e52a833fe71d35aa Mon Sep 17 00:00:00 2001 From: Zode Date: Wed, 11 Jun 2025 17:47:27 +0300 Subject: [PATCH 2/3] Make tool strip buttons more responsive by also reaction to double left clicks --- Source/Editor/GUI/ToolStripButton.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/Editor/GUI/ToolStripButton.cs b/Source/Editor/GUI/ToolStripButton.cs index 9ef454ccc..56e798a2e 100644 --- a/Source/Editor/GUI/ToolStripButton.cs +++ b/Source/Editor/GUI/ToolStripButton.cs @@ -215,6 +215,22 @@ namespace FlaxEditor.GUI return base.OnMouseUp(location, button); } + /// + public override bool OnMouseDoubleClick(Float2 location, MouseButton button) + { + if(button == MouseButton.Left) + { + if (AutoCheck) + Checked = !Checked; + Clicked?.Invoke(); + (Parent as ToolStrip)?.OnButtonClicked(this); + + return true; + } + + return false; + } + /// public override void OnMouseLeave() { From 648504ceb113ba21d46b324f3e56acfd7e7772c6 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 15 Jun 2025 20:31:04 +0200 Subject: [PATCH 3/3] Format code #3544 --- Source/Editor/GUI/ToolStripButton.cs | 24 ++++++++--------- Source/Editor/Windows/DebugLogWindow.cs | 34 ++++++++++--------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Source/Editor/GUI/ToolStripButton.cs b/Source/Editor/GUI/ToolStripButton.cs index 56e798a2e..c49cddcbb 100644 --- a/Source/Editor/GUI/ToolStripButton.cs +++ b/Source/Editor/GUI/ToolStripButton.cs @@ -122,6 +122,14 @@ namespace FlaxEditor.GUI return this; } + private void OnClicked() + { + if (AutoCheck) + Checked = !Checked; + Clicked?.Invoke(); + (Parent as ToolStrip)?.OnButtonClicked(this); + } + /// public override void Draw() { @@ -196,11 +204,7 @@ namespace FlaxEditor.GUI if (button == MouseButton.Left && _primaryMouseDown) { _primaryMouseDown = false; - if (AutoCheck) - Checked = !Checked; - Clicked?.Invoke(); - (Parent as ToolStrip)?.OnButtonClicked(this); - + OnClicked(); return true; } if (button == MouseButton.Right && _secondaryMouseDown) @@ -218,16 +222,12 @@ namespace FlaxEditor.GUI /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - if(button == MouseButton.Left) + if (button == MouseButton.Left) { - if (AutoCheck) - Checked = !Checked; - Clicked?.Invoke(); - (Parent as ToolStrip)?.OnButtonClicked(this); - + OnClicked(); return true; } - + return false; } diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index d0680c3c0..b5d71f6a0 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -318,7 +318,7 @@ namespace FlaxEditor.Windows private Color _colorWarning; private Color _colorError; private bool _colorDebugLogText; - + /// /// Initializes a new instance of the class. /// @@ -353,11 +353,11 @@ namespace FlaxEditor.Windows }).SetAutoCheck(true).LinkTooltip("Performs auto pause on error"); toolstrip.AddSeparator(); _groupButtons[0] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Error32, () => { OnGroupButtonPressed(0); }) - .SetAutoCheck(true).LinkTooltip("Shows/hides error messages"); + .SetAutoCheck(true).LinkTooltip("Shows/hides error messages"); _groupButtons[1] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Warning32, () => { OnGroupButtonPressed(1); }) - .SetAutoCheck(true).LinkTooltip("Shows/hides warning messages"); + .SetAutoCheck(true).LinkTooltip("Shows/hides warning messages"); _groupButtons[2] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Info32, () => { OnGroupButtonPressed(2); }) - .SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); + .SetAutoCheck(true).LinkTooltip("Shows/hides info messages"); UpdateCount(); // Split panel @@ -409,21 +409,21 @@ namespace FlaxEditor.Windows private void OnGroupButtonPressed(int index) { UpdateLogTypeVisibility((LogGroup)index, _groupButtons[index].Checked); - if(Input.GetKey(KeyboardKeys.Shift)) + if (Input.GetKey(KeyboardKeys.Shift)) { - for(int i = 0; i < (int)LogGroup.Max; i++) + for (int i = 0; i < (int)LogGroup.Max; i++) { - if(i == index) + if (i == index) continue; - _groupButtons[i].Checked = !_groupButtons[index].Checked; UpdateLogTypeVisibility((LogGroup)i, _groupButtons[i].Checked); } } - Editor.Options.Options.Interface.DebugLogShowErrorMessages = _groupButtons[0].Checked; - Editor.Options.Options.Interface.DebugLogShowWarningMessages = _groupButtons[1].Checked; - Editor.Options.Options.Interface.DebugLogShowInfoMessages = _groupButtons[2].Checked; + var options = Editor.Options.Options.Interface; + options.DebugLogShowErrorMessages = _groupButtons[0].Checked; + options.DebugLogShowWarningMessages = _groupButtons[1].Checked; + options.DebugLogShowInfoMessages = _groupButtons[2].Checked; Editor.Options.Apply(Editor.Options.Options); } @@ -464,15 +464,9 @@ namespace FlaxEditor.Windows // Create new entry switch (_timestampsFormats) { - case InterfaceOptions.TimestampsFormats.Utc: - desc.Title = $"[{DateTime.UtcNow}] {desc.Title}"; - break; - case InterfaceOptions.TimestampsFormats.LocalTime: - desc.Title = $"[{DateTime.Now}] {desc.Title}"; - break; - case InterfaceOptions.TimestampsFormats.TimeSinceStartup: - desc.Title = string.Format("[{0:g}] ", TimeSpan.FromSeconds(Time.TimeSinceStartup)) + desc.Title; - break; + case InterfaceOptions.TimestampsFormats.Utc: desc.Title = $"[{DateTime.UtcNow}] {desc.Title}"; break; + case InterfaceOptions.TimestampsFormats.LocalTime: desc.Title = $"[{DateTime.Now}] {desc.Title}"; break; + case InterfaceOptions.TimestampsFormats.TimeSinceStartup: desc.Title = string.Format("[{0:g}] ", TimeSpan.FromSeconds(Time.TimeSinceStartup)) + desc.Title; break; } var newEntry = new LogEntry(this, ref desc);