Back

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

42 points3 hoursgithub.com
kartoffelsaft1 hour ago

This has been my goto for personal toy projects for a while now. Trivial to slot in to basically anything that can display text and takes mouse input.

I will mention, however, it's kinda abandonware at this point. There is some bug with the draw call iterator which does a misaligned pointer access, which, if your environment is set up to catch that, can get annoying (Zig for example panics on it). There's a github issue that some have used as reason to fork it but all the forks I tried were subtly wrong, for what that's worth.

haeseong53 minutes ago

[flagged]

abtinf2 hours ago

The first thing I look for in any UI library is accessibility support. Makes it trivial to filter out toy projects.

RodgerTheGreat1 hour ago

"Accessibility" is an open-ended set of functionality, not a checkbox; it is never "complete", there is always room for improvement. Colorblind support (which ones)? High-Contrast mode? Adjustable text size? Screenreader integration? Localization? IME support? Keyboard navigation? Keyboard remapping? Functional entirely without a keyboard? Touch support? Pen support? Dyslexia-aiding typefaces? The list goes on and on.

Dwedit46 minutes ago

One clearly defined starting point is exposing any custom controls to accessibility APIs that are used to enumerate and interact (simulated mouse actions, reading the text, etc) with controls on the screen. Both scripting tools and screen readers make use of these. Built-in controls already have the enumeration and interaction feature and don't need additional code, but custom controls may not have that.

In the MicroUI example here, there are buttons and text labels and other kinds of controls, but no ability to enumerate or interact with the controls. Any program will just set a single giant window with no text and no controls inside. Accessibility software can still hook text output APIs, but not if it also uses custom font rendering.

jazzypants1 hour ago

This is one of the reasons why web technology is so popular and persistent. You get almost all of that for free as long as you use semantic HTML.

xyzzy_plugh2 hours ago

No. As much as I would like it to be the case, that is most certainly a poor criteria to evaluate a UI library.

Dear ImGui [0] is without a doubt the most prevalent immediate mode UI library. It does not have native accessibility features, but that hasn't stopped companies such as Intel, Meta, IKEA and Google from shipping products built upon it. It's also used in a ton of games.

Calling Dear ImGui a toy project at this point would be like calling Unreal Engine a toy project.

It's a shame accessibility support is not more widespread, and furthermore it's a shame that it is so laborious to add it.

0: https://github.com/ocornut/imgui/

whizzter2 hours ago

This is a library in similar vein to "Dear imgui", minimal requirements for integration (rectangle and text rendering) so that it's easy to embed into game-engines,etc for debug UI's and similar things.

monocasa2 hours ago

Or, not every UI library is intended for use cases where a13y even makes sense.

Like a debug UI in a game engine, or in an embedded device that doesn't even have input for a13y.

spwa42 hours ago

Then just save yourself some time. Immediate mode and accessibility are mutually exclusive.

afavour1 hour ago

Cool to see a demo in there that you can run in a browser, presumably compiled to WebAssembly. The kind of thing that was unimaginable years ago.

synergy201 hour ago

how is this different from lvgl? is this immediate mode or retained mode?

peter_d_sherman3 hours ago

>"Features

o Tiny: around 1100 sloc of ANSI C

o Works within a fixed-sized memory region: no additional memory is allocated

o Built-in controls: window, scrollable panel, button, slider, textbox, label, checkbox, wordwrapped text

o Works with any rendering system that can draw rectangles and text

o Designed to allow the user to easily add custom controls

o Simple layout system"

ur-whale2 hours ago

Nice, except the hard part seems to be missing: interfacing with an actual window system (X11, TUI, WIN32, whatever ...)

exDM692 hours ago

That's the whole point!

You plug it into your project and it can be rendered on anything that can push pixels and/or triangles to the screen. Events from windowing system go in, list of triangles comes out.

This is intended to be used with OpenGL, Vulkan, D3D and other graphics environment and used in cases where integrating a "real" GUI toolkit would be more trouble than it's worth.

Other popular libs like Dear Imgui or Egui work the same way.

foul2 hours ago

In demo/ someone can "steal" the renderer part which, being based on SDL, is to some extent cross-platform.

Littice3 hours ago

[dead]