From f18340a00b4e4cd4933ceef8a5c9980d125f6f6a Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:33:34 +1000 Subject: [PATCH] add icon with custom draw --- ...iablesSubTab.DebuggerVariableCustomDraw.cs | 20 +++++++++++++++++++ .../Tab/SubTabs/ThreadsVariablesSubTab.cs | 16 ++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs index 438cc5e..84d5b17 100644 --- a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs @@ -1,4 +1,5 @@ using Godot; +using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages; namespace SharpIDE.Godot.Features.Debug_.Tab.SubTabs; @@ -12,6 +13,21 @@ public partial class ThreadsVariablesSubTab { var variable = _variableReferenceLookup.GetValueOrDefault(treeItem); if (variable is null) return; + + const int iconSize = 18; + var icon = variable.PresentationHint?.Kind switch + { + VariablePresentationHint.KindValue.Data => _fieldIcon, + VariablePresentationHint.KindValue.Property => _propertyIcon, + VariablePresentationHint.KindValue.Class => _staticMembersIcon, + _ => null + }; + if (icon is null) + { + // unlike sharpdbg and presumably vsdbg, netcoredbg does not set PresentationHint for variables + if (variable.Name == "Static members") icon = _staticMembersIcon; // Will not currently occur, as 'Static members' are not handled by this custom draw + else icon = _fieldIcon; + } var font = _variablesTree.GetThemeFont(ThemeStringNames.Font); var fontSize = _variablesTree.GetThemeFontSize(ThemeStringNames.FontSize); @@ -20,6 +36,10 @@ public partial class ThreadsVariablesSubTab var currentX = rect.Position.X + padding; var textYPos = rect.Position.Y + (rect.Size.Y + fontSize) / 2 - 2; + var iconRect = new Rect2(currentX, rect.Position.Y + (rect.Size.Y - iconSize) / 2, iconSize, iconSize); + _variablesTree.DrawTextureRect(icon, iconRect, false); + currentX += iconSize + padding; + _variablesTree.DrawString(font, new Vector2(currentX, textYPos), variable.Name, HorizontalAlignment.Left, -1, fontSize, VariableNameColor); var variableNameDrawnSize = font.GetStringSize(variable.Name, HorizontalAlignment.Left, -1, fontSize).X; diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs index 7dde0d2..ceaba7b 100644 --- a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs @@ -142,24 +142,12 @@ public partial class ThreadsVariablesSubTab : Control { var variableItem = _variablesTree.CreateItem(parentItem); _variableReferenceLookup[variableItem] = variable; - var icon = variable.PresentationHint?.Kind switch - { - VariablePresentationHint.KindValue.Data => _fieldIcon, - VariablePresentationHint.KindValue.Property => _propertyIcon, - VariablePresentationHint.KindValue.Class => _staticMembersIcon, - _ => null - }; - if (icon is null) - { - // unlike sharpdbg and presumably vsdbg, netcoredbg does not set PresentationHint for variables - if (variable.Name == "Static members") icon = _staticMembersIcon; - else icon = _fieldIcon; - } - variableItem.SetIcon(0, icon); + variableItem.SetMetadata(0, new Vector2I(0, variable.VariablesReference)); if (variable.Name == "Static members") { variableItem.SetTooltipText(0, null); + variableItem.SetIcon(0, _staticMembersIcon); variableItem.SetText(0, "Static members"); } else