add reactive binding

This commit is contained in:
Matt Parker
2025-09-12 18:04:20 +10:00
parent 4485b51b1e
commit 1b2ebcb1e8
41 changed files with 1411 additions and 4 deletions

View File

@@ -1,13 +1,25 @@
using Godot;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
using SharpIDE.Godot.Features.Problems;
namespace SharpIDE.Godot.Features.BottomPanel;
public partial class BottomPanelManager : Panel
{
public SharpIdeSolutionModel? Solution
{
get;
set
{
field = value;
_problemsPanel.Solution = value;
}
}
private Control _runPanel = null!;
private Control _debugPanel = null!;
private Control _buildPanel = null!;
private Control _problemsPanel = null!;
private ProblemsPanel _problemsPanel = null!;
private Dictionary<BottomPanelType, Control> _panelTypeMap = [];
@@ -16,7 +28,7 @@ public partial class BottomPanelManager : Panel
_runPanel = GetNode<Control>("%RunPanel");
_debugPanel = GetNode<Control>("%DebugPanel");
_buildPanel = GetNode<Control>("%BuildPanel");
_problemsPanel = GetNode<Control>("%ProblemsPanel");
_problemsPanel = GetNode<ProblemsPanel>("%ProblemsPanel");
_panelTypeMap = new Dictionary<BottomPanelType, Control>
{

View File

@@ -0,0 +1,8 @@
using Godot;
namespace SharpIDE.Godot.Features.Problems;
public partial class ProblemEntry : Control
{
}

View File

@@ -0,0 +1 @@
uid://dkgiknux4rqit

View File

@@ -0,0 +1,30 @@
using System.Collections.Specialized;
using Godot;
using ObservableCollections;
using R3;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Godot.Features.Problems;
public partial class ProblemsPanel : Control
{
private PackedScene _problemsPanelProjectEntryScene = GD.Load<PackedScene>("uid://do72lghjvfdp3");
private VBoxContainer _vBoxContainer = null!;
// TODO: Use observable collections in the solution model and downwards
public SharpIdeSolutionModel? Solution { get; set; }
private readonly ObservableHashSet<SharpIdeProjectModel> _projects = [];
public override void _Ready()
{
Observable.EveryValueChanged(this, manager => manager.Solution)
.Where(s => s is not null)
.Subscribe(s =>
{
GD.Print($"ProblemsPanel: Solution changed to {s?.Name ?? "null"}");
_projects.Clear();
_projects.AddRange(s!.AllProjects);
});
_vBoxContainer = GetNode<VBoxContainer>("ScrollContainer/VBoxContainer");
_vBoxContainer.BindChildren(_projects, _problemsPanelProjectEntryScene);
}
}

View File

@@ -0,0 +1 @@
uid://b1r3no4u3khik

View File

@@ -1,4 +1,7 @@
[gd_scene format=3 uid="uid://tqpmww430cor"]
[gd_scene load_steps=3 format=3 uid="uid://tqpmww430cor"]
[ext_resource type="Script" uid="uid://b1r3no4u3khik" path="res://Features/Problems/ProblemsPanel.cs" id="1_bnenc"]
[ext_resource type="PackedScene" uid="uid://do72lghjvfdp3" path="res://Features/Problems/ProblemsPanelProjectEntry.tscn" id="2_xj8le"]
[node name="ProblemsPanel" type="Control"]
layout_mode = 3
@@ -7,3 +10,23 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_bnenc")
[node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="ProblemsPanelProjectEntry" parent="ScrollContainer/VBoxContainer" instance=ExtResource("2_xj8le")]
layout_mode = 2
[node name="ProblemsPanelProjectEntry2" parent="ScrollContainer/VBoxContainer" instance=ExtResource("2_xj8le")]
layout_mode = 2

View File

@@ -0,0 +1,14 @@
using Godot;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Godot.Features.Problems;
public partial class ProblemsPanelProjectEntry : MarginContainer
{
public SharpIdeProjectModel Project { get; set; } = null!;
public override void _Ready()
{
GetNode<Label>("Label").Text = Project?.Name ?? "NULL";
}
}

View File

@@ -0,0 +1 @@
uid://bx5v8rr87343o

View File

@@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://do72lghjvfdp3"]
[ext_resource type="Script" uid="uid://bx5v8rr87343o" path="res://Features/Problems/ProblemsPanelProjectEntry.cs" id="1_2yh8u"]
[node name="ProblemsPanelProjectEntry" type="MarginContainer"]
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("1_2yh8u")
[node name="Label" type="Label" parent="."]
layout_mode = 2
text = "Project"