On this page
  1. On pages of their own
  2. Vocabulary
    1. Align
    2. Variant
    3. ColorRole
    4. Size
  3. Pictures
    1. NineSlice
    2. slice
    3. nine_slice
  4. Looks: shadows, outlines, skins, sounds and motion
    1. Shadow
    2. TextOutline
    3. TextShadow
    4. Skin
    5. Sounds
    6. Motion
    7. Style
  5. The theme
    1. Theme
    2. current_theme, set_theme
    3. theme_dark, theme_light
  6. Fonts
    1. set_font
    2. font_name
  7. Scale
    1. scale
    2. set_scale
  8. Breakpoints
    1. Breakpoint
    2. current_breakpoint
    3. compact
  9. The frame
    1. FrameOptions
    2. begin
    3. end
  10. Overlays
    1. OverlayOptions
    2. overlay
  11. Widgets
    1. ButtonOptions
    2. TextOptions
    3. RichTextOptions
    4. rich_text
    5. rich_text_length
    6. button
    7. ImageButtonOptions
    8. image_button
    9. text
  12. Containers
    1. BoxOptions
    2. PanelOptions
    3. ImageOptions
    4. ProgressOptions
    5. row
    6. column
    7. panel
    8. center
    9. stack, layer
    10. spacer
  13. More widgets
    1. image
    2. progress
  14. Grid and scroll
    1. GridOptions
    2. ScrollOptions
    3. grid
    4. cell, grid
    5. scroll
  15. Controls that own a value
    1. CheckboxOptions
    2. SliderOptions
    3. DropdownOptions
    4. TextInputOptions
    5. checkbox
    6. slider
    7. dropdown
    8. text_input
  16. Over the world, over a control, over everything
    1. AtOptions
    2. at
  17. Dialogue presenters
    1. Portrait
    2. Speaker
    3. DialogueSide
    4. DialogueChoices
    5. DialogueFlow
    6. DialogueMemory
    7. dialogue_line
    8. dialogue_choices
    9. BubbleSpeaker
    10. DialogueBubble
    11. TooltipOptions
    12. tooltip
    13. NotifyOptions
    14. notify
  18. Input, and who gets it
    1. wants_pointer
    2. wants_keyboard
  19. Focus, keyboard and gamepad
    1. focus
    2. focused
    3. set_navigation_enabled, navigation_enabled
  20. Events
    1. EventKind
    2. WidgetKind
    3. Event
    4. on_event
  21. Widgets you keep
    1. KeptState
  22. Lifecycle
    1. shutdown

rmp::ui

namespace #include <rmp/ui.h>

rmp::ui — the interface layer.

The whole point, in four lines:

rmp::ui::begin();
if (rmp::ui::button("Play")) play();
if (rmp::ui::button("Quit")) quit();
rmp::ui::end();

That is a centred, responsive main menu. No coordinates, no sizes, no anchors, no fonts, no hitboxes, and it looks the same at 800x600 as it does at 4K. Everything else in this header is what you reach for when the default is not what you want — and you only pay for it when you use it.

Three rules worth knowing, and that is genuinely all of them:

  1. end() draws. So the begin()/end() pair goes between BeginDrawing() and EndDrawing(), and before SmokeTest_CaptureFrame() if you keep that.
  2. Describe it where it is drawn: in a scene's _draw(), in screen space. Not in _update(), which draws nothing, and not in an object's _draw(), which runs under the camera — at() is how a box follows the world. A call in the wrong place is reported once, and does nothing. Each begin()/end() pair is a pass, and a frame may hold several: a HUD and the pause menu over it, or a screen and its overlay().
  3. Interaction uses the previous frame's geometry. A button cannot be clicked on the very first frame it appears — 16 ms at 60 fps. This is inherent to immediate mode; see TECHNICAL.md for why the alternative is worse.

The layout engine underneath is Clay, and it is deliberately invisible: not one of its types appears in this header, so it can be replaced without any of your code changing.

On pages of their own

  • rmp::ui::Picture — Anything rmp::ui can show.
  • rmp::ui::SoundName — The name of a sound, as rmp::audio::play() takes it ("click" is click.wav, click.ogg...): written as a string, .click = "click".
  • rmp::ui::DialogueBox — The classic box: along the bottom of the screen, the speaker's portrait and name beside the line, the choices as buttons under it.
  • rmp::ui::DialogueStage — A visual novel's stage: big portraits of who is on it, the speaker in front and the rest dimmed, and the line in a box under them.
  • rmp::ui::Button — A button: text, an icon, or both.
  • rmp::ui::Label — Text, as text() draws it, with a style of its own: a title in another font, with an outline.
  • rmp::ui::Image — A picture with a style — a frame, a shadow — that can be clicked.
  • rmp::ui::Panel — A container: a panel with a look of its own (style), and a look for everything inside it (children), which every descendant inherits — the nearest container's wins.
  • rmp::ui::Checkbox — A checkbox that holds its own value.
  • rmp::ui::Slider — A slider that holds its own value.
  • rmp::ui::Dropdown — A dropdown that holds its items and its choice.
  • rmp::ui::TextInput — A text field that holds its own text.
  • rmp::ui::ProgressBar — A progress bar with a look of its own: the style is the track's (its background, its skin), fill and fill_picture the bar's.

Vocabulary

Align

enum class Align

Where content sits inside the space it was given. Read them as a 3x3 grid: three verticals (top/center/bottom) crossed with three horizontals (left/center/right).

ValueMeans
TOP_LEFT
TOP_CENTER
TOP_RIGHT
CENTER_LEFT
CENTER
CENTER_RIGHT
BOTTOM_LEFT
BOTTOM_CENTER
BOTTOM_RIGHT

Variant

enum class Variant

What a control *means*, not what colour it is. The theme decides the colour, so restyling the game never means revisiting every call site.

normal    a filled surface: the default, and most buttons
primary   the one thing you want pressed on this screen
danger    destructive, and it should look like it
outline   an outline and a label, no fill: a secondary action
ghost     just the label until you point at it: toolbars, "back" links
ValueMeans
NORMAL
PRIMARY
DANGER
OUTLINE
GHOST

ColorRole

enum class ColorRole

Which colour of the theme a piece of text uses: TEXT is the theme's text, MUTED its text_muted, PRIMARY its primary and DANGER its danger.

ValueMeans
TEXT
MUTED
PRIMARY
DANGER

Size

enum class Size

The three type steps. Anywhere a size is asked for you can write one of these or a plain number of design units — it is the same field either way:

