tiny_ui is a C++17 library for creating simple UIs on Windows and Linux, using SDL2 as the renderer. Built with CMake and vcpkg.
# Configure with CMake (uses vcpkg toolchain)
cmake -B build -DCMAKE_BUILD_TYPE=Release
# Build library and samples
cmake --build build --config ReleaseOr use CMake Presets: cmake --preset default
On Windows: open tiny_ui.slnx or use .vcxproj files.
- SDL2, SDL2_image, SDL2_ttf, glm
./bin/release/tiny_ui_sample.exe # Windows
./bin/tiny_ui_sample # Linuxclang-format -i src/tinyui.cpp # single file
find src -name "*.cpp" -o -name "*.h" | xargs clang-format -i # allNo automated tests exist yet (CI test step is commented out). When added:
cd build && ctest -C Release # all tests
ctest -R test_name_pattern # single test- C++ Standard: C++17
- Formatting:
.clang-format(LLVM-based) - Indentation: 4 spaces, no tabs
- Column Limit: 0 (unlimited)
- Headers (
.h) and sources (.cpp) insrc/ - Backend code in
src/backends/ - Samples in
samples/ - All files require MIT License header
- Local project (
"*.h") - System headers (
<*.h>) - Other headers (
<*>)
#include "tinyui.h"
#include "backends/sdl2_renderer.h"
#include <iostream>
#include "stb_image.h"- Types/Enums: PascalCase (
Widget,Alignment) - Functions: camelCase (
createContext) - Members:
mprefix (mId,mRoot) - Constants: PascalCase (
ResultOk) orkprefix - Namespaces: lowercase (
tinyui)
- Use
int32_tfor explicit-width integers - Use
ret_code(int32_t) for return values - Use
nullptrnotNULL - Use
constexprfor compile-time constants - Use
static constexprfor class constants
static constexpr ret_code InvalidRenderHandle = -3;
static constexpr ret_code InvalidHandle = -2;
static constexpr ret_code ErrorCode = -1;
static constexpr ret_code ResultOk = 0;- Return error codes for recoverable errors
- Use
assert()for invariants - Validate inputs at function start
enum class Alignment : int32_t {
Invalid = -1,
Left = 0, Center, Right,
Count // for array sizing
};- Use structs for POD types
- Use
= defaultfor trivial constructors/destructors - Initialize members with default values
- Use Doxygen-style
/// @briefcomments
GitHub Actions (.github/workflows/cmake.yml): builds on Ubuntu, installs SDL2 libs, runs CMake configure + build.
CMakeLists.txt- build configvcpkg.json- dependencies.clang-format- formatting rulessrc/tinyui.h- core typessrc/widgets.h- widget definitionssrc/backends/- platform backends