Skip to content

Commit 76430f7

Browse files
committed
Enhance debug GUI: dynamically adjust message column width
1 parent e38645c commit 76430f7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

c_debugGUI.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,8 @@ function updateDebugGridList(searchText)
10691069

10701070
guiGridListClear(debugGrid)
10711071

1072+
local longestTextLength = 0 -- Track the longest text length
1073+
10721074
for _, msg in ipairs(debugMessages) do
10731075
local debugLevel = DEBUG_LEVELS[msg.level].level
10741076

@@ -1078,13 +1080,21 @@ function updateDebugGridList(searchText)
10781080
guiGridListSetItemText(debugGrid, row, 1, msg.time, false, false)
10791081
guiGridListSetItemText(debugGrid, row, 2, msg.level, false, false)
10801082
guiGridListSetItemText(debugGrid, row, 3, msg.displayMessage, false, false)
1083+
1084+
longestTextLength = math.max(longestTextLength, #msg.displayMessage)
1085+
10811086
local r, g, b = hexToRGB(msg.color)
10821087
for col = 1, 3 do
10831088
guiGridListSetItemColor(debugGrid, row, col, r * 255, g * 255, b * 255, 255)
10841089
end
10851090
end
10861091
end
10871092

1093+
-- Dynamically adjust the third column width based on the longest text
1094+
local charWidth = 8 -- Approximate width of a character in pixels
1095+
local minWidth = 200 -- Minimum width for the message column
1096+
local newWidth = math.max(minWidth, math.min(longestTextLength * charWidth, panelWidth - 50))
1097+
guiGridListSetColumnWidth(debugGrid, 3, newWidth, false)
10881098

10891099
setTimer(function()
10901100
guiGridListSetVerticalScrollPosition(debugGrid, 100)

0 commit comments

Comments
 (0)