Improved readability of highlighted text in drop-down menus

TextColorHighlighted is now automatically lightened if too dark, by calculating brightness and interpolating towards white. This ensures better readability of selected items in drop-down menus.
This commit is contained in:
Phantom
2025-12-14 13:14:45 +01:00
parent bd58bd91b4
commit bb2e22ecf2

View File

@@ -588,6 +588,7 @@ namespace FlaxEngine.GUI
AutoFocus = false,
Size = size,
};
float brightness = TextColorHighlighted.R * 0.299f + TextColorHighlighted.G * 0.587f + TextColorHighlighted.B * 0.114f;
var label = new DropdownLabel
{
AutoFocus = true,
@@ -595,7 +596,7 @@ namespace FlaxEngine.GUI
Size = new Float2(size.X - margin, size.Y),
Font = Font,
TextColor = TextColor * 0.9f,
TextColorHighlighted = TextColorHighlighted,
TextColorHighlighted = brightness < 0.05f ? Color.Lerp(TextColorHighlighted, Color.White, 0.3f) : TextColorHighlighted,
HorizontalAlignment = HorizontalAlignment,
VerticalAlignment = VerticalAlignment,
Text = _items[i],