add diag warning icon

This commit is contained in:
Matt Parker
2025-09-12 19:37:27 +10:00
parent 4ee90bff50
commit 6dbfb3a67c
2 changed files with 15 additions and 1 deletions

View File

@@ -9,6 +9,11 @@ namespace SharpIDE.Godot.Features.Problems;
public partial class ProblemsPanel : Control
{
[Export]
public Texture2D WarningIcon { get; set; } = null!;
[Export]
public Texture2D ErrorIcon { get; set; } = null!;
public SharpIdeSolutionModel? Solution { get; set; }
private Tree _tree = null!;
@@ -75,6 +80,12 @@ public partial class ProblemsPanel : Control
{
var diagItem = tree.CreateItem(parent);
diagItem.SetText(0, e.NewItem.Value.GetMessage());
diagItem.SetIcon(0, e.NewItem.Value.Severity switch
{
DiagnosticSeverity.Error => ErrorIcon,
DiagnosticSeverity.Warning => WarningIcon,
_ => null
});
e.NewItem.View.Value = diagItem;
});
}

View File

@@ -1,6 +1,7 @@
[gd_scene load_steps=2 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="Texture2D" uid="uid://pd3h5qfjn8pb" path="res://Features/Problems/Resources/Warning.svg" id="2_xj8le"]
[node name="ProblemsPanel" type="Control"]
layout_mode = 3
@@ -10,6 +11,8 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_bnenc")
WarningIcon = ExtResource("2_xj8le")
ErrorIcon = ExtResource("2_xj8le")
[node name="ScrollContainer" type="ScrollContainer" parent="."]
layout_mode = 1