- C++ 98%
- CMake 1%
- Shell <1%
Rivet #
A C++23 UI library with a frame-built typed tree, measure/arrange layout, retained interaction state and renderer-independent drawing. The core uses only the standard library; rendering and fonts belong to the host.
Status: 0.0.1, API unstable. Names, signatures and behavior may change without notice until a 1.0 release. Pin a commit if you depend on it.
At a glance #
- Declare the UI each frame in plain C++; application values stay yours.
- Type-based control identity: no strings, no call-order bugs.
- Row, Column, Stack, Grid and Scroll layout with
Fixed,Content,PercentandFlexsizing. - Buttons, checkboxes, toggles, radio groups, sliders with ticks, number fields (float or int), progress bars, textboxes, dropdowns, listboxes, horizontal and vertical tabs, panels, groups, separators, windows, modals and a color picker.
- Input arrives as ordered portable events; output is a portable draw list.
- Steady frames make no heap allocations.
#include <rivet/rivet.hpp>
struct Apply;
struct Volume;
void frame(rivet::UI& ui, const rivet::InputState& input, rivet::Viewport viewport,
float& volume, rivet::DrawList& draw) {
ui.begin_frame(input, viewport);
if (ui.button<Apply>("Apply")) {
// Application handles the action here; its effects shape this frame.
}
if (ui.slider<Volume>(volume, 0.f, 1.f)) {
// volume has already changed.
}
ui.resolve();
draw = ui.draw_list();
}
The host renders the draw list with its own renderer. An SDL3 reference host lives in dev-env/. See the guide for the host contract, identity, lifecycle, layout and colors.
The dev-env Controls scene:

Requirements and platforms #
- CMake 3.25+ and a C++23 compiler. Tested with GCC 16 and Clang 23 on Linux; other platforms and compilers are untested.
- Tests: Catch2 3.8.1+.
- Development host: SDL3 and SDL3_ttf 3.x. It locates Noto Sans or DejaVu Sans in common Linux font directories; elsewhere pass
--fontor setRIVET_FONT.
Build and try #
cmake --preset debug
cmake --build --preset debug
ctest --preset debug
build/debug/dev-env/rivet-dev
To choose another font:
build/debug/dev-env/rivet-dev --font /path/to/font.ttf
# Alternatively set RIVET_FONT.
Choose Basics, Layout, Controls, Scrolling, Text, Windows, Console, Stress or Colors using the top tab strip. Resize the window to exercise proportional and flexible sizing. The bounds checkbox overlays measured rectangles in yellow and clips in green. Scroll with the mouse wheel or drag the right scrollbar. Drag floating windows by their header and resize using their bottom-right corner. Textboxes support committed UTF-8, measured cursor positioning, drag selection, navigation, Ctrl+arrow word motion and deletion, Shift selection, Ctrl+A, Ctrl+C/X/V, deletion and Enter submission. The console keeps its log in virtual rows that follow new output, colors results and errors, recalls history with Up/Down, completes command names with Tab (showing each variable's value), scrolls the log with PageUp/PageDown and Ctrl+Home/End while typing, clears the line with Esc, and shows a status row with a hint for the command being typed, whether the log follows new output (or how many newer lines wait below), the error count and the line count; enter help for commands.
A bounded automated lifecycle check renders all nine scenes, including stress, resizing and wheel translation:
SDL_VIDEODRIVER=dummy build/debug/dev-env/rivet-dev --smoke
Visual correctness still needs a human look at the scenes.
Portable library only #
Neither SDL nor Catch2 is required for this configuration:
cmake -S . -B build/core -DRIVET_BUILD_DEV_ENV=OFF -DRIVET_BUILD_TESTS=OFF
cmake --build build/core --target rivet
cmake --install build/core --prefix /your/install/prefix
Public headers live under rivet/include/rivet/. The core uses the C++ standard library only.
The library is static by default. Pass -DBUILD_SHARED_LIBS=ON for a shared library; it exports only
the public UI interface, and its package config carries the RIVET_SHARED definition consumers
need. There is no ABI promise before 1.0, so the soname is the full version (librivet.so.0.0.1).
Integration #
Consumers link rivet::rivet.
CPM #
CPMAddPackage(
NAME rivet
GIT_REPOSITORY https://tangled.org/branko.tngl.sh/rivet.git
GIT_TAG main
GIT_SHALLOW TRUE
SYSTEM
)
target_link_libraries(your_target PRIVATE rivet::rivet)
FetchContent #
include(FetchContent)
FetchContent_Declare(rivet
GIT_REPOSITORY https://tangled.org/branko.tngl.sh/rivet.git
GIT_TAG main
)
FetchContent_MakeAvailable(rivet)
target_link_libraries(your_target PRIVATE rivet::rivet)
Installed package #
find_package(rivet CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE rivet::rivet)
Documentation #
- Guide: host contract, identity, lifecycle, layout, colors.
- Decision log: why Rivet is shaped this way.
- Developing Rivet: verification, sanitizers, formatting.
- Contributing: layout, design rules, code style, testing, commits.