add icon with custom draw
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user