Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

TLDR;

Typically we build GUIs using event driven callbacks. This causes problems in managing life times, dynamic layouts, threading issues etc. The idea behind immediate mode GUI is that you get a frame and in each frame you create/update layout, check for user actions - just like you do in render frame in game loop. So there are no call backs and you don't have to worry about issues arising from event-driven code.



Does this pretty-much rule out (without a huge amount of effort) nonmodal GUIs? It seems without callbacks, you would need to roll your own window management, Z-ordering of overlapping UI elements, state transition validation (e.g. clicking on the parent dialogue’s Cancel button while a child window is still open), ...


There's no reason that that can't all be done as part of the underlying IMGUI implementation; what you're working with above that is essentially a DSL that renders out to a workable set of controls. Layout management and the actual rendered graphics / animations are handled by the code you don't have to see.

If anything, this is actually a lot like Web 1.0 programming: server side rendering, often using templates that end up looking a lot like a DSL. Each page view is rendered based on those templates against data fetched in advance of the output.

You can get pretty deep with that kind of thing, though of course the page refresh time was what killed this otherwise fairly nice style of writing an application. Users expected actions like sorting a column to be as fast in the browser as it was in a Windows 95-era file explorer or Excel, and it simply wasn't happening.

(Imagine if first-class client-side-interactive UI components like a sortable table, tabbed panel, etc. like what XUL provides had been in HTML in the 90s. We wouldn't need half the Javascript bullshit people have to use now to replicate that functionality half-assedly...)


Here's an browser demo for dear imgui (https://github.com/ocornut/imgui) library:

https://pbrfrat.com/post/imgui_in_browser.html

For modal demo check "Popups & modal windows" -> "Modals" example.

This is how it looks in C++ code: https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp#...


Here's another

https://greggman.github.io/doodles/glfw-imgui/out/glfw-imgui...

In the "ImGUI Demo" window start expanding the collapsed items or from the menus pick "Examples"

Note that no effort has been spent to actually make the demo web browser friendly so there are rough edges.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: