Quote:Maybe IM and RM aren't such great terms for a GUI API anyway, since everything gets kinda blurry when you introduce things like bindings/callbacks or my get_state.
Exactly what I've been saying for the last few pages! :P Your "IM library" is very similar to my "polling-based RM library" (not what I gave an example of, it would be a different design which I do not generally favor). I think the real points of contention are:
Unimportant -- Mostly Syntax1) How widgets are specified
- YOURS, every frame, in a procedural manner (i.e. this frame, I'm drawing this, then this, then, if X, that), allowing the library to construct the actual display list based on the sequence of UI procedures called that frame (probably caching data between frames for optimization)
- MINE, at initialization, in a declarative manner (i.e. this is a list of the things that you will be drawing, and when you will be drawing them), with the library maintaining that list and internally deciding what to render and when
2) How events are handled
- YOURS, polling-based, every frame you're essentially asking, "Was this button pressed? How about this button? And this button, what about it?"
- MINE, event-based, at initialization I connect widget events to their handlers, and the UI library fires them off as needed based user input and its internal model of the current structure of the scene (I could see an IM-style system doing it this way, which I would personally prefer)
Most Importantly3) How much the UI library "knows"
- YOURS, it knows what's being drawn this frame, and could obviously retain a cache of information regarding what's previously been drawn
- MINE, in addition to what your UI system knows, mine also knows
what might be drawn in the futureIt's #3 that's the real advantage here. If, for example, a scene is declared in such a way that my UI system can determine it will not change in the future, it can optimize the drawing directly to a static display list that it simply passes to the renderer directly every frame in a single command, and never looks at again.
With an IM-style system, I would argue, this isn't possible*, because the very POINT of an IM-style system is that the scene description is built up procedurally by the library user at run time, which obviously is not something the library has a direct view of.
* It could be possible with a reflective language where the GUI system is capable of actually reflecting into all of the calls the application can make to it--man that would be quite the thing to design! EDIT: A lot easier to do it this way if your UI system is script-based.