|
1 | | -# leanUI |
| 1 | +# LeanUI |
| 2 | + |
| 3 | +LeanUI is a small immediate-mode UI library written in C99. |
| 4 | +It’s designed for games and lightweight applications that need a clean, polished interface without bringing in a full framework. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +- Immediate-mode API |
| 13 | +- No allocations, no dependencies beyond the C standard library |
| 14 | +- Single header / single source, easy to drop into any project |
| 15 | +- Built-in easing and animation for a smooth, modern feel |
| 16 | +- A focused set of well-designed widgets |
| 17 | +- ~500 lines of code, compiles in seconds |
| 18 | + |
| 19 | +LeanUI aims to sit between *microui’s minimalism* and *modern UI polish*. |
| 20 | +It’s not a giant toolkit, but it’s not barebones either. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Widgets |
| 25 | + |
| 26 | +LeanUI provides a small, cohesive set of widgets: |
| 27 | + |
| 28 | +- **Buttons** — with hover and press animations |
| 29 | +- **Labels / value fields** — for clean key–value layouts |
| 30 | +- **Toggles** — animated switches inspired by iOS |
| 31 | +- **Segmented controls** — for mode switching |
| 32 | + |
| 33 | +Each widget is built with consistent spacing, alignment, and interaction patterns. |
| 34 | +The goal is not to cover everything, but to make a minimal set look and feel right out of the box. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## Animation & Easing |
| 39 | + |
| 40 | +Unlike most tiny immediate-mode UI libraries, LeanUI has animation built in: |
| 41 | + |
| 42 | +- Hover, press, and toggle states are automatically eased over time. |
| 43 | +- New windows and panels animate smoothly when they appear. |
| 44 | +- No per-widget state is stored — transitions are computed implicitly based on widget identity. |
| 45 | +- Common easing functions (e.g. quadratic, overshoot) are included. |
| 46 | + |
| 47 | +This gives small UIs a fluid, modern feel without adding complexity to your code. |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Example |
| 52 | + |
| 53 | +```c |
| 54 | +#include "lean_ui.h" |
| 55 | + |
| 56 | +void frame(void) |
| 57 | +{ |
| 58 | + ui_begin(); |
| 59 | + |
| 60 | + if (ui_button("Click Me")) { |
| 61 | + // Handle button press |
| 62 | + } |
| 63 | + |
| 64 | + ui_end(); |
| 65 | +} |
0 commit comments