add reactive binding
This commit is contained in:
@@ -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>
|
||||
{
|
||||
|
||||
8
src/SharpIDE.Godot/Features/Problems/ProblemEntry.cs
Normal file
8
src/SharpIDE.Godot/Features/Problems/ProblemEntry.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
|
||||
namespace SharpIDE.Godot.Features.Problems;
|
||||
|
||||
public partial class ProblemEntry : Control
|
||||
{
|
||||
|
||||
}
|
||||
1
src/SharpIDE.Godot/Features/Problems/ProblemEntry.cs.uid
Normal file
1
src/SharpIDE.Godot/Features/Problems/ProblemEntry.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dkgiknux4rqit
|
||||
30
src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs
Normal file
30
src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b1r3no4u3khik
|
||||
@@ -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
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bx5v8rr87343o
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user