diff --git a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs index b1fd27a..805e44e 100644 --- a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs +++ b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.cs @@ -8,14 +8,18 @@ namespace SharpIDE.Godot.Features.Problems; public partial class ProblemsPanel : Control { - private PackedScene _problemsPanelProjectEntryScene = GD.Load("uid://do72lghjvfdp3"); - private VBoxContainer _vBoxContainer = null!; - // TODO: Use observable collections in the solution model and downwards public SharpIdeSolutionModel? Solution { get; set; } + + private Tree _tree = null!; + private TreeItem _rootItem = null!; + // TODO: Use observable collections in the solution model and downwards private readonly ObservableHashSet _projects = []; public override void _Ready() { + _tree = GetNode("ScrollContainer/Tree"); + _rootItem = _tree.CreateItem(); + _rootItem.SetText(0, "Problems"); Observable.EveryValueChanged(this, manager => manager.Solution) .Where(s => s is not null) .Subscribe(s => @@ -24,8 +28,27 @@ public partial class ProblemsPanel : Control _projects.Clear(); _projects.AddRange(s!.AllProjects); }); - _vBoxContainer = GetNode("ScrollContainer/VBoxContainer"); - _vBoxContainer.GetChildren().ToList().ForEach(c => c.QueueFree()); - _vBoxContainer.BindChildren(_projects, _problemsPanelProjectEntryScene); + BindToTree(_projects); + } + + public void BindToTree(ObservableHashSet list) + { + var view = list.CreateView(x => + { + var treeItem = _tree.CreateItem(_rootItem); + treeItem.SetText(0, x.Name); + Observable.EveryValueChanged(x, s => s.Diagnostics.Count) + .Subscribe(s => treeItem.Visible = s is not 0); + return treeItem; + }); + view.ViewChanged += OnViewChanged; + } + private static void OnViewChanged(in SynchronizedViewChangedEventArgs eventArgs) + { + GD.Print("View changed: " + eventArgs.Action); + if (eventArgs.Action == NotifyCollectionChangedAction.Remove) + { + eventArgs.OldItem.View.Free(); + } } } \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.tscn b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.tscn index ff60dc8..953e384 100644 --- a/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.tscn +++ b/src/SharpIDE.Godot/Features/Problems/ProblemsPanel.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=3 format=3 uid="uid://tqpmww430cor"] +[gd_scene load_steps=2 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 @@ -20,13 +19,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] +[node name="Tree" type="Tree" 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 +hide_root = true diff --git a/src/SharpIDE.Godot/Features/Problems/ProblemsPanelProjectEntry.cs b/src/SharpIDE.Godot/Features/Problems/ProblemsPanelProjectEntry.cs deleted file mode 100644 index c6f608a..0000000 --- a/src/SharpIDE.Godot/Features/Problems/ProblemsPanelProjectEntry.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Godot; -using R3; -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