change toggle button state externally
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Ardalis.GuardClauses;
|
||||
using Godot;
|
||||
|
||||
namespace SharpIDE.Godot.Features.LeftSideBar;
|
||||
@@ -20,5 +21,20 @@ public partial class LeftSideBar : Panel
|
||||
_problemsButton.Toggled += toggledOn => GodotGlobalEvents.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Problems : null);
|
||||
_runButton.Toggled += toggledOn => GodotGlobalEvents.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Run : null);
|
||||
_buildButton.Toggled += toggledOn => GodotGlobalEvents.InvokeBottomPanelTabSelected(toggledOn ? BottomPanelType.Build : null);
|
||||
GodotGlobalEvents.BottomPanelTabExternallySelected += OnBottomPanelTabExternallySelected;
|
||||
}
|
||||
|
||||
private async Task OnBottomPanelTabExternallySelected(BottomPanelType arg)
|
||||
{
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
switch (arg)
|
||||
{
|
||||
case BottomPanelType.Run: _runButton.ButtonPressed = true; break;
|
||||
case BottomPanelType.Build: _buildButton.ButtonPressed = true; break;
|
||||
case BottomPanelType.Problems: _problemsButton.ButtonPressed = true; break;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(arg), arg, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public partial class RunMenuItem : HBoxContainer
|
||||
|
||||
private async void OnRunButtonPressed()
|
||||
{
|
||||
GodotGlobalEvents.InvokeBottomPanelTabSelected(BottomPanelType.Run);
|
||||
GodotGlobalEvents.InvokeBottomPanelTabExternallySelected(BottomPanelType.Run);
|
||||
await Singletons.RunService.RunProject(Project).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
public static class GodotGlobalEvents
|
||||
{
|
||||
public static event Func<BottomPanelType, Task> BottomPanelTabExternallySelected = _ => Task.CompletedTask;
|
||||
public static void InvokeBottomPanelTabExternallySelected(BottomPanelType type) => BottomPanelTabExternallySelected.Invoke(type);
|
||||
|
||||
public static event Func<BottomPanelType?, Task> BottomPanelTabSelected = _ => Task.CompletedTask;
|
||||
public static void InvokeBottomPanelTabSelected(BottomPanelType? type) => BottomPanelTabSelected.Invoke(type);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public partial class IdeRoot : Control
|
||||
|
||||
private async void OnBuildSlnButtonPressed()
|
||||
{
|
||||
GodotGlobalEvents.InvokeBottomPanelTabSelected(BottomPanelType.Build);
|
||||
GodotGlobalEvents.InvokeBottomPanelTabExternallySelected(BottomPanelType.Build);
|
||||
await Singletons.BuildService.MsBuildSolutionAsync(_solutionExplorerPanel.SolutionModel.FilePath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user