From 608839b6a5eb547929dfe0c270c0a1f6cf0697ae Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 2 Jun 2025 22:33:22 +0200 Subject: [PATCH] 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