rmp::ui::text("Chapter One", { .size = rmp::ui::Size::LARGE });
rmp::ui::text("Chapter One", { .size = 34 });

The steps are what you want almost always: they come from the theme, so they move together when someone changes the type scale, and they stay in proportion at every screen size. A number is the escape hatch. SMALL, MEDIUM and LARGE are the theme's font_size_small, font_size and font_size_large.

ValueMeans
SMALL
MEDIUM
LARGE

Pictures

NineSlice

struct NineSlice

A picture that stretches without stretching its corners: the classic "9-patch". The four margins cut the source into a 3x3 grid; the corners are drawn at their size, the edges stretch along one axis and the middle along both. That is how one small frame becomes a button of any length.

rmp::ui::NineSlice frame{ .texture = ui_art, .source = { 0, 0, 24, 24 },
                          .left = 8, .top = 8, .right = 8, .bottom = 8 };

Or read from Aseprite, where an artist draws it: a slice with 9-slices on gives its own margins — rmp::ui::nine_slice(sheet, "button").

FieldTypeDefaultWhat it is
texturermp::Texture

The picture

sheetrmp::SpriteSheet

Or an Aseprite sheet's, when texture is empty

sourceRectangle{}

The part of it to cut; {0,0,0,0} = all of it

leftfloat0

The margins, in pixels of the SOURCE: the left column

topfloat0

The top row

rightfloat0

The right column

bottomfloat0

The bottom row

scalefloat0

How big a source pixel is drawn, in design units: the corners are left * scale design units wide, and grow with the UI's scale like everything else. 0 = 1, so a 24-pixel frame is drawn as drawn. Pixel art wants a whole number: 2, 3, 4.

slice

Picture slice(const rmp::SpriteSheet &sheet, std::string_view name)

A named slice of an Aseprite file, as a Picture: the part of the first frame the slice covers, with its 9-slice margins when the slice has them. This is how one .aseprite becomes an atlas of icons, by name:

static rmp::SpriteSheet icons = rmp::assets::load_sheet("icons.aseprite");
rmp::ui::image(rmp::ui::slice(icons, "coin"));

A name the sheet does not have is an empty Picture, said once.

nine_slice

NineSlice nine_slice(const rmp::SpriteSheet &sheet, std::string_view name)

The same slice as a NineSlice, to change its scale or hand it on. A slice without 9-slices comes back with all four margins 0, said once.

Looks: shadows, outlines, skins, sounds and motion

Shadow

struct Shadow

A soft shadow under a box: under a button, a panel, an image. Drawn as a few rounded rectangles that get fainter outwards, which reads as blurred on every target — the software renderer and OpenGL ES 2.0 included — and costs a handful of rectangles. Sizes are in design units.

FieldTypeDefaultWhat it is
offsetVector2{ 0, 4 }

Where it falls: down a little, as light from above

blurfloat8

How far it fades out past the box; 0 = a hard shadow

spreadfloat0

How much bigger than the box it is before it fades

colorColorCLITERAL(Color){ 0, 0, 0, 90 }

At the box; fainter outwards

TextOutline

struct TextOutline

An outline around every letter, so a title reads over any background. In design units; drawn as copies of the text around it, so keep it small: 1 to 3.

FieldTypeDefaultWhat it is
widthfloat1

How far it reaches past each letter, in design units

colorColorCLITERAL(Color){ 0, 0, 0, 255 }

Its colour

TextShadow

struct TextShadow

A copy of the text under it, offset: the shadow of a letter.

FieldTypeDefaultWhat it is
offsetVector2{ 1, 2 }

Design units

colorColorCLITERAL(Color){ 0, 0, 0, 160 }

Its colour

Skin

struct Skin

Pictures instead of a flat colour, one per state. Only normal is needed: a state without its own picture shows normal, tinted the way the colours of that state would be — lighter under the pointer, darker pressed, grey disabled. Give the others when the artist drew them.

FieldTypeDefaultWhat it is
normalPicture

At rest

hoverPicture

Under the pointer

pressPicture

Held down

disabledPicture

Enabled = false

focusPicture

Has the keyboard or gamepad focus (the ring is still drawn)

Sounds

struct Sounds

Sounds, by name. Each event has its own; one that is not set is inherited from what is around it and, at the end, from the Theme. An EMPTY name is silence: .hover = "" turns off a hover sound set further out.

FieldTypeDefaultWhat it is
hoverstd::optional<SoundName>

The pointer arrives on a control

pressstd::optional<SoundName>

The pointer goes down on it

releasestd::optional<SoundName>

...and comes up

clickstd::optional<SoundName>

It was pressed: pointer, Enter, the A button

focusstd::optional<SoundName>

The keyboard or gamepad focus arrives

changestd::optional<SoundName>

A checkbox, slider, dropdown or field changed

openstd::optional<SoundName>

A dropdown opened

closestd::optional<SoundName>

...and closed

shakestd::optional<SoundName>

Shake(): "no", a wrong password

volumestd::optional<float>

0..1, for all of them; 1 when nobody sets it

Motion

struct Motion

Movement, which the framework's own themes leave all off: a button that grows under the pointer is a choice of style, and a game that wants it says so here. Nothing here moves the LAYOUT: a control is drawn bigger, lifted or sliding, but it is laid out — and clicked — where it always was.

FieldTypeDefaultWhat it is
hover_scalefloat1

1.05: 5% bigger under the pointer

press_scalefloat1

0.95: 5% smaller while held down

hover_liftfloat0

How far the box rises under the pointer, in design units, its shadow falling further below it: a card lifting off the table.

speedfloat0.12f

How long hover and press take to get there, in seconds.

appearfloat0

Arriving: the first frame a box is drawn, it fades in over appear seconds, sliding up from appear_offset design units below and growing from appear_scale. 0 = it is simply there. Panels and overlays are where this is for.

appear_offsetfloat0

Arriving: the first frame a box is drawn, it fades in over appear seconds, sliding up from appear_offset design units below and growing from appear_scale. 0 = it is simply there. Panels and overlays are where this is for.

appear_scalefloat1

Arriving: the first frame a box is drawn, it fades in over appear seconds, sliding up from appear_offset design units below and growing from appear_scale. 0 = it is simply there. Panels and overlays are where this is for.

shakefloat0.4f

Shake(): how long, and how far side to side, in design units.

shake_strengthfloat8

Shake(): how long, and how far side to side, in design units.

Style

struct Style

How ONE thing looks: a button, a panel, a label. Every field is optional, and one that is not set comes from around it: the children style of the containers it is in (the nearest wins), then the Theme's style for its kind (theme.styles.button, theme.styles.panel...), then the Theme's colours and metrics.

