Styles and colors#

Declared in ui.h. See styling for the style record, states and palette roles. The types and macros these functions use are in the theme header.

ui_next_style#

void ui_next_style(const ui_style_t *style);

Replaces the main style of the next widget with style. It applies to one widget. The style must stay valid until the frame is drawn, so define it const at file scope. Which style is a widget’s main style is listed in one widget in another style.

ui_palette#

void ui_palette(const uint16_t *colors, uint8_t count);

Writes palette slots 1 to count - 1 from colors, an array indexed by slot. colors[0] is not used, and slots at or above UI_SLOTS are skipped. The screen changes color at once, without a redraw.

Parameter

Meaning

colors

Colors in graphx’s 1555 format, such as UI_RGB(244, 245, 247), indexed by slot

count

One more than the highest slot to write, usually UI_ROLES or the count of your own slot enum

ui_init calls ui_palette(ui_palette_default, UI_ROLES).

ui_set_color#

void ui_set_color(uint8_t slot, uint16_t color);

Writes one palette slot. Slot 0 and slots at or above UI_SLOTS are ignored.

Parameter

Meaning

slot

A role such as UI_ACCENT, or one of your own slots

color

A 1555 color, such as UI_RGB(60, 110, 230)

ui_color#

uint8_t ui_color(uint8_t slot);

Returns the graphx palette index of a slot, UI_PALETTE_BASE + slot. Use it with gfx_SetColor in a canvas, or to fill sprite pixels, so your drawing follows the theme and dark mode.