From e26e9dbd9f18e15a9e98a6cdc38b2822b90c6eea Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Wed, 27 Aug 2025 21:05:35 +1000 Subject: [PATCH] handle button toggling --- .../Features/BottomPanel/BottomPanelManager.cs | 8 +++----- .../LeftSideBar/LeftBottomSidebarButtonGroup.tres | 4 ++++ src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs | 7 ++++--- src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.tscn | 6 +++++- src/SharpIDE.Godot/GodotGlobalEvents.cs | 4 ++-- 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 src/SharpIDE.Godot/Features/LeftSideBar/LeftBottomSidebarButtonGroup.tres diff --git a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs index 80748fe..84b6cc2 100644 --- a/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs +++ b/src/SharpIDE.Godot/Features/BottomPanel/BottomPanelManager.cs @@ -9,7 +9,6 @@ public partial class BottomPanelManager : Panel private Control _problemsPanel = null!; private Dictionary _panelTypeMap = []; - private BottomPanelType? _currentPanelType = BottomPanelType.Run; public override void _Ready() { @@ -23,16 +22,15 @@ public partial class BottomPanelManager : Panel { BottomPanelType.Problems, _problemsPanel } }; - GodotGlobalEvents.LeftSideBarButtonClicked += OnLeftSideBarButtonClicked; + GodotGlobalEvents.BottomPanelTabSelected += OnBottomPanelTabSelected; } - private async Task OnLeftSideBarButtonClicked(BottomPanelType type) + private async Task OnBottomPanelTabSelected(BottomPanelType? type) { await this.InvokeAsync(() => { - if (type == _currentPanelType) + if (type == null) { - _currentPanelType = null; // TODO: Ask parent to to collapse slider. } foreach (var kvp in _panelTypeMap) diff --git a/src/SharpIDE.Godot/Features/LeftSideBar/LeftBottomSidebarButtonGroup.tres b/src/SharpIDE.Godot/Features/LeftSideBar/LeftBottomSidebarButtonGroup.tres new file mode 100644 index 0000000..5c90e98 --- /dev/null +++ b/src/SharpIDE.Godot/Features/LeftSideBar/LeftBottomSidebarButtonGroup.tres @@ -0,0 +1,4 @@ +[gd_resource type="ButtonGroup" format=3 uid="uid://c2nmo2x3va0gi"] + +[resource] +allow_unpress = true diff --git a/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs b/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs index 298bde1..e8c6959 100644 --- a/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs +++ b/src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs @@ -5,6 +5,7 @@ namespace SharpIDE.Godot.Features.LeftSideBar; public partial class LeftSideBar : Panel { private Button _slnExplorerButton = null!; + // These are in a ButtonGroup, which handles mutual exclusivity of being toggled on private Button _problemsButton = null!; private Button _runButton = null!; private Button _buildButton = null!; @@ -16,8 +17,8 @@ public partial class LeftSideBar : Panel _runButton = GetNode