feat(context): Ghost Drawing - suppress_commands flag

Nuevo flag para "Dibujo Fantasma":
- suppress_commands: bool en Context
- pushCommand() y pushOverlayCommand() retornan si está activo
- Permite procesar input (draw) sin generar comandos (ahorra CPU)

Solución de Gemini para immediate-mode + dirty panels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
R.Eugenio 2026-01-02 11:32:42 +01:00
parent 0342d5c145
commit 84bf37cd89

View file

@ -97,6 +97,11 @@ pub const Context = struct {
/// Dirty flags per panel (true = needs redraw)
dirty_panels: std.StringHashMapUnmanaged(bool),
/// "Ghost Drawing" mode: when true, pushCommand does nothing.
/// Used to process widget input (via draw) without generating render commands.
/// Set by application for non-dirty panels to save CPU while keeping input working.
suppress_commands: bool = false,
/// Frame statistics
stats: FrameStats,
@ -468,13 +473,17 @@ pub const Context = struct {
}
/// Push a draw command
/// If suppress_commands is true (Ghost Drawing mode), does nothing.
pub fn pushCommand(self: *Self, cmd: Command.DrawCommand) void {
if (self.suppress_commands) return;
self.commands.append(self.allocator, cmd) catch {};
}
/// Push an overlay command (drawn AFTER all regular commands)
/// Use this for dropdowns, tooltips, popups that need to appear on top
/// If suppress_commands is true (Ghost Drawing mode), does nothing.
pub fn pushOverlayCommand(self: *Self, cmd: Command.DrawCommand) void {
if (self.suppress_commands) return;
self.overlay_commands.append(self.allocator, cmd) catch {};
}