[HN Gopher] About the IMGUI Paradigm
       ___________________________________________________________________
        
       About the IMGUI Paradigm
        
       Author : ibobev
       Score  : 7 points
       Date   : 2024-08-22 16:38 UTC (1 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | zzo38computer wrote:
       | > The structure and function of your UI is naturally expressed in
       | the code of the functions that draw it, instead of in ephemeral
       | and opaque object trees that only exist in RAM after they're
       | constructed at runtime
       | 
       | This is probably it (although perhaps it is not quite the best
       | explanation, but the example in the article helps to explain it);
       | there are many possible implementations of an idea such as this.
       | However, depending on the program and on other stuff, it is not
       | always best for all kind of programs and all kind of UI. (In some
       | cases, a kind of hybrid might do.)
       | 
       | And, as they say about the example, there are things to criticize
       | about it. Still, it can show an example of its use, even though
       | it is a simple example.
       | 
       | I had made my own variant of IMGUI. It uses a "win_form" block,
       | which can be nested and which supports "break", and various other
       | commands inside of the win_form block such as "win_command",
       | "win_numeric", "win_boolean", etc; these commands do not have to
       | be directly but can also be inside of a "if", "for", "switch",
       | etc. These are implemented by C99 macros. The amount of state is
       | small, not more than twenty bytes per active form (regardless of
       | the number of widgets), and it is stored in the stack (but there
       | is no need to explicitly add commands to declare or allocate this
       | state; the "win_form" macro does this automatically).
       | 
       | The git repository https://github.com/zzo38/superzz0 is for a
       | program that contains this UI implementation. The file called
       | "common.h" contains the macros and function declarations, and
       | "window.c" contains the implementation. You can see many uses of
       | it in "edit.c" (search for "win_form" to find many of the uses).
       | 
       | As they say in the article, immediate mode does not necessarily
       | mean that the library doesn't retain data (mine retains a single
       | pointer, which is used to restore state when leaving a nested
       | win_form block), that it needs a GPU to render, etc.
        
       | bgribble wrote:
       | I love the developer experience of Dear ImGUI, even though I use
       | it through Python wrappers that confuse things sometimes. It just
       | slices like a sword through several layers of often-pointless
       | abstraction and puts the control over the main loop right in your
       | hands.
       | 
       | And when you need to read the source to figure something out,
       | it's just a few files of pretty self-evident C-ish code.
        
       | amelius wrote:
       | Say I have a very long listbox containing thousands of items, and
       | each item has a height that may be different (e.g. a list of font
       | families where each line may have a slightly different line
       | height).
       | 
       | How would IMGUI perform the drawing, given the scrollbar is at
       | (say) 20%?
        
       ___________________________________________________________________
       (page generated 2024-08-23 23:00 UTC)