feat(core): Add MainLoop helper for optimized application loops
MainLoop encapsulates the CPU optimization patterns:
- Progressive sleep (8ms → 33ms → SDL_WaitEventTimeout)
- Automatic event handling
- Dirty region support
- Configurable timing parameters
Usage:
```zig
const MyApp = struct {
pub fn handleEvent(self: *MyApp, event: Event, ctx: *Context) void { ... }
pub fn update(self: *MyApp, ctx: *Context) bool { return changed; }
pub fn draw(self: *MyApp, ctx: *Context, renderer: *Renderer) void { ... }
};
var loop = try MainLoop.init(allocator, 800, 600);
loop.run(backend, &app);
```
This moves CPU optimization from application code to library level,
making it easy for all zcatgui apps to achieve 0% CPU in idle.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>