Vixen
dd8b0a81
csharp
public readonly record struct SystemAccent

The accent colour the user picked in their operating system's settings.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

One role rather than a palette, because one role is what every desktop can answer and what the control theme already draws with. ControlTheme.vcss's --accent is the focus ring, the switch, the spinner and the selection — thirty-one declarations in one sheet — and until this type existed nothing anywhere read the operating system's choice into it. The wider platform palette (AppKit's labelColor and the rest) is a separate read with a separate destination; see SystemPalette.

⚠ sRGB, and that is a decision rather than an accident. Every platform hands its accent over in sRGB — NSColor resolved through sRGBColorSpace, DWM's colourisation word, a GNOME hex string — while SystemPalette holds linear, and its own remarks record that handing it an sRGB Color4 makes a palette that is visibly too bright with nothing anywhere reporting it. So the conversion happens once, in PlatformInput.ApplyAccent, rather than in each platform's reader where the second one to be written is the one that forgets.

⚠ null is a real answer and is not "the user has no accent". Every desktop has an accent; what a platform can be missing is a way to read it. Reporting some default blue would be indistinguishable at the destination from having read that blue off the machine, and the destination has to be able to tell — a role nobody has supplied keeps following SystemPalette's own tables, and a role somebody has supplied survives the next appearance change.

⚠ Text is nullable separately, and a platform answering the accent without it is the normal case. macOS has alternateSelectedControlTextColor and Windows has a text colour beside its accent; a hex string out of a GNOME setting has nothing of the kind. Leaving it null keeps AccentColorText on the default table, which is the pairing rule SystemAccessibility's neighbour SystemColor is ordered to enforce: a background role and its text role are guaranteed to contrast within a pair and guaranteed nothing across two.

Fields and properties (4)

  • public Color4? Color

    The accent itself, in sRGB, or null where the platform cannot say.

  • public Color4? Text

    What the platform draws on top of the accent, in sRGB, or null where it has no separate answer for that.

  • public static SystemAccent Unknown

    What a platform with no way to read an accent reports.

  • public bool IsKnown

    Whether the platform read an accent at all.

Methods (1)

  • public SystemAccent(Color4? Color = null, Color4? Text = null)

    The accent colour the user picked in their operating system's settings.

Used by (14)

  • DesktopAppearanceVixen.Platform.Desktop
  • DesktopPlatformVixen.Platform.Desktop
  • HeadlessPlatformVixen.Platform.Headless
  • IPlatformVixen.Platform
  • LinuxAccentVixen.Platform.Linux
  • LinuxAccentTestsVixen.Platform.Linux.Tests
  • MacOSAccentVixen.Platform.MacOS
  • MacOSAccentTestsVixen.Platform.MacOS.Tests
  • PlatformInputVixen.Platform.Ui
  • SystemPaletteWiringTestsVixen.Platform.Ui.Tests
  • WindowsAccentVixen.Platform.Windows
  • WindowsAccentTestsVixen.Platform.Windows.Tests
  • PinningPlatformVixen.App.Tests
  • PresentingPlatformVixen.App.Tests