Skip to content

UXColorEntry

UXColorEntry is one name/colour pair in a UXColorList.

#use <UXKit> // or #import "UXColorList.xc"
class UXColorEntry : Object {
u8* name; // "windowBackground", "accent", "text"
UXColor* color;
}

A widget that hardcodes a pen number cannot be re-themed. A widget that asks for "windowBackground" gets whatever the current theme says, and swapping the theme restyles the whole interface without touching any control.

This two-field class provides that indirection.

The names in the default theme are semantic: they describe what the colour is for, not what it looks like. "text" is used instead of "black", so a dark theme can make it white and every label follows.

An application customises a theme by setting a name that already exists. There is no separate “override” concept: any lookup finds the entry for that name, so replacing the entry is the mechanism.

An application can also invent names of its own and keep them in the same list as the standard ones. A "gridLine" entry is no different in kind from "accent"; only the default theme’s own entries are shipped.

UXColor* color

The entry holds the pointer it was given. UXColor is treated as immutable throughout the toolkit (lightened, darkened and blend all return new colours), so several entries can share one colour and a control can keep what it looked up.

Mutating a colour’s fields in place would change every entry that refers to it. No toolkit code does this.

u8* name

Compared by content, so a name built at run time matches a literal. Kept, not copied: pass a literal or a UXStr.dup.

UXColor* color