Dear ImGui: Graphical User Interface library for C++
github.com
github.com
That said, be aware its original purpose is as a UI for internal game dev tools and not customer facing tool. It's neither international friendly nor accessibility friendly. Those are 2 feature usually not needed for internal tools.
I will never use anything other than Dear ImGUI from now on. The explicitness, lack of state, speed of development and maintainability of the code means it wins hands down.
Well worth investing your time in and if you are a leader in the games industry well worth supporting financially.
The thing is, immediate mode UIs are not really usable, because a widget needs internal state, so a pure immediate mode UI would require the caller to carry around all that state. Obviously that is burdensome, which is why Dear ImGUI hides it for you. But in my opinion, it's a bit of a fraud to call that an immediate mode UI, when it retains a copy of state behind its back.
So basically you are dismissing an existing definition to turn it into your own to say that existing libs are not fulfilling that definition.
ImGUI is cool for gaming yes, but not good for daily normal GUI desktop apps, per the design.
And I love how it allows me develop for Windows, Linux and MacOs with minimal overhead.
Sorry for caps (transcribed from image).
You can use tr to quickly convert it to lowercase:
pbpaste | tr '[:upper:]' '[:lower:]'
(Though I usually paste text in VSCodium and convert it there.)...indirectly by embedding a home computer emulator with a Dear ImGui debugger UI, compiled to WASM+WebGL running in a webview panel, but the idea to use Dear ImGui for tooling UIs in VSCode extensions where HTML+CSS might be too awkward is certainly interesting (think not just "traditional UIs", but also things like noodle-graphs, flame-graphs, diagrams... the vector renderer coming with Dear ImGui is great for that type of stuff).
[1] https://marketplace.visualstudio.com/items?itemName=floooh.v...
People wonder why their Electron apps use 16GB of memory.
The embedded emulator including the Dear ImGui debugging UI compiled to WASM is just around 700 KBytes, runs on all platforms (even in the VSCode browser version) and is safely sandboxed, that same code compiled to a native executable on macOS is 847 KBytes, doesn't run on any other OS without compiling another version, and would be blocked to run anyway because it is potentially unsafe.
Isn't a more declarative approached like XAML/QML (or even html/ccs) a better way to represent a GUI interface as opposed to an imperative list of command embedded inside the business logic of the application ?
How does IMGUI handle theming, reflow or even GPU acceleration on different platform ? It seems to me that a more declarive representation would allow for better tooling and easier split between presentation and themes to match the native platform.
For instance:
if (ImGui::Button("Click Me")) {
// do the stuff that should happen when the button is clicked
}
To hide a part of the UI you simply skip the code which describes that part of the UI. if (!btnHidden) {
if (ImGui::Button("Click Me")) {
...
}
}
Your code describes what the UI should look like in the current frame, and what should happen on user interactions, but without event listeners or callback functions.How you keep the UI declaration separate from the "business logic" is up to you. Dear ImGui allows very close coupling (which quite often is actually an advantage for adhoc UIs), or you can keep both separated as much as you prefer.
> How does IMGUI handle theming, reflow or even GPU acceleration on different platform ?
Dear ImGui actually builds an internal "stateful" representation of the UI declaration (it needs to remember at least some state between frames, otherwise simple features like moveable/sizeable windows wouldn't be possible) and then generates an optimized list of rendering commands that plug almost directly into 3D rendering APIs like D3D, Metal, GL etc... (the renderer is implemented outside of Dear ImGui by yourself, however Dear ImGui also comes with pluggable example renderers and window system glue for pretty much any platform and 3D API).
Themeing/skinning is indeed a weak point of Dear ImGui specifically, other immediate mode UI frameworks like Nuklear offer more flexibility there, but this has nothing to do with the imgui philosophy, only with feature sets of specific imgui libraries.
Themeing isn't a just a retained mode thing, you can do wonders with immediate UIs, even though (dear)ImGui doesn't provide much, you can still do wonders: https://github.com/ocornut/imgui/issues/707#issuecomment-362...
The gaming cheating community is quite creative as well: https://www.unknowncheats.me/forum/c-and-c-/505940-advanced-...
More on that topic: https://www.youtube.com/watch?v=Z1qyvQsjK5Y
It’s just so simple
For example adding an input box for editing a float value is one line of code and the syncing is done by just passing it a pointer.
This is a fantastic (imo) way to build user interfaces, because sometimes the most convenient way to manage state or construct a complex widget is to write a retained mode object that hosts some other child objects, and in other circumstances it's most convenient to write a modal dialog or something by just slamming out some imgui code in a standalone function.
I also think the imgui approach to layout (use an algorithm that can fully reconstruct your layout from scratch every frame without much of a performance penalty) removes a lot of potential bugs and quirks that are common in UI, like one-frame glitches or having to manually propagate state through a bunch of objects and layers. Though imgui approaches have their own downsides, like the "page tearing" issue. I've had to do some weird contortions to solve that one in my own code and I still get bugs occasionally.
The game I'm building right now does almost all of its scene layout and UI as a single graph of components that mix retained and immediate mode, and it's been a relaxing way to do things compared to the 'manually paint widgets in places and do hit testing' approach I've used for some previous titles.
A large portion of the UI is constructed via what I'd call 'value replication', where a container control is attached to a list of game objects (entities, components attached to entities, parameters to a script) and then the container automatically creates a list of child controls for each game object automatically. This allows easy virtualization (i.e. only having 20 controls to represent a scrolling view with 1000 items) and means I don't have to manually do a bunch of state synchronization.
1: https://github.com/sq/Libraries/tree/master/Squared/PRGUI
The tool creators needed some way to provide mod developers with access to a unified UI, and hooking the game’s built-in UI was far too high effort for the reward.
I played around with it to develop a couple mods for fun and have since become a huge fan of it, and started using Dear ImGUI to add interfaces to some of my personal tools that were previously CLI-only.
Maybe you can customize it and make it look great, but the "out of the box" experience is just... oof.
Q. What is this library called?
This library is called Dear ImGui. Please refer to it as Dear ImGui (not ImGui, not IMGUI).
(The library misleadingly started its life in 2014 as "ImGui" due to the fact that I didn't give it a proper name when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations e.g. Unity uses it own implementation of the IMGUI paradigm. To reduce the ambiguity without affecting existing code bases, I have decided in December 2015 a fully qualified name "Dear ImGui" for this library.
[1] https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-w...
https://github.com/floooh/sokol-samples
For example, the basic demo window:
Personally I found it a lot easier to grok than (for example) React or Qt (as two examples from opposite ends of the spectrum).
Dear ImGUI cleans Gtk's clock in the "clean", "simple", "functional", and "just works" categories these days, and I am currently porting my biggest side project from Gtk to Imgui.
If you are trying to "integrate with the (GNOME) desktop", I'm sure you should still use Gtk, but for most purposes I don't see the point. It seems from the outside like there are few core Gtk developers left, and they are basically in life support mode for an entire desktop suite, one that is stuck between two broken display engines (Xorg and Wayland) with no way to really fix things and every desktop Linux user expecting miracles.
ImGUI is just a busy dude banging away on a single toolkit, without the baggage of millions of nontechnical users to support. As a developer, I know which one is going to be producing the good stuff.
Maybe my standards are too low, but for quick internal tools, it's hard to beat 30-year-old Tcl+Tk.
Unlike most other toolkits, this one doesn't actually handle its own rendering/contexts. It outputs the low-level vertex buffers and textures that you can pull into your own graphics pipeline. Which means you can integrate it into any sort of 3d application or backend that you want.
Visual Node Graph with ImGui - https://news.ycombinator.com/item?id=37702059 - Sept 2023 (90 comments)
ImPlot: Interactive plotting library, ImGui style - https://news.ycombinator.com/item?id=37000594 - Aug 2023 (39 comments)
ImGUI Ported to a LiteX SoC - https://news.ycombinator.com/item?id=34540206 - Jan 2023 (12 comments)
Show HN: ImThemes – a Dear ImGui theme browser and editor - https://news.ycombinator.com/item?id=32290700 - July 2022 (1 comment)
Show HN: Python Live GUI – A Hybrid of Dear ImGUI and Phoenix LiveView - https://news.ycombinator.com/item?id=31679945 - June 2022 (19 comments)
Dear ImGui – Bloat-free graphical user interface library for C++ - https://news.ycombinator.com/item?id=24986908 - Nov 2020 (180 comments)
ImPlot: Advanced 2D Plotting for Dear ImGui - https://news.ycombinator.com/item?id=23128262 - May 2020 (6 comments)
Dear ImGui: Bloat-free Immediate Mode GUI for C++ with minimal dependencies - https://news.ycombinator.com/item?id=23065472 - May 2020 (1 comment)
Runtime Compiled C++ Dear ImGui and DirectX11 Tutorial - https://news.ycombinator.com/item?id=22233109 - Feb 2020 (12 comments)
Could ImGUI Be the Future of GUIs? - https://news.ycombinator.com/item?id=19745809 - April 2019 (124 comments)
Immediate Mode GUI - https://news.ycombinator.com/item?id=19744513 - April 2019 (128 comments)
ImGui: Bloat-Free Immediate Mode GUI for C++ with Minimal Dependencies - https://news.ycombinator.com/item?id=18121600 - Oct 2018 (1 comment)
ImGui: Bloat-Free Immediate Mode Graphical UI for C++ with Minimal Dependencies - https://news.ycombinator.com/item?id=16193560 - Jan 2018 (1 comment)
Using ImGui with modern C++ and STL for creating game dev tools – Part 2 - https://news.ycombinator.com/item?id=12148661 - July 2016 (33 comments)
Imgui: Immediate Mode Graphical User Interface with minimal dependencies - https://news.ycombinator.com/item?id=8161601 - Aug 2014 (41 comments)
Sol on Immediate Mode GUIs (IMGUI) - https://news.ycombinator.com/item?id=4201748 - July 2012 (15 comments)
> Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal and lacks certain features commonly found in more high-level libraries.
Here's a quote from my comment [1] on an earlier discussion about Dear ImGui vs. "bloated" browser APIs:
> This is what I hear when I enable VoiceOver on macOS and open Discord (either the web app or the desktop app):
> 1. “Discord, friends - Discord window, direct messages, selected cell”
> 2. “You are currently on a cell inside of a table. To navigate the cells within a table, press…”
> 3. (when navigating with the keyboard) “1 mention, $SERVER_NAME, cell” “$SERVER_NAME, cell” etc
> And here’s when I do the same with a random Dear ImGui app I have installed:
> 1. “$APP_NAME, $APP_NAME window, $APP_NAME window”
> 2. “You are currently in a window”
> 3. (when navigating with the keyboard) [silence; no additional instructions]
You're offering a retort to someone who is communicating their position that you ought not do something, where the retort consists of nothing more than explaining that people are doing it. Yes, clearly. But what the person you're responding to is arguing is that you ought not do it.
Consider the following hypothetical:
Person A: Here's little advice: don't take up smoking. Smoking is bad for you.
Person B: Yet people smoke—my cousin, for example.
The point of the other comment wasn't that it isn't happening or that it's physically impossible to even try. Indeed, the fact that it's being done—or that people are attracted, at least, to trying to do it—was rather the entire premise of their "word of caution".
Seems we should lift up Dear ImGui -- contribute, donate, feedback (document, gather requirements, etc), etc -- as opposed to suggest we not use it.
But any effort to document, specs, clarify etc would be helpful and not just to Dear ImGui.
Accessibility is a whole world that is hard to grasp when you are not a end-user, API are large, confusing, poorly documented, and I presume that there are a large variety of tools and use cases and it's even hard to gauge what are the low-hanging fruits that would be the best to implement/bind.
Given how obfuscated Web stacks are nowadays (since they do try to prevent unauthorized scrapping and automation), I'm honestly also a little bit surprised that nowadays screen readers aren't relying on OCR more?
Inevitable, you have to reach out to the specifics of the UI end, but for most of the tests all you may need is - Run App, Accept Some License / Button, Press something else, then something else - and it elevates some confidence that at least it can run and go that far (sometimes changes can break even this).
So such tests can be coded by completely autonomous team, not having to deal with how you've build the software to begin with, or coordinate changes you've made later (apart from how the UI works).
Your caution isn't wrong, but ultimately it may be futile.
The mental model of immediate mode guis makes it really easy to work on it as a side project with 10-20 minutes here or there before bed, though doing proper layout to make it look nice is sometimes a challenge. The other advantage is that I can just jump into the implementation, and the egui code itself is pretty easy to grok.
A good addition would be something like how flutter's LSP-based tools, which I use in Emacs), have a "wrap with widget" auto-refactoring tool, for e.g. when you want to wrap an entire widget tree in a new layout without having to do it manually.