- 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 and Scroll layout with
Fixed,Content,PercentandFlexsizing. - Buttons, checkboxes, sliders, textboxes, dropdowns, listboxes, tabs, 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(rv::UI& ui, const rv::InputState& input, rv::Viewport viewport,
float& volume, rv::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();
ui.end_frame();
}
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, Shift selection, Ctrl+A, deletion and Enter submission. The console supports history with Up/Down, variable queries and changes; 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.
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.
- AGENTS.md: code conventions.