On this page

Themes

ui::theme is the whole palette and metric set a context paints with. Widgets read it, and so can your own boxes through ui::theme_of.

What a theme holds

FieldsUsed for
bg, panel, raised, rule, trackSurfaces, dividers and slider tracks.
accent, accent_dimThe primary action and focus colour, and its faint form.
text, text_soft, text_dimThree text strengths.
menu, menu_edgePopups such as combo lists and tooltips.
sunkThe press fill of framed controls, radios and calendar days. Zero steps it off raised toward the text colour, so a dark theme lifts and a light one sinks.
menu_hot, menu_pickThe hovered and the chosen menu item. Zero steps each off menu toward the text colour.
scrimBehind dialogs, sheets and drawers. Zero takes black at alpha 150.
chart[8]A categorical palette for series. An entry left at zero steps from the accent toward bg, further for each index.
lift[elev_count]Three elevations, elev_sm, elev_md and elev_lg, each two CSS box shadow layers. One left all zero is filled from bg by theme_lift when a context takes the theme. See shadows and elevation.
warn, error, okStatus colours.
radius, pad, gap, row_hWidget geometry.
text_px, small_px, head_px, trackingText sizes and letter spacing.
leadingThe wrapped line step as a multiple of the text size, 1.32 in theme_hud. Zero steps by the font's line height.
face_ui, face_bold, face_monoWhich atlas faces the text styles use.
directionThe root reading direction, a ui::dir. Inherit reads as left to right. See direction and bidi.
looks, own_looksOne look per role, which every widget paints from. They are rebuilt from the palette by theme_looks unless own_looks is set. See states and looks.

theme_hud and custom themes

ui::theme_hud() is the palette and metrics the old hud skin wore: near black surfaces, white accents, 17 unit body text and 30 unit rows. ui::ctx_create copies the theme you pass, and null means theme_hud. The app shell does the same with isolen_app_desc::theme. To tint it, start from theme_hud() and override what you want. The looks follow the new palette on their own.

ui::set_theme and isolen_set_theme swap the theme on a live context. The looks are rebuilt unless own_looks is set, and the next frame repaints.

themes.cpp
#include "isolenui/ui/ui.h"

// ctx_create takes the theme by pointer, a null one means theme_hud, the
// palette and metrics the old hud skin wore
static ui::ctx* boot_ui(const text_font* font, gfx_font handle)
{
    return ui::ctx_create(font, handle, nullptr);
}

// a custom theme starts from theme_hud and overrides what it wants, the
// accent here is the purple 8a64e5
static ui::ctx* boot_ui_tinted(const text_font* font, gfx_font handle)
{
    ui::theme t = ui::theme_hud();
    t.accent = ui::rgb("#8a64e5");
    t.accent_dim = ui::rgb("#8a64e540");
    t.radius = 6.0f;
    t.row_h = 28.0f;
    return ui::ctx_create(font, handle, &t);
}

// widgets read the live theme, a custom box can too
static void themed_panel(ui::ctx* u)
{
    const ui::theme* t = ui::theme_of(u);
    ui_box(u, ui::col().pad(t->pad).gap(t->gap).round(t->radius).bg(t->raised))
    {
        ui::text(u, "follows the theme", ui::body(u));
    }
}

Last updated 23 October 2026