On this page

Styles

ui::style is layout and paint in one value. It holds a lay_style plus fill, gradient, stroke, radius, glass, wobble and layer. Every call returns the same style by reference, so a chain can be as long as the box needs.

Starting styles

  • ui::row() and ui::col() start a flex row or column.
  • ui::stack() puts every child in one cell, overlaid in declaration order. It is how a caption sits on an image.
  • ui::view() is a column that scrolls. See overflow and views.

Paint

CallEffect
bg(color)A solid fill. Takes a hex string such as "#0b0b0d".
gradient(a, b, mix, angle)A two colour fill blended at an angle in radians. a and b are colours.
border(width, color)An outline of that width that follows the corner radius.
round(radius)The corner radius.
glassy(gloss)A glass fill, with gloss from zero up.
breathe(wobble)A slow living wobble on the fill.
lift(elev)Sits the box on a theme elevation, a soft drop painted under it. See shadows and elevation.
on_layer(layer)Draws the box on that gfx layer, so it covers anything on a lower one.

A colour is a hex string such as "#ff8800", ui::rgb(255, 136, 0) or ui::rgba(0, 0, 0, 0.5), checked when the program builds. See colours. Underneath it is a packed word with red in the low byte, which a raw uint32_t still fills, see colors.

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

// a chained style reads like a sentence, every call returns the same style
// by reference so the chain can go as long as the box needs
static void panel(ui::ctx* u)
{
    ui_box(u, ui::col()
                  .width(320.0f)
                  .pad(16.0f)
                  .gap(10.0f)
                  .bg("#111111")
                  .round(10.0f)
                  .border(1.0f, "#222222")
                  .glassy(0.4f))
    {
        ui::text(u, "panel", ui::head(u));
    }
}

// a gradient fill blended between two colors at an angle, in radians
static void hero_banner(ui::ctx* u)
{
    ui_box(u, ui::row()
                  .grow()
                  .height(120.0f)
                  .round(12.0f)
                  .gradient("#8a64e5", "#2a1373", 0.5f, 0.78f))
    {
        ui::text(u, "isolen", ui::head(u));
    }
}

// stack makes every child share one cell and overlay in declaration order,
// the caption sits on top of the tinted panel behind it
static void captioned_thumbnail(ui::ctx* u)
{
    ui_box(u, ui::stack().width(240.0f).height(140.0f).round(10.0f))
    {
        ui_box(u, ui::col().grow().bg("#1a1a2a")) {}
        ui_box(u, ui::col().grow().pad(10.0f).justify(lay_align_end))
        {
            ui::text(u, "render pass", ui::caption(u));
        }
    }
}

// on_layer draws the box on a higher gfx layer, breathe gives
// the fill a slow living wobble
static void live_badge(ui::ctx* u)
{
    ui_box(u, ui::row().pad(6.0f, 12.0f).round(999.0f).bg("#e53a3a")
                  .breathe(0.6f).on_layer(2u))
    {
        ui::text(u, "live", ui::caption(u));
    }
}

Opacity and inert

CallEffect
opacity(a)Fades the box and everything inside it, text, marks and scroll bars included. a is clamped to 0 to 1.
inert(on)The box and everything inside it take no hover, press, focus or hit, but keep their normal look.
disable(on)The same as inert, plus the disabled look. See states.

Opacity multiplies down the tree, so a box at 0.5 inside a box at 0.5 draws at 0.25. It is applied per element as it paints, with no offscreen layer, so overlapping children inside a faded box each blend on their own. A portal starts afresh at the opacity its own style gives, whatever box it was declared in. At zero nothing of the box is drawn, except that a canvas callback still runs, since some read whether they were painted. A box at zero opacity still takes the pointer unless it is also inert.

Inert and disabled both pass down to every child, and both carry into a portal declared inside them. An inert element that held focus loses it. state_of reports state_disabled for an inert element, so code reading the bits treats it as off, while the element itself paints with no disabled step.

The fields behind these are style::dim, one less the opacity so a zeroed style stays opaque, and style::muted for inert. The kit's menus, popovers and tooltips fade in through opacity, and a drawer swiped shut slides off inert, see overlays.

settings.cpp
#include "isolenui/ui/ui.h"
#include "isolenui/kit/kit.h"

struct settings {
    bool saving = false;
    bool sync = true;
    bool backups = false;
    bool metered = false;
    // how far the advanced block has faded in, eased by the app
    float shown = 0.0f;
};

static void settings_view(ui::ctx* u, settings* s)
{
    // while a save runs the form takes no input and dims, without the disabled look
    ui_box(u, ui::col().gap(8.0f).inert(s->saving).opacity(s->saving ? 0.6f : 1.0f))
    {
        ui::toggle(u, "sync", &s->sync);
        ui::toggle(u, "backups", &s->backups);
        if (ui::button(u, "save")) {
            s->saving = true;
        }
    }

    // one opacity fades the box, its text and every child together
    const float step = ui::dt(u) * 6.0f;
    s->shown = s->sync ? (s->shown + step < 1.0f ? s->shown + step : 1.0f)
                       : (s->shown - step > 0.0f ? s->shown - step : 0.0f);
    if (s->shown > 0.0f && s->shown < 1.0f) {
        ui::redraw(u);
    }
    ui_box(u, ui::col().gap(8.0f).opacity(s->shown).inert(s->shown < 1.0f))
    {
        ui::text(u, "advanced", ui::head(u));
        ui::toggle(u, "sync over metered links", &s->metered);
    }
}

Last updated 23 October 2026