←back to thread

205 points samspenc | 5 comments | | HN request time: 0.205s | source
1. kg ◴[] No.45146889[source]
This is one scenario where IMGUI approaches have a small win, even if it's by accident - since GUI elements are constructed on demand in immediate mode, invisible/unused elements won't have tooltip setup run, and the tooltip setup code will probably only run for the control that's showing a tooltip.

(Depending on your IMGUI API you might be setting tooltip text in advance as a constant on every visible control, but that's probably a lot fewer than 38000 controls, I'd hope.)

It's interesting that every control previously had its own dedicated tooltip component, instead of having all controls share a single system wide tooltip. I'm curious why they designed it that way.

replies(3): >>45147379 #>>45147966 #>>45147993 #
2. krzat ◴[] No.45147379[source]
How does this compare to React-like approach (React, Flutter, SwiftUI)?

It seems like those libraries do what IMGUI do, but more structured.

replies(1): >>45153347 #
3. bob1029 ◴[] No.45147966[source]
Unity uses an IMGUI approach and it makes all the difference in the universe. Overriding an OnDrawGizmos method to quickly get at an editor viz of a new component is super efficient. There are some sharp edges like forgetting to set/reset colors, etc, but I much prefer these little annoyances for the convenience I get in return.

AFAIK, UE relies on a retained mode GUI, but I never got far enough into that version of Narnia to experience it first hand.

4. lentil_soup ◴[] No.45147993[source]
No idea why you're getting down voted but that was my thought as well.

With immediate mode you don't have to construct any widgets or objects. You just render them via code every frame which gives you more freedom in how you tackle each UI element. You're not forced into one widget system across the entire application. For example, if you detect your tooltip code is slow you could memcpy all the strings in a block of memory and then have tooltips use an index to that memory, or have them load on demand from disk, or the cloud or space or whatever. The point being you can optimise the UI piecemeal.

Immediate mode has its own challenges but I do find it interesting to at least see how the different approaches would tackle the problem

5. socalgal2 ◴[] No.45153347[source]
ImGUIs you do whatever you want with your state. You read your state and call UI functions.

React requires knowing about your state because it wants to monitor all of it for changes to try to optimize not doing things if nothing changed. This ends up infecting every part of your code to do so. It's the number 1 frustration I have using React. I haven't used Flutter or SwiftUI so I don't know if they are analogus