switch between bottom panels
This commit is contained in:
@@ -4,5 +4,41 @@ namespace SharpIDE.Godot.Features.BottomPanel;
|
||||
|
||||
public partial class BottomPanelManager : Panel
|
||||
{
|
||||
private Control _runPanel = null!;
|
||||
private Control _buildPanel = null!;
|
||||
private Control _problemsPanel = null!;
|
||||
|
||||
private Dictionary<BottomPanelType, Control> _panelTypeMap = [];
|
||||
private BottomPanelType? _currentPanelType = BottomPanelType.Run;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_runPanel = GetNode<Control>("%RunPanel");
|
||||
_buildPanel = GetNode<Control>("%BuildPanel");
|
||||
_problemsPanel = GetNode<Control>("%ProblemsPanel");
|
||||
_panelTypeMap = new Dictionary<BottomPanelType, Control>
|
||||
{
|
||||
{ BottomPanelType.Run, _runPanel },
|
||||
{ BottomPanelType.Build, _buildPanel },
|
||||
{ BottomPanelType.Problems, _problemsPanel }
|
||||
};
|
||||
|
||||
GodotGlobalEvents.LeftSideBarButtonClicked += OnLeftSideBarButtonClicked;
|
||||
}
|
||||
|
||||
private async Task OnLeftSideBarButtonClicked(BottomPanelType type)
|
||||
{
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
if (type == _currentPanelType)
|
||||
{
|
||||
_currentPanelType = null;
|
||||
// TODO: Ask parent to to collapse slider.
|
||||
}
|
||||
foreach (var kvp in _panelTypeMap)
|
||||
{
|
||||
kvp.Value.Visible = kvp.Key == type;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
23
src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs
Normal file
23
src/SharpIDE.Godot/Features/LeftSideBar/LeftSideBar.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Godot;
|
||||
|
||||
namespace SharpIDE.Godot.Features.LeftSideBar;
|
||||
|
||||
public partial class LeftSideBar : Panel
|
||||
{
|
||||
private Button _slnExplorerButton = null!;
|
||||
private Button _problemsButton = null!;
|
||||
private Button _runButton = null!;
|
||||
private Button _buildButton = null!;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_slnExplorerButton = GetNode<Button>("%SlnExplorerButton");
|
||||
_problemsButton = GetNode<Button>("%ProblemsButton");
|
||||
_runButton = GetNode<Button>("%RunButton");
|
||||
_buildButton = GetNode<Button>("%BuildButton");
|
||||
|
||||
_problemsButton.Pressed += () => GodotGlobalEvents.InvokeLeftSideBarButtonClicked(BottomPanelType.Problems);
|
||||
_runButton.Pressed += () => GodotGlobalEvents.InvokeLeftSideBarButtonClicked(BottomPanelType.Run);
|
||||
_buildButton.Pressed += () => GodotGlobalEvents.InvokeLeftSideBarButtonClicked(BottomPanelType.Build);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bddno1bbvvp5q
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://biyhfwx36ium8"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://biyhfwx36ium8"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bkty6563cthj8" path="res://Features/Run/Resources/Run.svg" id="1_6wc7d"]
|
||||
[ext_resource type="Script" uid="uid://bddno1bbvvp5q" path="res://Features/LeftSideBar/LeftSideBar.cs" id="1_rgaf0"]
|
||||
|
||||
[node name="LeftSideBar" type="Panel"]
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
@@ -10,6 +11,7 @@ anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_rgaf0")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
@@ -25,7 +27,8 @@ theme_override_constants/margin_bottom = 5
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
|
||||
[node name="ExplorerButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
[node name="SlnExplorerButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
theme_override_font_sizes/font_size = 13
|
||||
@@ -41,6 +44,7 @@ layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ProblemsButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
theme_override_font_sizes/font_size = 13
|
||||
@@ -52,6 +56,7 @@ vertical_icon_alignment = 0
|
||||
expand_icon = true
|
||||
|
||||
[node name="RunButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
theme_override_font_sizes/font_size = 13
|
||||
@@ -63,6 +68,7 @@ vertical_icon_alignment = 0
|
||||
expand_icon = true
|
||||
|
||||
[node name="BuildButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
theme_override_font_sizes/font_size = 13
|
||||
|
||||
9
src/SharpIDE.Godot/Features/Problems/ProblemsPanel.tscn
Normal file
9
src/SharpIDE.Godot/Features/Problems/ProblemsPanel.tscn
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_scene format=3 uid="uid://tqpmww430cor"]
|
||||
|
||||
[node name="ProblemsPanel" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
14
src/SharpIDE.Godot/GodotGlobalEvents.cs
Normal file
14
src/SharpIDE.Godot/GodotGlobalEvents.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace SharpIDE.Godot;
|
||||
|
||||
public static class GodotGlobalEvents
|
||||
{
|
||||
public static event Func<BottomPanelType, Task> LeftSideBarButtonClicked = _ => Task.CompletedTask;
|
||||
public static void InvokeLeftSideBarButtonClicked(BottomPanelType type) => LeftSideBarButtonClicked?.Invoke(type);
|
||||
}
|
||||
|
||||
public enum BottomPanelType
|
||||
{
|
||||
Run,
|
||||
Build,
|
||||
Problems
|
||||
}
|
||||
1
src/SharpIDE.Godot/GodotGlobalEvents.cs.uid
Normal file
1
src/SharpIDE.Godot/GodotGlobalEvents.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgws4lmqv2bsf
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bavypuy7b375x" path="res://IdeRoot.cs" id="1_whawi"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkty6563cthj8" path="res://Features/Run/Resources/Run.svg" id="2_8x8ub"]
|
||||
@@ -10,6 +10,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://bcoytt3bw0gpe" path="res://Features/Run/RunPanel.tscn" id="5_y3aoi"]
|
||||
[ext_resource type="Script" uid="uid://cvvgp42r3nml8" path="res://Features/BottomPanel/BottomPanelManager.cs" id="7_i62lx"]
|
||||
[ext_resource type="PackedScene" uid="uid://co6dkhdolriej" path="res://Features/Build/BuildPanel.tscn" id="9_rllbf"]
|
||||
[ext_resource type="PackedScene" uid="uid://tqpmww430cor" path="res://Features/Problems/ProblemsPanel.tscn" id="11_b7c1a"]
|
||||
|
||||
[sub_resource type="FontVariation" id="FontVariation_y3aoi"]
|
||||
base_font = ExtResource("2_rk34b")
|
||||
@@ -153,10 +154,16 @@ script = ExtResource("7_i62lx")
|
||||
|
||||
[node name="RunPanel" parent="VBoxContainer/HBoxContainer/VSplitContainer/BottomPanel" instance=ExtResource("5_y3aoi")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="BuildPanel" parent="VBoxContainer/HBoxContainer/VSplitContainer/BottomPanel" instance=ExtResource("9_rllbf")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="ProblemsPanel" parent="VBoxContainer/HBoxContainer/VSplitContainer/BottomPanel" instance=ExtResource("11_b7c1a")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
||||
[node name="OpenSolutionDialog" type="FileDialog" parent="."]
|
||||
|
||||
Reference in New Issue
Block a user