mui

A tiny immediate-mode UI library


Keywords
ui, microui, nim, sokol
License
MIT
Install
nimble install mui

Documentation

microui

A tiny, portable, immediate-mode UI library written in ANSI C

Copy by rxi/microui

Features

  • Tiny: around 1100 sloc of ANSI C
  • Works within a fixed-sized memory region: no additional memory is allocated
  • Built-in controls: window, scrollable panel, button, slider, textbox, label, checkbox, wordwrapped text
  • Works with any rendering system that can draw rectangles and text
  • Designed to allow the user to easily add custom controls
  • Simple layout system

Example

example

import mui as mu
if mu.begin_window(ctx, "My Window", mu.Rect(x:10, y:10, w:140, h:86))!=0:
  var v {.global.} = [60.cint, -1]
  mu.layout_row(ctx, 2, v[0].addr, 0);

  mu.label(ctx, "First:");
  if mu.button(ctx, "Button1")!=0:
    echo "Button1 pressed"

  mu.label(ctx, "Second:");
  if mu.button(ctx, "Button2")!=0:
    mu.open_popup(ctx, "My Popup")

  if mu.begin_popup(ctx, "My Popup")!=0:
    mu.label(ctx, "Hello world!")
    mu.end_popup(ctx)

  mu.end_window(ctx)

Screenshot

screenshot

Browser Demo

Usage

  • See doc/usage.md for usage instructions
  • See the demo directory for a usage example

Notes

The library expects the user to provide input and handle the resultant drawing commands, it does not do any drawing itself.

Contributing

The library is designed to be lightweight, providing a foundation to which you can easily add custom controls and UI elements; pull requests adding additional features will likely not be merged. Bug reports are welcome.

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.