Content and spacing
text and textf declare a run of text, in a text style or the body style by default. image and svg draw an asset into a styled box with one of three fits: fit_contain letterboxes it, fit_cover crops it to fill, and fit_stretch distorts it. The natural size comes from the device, so call bind_device once. Without a device, a fit just stretches. A host that draws with no gfx device answers sizes itself through bind_sizes(u, fn, user): an art_size_fn gets the asset, whether it is an svg, and writes the width and height, returning false for an asset it does not know. bind_device is that hook filled from the device, and it lives in its own unit so a ui without a device links without the backends.


In the gallerySeparatorseparatorTypographytypography
spacer is a flexible gap that takes a weighted share of free space. gap inserts a fixed one, which is different from the container level ui::style::gap. rule draws a divider across its container.
#include "isolenui/ui/ui.h"
// bind_device gives the tree somewhere to ask for an image or svg's natural
// size, without one a fit stretches to whatever box it is given instead
static void boot(ui::ctx* u, const gfx_device* dev)
{
ui::bind_device(u, dev);
}
static void about_panel(ui::ctx* u, gfx_image screenshot, gfx_svg logo)
{
ui_box(u, ui::col().grow().pad(20.0f))
{
// svg, drawn at natural size when the box just fits it
ui::svg(u, logo, ui::col().width(48.0f).height(48.0f));
// gap, a fixed space with nothing in it
ui::gap(u, 12.0f);
ui::text(u, "isolen ui", ui::head(u));
// rule, a thin divider the width of its container
ui::rule(u);
ui::gap(u, 12.0f);
// image, cropped to fill its box instead of letterboxed inside it
ui::image(u, screenshot, ui::col().grow().height(220.0f).round(8.0f),
ui::fit_cover);
}
}