Skip to content

Repository files navigation

tiny_ui

A lightweight C++23 UI library for Windows and Linux, using SDL2 as the renderer.

Features

  • Widgets:
    • Panel
    • Button
      • Text
      • Images
    • Label
    • Progress Bar
    • Imageview
    • Checkboxes / Selectionboxes
    • Tree-View (experimental)
    • Input-Field (experimental)
    • Status Bar
    • Standard-Dialogs
      • Open-File-Dialog
      • Save-File-Dialog
  • Platforms:
    • Windows
    • Linux

Build

# Configure and build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

Samples

You can check out samples at Samples-Section

Quick Start

intquit(WidgetHandle, void *instance) {
if (instance != nullptr) {
auto *ctx = static_cast<Context *>(instance);
ctx->mRequestShutdown = true;
return ResultOk; }
return ErrorCode;
}
intmain(int argc, char *argv[]) {
if (Style style = TinyUi::getDefaultStyle(); !TinyUi::createContext("Sample-Screen", style)) {
return -1;
}
if (TinyUi::initScreen(20, 20, 1024, 768) == -1) {
constauto &ctx = TinyUi::getContext();
ctx.mLogger(LogSeverity::Error, "Cannot init screen");
return ErrorCode;
}
constexprint32_t ButtonHeight = 18;
WidgetHandle rootPanel = Widgets::panel(WidgetHandle::getRootHandle(), "Sample-Dialog", Rect(90, 5, 220, 60), nullptr);
if (!panel.isValid()) {
constauto &ctx = TinyUi::getContext();
ctx.mLogger(LogSeverity::Error, "Cannot create panel");
return ErrorCode;
}
auto &ctx = TinyUi::getContext();
auto *dynamicQuitCallback = newCallbackI(quit, (void*) &ctx);
Widgets::label(rootPanel, "Hi, World!", Rect(100, 10, 200, ButtonHeight), Alignment::Center);
Widgets::textButton(rootPanel, "Quit", Rect(100, 30, 200, ButtonHeight), Alignment::Center, dynamicQuitCallback);
while (TinyUi::run()) {
TinyUi::render();
}
TinyUi::release();
return0;
}

Running the Sample

./bin/release/tiny_ui_sample.exe # Windows
./bin/tiny_ui_sample # Linux

results to

Sample

Planned

  1. Layouter
  2. Copy & Paste
  3. Groups
  4. Tabs
  5. Engine Integration examples
  6. Tutorials

CMakeQuality Gate

About

My tiny ui-lib, mostly used for simple tools and games

Resources

Stars

21 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages