display icon overlays

This commit is contained in:
Matt Parker
2025-11-29 10:49:15 +10:00
parent 6595a41a80
commit 6753b46ed1
4 changed files with 39 additions and 21 deletions

View File

@@ -23,9 +23,9 @@
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:zoom="32"
inkscape:cx="10.28125"
inkscape:cy="16.171875"
inkscape:zoom="22.627417"
inkscape:cx="1.5026019"
inkscape:cy="14.473592"
inkscape:window-width="2560"
inkscape:window-height="1369"
inkscape:window-x="-8"
@@ -41,22 +41,10 @@
id="path1"
sodipodi:nodetypes="csssssscc"
style="display:none;stroke-width:1;stroke-dasharray:none" /><path
style="display:inline;fill:none;fill-opacity:1;stroke:#dfe5e9;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
style="display:none;fill:none;fill-opacity:1;stroke:#dfe5e9;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 5.471908,7.9141718 5.648118,0.010562 7.76e-4,-4.8208776"
id="path2"
sodipodi:nodetypes="ccc" /><path
d="m 19.611825,14.071401 v 7.674696 c 0,0.626632 -0.504473,1.131105 -1.131105,1.131105 -0.626632,0 -1.131105,-0.504473 -1.131105,-1.131105 v -7.674696"
style="fill:#2b3f64;fill-opacity:1;stroke:#5287f1;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="path1-8" /><path
id="rect5"
style="fill:#2b3f64;fill-opacity:1;stroke:#5287f1;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="m 21.777449,11.640102 c 0,1.794571 -1.454787,3.249358 -3.249358,3.249358 -1.794571,0 -3.249357,-1.454787 -3.249357,-3.249358 0,-1.7945702 1.454787,-3.2493567 3.249357,-3.2493568 1.794571,-4e-7 3.249358,1.4547862 3.249358,3.2493568 z"
sodipodi:nodetypes="sssss" /><rect
style="display:inline;fill:#2b3f64;fill-opacity:1;stroke:#5287f1;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
id="rect6"
width="2.1231384"
height="6.7741694"
x="17.466522"
y="5.9328065"
ry="1.1311053"
rx="1.0615692" /></svg>
d="M 17.466797 8.5683594 C 16.193511 9.0082857 15.279297 10.217795 15.279297 11.640625 C 15.279297 13.019522 16.137626 14.19805 17.349609 14.669922 L 17.349609 21.746094 C 17.349609 22.372726 17.853837 22.876953 18.480469 22.876953 C 19.107101 22.876953 19.611328 22.372726 19.611328 21.746094 L 19.611328 14.705078 C 20.873049 14.258837 21.777344 13.055186 21.777344 11.640625 C 21.777344 10.217795 20.86313 9.0082856 19.589844 8.5683594 L 19.589844 11.576172 C 19.589844 12.202804 19.115453 12.707031 18.527344 12.707031 C 17.939234 12.707031 17.466797 12.202804 17.466797 11.576172 L 17.466797 8.5683594 z " /></svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,18 @@
[remap]
importer="svg"
type="DPITexture"
uid="uid://fa7tdmldi206"
path="res://.godot/imported/PropsFile.svg-893cbb231ed52552fc392981ba695c0b.dpitex"
[deps]
source_file="res://Features/SolutionExplorer/Resources/FileExtensions/GenericFileAdornments/PropsFile.svg"
dest_files=["res://.godot/imported/PropsFile.svg-893cbb231ed52552fc392981ba695c0b.dpitex"]
[params]
base_scale=1.0
saturation=1.0
color_map={}
compress=true

View File

@@ -12,8 +12,11 @@ public partial class SolutionExplorerPanel
private readonly Texture2D _htmlIcon = ResourceLoader.Load<Texture2D>("uid://q0cktiwdkt1e");
private readonly Texture2D _cssIcon = ResourceLoader.Load<Texture2D>("uid://b6m4rm5u8hd1c");
private readonly Texture2D _txtIcon = ResourceLoader.Load<Texture2D>("uid://b6bpjhs2o1j2l");
private readonly Texture2D _genericFileIcon = ResourceLoader.Load<Texture2D>("uid://bile1h6sq0l08");
private readonly Texture2D _propsFileOverlayIcon = ResourceLoader.Load<Texture2D>("uid://fa7tdmldi206");
private Texture2D GetIconForFileExtension(string fileExtension)
private (Texture2D Icon, Texture2D? OverlayIcon) GetIconForFileExtension(string fileExtension)
{
var texture = fileExtension switch
{
@@ -24,8 +27,15 @@ public partial class SolutionExplorerPanel
".html" or ".htm" => _htmlIcon,
".css" => _cssIcon,
".txt" => _txtIcon,
".props" => _genericFileIcon,
_ => _csIcon
};
return texture;
};
var overlayTexture = fileExtension switch
{
".props" => _propsFileOverlayIcon,
_ => null
};
return (texture, overlayTexture);
}
}

View File

@@ -299,7 +299,9 @@ public partial class SolutionExplorerPanel : MarginContainer
}
var fileItem = tree.CreateItem(parent, newStartingIndex);
fileItem.SetText(0, sharpIdeFile.Name);
fileItem.SetIcon(0, GetIconForFileExtension(sharpIdeFile.Extension));
var (icon, overlayIcon) = GetIconForFileExtension(sharpIdeFile.Extension);
fileItem.SetIcon(0, icon);
if (overlayIcon is not null) fileItem.SetIconOverlay(0, overlayIcon);
fileItem.SetCustomColor(0, GetColorForGitStatus(sharpIdeFile.GitStatus));
fileItem.SetMetadata(0, new RefCountedContainer<SharpIdeFile>(sharpIdeFile));