const rmp::ui::Style gold{
    .background = GOLD, .text = BLACK, .radius = 0,
    .shadow = rmp::ui::Shadow{}, .text_outline = rmp::ui::TextOutline{ .color = WHITE },
};
rmp::ui::Button buy{ .text = "Buy", .style = gold };

Theme::styles holds one for every kind of widget, under them all.

Written in the order you would think of them: the box, its spacing, its text, and how it feels. Designated initialisers have to follow that order.

FieldTypeDefaultWhat it is
backgroundstd::optional<Color>

Its fill. On a button, checkbox, dropdown or field, the hover and press colours are worked out from it — a little lighter, a little darker — unless you give them.

background_hoverstd::optional<Color>

Its fill. On a button, checkbox, dropdown or field, the hover and press colours are worked out from it — a little lighter, a little darker — unless you give them.

background_pressstd::optional<Color>

Its fill. On a button, checkbox, dropdown or field, the hover and press colours are worked out from it — a little lighter, a little darker — unless you give them.

background_disabledstd::optional<Color>

Its fill. On a button, checkbox, dropdown or field, the hover and press colours are worked out from it — a little lighter, a little darker — unless you give them.

skinstd::optional<Skin>

Pictures instead of the fill, per state. See Skin.

tintstd::optional<Color>

Multiplies the colours of a skin or an image: WHITE leaves them as drawn.

borderstd::optional<Color>

The outline's colour; shown when border_width > 0

border_widthstd::optional<float>

Design units; 0 = none

radiusstd::optional<float>

Of the corners, design units; 0 = square

shadowstd::optional<Shadow>

Under the box

padding_xstd::optional<float>

Inside, left and right

padding_ystd::optional<float>

Inside, above and below

gapstd::optional<float>

Between the children of a container

textstd::optional<Color>

The colour of its text

text_disabledstd::optional<Color>

...when enabled = false

fontrmp::Font

A font you loaded: .font = rmp::assets::load_font("title.ttf", 32). The interface draws with that FILE, baked by itself at every size it needs, with any letter a text asks for — so the size you loaded it at does not matter, and the text stays sharp. Empty = inherited.

font_sizestd::optional<float>

Design units: what Size::MEDIUM is here

text_outlinestd::optional<TextOutline>

A font you loaded: .font = rmp::assets::load_font("title.ttf", 32). The interface draws with that FILE, baked by itself at every size it needs, with any letter a text asks for — so the size you loaded it at does not matter, and the text stays sharp. Empty = inherited.

text_shadowstd::optional<TextShadow>

A font you loaded: .font = rmp::assets::load_font("title.ttf", 32). The interface draws with that FILE, baked by itself at every size it needs, with any letter a text asks for — so the size you loaded it at does not matter, and the text stays sharp. Empty = inherited.

motionstd::optional<Motion>

How it moves; see Motion

soundsSounds

Per event; see Sounds

The theme

Theme

struct Theme

Every colour and metric the widgets are drawn with. A default-constructed Theme is the dark theme: theme_dark() returns exactly that.

FieldTypeDefaultWhat it is
backgroundColorCLITERAL(Color){ 18, 18, 22, 255 }

The colour behind the interface; no widget paints it. rmp::app clears every frame with it unless the scene sets rmp::Scene::background; in a plain raylib loop, pass it to ClearBackground() yourself.

panelColorCLITERAL(Color){ 30, 30, 38, 255 }

The fill of panel() and of a dropdown's open list.

surfaceColorCLITERAL(Color){ 44, 44, 56, 255 }

A NORMAL button at rest, the field of a dropdown and of a text input, a slider's rail, an unticked checkbox's box, and the track of progress().

surface_hoverColorCLITERAL(Color){ 60, 60, 76, 255 }

A NORMAL, OUTLINE or GHOST button under the pointer; also a checkbox's row, a dropdown's field and the items of its open list.

surface_pressColorCLITERAL(Color){ 26, 26, 34, 255 }

What surface_hover paints, while the pointer is held down on it.

borderColorCLITERAL(Color){ 70, 70, 88, 255 }

The outline of an OUTLINE button, of an unticked checkbox's box and of a dropdown's open list; and, when border_width > 0, of a NORMAL button and of a panel that has no border of its own.

textColorCLITERAL(Color){ 235, 235, 242, 255 }

Text() with ColorRole::TEXT, the label of a NORMAL, OUTLINE or GHOST button, the labels of the controls, and what a dropdown or a text input shows.

text_mutedColorCLITERAL(Color){ 150, 150, 168, 255 }

Text() with ColorRole::MUTED, a slider's percentage, and the placeholder of an empty text input.

text_on_accentColorCLITERAL(Color){ 255, 255, 255, 255 }

The label of a PRIMARY or DANGER button, and the dot of a ticked checkbox.

primaryColorCLITERAL(Color){ 88, 120, 245, 255 }

A PRIMARY button at rest, text() with ColorRole::PRIMARY, a ticked checkbox, the filled part of a slider, and the bar of progress().

primary_hoverColorCLITERAL(Color){ 110, 140, 255, 255 }

A PRIMARY button under the pointer.

primary_pressColorCLITERAL(Color){ 70, 98, 210, 255 }

A PRIMARY button while the pointer is held down on it.

dangerColorCLITERAL(Color){ 220, 72, 80, 255 }

A DANGER button at rest, and text() with ColorRole::DANGER.

danger_hoverColorCLITERAL(Color){ 236, 96, 104, 255 }

A DANGER button under the pointer.

danger_pressColorCLITERAL(Color){ 184, 56, 64, 255 }

A DANGER button while the pointer is held down on it.

disabledColorCLITERAL(Color){ 60, 60, 70, 255 }

The fill of a control whose enabled is false: a button, a checkbox's box, a slider's filled part, a text input's field.

disabled_textColorCLITERAL(Color){ 110, 110, 124, 255 }

The label of a control whose enabled is false, and the value a disabled dropdown or text input shows.

focusColorCLITERAL(Color){ 130, 170, 255, 255 }

The outline on whatever the keyboard or gamepad is pointing at. Without it a controller build is unusable, so it is a theme colour rather than something each widget decides.

font_sizefloatRMP_UI_FONT_SIZE

[ui] font_size

font_size_smallfloatRMP_UI_FONT_SIZE * 0.8f

Size::SMALL

font_size_largefloatRMP_UI_FONT_SIZE * 1.4f

Size::LARGE

padding_xfloat20

