From 608839b6a5eb547929dfe0c270c0a1f6cf0697ae Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 2 Jun 2025 22:33:22 +0200 Subject: [PATCH 1/4] set width of command suggestions based on longest command --- Source/Editor/Windows/OutputLogWindow.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 6fc0659d7..5c6e9a27e 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -233,7 +233,10 @@ namespace FlaxEditor.Windows else cm.ClearItems(); + float longestItemWidth = 0.0f; + // Add items + var font = Style.Current.FontMedium; ItemsListContextMenu.Item lastItem = null; foreach (var command in commands) { @@ -244,7 +247,7 @@ namespace FlaxEditor.Windows }); var flags = DebugCommands.GetCommandFlags(command); if (flags.HasFlag(DebugCommands.CommandFlags.Exec)) - lastItem.TintColor = new Color(0.85f, 0.85f, 1.0f, 1.0f); + lastItem.TintColor = new Color(0.75f, 0.75f, 1.0f, 1.0f); else if (flags.HasFlag(DebugCommands.CommandFlags.Read) && !flags.HasFlag(DebugCommands.CommandFlags.Write)) lastItem.TintColor = new Color(0.85f, 0.85f, 0.85f, 1.0f); lastItem.Focused += item => @@ -252,6 +255,10 @@ namespace FlaxEditor.Windows // Set command Set(item.Name); }; + + float width = font.MeasureText(command).X; + if (width > longestItemWidth) + longestItemWidth = width; } cm.ItemClicked += item => { @@ -262,6 +269,10 @@ namespace FlaxEditor.Windows // Setup popup var count = commands.Count(); var totalHeight = count * lastItem.Height + cm.ItemsPanel.Margin.Height + cm.ItemsPanel.Spacing * (count - 1); + + // Account for scroll bars taking up a part of the width + longestItemWidth += 25f; + cm.Width = longestItemWidth; cm.Height = 220; if (cm.Height > totalHeight) cm.Height = totalHeight; // Limit popup height if list is small From c9fe9213b33835e79432d5a4c801efd83c4aba62 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 2 Jun 2025 23:25:50 +0200 Subject: [PATCH 2/4] add showing all commands if prompt is whitespace(s) --- Source/Editor/Windows/OutputLogWindow.cs | 11 ++++++++--- Source/Engine/Debug/DebugCommands.cpp | 11 +++++++++++ Source/Engine/Debug/DebugCommands.h | 7 +++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 5c6e9a27e..7d3dfa644 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -325,12 +325,17 @@ namespace FlaxEditor.Windows // Show commands search popup based on current text input var text = Text.Trim(); - if (text.Length != 0) + bool isWhitespaceOnly = string.IsNullOrWhiteSpace(Text) && !string.IsNullOrEmpty(Text); + if (text.Length != 0 || isWhitespaceOnly) { DebugCommands.Search(text, out var matches); - if (matches.Length != 0) + if (matches.Length != 0 || isWhitespaceOnly) { - ShowPopup(ref _searchPopup, matches, text); + string[] commands = []; + if (isWhitespaceOnly) + DebugCommands.GetAllCommands(out commands); + + ShowPopup(ref _searchPopup, isWhitespaceOnly ? commands : matches, isWhitespaceOnly ? commands[0] : text); return; } } diff --git a/Source/Engine/Debug/DebugCommands.cpp b/Source/Engine/Debug/DebugCommands.cpp index 5d94cf557..9c66341ab 100644 --- a/Source/Engine/Debug/DebugCommands.cpp +++ b/Source/Engine/Debug/DebugCommands.cpp @@ -435,6 +435,17 @@ void DebugCommands::InitAsync() AsyncTask = Task::StartNew(InitCommands); } +void DebugCommands::GetAllCommands(Array& commands) +{ + EnsureInited(); + ScopeLock lock(Locker); + + for (auto& command : Commands) + { + commands.Add(command.Name); + } +} + DebugCommands::CommandFlags DebugCommands::GetCommandFlags(StringView command) { CommandFlags result = CommandFlags::None; diff --git a/Source/Engine/Debug/DebugCommands.h b/Source/Engine/Debug/DebugCommands.h index 73b2def69..6028ab9d8 100644 --- a/Source/Engine/Debug/DebugCommands.h +++ b/Source/Engine/Debug/DebugCommands.h @@ -46,6 +46,13 @@ public: /// API_FUNCTION() static void InitAsync(); + /// + /// Gets all available commands. + /// + /// The output list of all commands (unsorted). + /// TODO. + API_FUNCTION() static void GetAllCommands(API_PARAM(Out) Array& commands); + /// /// Returns flags of the command. /// From c4130aa20f649b64649d4c3e901c6546a1f50afd Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Wed, 4 Jun 2025 15:23:42 +0200 Subject: [PATCH 3/4] fix and improve show all commands on " " behavior --- Source/Editor/Windows/OutputLogWindow.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 7d3dfa644..f1efebeb4 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -335,7 +335,15 @@ namespace FlaxEditor.Windows if (isWhitespaceOnly) DebugCommands.GetAllCommands(out commands); - ShowPopup(ref _searchPopup, isWhitespaceOnly ? commands : matches, isWhitespaceOnly ? commands[0] : text); + ShowPopup(ref _searchPopup, isWhitespaceOnly ? commands : matches, text); + + if (isWhitespaceOnly) + { + // Scroll to and select first item for consistent behaviour + var firstItem = _searchPopup.ItemsPanel.Children[0] as Item; + _searchPopup.ScrollToAndHighlightItemByName(firstItem.Name); + } + return; } } From ec154b4998415c218dc5017a72813ab43407ae15 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Thu, 12 Jun 2025 19:31:32 +0200 Subject: [PATCH 4/4] remove unnecessary returns xml doc comment --- Source/Engine/Debug/DebugCommands.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Engine/Debug/DebugCommands.h b/Source/Engine/Debug/DebugCommands.h index 6028ab9d8..cfe70db73 100644 --- a/Source/Engine/Debug/DebugCommands.h +++ b/Source/Engine/Debug/DebugCommands.h @@ -50,7 +50,6 @@ public: /// Gets all available commands. /// /// The output list of all commands (unsorted). - /// TODO. API_FUNCTION() static void GetAllCommands(API_PARAM(Out) Array& commands); ///