Immediate-mode UI (IMGUI) flips the traditional model on its head. Instead of creating widget objects once and then mutating them over time, you describe your entire UI from scratch on every frame — Paper handles the rest. This page explains what that means in practice, why it is powerful, and how Paper keeps things efficient behind the scenes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Paper/llms.txt
Use this file to discover all available pages before exploring further.
The Frame Loop
Every frame, your code callsBeginFrame, declares all the elements you want to see, then calls EndFrame. Paper collects those declarations, runs layout, and renders the result.
BeginFrame resets the internal element tree. EndFrame runs layout, triggers interactions, and renders — in that order.
Nothing you declare survives past
EndFrame as a live object. The element tree is rebuilt completely the next time BeginFrame runs.Retained Mode vs. Immediate Mode
To understand why this matters, compare the two approaches with a simple toggle button.How Element Identity Works
Because the element tree is rebuilt every frame, Paper needs a stable way to match this frame’s elements to last frame’s elements. This is how animated transitions, hover states, and per-element storage all survive across frames. Every element gets a deterministic integer ID computed from four ingredients:stringID still get distinct IDs because lineID differs. An element created inside a for loop needs the loop index passed as intID (or a PushID scope) to stay distinct across iterations.
Persisting State Across Frames
IMGUI elements don’t exist between frames, so any state that needs to survive — scroll position, open/closed flag, animation progress — must be stored explicitly. Paper provides per-element storage keyed by your element’s stable ID:GetElementStorage<T> and SetElementStorage<T> have overloads that accept an explicit ElementHandle. During event callbacks such as OnClick, CurrentParent has already returned to the root element — always capture the handle before entering the scope and pass it explicitly inside callbacks. Storage entries whose element was not created in the last frame are automatically cleaned up by EndFrame.
There is also a root-level store for truly global state:
When to Use Immediate Mode
IMGUI shines for:- Game UIs and tooling — content changes frequently and closely follows application state.
- Developer tools — property inspectors, debuggers, level editors.
- Dynamic lists and data grids — add or remove rows without managing widget lifecycles.
- Prototyping — iterate quickly without architecture ceremony.
- The UI is largely static and driven by data binding infrastructure (e.g. MVVM).
- Accessibility trees or native widget semantics are a hard requirement.
- You need deep OS integration (system dialogs, native menus).