Inside a button, left and right of the label

padding_yfloat12

Inside a button, above and below the label

gapfloat12

Between siblings

panel_paddingfloat20

Inside a panel(), and around what begin() lays out

corner_radiusfloat8

Of buttons, panels and the controls' fields; 0 = square

border_widthfloat0

0 = the default Theme draws no borders

control_sizefloat22

A checkbox's box; the height of a slider's drag area

track_thicknessfloat6

A slider's rail

focus_ringfloat2

The outline on the focused control

transitionfloat0.12f

How long a control takes to reach its new colour, in seconds. Nothing about the layout moves — only colour — so this can never make a button arrive somewhere else than where you clicked. 0 turns it off, which is both the "reduce motion" setting and what a test wants.

min_touch_sizefloat44

The shortest a button can be. It follows the button's type size, so a SMALL one may be shorter, except on Android and iOS, where no button is. 44 design units is Apple's touch target guidance and close to Material's 48dp — it is the difference between a menu you can use with a thumb and one you cannot.

soundsSounds{}

Sounds and motion every widget starts from. Silent in theme_dark() and theme_light(); the motion they have is the buttons' and the panels', in styles below.

motionMotion{}

Sounds and motion every widget starts from. Silent in theme_dark() and theme_light(); the motion they have is the buttons' and the panels', in styles below.

styles{}

One Style per kind of widget, under every widget of it

current_theme, set_theme

const Theme &current_theme()
void set_theme(const Theme &t)

The theme every widget is drawn with: current_theme() reads it, set_theme() copies a new one over it. There is one stored copy, so the reference current_theme() returns sees every later set_theme(), and a widget drawn after the call already uses the new one. Both work at any time, before the window exists too; until the first set_theme() it is the one [ui] theme names. A metric set_theme() is handed that is NaN, below 0 or past 4096 design units (transition: 60 seconds) is the game's mistake: said once by its name, and theme_dark()'s is kept in its place.

theme_dark, theme_light

Theme theme_dark()
Theme theme_light()

The two that come with the framework. Which one starts is [ui] theme in raylib_multiplatform.toml; these let you switch at runtime, which is what an in-game "appearance" setting does:

if (rmp::ui::checkbox("Light Theme", light))
    rmp::ui::set_theme(light ? rmp::ui::theme_light() : rmp::ui::theme_dark());

They return a copy, so the usual copy-modify-set still applies on top.

Fonts

set_font

void set_font(std::string_view name)
void set_font(const rmp::Font &font)

