recent sln colours
This commit is contained in:
@@ -7,6 +7,7 @@ public partial class PreviousSlnEntry : HBoxContainer
|
||||
{
|
||||
private Label _slnPathLabel = null!;
|
||||
private Label _slnNameLabel = null!;
|
||||
private Panel _slnColourPanel = null!;
|
||||
|
||||
public PreviouslyOpenedSln PreviouslyOpenedSln { get; set; } = null!;
|
||||
|
||||
@@ -15,7 +16,9 @@ public partial class PreviousSlnEntry : HBoxContainer
|
||||
if (PreviouslyOpenedSln is null) return;
|
||||
_slnNameLabel = GetNode<Label>("%SlnNameLabel");
|
||||
_slnPathLabel = GetNode<Label>("%SlnPathLabel");
|
||||
_slnColourPanel = GetNode<Panel>("Panel");
|
||||
_slnNameLabel.Text = PreviouslyOpenedSln.Name;
|
||||
_slnPathLabel.Text = PreviouslyOpenedSln.FilePath;
|
||||
_slnColourPanel.Modulate = RandomRecentSlnColours.GetColourForFilePath(PreviouslyOpenedSln.FilePath);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ content_margin_left = 0.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0.38039216, 1, 0.91764706, 1)
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Godot;
|
||||
|
||||
namespace SharpIDE.Godot.Features.SlnPicker;
|
||||
|
||||
public static class RandomRecentSlnColours
|
||||
{
|
||||
public static readonly Color Teal = new Color("24a0a7");
|
||||
public static readonly Color Purple = new Color("9b55e0");
|
||||
public static readonly Color Pink = new Color("bd4fa4");
|
||||
public static readonly Color Blue = new Color("5390ce");
|
||||
public static readonly Color LightGreen = new Color("8fa759");
|
||||
public static readonly Color Orange = new Color("e3855e");
|
||||
public static readonly Color Green = new Color("53a472");
|
||||
public static readonly Color DarkYellow = new Color("b48615");
|
||||
public static readonly Color DarkBlue = new Color("4e6ef0");
|
||||
|
||||
public static readonly List<Color> AllColours =
|
||||
[
|
||||
Teal,
|
||||
Purple,
|
||||
Pink,
|
||||
Blue,
|
||||
LightGreen,
|
||||
Orange,
|
||||
Green,
|
||||
DarkYellow,
|
||||
DarkBlue
|
||||
];
|
||||
|
||||
public static Color GetColourForFilePath(string filePath)
|
||||
{
|
||||
var hashBytes = MD5.HashData(Encoding.UTF8.GetBytes(filePath));
|
||||
|
||||
// Convert first 4 bytes to an int
|
||||
var hash = BitConverter.ToInt32(hashBytes, 0);
|
||||
|
||||
var index = Math.Abs(hash) % AllColours.Count;
|
||||
return AllColours[index];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bdh3csaym7l1n
|
||||
Reference in New Issue
Block a user