5 ms·
MicroUI – A tiny, portable, immediate-mode UI library written in ANSI C
- peter_d_sherman 4mo 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"
- Littice 4mo agoImmediate-mode in pure C is a nice constraint. how does it handle text rendering, do you bring your own atlas or is there something built in? Thats usually the part that balloons the dependency footprint.
- dvhh 4mo agoit does not, it basically delegate that part to lower level library for which you have to write the glue code for, there is an example for SDL.
- flohofwoe 4mo agoThe demo uses a simple prebuilt fixed-size font atlas texture and renders the entire UI (including character quads) via batched glDrawElements calls (one draw call per clip-rect). But the way how text rendering is delegated to the user is quite flexible, microui basically calls these three user-provided functions: int r_get_text_height(void) int r_get_text_width(const char* text, int len); void r_draw_text(const char* text, mu_Vec2 pos, mu_Color color); ...how r_draw_text() is implemented is then entirely up to you.
- deleted 4mo ago[deleted]
- krapp 4mo agoIf anyone wants it here is an old fork of mine that uses SDL3 - https://codeberg.org/krapp/microui_sdl3_demo https://codeberg.org/krapp/microui_sdl3_demo
- ur-whale 4mo agoNice, except the hard part seems to be missing: interfacing with an actual window system (X11, TUI, WIN32, whatever ...)
- foul 4mo agoIn demo/ someone can "steal" the renderer part which, being based on SDL, is to some extent cross-platform.
- exDM69 4mo agoThat'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.
- flohofwoe 4mo agoIt's a "bring your own renderer" UI framework, just like Dear ImGui or Nuklear. In some situation (e.g. when adding debugging UIs to a game) this is actually a big advantage compared to the renderer being baked into the library, since the game already has a renderer subsystem which the UI can easily hook into.
- pkolchanov 4mo agoI've worked on a minimal application layer (Cocoa, X11, win32) that you might find interesting. It includes a microui example. https://github.com/pkolchanov/brr https://github.com/pkolchanov/brr
- abtinf 4mo agoThe first thing I look for in any UI library is accessibility support. Makes it trivial to filter out toy projects.
- HumblyTossed 4mo agoEverything is an engineering decision. Leaving out something doesn't mean it's a "toy". So, I don't really get your criticism here.
- spwa4 4mo agoThen just save yourself some time. Immediate mode and accessibility are mutually exclusive.
- whizzter 4mo agoThis 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.
- monocasa 4mo agoOr, 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.
- fwip 4mo agoBeing accessible to the intended users always matters. If you think it doesn't, that probably means it's currently accessible to those users (or that those who are it is inaccessible to have filtered themselves out, and are no longer users). For example - in your debug UI, colorblind-friendly colors don't matter, until you hire your twelfth member of the team, who struggles to tell red and green apart.
- monocasa 4mo agoThis library's default is greyscale anyway, so it's by default colorblind friendly.
- synergy20 4mo agohow is this different from lvgl? is this immediate mode or retained mode?
- flohofwoe 4mo agoVery different, starting at the line count: Lvgl is 440kloc across 1134 files (in the src directory), while microui is 1121 lines of code in one .c and one .h file. Microui is immediate mode, very minimal and 'bring your own renderer'. Probably most useful for adding a small debugging UI to a 3D game/app.
- kartoffelsaft 4mo agoThis 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.
- haeseong 4mo ago[flagged]
- packetlost 4mo ago> it's kinda abandonware at this point That's sad. I'm a fan of rxi's work, including this one.
- pstuart 4mo agoIt's MIT and these days handing it off to Claude to tart it up as needed should be viable.
- leecommamichael 4mo agoGenuine question; abandonware or complete? Something of this size serves as a nice substrate or starting-point regardless.
- HumblyTossed 4mo agoExactly. Software can be _done_. And that's okay(tm).
- Intralexical 4mo agoThe whole thing's less than 2kLoCs. If it needs ongoing maintenance, something's gone wrong IMO. I think it's reasonable to just patch it yourself if it doesn't work with your other tools (Zig). Though thank you for sharing the heads up.
- afavour 4mo agoCool 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.
- OvervCW 4mo agoWhat is the advantage of this compared to Dear Imgui?
- ranger_danger 4mo agoit's lighter weight and written in C
- kettlez 4mo agoThis is included in the Odin vendor libraries, it's fantastic for Raylib debug menus
- dsego 4mo agoRaylib also has Raygui https://github.com/raysan5/raygui https://github.com/raysan5/raygui But I found it pretty straightforward (and satisfying) to just build my own gui functions/widgets with raylib (inspired by raygui). https://github.com/dsego/strobe-tuner/blob/main/app/gui.odin https://github.com/dsego/strobe-tuner/blob/main/app/gui.odin
- flohofwoe 4mo agoI wrote a little demo to run microui on top of the sokol headers here, it's really interesting in how minimal it is. WASM demo: https://floooh.github.io/sokol-html5/sgl-microui-sapp.html https://floooh.github.io/sokol-html5/sgl-microui-sapp.html Source code: https://github.com/floooh/sokol-samples/blob/master/sapp/sgl-microui-sapp.c https://github.com/floooh/sokol-samples/blob/master/sapp/sgl... The renderer backend is just a bunch of C functions you need to provide: https://github.com/floooh/sokol-samples/blob/3f4185a8578cd2bd79fe39209b1ffc6b926bfc74/sapp/sgl-microui-sapp.c#L377-L507 https://github.com/floooh/sokol-samples/blob/3f4185a8578cd2b... It's also interesting to compare the binary sizes: microui sample (https://floooh.github.io/sokol-html5/sgl-microui-sapp.html https://floooh.github.io/sokol-html5/sgl-microui-sapp.html): 79.6 KBytes compressed download Nuklear sample (https://floooh.github.io/sokol-html5/nuklear-sapp.html https://floooh.github.io/sokol-html5/nuklear-sapp.html): 155 kb compressed download Dear ImGui sample (https://floooh.github.io/sokol-html5/imgui-sapp.html https://floooh.github.io/sokol-html5/imgui-sapp.html): 491 KB compressed download
- zuzululu 4mo agopretty nifty but im trying to figure out what the use case for this is when its aimed at hobbyists ? I use pygtk and dont have to fiddle with lower level stuff
- flohofwoe 4mo agoMinimal debugging/controller overlays for games would be the most obvious use case (e.g. similar to dat.gui for web).
- Levitating 4mo agopygtk requires GTK, this library works with any rendering library that can draw rectangles and text
- onsclom 4mo agoI made my own WASM demo @ https://microui-wasm.vercel.app/ https://microui-wasm.vercel.app/ and it's only 14.6 kB compressed! Will share source code if someone is interested, but key bits: - had a small JS glue layer using CanvasRenderingContext2D to render - made a `wasm32-freestanding` build to lower the wasm bundle size, which meant shimming the bits of the libc microui uses
- jacereda 4mo agoI used this one in 2022 to make a proof of concept for a build once / run anywhere graphical app and IIRC the library was quite nice, even if a bit limited. The resulting kludge is at https://github.com/jacereda/cosmogfx https://github.com/jacereda/cosmogfx and there's a prebuilt binary that should run on Linux, Windows and some BSDs. https://github.com/jacereda/cosmogfx/releases/download/v0.0.1-alpha/demo.com https://github.com/jacereda/cosmogfx/releases/download/v0.0.... Cosmopolitan Libc has since integrated the bits to make OpenGL work in cross-platform binaries and it's awesome.
- jmiskovic 4mo agoAlso see: https://rxi.github.io/microui_v2_an_implementation_overview.html https://rxi.github.io/microui_v2_an_implementation_overview....
- em-bee 4mo agoanyone working on bindings to other languages? (go, python, ruby, etc)
- HumblyTossed 4mo agoI was just thinking this would be great with go. If it would work.
- shideneyu 4mo agolove the web assembly demo. By the way, I hope this kind of interface for the web becomes more mainstream in the future, I start to hate html / css cuz everything looks the same because of it (even in the train stations they use it for scheduling)
- einpoklum 4mo agoHow can such a library be both tiny and portable, when the C standard library has no graphics facilities? Don't you need to lay down a lot of basis for different platforms and graphics backends, to be portable? And if you do that, how can you be tiny?
- b3orn 4mo agoAlmost all of these immediate mode UI libraries for C/C++ come without a rendering backend. Usually there are "example" implementations for libraries like SDL that you can use, or you implement your own backend. A lot of these libraries are popular for debug UIs in games and you probably need a custom backend for whatever graphics engine you use in your game.
- hparadiz 4mo agoI need something like this but with a few more bells and whistles.
- amelius 4mo agoThe problem is always: you don't know beforehand what bells and whistles you will need. That's why Qt is probably the only safe bet (or Web/Electron if you don't mind the slower performance).
- hparadiz 4mo agoI know exactly what I need. I just built a task manager in C with GTK+. It uses the theming built into GTK to allow users to change themes while the program is running but it's too memory heavy for my taste. I also have a background in web dev and understand how to build for accessibility. Currently the memory allocated for every single process on my computer is <3 MB but the interface displaying that information uses almost 55MB total when rendering. I need the ability to set fonts, colors, and sizes and the ability draw text as desktop manager understandable standard copy/pastable text. I want the font rendering to support basic anti aliasing. The API also needs to expose draw surfaces for me to draw OpenGL/Vulkan as needed. It needs to support both X and Waylandisms for window decorations. I specifically need the API to support animated icons for window decorations as that is currently unsupported by anyone at all in this space. https://github.com/hparadiz/evemon https://github.com/hparadiz/evemon You're right though I'm already thinking of scaling and hidpi as another thing I need.
- deleted 4mo ago[deleted]
- 0x0203 4mo agoFor a slightly larger, cross-platform, retained mode GUI written in C, there's libagar [0]. Different use case than MicroUI, but still a neat project. [0] https://libagar.org/ https://libagar.org/
- Narishma 4mo agoIf that's your project, the Arabic text rendering is broken in this screenshot: https://libagar.org/screenshots/agar171.png https://libagar.org/screenshots/agar171.png
- 0x0203 4mo agoIt's not mine; just a project I've toyed with a few times in my search for GUI toolkits over the years. Issues and/or PRs can be filed on the github page though.
- wefw3434 4mo agothis is easy question is how produce sms-message like text widget, with alligment like iphone
- ioma8 4mo agoI just ported it to rust 1:1 (https://github.com/ioma8/microui-rs https://github.com/ioma8/microui-rs) Yes with assistance of AI, not ashamed of that.
- skrellm 4mo agoI've created a similar (minimal, lightweight, ANSI C) UI library, which is even easier to use. https://gitlab.com/bztsrc/smgui https://gitlab.com/bztsrc/smgui I don't like immediate-mode, because you must handle everything in the same thread, so mine is a state-mode GUI. For immediate-mode and ANSI C, there's also Nuklear: https://github.com/Immediate-Mode-UI/Nuklear https://github.com/Immediate-Mode-UI/Nuklear This latter has all the bells and whistles.