The global font, by its name in resources/ ("" = raylib's built-in one).

font_name

std::string_view font_name()

The global font's name right now: the last set_font(), or [ui] font.

Scale

scale

float scale()

The factor in use right now.

set_scale

void set_scale(float s)

Pin it, above 0 and at most 16. 0 goes back to automatic; NaN or below 0 is a mistake, said once, and automatic too, and past 16 is 16, said once. This is how you would implement an "interface size" accessibility option.

Breakpoints

Breakpoint

enum class Breakpoint

The shape of the screen, by width / height: COMPACT below 1 (taller than it is wide), MEDIUM from 1 up to 1.6, EXPANDED at 1.6 and wider.

ValueMeans
COMPACT
MEDIUM
EXPANDED

current_breakpoint

Breakpoint current_breakpoint()

Which Breakpoint the game's area is right now: the window, or under rmp::app::Stretch::LETTERBOX the world inside its bars — the design's shape, whatever the window does. It reads the size when it is called, so it needs no begin() first; a window with no height yet is MEDIUM.

compact

bool compact()

Shorthand for the case that comes up: current_breakpoint() == Breakpoint::COMPACT.

The frame

FrameOptions

struct FrameOptions

How begin() lays out the frame: a root that fills the screen, holding one column that everything you declare goes into. The defaults are the centred menu that begin() with no arguments opens.

FieldTypeDefaultWhat it is
placementAlignAlign::CENTER

Where the root's content sits

gapfloat-1

Between children; -1 = the theme's

paddingfloat-1

Inside the root; -1 = the theme's

growboolfalse

False: the column FITS what is in it, so a child that grows fills the column and no more — which is what makes the buttons of a menu one width. true: the column fills the window, less the padding, on both axes, so a child with grow_x or grow_y reaches the edges: a sidebar and a content area that take the whole screen. What does not grow is still placed by placement.

rmp::ui::begin({ .grow = true });
rmp::ui::row({ .grow_x = true, .grow_y = true }, [&] { side(); main(); });
rmp::ui::end();
focus_firststd::optional<bool>{}

Whether the frame's first control takes the focus by itself, so that Enter and the A button press it the moment it appears. Left unset, the framework decides: yes — which is what keeps a menu three functions long — unless the scene drawing it reads the keys the interface navigates with (Enter, Space, the arrows, Tab, the d-pad, the A button, the left stick) through rmp::input. That scene is being played, so this is a HUD over it: its controls take no focus and no key until the player presses Tab, and Escape, the B button or a click elsewhere hands the keys back to the game. true or false decides it yourself.

rmp::ui::begin({ .placement = rmp::ui::Align::TOP_RIGHT, .focus_first = false });

begin

void begin()
void begin(const FrameOptions &o)

Open the UI for this frame. The default is a centred column, which is what makes a main menu three functions.

end

void end()

Lay out, resolve interaction, and draw. Call it between BeginDrawing() and EndDrawing().

Overlays

OverlayOptions

struct OverlayOptions

How overlay() covers what is under it, and where its content goes.

FieldTypeDefaultWhat it is
placementAlignAlign::CENTER

Where its content sits, as FrameOptions::placement

blurfloat0

How far to blur what is underneath: the Gaussian's standard deviation in design units, as CSS's blur() means it; 0 = no blur, which costs one rectangle. A real blur on every GPU raylib drives, OpenGL ES 2.0 and WebGL included. raylib's software renderer has no shaders, so there — and wherever a shader cannot be built — the veil comes alone.

dimfloat0.45f

0..1: how far what is underneath goes towards veil

veilColorCLITERAL(Color){ 0, 0, 0, 255 }

What it is dimmed towards

overlay

template <class Body> void overlay(const OverlayOptions &o, Body &&body)
template <class Body> void overlay(Body &&body)

A frame in front of everything drawn before it. See above.

Widgets

ButtonOptions

struct ButtonOptions

How a button() looks, how big it is, and whether it can be pressed.

FieldTypeDefaultWhat it is
styleVariantVariant::NORMAL

What it means; the theme picks its colours

sizedetail::Sizing{}

One of the three steps, or a number of design units. The padding and the minimum touch height follow the type size, so a large button is a large button all over rather than a normal one with bigger letters.

enabledbooltrue

False = the theme's disabled colours; no press, no focus

idstd::string_view{}

Only needed when two buttons share a label AND the UI is conditional. Identical labels in one frame are already told apart automatically. Empty means none. It is hashed on the spot, so a temporary is fine.

TextOptions

struct TextOptions

How text() paints a string: its colour, its size, and whether it wraps.

FieldTypeDefaultWhat it is
colorColorRoleColorRole::TEXT

Which theme colour it is painted in

sizedetail::Sizing{}

A step, a number, or nothing for the theme's

wrapbooltrue

Break between words to fit; false = never broken to fit

RichTextOptions

struct RichTextOptions

Text with markup, drawn a letter at a time: Yarn's markup, which a dialogue line already carries --

rmp::ui::rich_text("A [wave]strange[/wave] [color=#ffcc00]light[/color]!");
[b]           bold                [color=#rrggbb] or [color=red]
[size=30]     in design units     [wave] [shake] [rainbow]: moving letters

Its visible letters, the rest held back: a typewriter counts them up.

FieldTypeDefaultWhat it is
widthfloat0

Wrap at this many design units; 0 = the width it is given

sizedetail::Sizing{}

A step, a number, or nothing for the theme's

colorColorRoleColorRole::TEXT

The colour of what no [color] paints

visibleint-1

How many letters show; -1 = every one

idstd::string_view{}

As ButtonOptions::id: two with one text

rich_text

void rich_text(const rmp::Text &text)
void rich_text(const rmp::Text &text, const RichTextOptions &o)

rich_text_length

int rich_text_length(const rmp::Text &text)

How many letters a rich text has once its markup is gone: where a typewriter stops.

button

bool button(const rmp::Text &label)
bool button(const rmp::Text &label, const ButtonOptions &o)

True on the frame it is pressed: the pointer released over it, or, while it has the focus, Enter or the gamepad's accept button. Reads as it looks:

if (rmp::ui::button("Play")) play();

ImageButtonOptions

struct ImageButtonOptions

How image_button() is sized, and whether it can be pressed. Sizes are in design units.

FieldTypeDefaultWhat it is
widthfloat0

0 = the picture's own width, scaled

heightfloat0

0 = the picture's own height, scaled

enabledbooltrue

False = the disabled tint; no press, no focus

idstd::string_view{}

It has no label to be told apart by, so two image buttons that come and go are told apart by this. Empty = by its order among the unnamed ones.

image_button

bool image_button(const Picture &picture)
bool image_button(const Picture &picture, const ImageButtonOptions &o)

A button that is a picture: an icon, an inventory slot, a skinned "Play" drawn by your artist. Pressed like button(), focusable like button(), and it wears theme.styles.button — its skin behind the picture, its sounds.

if (rmp::ui::image_button(gear)) open_settings();

text

void text(const rmp::Text &s)
void text(const rmp::Text &s, const TextOptions &o)

The string is copied immediately, so a temporary is safe:

rmp::ui::text(std::to_string(score));

Containers

BoxOptions

struct BoxOptions

Shared by every container. All measurements are in design units and are scaled; -1 means "whatever the theme says".

FieldTypeDefaultWhat it is
gapfloat-1

Between children

paddingfloat-1

Inside this container; -1 = none, panel_padding in a panel

itemsAlignAlign::CENTER

Where children sit in the leftover space

grow_xboolfalse

Sizing is interleaved by axis — x then y — rather than grouped by kind, and that is not cosmetic. Designated initialisers have to be written in declaration order, so grouping them as grow_x, grow_y, width, height would make { .width = 240, .grow_y = true } illegal: a fixed-width sidebar that fills the height, which is about the most ordinary thing anyone writes. This way round, every combination is legal.

widthfloat0

> 0 = a fixed width, overriding fit/grow

grow_yboolfalse

Fill the parent's height instead of fitting content

heightfloat0

> 0 = a fixed height, overriding fit/grow

idstd::string_view{}

A stable name for the container: the same element from frame to frame, whatever else is on screen. Nothing in rmp::ui needs it — it is for a test that finds an element by name, as tests/ui_layout_test.cpp does. Unnamed containers are anonymous, which is what almost all of them want.

PanelOptions

struct PanelOptions

A panel is a box with a background, which is what makes it visible.

FieldTypeDefaultWhat it is
boxBoxOptions{}

The layout, as column() takes it, except that a padding of -1 is the theme's panel_padding rather than none.

backgroundColorCLITERAL(Color){ 0, 0, 0, 0 }

{0,0,0,0} = the theme's panel

radiusfloat-1

-1 = the theme's

borderColorCLITERAL(Color){ 0, 0, 0, 0 }

{0,0,0,0} = the theme's border, drawn only when the theme's border_width is above 0 (it is 1 in theme_light(), 0 in theme_dark()).

border_widthfloat-1

Of border, when set; -1 = 1 design unit

ImageOptions

struct ImageOptions

How image() sizes and tints a texture. Sizes are in design units.

FieldTypeDefaultWhat it is
growboolfalse

Fill the space available

widthfloat0

Otherwise: 0 = the texture's own width, scaled

heightfloat0

0 = the texture's own height, scaled

tintColorWHITE

Multiplies the texture's colours; WHITE leaves them as they are

ProgressOptions

struct ProgressOptions

How progress() sizes and colours its bar. Sizes are in design units.

FieldTypeDefaultWhat it is
widthfloat0

0 = fill the space available

heightfloat-1

-1 = derived from the theme's font size

radiusfloat-1

-1 = half the height, for round ends

fillColorCLITERAL(Color){ 0, 0, 0, 0 }

{0,0,0,0} = the theme's primary

trackColorCLITERAL(Color){ 0, 0, 0, 0 }

{0,0,0,0} = the theme's surface

idstd::string_view{}

Names the bar, as BoxOptions::id names a container

row

template <class Body> void row(const BoxOptions &o, Body &&body)
template <class Body> void row(Body &&body)

Left to right.

column

template <class Body> void column(const BoxOptions &o, Body &&body)
template <class Body> void column(Body &&body)

Top to bottom.

panel

template <class Body> void panel(const PanelOptions &o, Body &&body)
template <class Body> void panel(Body &&body)

A column with a background and padding: the thing you put a dialog in.

center

template <class Body> void center(Body &&body)

Takes all the space it is given and puts its contents in the middle of it.

stack, layer

template <class Body> void stack(Body &&body)
template <class Body> void layer(Body &&body)

Layers, drawn back to front. Each child has to be a layer():

rmp::ui::stack([&]{
    rmp::ui::layer([&]{ rmp::ui::image(background); });
    rmp::ui::layer([&]{ rmp::ui::text("PAUSED");   });
});

The explicit layer() is not ceremony — it is what tells the layout which things are supposed to overlap and which are ordinary children.

spacer

void spacer()
void spacer(float fixed)

Eats the space left over, which is how you push things apart:

rmp::ui::row({ .grow_x = true }, []{
    rmp::ui::text("Health");
    rmp::ui::spacer();          // <- shoves the score to the right
    rmp::ui::text("999");
});

More widgets

image

void image(const Texture2D &texture)
void image(const Texture2D &texture, const ImageOptions &o)
void image(const Picture &picture)
void image(const Picture &picture, const ImageOptions &o)
void image(const rmp::Texture &texture)
void image(const rmp::Texture &texture, const ImageOptions &o)

The Texture2D is copied on the way in, so the struct you pass may be a temporary. What the copy holds is a GPU handle, though, so the texture itself has to stay loaded until end() has drawn the frame: keep the rmp::Texture that owns it, as a member or a global. A temporary rmp::Texture does not compile here — image(rmp::assets::load_texture("icon.png")) would unload the texture at the semicolon. By default it is drawn at its own size, scaled with the rest of the UI.

progress

void progress(float fraction)
void progress(float fraction, const ProgressOptions &o)

A bar. fraction is 0..1 and is clamped; NaN — hp / max_hp with no max_hp — is an empty bar, said once.

Grid and scroll

GridOptions

struct GridOptions

How grid() counts its columns, spaces its cells, and how much room it takes. Measurements are in design units, and -1 means the default given beside it.

FieldTypeDefaultWhat it is
columnsint0

0 = as many as fit, at least one, recomputed as the window changes

min_cellfloat96

Only used when columns = 0

gapfloat-1

Between cells and between rows; -1 = the theme's

paddingfloat-1

Inside the grid; -1 = none

grow_xbooltrue

A grid almost always wants the width it is offered

grow_yboolfalse

Fill the parent's height instead of fitting the rows

idstd::string_view{}

A name for the grid. columns = 0 reads the width the grid had last frame and finds it by this name; without one, by its order among the unnamed grids of the pass, which a grid that comes and goes before it changes.

ScrollOptions

struct ScrollOptions

How scroll() clips its contents, spaces them, and how much room it takes. Measurements are in design units, and -1 means the default given beside it.

FieldTypeDefaultWhat it is
horizontalboolfalse

Vertical by default, which is what lists want

verticalbooltrue

Clip and scroll top to bottom

gapfloat-1

Between children; -1 = the theme's

paddingfloat-1

Inside the area; -1 = none

grow_xbooltrue

Fill the parent's width

widthfloat0

> 0 = a fixed width, overriding grow_x

grow_ybooltrue

Fill the parent's height, and clip there. In a parent that fits its contents, that is the room left in the window: the rows never push it.

heightfloat0

> 0 = a fixed height, overriding grow_y

idstd::string_view{}

A name for the area. Without one it is told apart by its order among the unnamed scroll areas of the pass, so an area that comes and goes before it changes which one it is.

grid

template <class Body> void grid(const GridOptions &o, Body &&body)

Equal columns, as many rows as it takes. Each item goes in a cell(), which is what lets the grid count them and start a new row at the right moment — the layout engine underneath wraps text, not elements, so the rows are real rows.

rmp::ui::grid(4, [&]{
    for (auto &item : inventory)
        rmp::ui::cell([&]{ rmp::ui::image(item.icon); });
});

With columns = 0 it works out how many fit in the width it has and works it out again when the window changes, which is what an inventory should do rather than staying at the number someone typed on a desktop.

cell, grid

template <class Body> void cell(Body &&body)
template <class Body> void grid(int columns, Body &&body)
template <class Body> void grid(Body &&body)

One item in a grid. Every child of a grid has to be one.

scroll

template <class Body> void scroll(const ScrollOptions &o, Body &&body)
template <class Body> void scroll(Body &&body)

Clips its contents and scrolls them. The wheel works, and so does dragging with a finger — the same gesture on a phone.

Controls that own a value

CheckboxOptions

struct CheckboxOptions

Whether a checkbox() can be toggled, and the name that tells it apart.

FieldTypeDefaultWhat it is
enabledbooltrue

False = the theme's disabled colours; no toggle, no focus

idstd::string_view{}

As ButtonOptions::id: for a shared label

SliderOptions

struct SliderOptions

How a slider() is sized, stepped and shown. Sizes are in design units.

FieldTypeDefaultWhat it is
widthfloat0

0 = fill the space available

stepfloat0

0 = continuous; otherwise snap to multiples

enabledbooltrue

False = the theme's disabled colours; no drag, no focus

show_valuebooltrue

Draw the position, as a percentage, after the bar

idstd::string_view{}

As ButtonOptions::id: for a shared label

TextInputOptions

struct TextInputOptions

How a text_input() is sized, what it shows while it is empty, and how much it takes.

FieldTypeDefaultWhat it is
widthfloat0

Of the field, in design units; 0 = fill the space available

enabledbooltrue

False = the theme's disabled colours; no typing, no focus

placeholderrmp::Text{}

Shown in the theme's text_muted while the field is empty and does not have the focus. It is copied, so a temporary is fine.

idstd::string_view{}

As ButtonOptions::id: for a shared label

max_lengthint0

The most CHARACTERS it holds — what the player counts, so an "é" is one and not the two bytes it takes. 0 = no limit. Typing stops at it, and a longer value you hand in is cut to it on the frame the field is drawn, never inside a character.

checkbox

bool checkbox(const rmp::Text &label, bool &value)
bool checkbox(const rmp::Text &label, bool &value, const CheckboxOptions &o)

A box that flips value when it is clicked, or activated from the keyboard or a gamepad while it has the focus. True on the frame it flipped.

slider

bool slider(const rmp::Text &label, float &value, float min, float max)
bool slider(const rmp::Text &label, float &value, float min, float max, const SliderOptions &o)

A bar that sets value between min and max: dragged, or moved with left and right while it has the focus, one step (or 5% of the range) per press, then twelve a second while held. value is clamped to the range, and snapped to step when there is one, on every call; true on any frame that changed it. Nothing is drawn when max <= min — nor when an end is NaN or an infinity, which is said once. A value that is NaN is set to min, and a step that is not a positive number is none, each said once.

text_input

bool text_input(const rmp::Text &label, std::string &value)
bool text_input(const rmp::Text &label, std::string &value, const TextInputOptions &o)

Edits your string, in UTF-8 — what the player types goes on the end, and Backspace takes off the last character, never half of one — and only while the field has the keyboard; TextInputOptions::max_length caps it. True on the frame it changed. It takes the keyboard when it is clicked, when the focus is moved onto it (Tab, the arrows, the d-pad, focus()), or when Enter, Space or the A button is pressed while it has the focus — but not from the focus a screen gives its first control by itself. It gives it back on Enter or the A button (Space is typed), on Escape or the B button, and on a click anywhere else; the focus stays on it. Tab, up and down move the focus on from a field as from any other control, and take the keyboard with them.

Over the world, over a control, over everything

AtOptions

struct AtOptions

Where at() puts its box, relative to the point it follows.

FieldTypeDefaultWhat it is
anchorAlignAlign::BOTTOM_CENTER

The point of the box that sits on the world position: BOTTOM_CENTER puts the box above it, which is where a health bar or a name goes.

offsetVector2{ 0, 0 }

Design units, after projecting: { 0, -8 } lifts it

idstd::string_view{}

A stable name for the box, as BoxOptions::id

at

template <class Body> void at(Vector2 world, const AtOptions &o, Body &&body)
template <class Body> void at(Vector2 world, Body &&body)

A box over a point of the WORLD, wherever the scene's camera shows it — zoomed, scrolled, shaken and stretched with it. Between begin() and end(), in the scene's _draw(), like everything else here:

rmp::ui::begin();
for (const rmp::Handle<Enemy> &e : enemies)
    if (e) rmp::ui::at(e->position, [&] { rmp::ui::progress(e->hp / 10.0f); });
rmp::ui::end();

What it paints does not take the pointer: a click on the enemy under its health bar still reaches the enemy. A control inside it is a control like any other — it can be clicked and focused where it is drawn. While the point is off the screen the box is not drawn at all, and nothing in it takes the pointer, the focus or the keys. Without scenes there is no camera, and the world is the screen.

Dialogue presenters

Portrait

struct Portrait

A speaker's picture, and one for each mood a line's #mood:happy names.

FieldTypeDefaultWhat it is
speakerstd::string

The name before the colon of a line: "Mika"

moodstd::string{}

Empty: the picture for any mood without its own

picturePicture{}

A texture, an atlas region, a sprite's frame or a nine-slice

Speaker

struct Speaker

Who speaks, as they look and sound: their lines in a box of their own, their name plate, their voice. Unset fields are the presenter's.

FieldTypeDefaultWhat it is
namestd::string

The name before the colon of a line: "Mika"

blipSoundName{}

Their blip; empty: the flow's

pitchfloat1

Their blip's pitch: 1.3 higher, 0.8 lower

styleStyle{}

Over the presenter's style, for their lines

name_styleStyle{}

Over the presenter's name_style

DialogueSide

enum class DialogueSide

Which side of the box a portrait sits on.

ValueMeans
LEFTBefore the line
RIGHTAfter it

DialogueChoices

enum class DialogueChoices

Where a box puts the choices.

ValueMeans
IN_BOXIn the box, in place of the line
ABOVEIn a panel of their own above the box, at its right
CENTERIn a panel in the middle of the screen

DialogueFlow

struct DialogueFlow

How a presenter types a line out, and goes on.

FieldTypeDefaultWhat it is
letters_per_secondfloat45

The typewriter; 0 = the whole line at once

blipSoundName{}

A sound as the letters appear

blip_everyint2

Letters between two blips

blip_jitterfloat0

Each blip's pitch moves by up to this: 0.08 = 8 %

auto_advancefloat0

Seconds a whole line stays before it goes on; 0 = wait

skip_seenboolfalse

A line already read goes by at once

voicesstd::string{}

A recorded line: the sound named voices + its id ("vo/hello")

choice_secondsfloat0

A timed choice: seconds to choose; 0 = no timer

default_choiceint0

What a timed choice takes when the time is up

DialogueMemory

struct DialogueMemory

What a presenter remembers from one frame to the next.

FieldTypeDefaultWhat it is
line_idstd::string

The line on screen

shownfloat0

Letters typed so far

lengthint0

Letters in the line

waitedfloat0

Seconds since it was all shown, or of a [pause]

choice_leftfloat0

Seconds left of a timed choice

blipsint0

Blips played for this line

historystd::vector<std::pair<std::string, std::string>>

Speaker, line: read so far

seenstd::vector<std::string>

The ids of the lines read

stagestd::vector<std::string>

DialogueStage: who is on stage, left to right

enteredstd::vector<float>

DialogueStage: seconds each has been on stage

focusstd::vector<float>

DialogueStage: 0..1, how much each is the speaker

shakingfloat-1

DialogueStage: seconds into a shake(); -1 = none

shake_strengthfloat0

...how far, in design units

shake_secondsfloat0

...how long

flashingfloat-1

DialogueStage: seconds into a flash(); -1 = none

flash_secondsfloat0

...how long

flash_colorColorWHITE

...of which colour

showing_historyboolfalse

Toggle_history(): the backlog instead of the box

dialogue_line

bool dialogue_line(rmp::Dialogue &dialogue, DialogueMemory &memory, const DialogueFlow &flow, const RichTextOptions &text = {})

A presenter's pieces, for a presenter of your own: the dialogue's line, typed out where the call is in your layout — its [speed] and [pause], its blips and recorded voice, auto-advance, skip-seen, and a click or Enter going on (on the line, or the next button it draws after it). True while there is a line. The flow blip is the one played: a Speaker's is yours to put in it.

dialogue_choices

bool dialogue_choices(rmp::Dialogue &dialogue, DialogueMemory &memory, const DialogueFlow &flow, const Style &choice_style = {})

The choices, as buttons in a column where the call is, and a timed choice's bar. True while there are choices.

BubbleSpeaker

struct BubbleSpeaker

Who a bubble points at: a speaker by name, and the object that speaks.

FieldTypeDefaultWhat it is
namestd::string

The speaker of the lines it says

objectrmp::Handle<rmp::Object>{}

What it is drawn over; empty: where the UI puts it

offsetVector2{ 0, -18 }

From the object's position, in world units

blipSoundName{}

Their blip; empty: the flow's

pitchfloat1

Their blip's pitch

styleStyle{}

Over the bubble's style, for their lines

DialogueBubble

struct DialogueBubble

A bubble over the speaker's head, in the world (rmp::ui::at()), the choices in it too. The world goes on around it.

FieldTypeDefaultWhat it is
speakersstd::vector<BubbleSpeaker>{}

Who says what, and over which object

flowDialogueFlow{}

The typewriter, the blips, auto-advance, timed choices

widthfloat220

Design units: the line wraps inside it

tailfloat10

Design units: the tail under it, to the speaker; 0 = none

tail_colorColorCLITERAL(Color){ 0, 0, 0, 0 }

The tail's colour; { 0, 0, 0, 0 } = the bubble's background, or the theme's panel. A bubble of art draws its own: give it a tail_picture.

tail_picturePicture{}

Drawn in the tail's place, 2 tails wide, 1 tall

pauses_worldboolfalse

The world goes on around a bubble

styleStyle{}

The bubble

choice_styleStyle{}

Each choice

oursDialogueMemory

Its state between frames; yours to read

bool show(rmp::Dialogue &dialogue)

Draws the line or the choices, and takes the player's answer. True while the dialogue has something to show.

TooltipOptions

struct TooltipOptions

How tooltip() places its line, and how long it waits.

FieldTypeDefaultWhat it is
sideAlignAlign::TOP_CENTER

Which side of the control it appears on

delayfloat0.5f

Seconds the pointer rests on the control before it shows; infinity: never by the pointer, by the focus alone.

tooltip

void tooltip(const rmp::Text &text)
void tooltip(const rmp::Text &text, const TooltipOptions &o)

A line about the control declared just before it, shown while the pointer rests on that control, or while the keyboard or gamepad focus is on it:

if (rmp::ui::button("Sell")) sell(item);
rmp::ui::tooltip("Gives you half of what it cost");

The text is copied. One with no control before it in the frame is reported once and shows nothing. An empty one shows nothing and is no mistake: tooltip(item.description) for an item without one.

NotifyOptions

struct NotifyOptions

How long notify() keeps a message, and its colour.

FieldTypeDefaultWhat it is
secondsfloat3

On screen for this long, then it fades out

colorColorRoleColorRole::TEXT

Which theme colour the text is painted in

notify

void notify(const rmp::Text &text)
void notify(const rmp::Text &text, const NotifyOptions &o)

A short message at the bottom of the screen that goes away by itself: "Saved", "Achievement unlocked". Call it from anywhere — _update(), a callback, a frame with no UI — because it only queues: the framework draws what is queued over everything else, and it never takes the pointer or the focus. The newest few are shown, one above the other. (In a game with its own frame hook they are drawn over the frame's first begin()/end(), there being no telling which end() is the last; and a frame of its that describes no interface draws none, so they wait, no older, for the next one that does.)

In a debug build the framework's own warnings arrive here too: a mistake it reports once in the log (an action nobody defined, a widget outside begin()/end()) is also said on screen, where it cannot scroll past.

Input, and who gets it

wants_pointer

bool wants_pointer()

The pointer is over the interface, or the interface is using it (dragging a slider). "Over the interface" is over anything it paints as a surface: every control, every box with a background colour or a border (a panel, a progress bar, an open dropdown list), an image, and a scroll area, empty part included — but not where a scroll area has clipped its contents away. Plain text with nothing behind it is NOT: a score drawn over the game does not stop the game being clicked through it.

wants_keyboard

bool wants_keyboard()

A text field has the keyboard, so the keys are its own: see text_input(). Having the focus is not enough — a field the player pressed Enter on keeps the focus and gives the keyboard back. And a HUD over a game being played that the player walked into with Tab, or whose control the game chose with focus(), has the keys until Escape, the B button, a click elsewhere or set_navigation_enabled(false): see FrameOptions::focus_first.

Focus, keyboard and gamepad

focus

void focus(std::string_view id)

Give a named control the focus — when a menu opens, or to point a controller at something other than the first control. Pass "" to clear it. A focus asked for by name is drawn straight away: you meant it, and a text field given it takes the keyboard. id is the control's label, or its explicit .id.

Outside begin()/end() — in a scene's _ready(), say — it waits for the next frame that draws controls and lands on the first one carrying that name, whichever scene draws it; if that frame has none, the request is dropped and the screen keeps its own default. On a HUD over a game being played it is the game choosing that control, as Tab would be: the keys are the interface's until Escape, the B button or a click elsewhere.

focused

std::string_view focused()

What has the focus right now, or "" if nothing does.

set_navigation_enabled, navigation_enabled

void set_navigation_enabled(bool on)
bool navigation_enabled()

Turn keyboard and gamepad navigation off if your game drives focus itself, and ask whether it is on. It starts on. Turning it off also gives back the keys of a HUD the player walked into with Tab, and turning it on again does not take them back.

Events

EventKind

enum class EventKind

What a control did.

ValueMeans
HOVERThe pointer arrived on it
UNHOVER...and left
PRESSThe pointer went down on it
RELEASEThe pointer came up after a PRESS, on it or not
CLICKIt was pressed: released on it, or Enter or the A button with the focus
FOCUSThe keyboard or gamepad focus arrived
BLUR...and left
CHANGEA checkbox, slider, dropdown or text field changed its value
OPENA dropdown opened its list
CLOSE...and closed it
SHAKEShake() was called on it

WidgetKind

enum class WidgetKind

Which kind of widget an event came from.

ValueMeans
BUTTON
LABEL
IMAGE
PANEL
CHECKBOX
SLIDER
DROPDOWN
TEXT_INPUT
PROGRESS

Event

struct Event

One event. name is the control's label, or its id when it has one; it is valid during the call only.

FieldTypeDefaultWhat it is
kindEventKindEventKind::CLICK

What happened

widgetWidgetKindWidgetKind::BUTTON

To which kind of widget

namestd::string_view{}

Its label or id

on_event

void on_event(rmp::Callback<const Event &> hook)

The one hook every event goes to, after its sound. Setting it again replaces it; an empty one — rmp::ui::on_event({}) — turns it off.

Widgets you keep

KeptState

struct KeptState

What a kept widget remembers between frames.

FieldTypeDefaultWhat it is
hoveredboolfalse

The pointer is on it

pressedboolfalse

Held down on it

focusedboolfalse

It has the focus

shakesint0

Shake() calls not yet started

Lifecycle

shutdown

void shutdown()

Called for you by the entry point macro, before on_exit() — while the window is still open, because releasing a font after CloseWindow() would be touching a GL context that no longer exists.

There is no init(): the UI starts itself on the first begin(), by which time there is a window. A game that never draws UI allocates nothing.