Disabled Hover (#define HOVER).

Added Color.GetHighlightColor. Simple implementation for now. Needs to be more robust.
This commit is contained in:
Tig
2024-04-08 10:16:30 -04:00
parent ac667dae2c
commit 6c296bb299
6 changed files with 103 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json.Serialization;
using ColorHelper;
namespace Terminal.Gui;
@@ -237,6 +238,27 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
[SkipLocalsInit]
private static float CalculateColorDistance (in Vector4 color1, in Vector4 color2) { return Vector4.Distance (color1, color2); }
/// <summary>
/// Gets a color that is the same hue as the current color, but with a different lightness.
/// </summary>
/// <returns></returns>
public Color GetHighlightColor ()
{
// TODO: This is a temporary implementation; just enough to show how it could work.
var hsl = ColorHelper.ColorConverter.RgbToHsl(new RGB (R, G, B));
var amount = .7;
if (hsl.L < 50)
{
amount += 1;
}
hsl.L = (byte)(hsl.L * amount);
var rgb = ColorHelper.ColorConverter.HslToRgb (hsl);
return new (rgb.R, rgb.G, rgb.B);
}
#region Legacy Color Names
/// <summary>The black color.</summary>