diff --git a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.SelectionChanged.cs.uid b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.SelectionChanged.cs.uid new file mode 100644 index 0000000..9db909d --- /dev/null +++ b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.SelectionChanged.cs.uid @@ -0,0 +1 @@ +uid://b7whlycv5lu0t diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs new file mode 100644 index 0000000..438cc5e --- /dev/null +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs @@ -0,0 +1,38 @@ +using Godot; + +namespace SharpIDE.Godot.Features.Debug_.Tab.SubTabs; + +public partial class ThreadsVariablesSubTab +{ + private static readonly Color VariableNameColor = new Color("f0ac81"); + private static readonly Color VariableWhiteColor = new Color("d4d4d4"); + private static readonly Color VariableTypeColor = new Color("70737a"); + + private void DebuggerVariableCustomDraw(TreeItem treeItem, Rect2 rect) + { + var variable = _variableReferenceLookup.GetValueOrDefault(treeItem); + if (variable is null) return; + + var font = _variablesTree.GetThemeFont(ThemeStringNames.Font); + var fontSize = _variablesTree.GetThemeFontSize(ThemeStringNames.FontSize); + const float padding = 4.0f; + + var currentX = rect.Position.X + padding; + var textYPos = rect.Position.Y + (rect.Size.Y + fontSize) / 2 - 2; + + _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; + currentX += variableNameDrawnSize; + _variablesTree.DrawString(font, new Vector2(currentX, textYPos), " = ", HorizontalAlignment.Left, -1, fontSize, + VariableWhiteColor); + currentX += font.GetStringSize(" = ", HorizontalAlignment.Left, -1, fontSize).X; + _variablesTree.DrawString(font, new Vector2(currentX, textYPos), $"{{{variable.Type}}} ", + HorizontalAlignment.Left, -1, fontSize, VariableTypeColor); + var variableTypeDrawnSize = + font.GetStringSize($"{{{variable.Type}}} ", HorizontalAlignment.Left, -1, fontSize).X; + currentX += variableTypeDrawnSize; + _variablesTree.DrawString(font, new Vector2(currentX, textYPos), variable.Value, HorizontalAlignment.Left, -1, + fontSize, VariableWhiteColor); + } +} \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs.uid b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs.uid new file mode 100644 index 0000000..6e2b253 --- /dev/null +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.DebuggerVariableCustomDraw.cs.uid @@ -0,0 +1 @@ +uid://nsu1apfuftmd diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs index 289479a..168e9eb 100644 --- a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs @@ -26,7 +26,7 @@ public partial class ThreadsVariablesSubTab : Control [Inject] private readonly RunService _runService = null!; private Callable? _debuggerVariableCustomDrawCallable; - private Dictionary _variableReferenceLookup = []; // primarily used for DebuggerVariableCustomDraw + private readonly Dictionary _variableReferenceLookup = []; // primarily used for DebuggerVariableCustomDraw public override void _Ready() { @@ -42,32 +42,6 @@ public partial class ThreadsVariablesSubTab : Control Project.ProjectStoppedRunning.Subscribe(ClearAllTrees); } - private static readonly Color VariableNameColor = new Color("f0ac81"); - private static readonly Color VariableWhiteColor = new Color("d4d4d4"); - private static readonly Color VariableTypeColor = new Color("70737a"); - private void DebuggerVariableCustomDraw(TreeItem treeItem, Rect2 rect) - { - var variable = _variableReferenceLookup.GetValueOrDefault(treeItem); - if (variable is null) return; - - var font = _variablesTree.GetThemeFont(ThemeStringNames.Font); - var fontSize = _variablesTree.GetThemeFontSize(ThemeStringNames.FontSize); - const float padding = 4.0f; - - var currentX = rect.Position.X + padding; - var textYPos = rect.Position.Y + (rect.Size.Y + fontSize) / 2 - 2; - - _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; - currentX += variableNameDrawnSize; - _variablesTree.DrawString(font, new Vector2(currentX, textYPos), " = ", HorizontalAlignment.Left, -1, fontSize, VariableWhiteColor); - currentX += font.GetStringSize(" = ", HorizontalAlignment.Left, -1, fontSize).X; - _variablesTree.DrawString(font, new Vector2(currentX, textYPos), $"{{{variable.Type}}} ", HorizontalAlignment.Left, -1, fontSize, VariableTypeColor); - var variableTypeDrawnSize = font.GetStringSize($"{{{variable.Type}}} ", HorizontalAlignment.Left, -1, fontSize).X; - currentX += variableTypeDrawnSize; - _variablesTree.DrawString(font, new Vector2(currentX, textYPos), variable.Value, HorizontalAlignment.Left, -1, fontSize, VariableWhiteColor); - } - private void OnVariablesItemExpandedOrCollapsed(TreeItem item) { var wasExpanded = item.IsCollapsed() is false; @@ -110,6 +84,7 @@ public partial class ThreadsVariablesSubTab : Control _threadsTree.Clear(); _stackFramesTree.Clear(); _variablesTree.Clear(); + _variableReferenceLookup.Clear(); }); }