ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
InputController.hpp File Reference

Hover / press / focus state and click-callback dispatch for one node. More...

#include "Common.hpp"
#include "UIEnums.hpp"

Go to the source code of this file.

Classes

struct  ZenitUI::InputController
 Stateless per-node input dispatcher. More...

Detailed Description

Hover / press / focus state and click-callback dispatch for one node.

Every Layout embeds one InputController (as input_). The controller is stateless: it only mutates the node's public state fields (state.hovered, state.pressed, state.focused) and fires the node's callbacks. The per-node state itself lives in Layout, which is what the style resolver reads to select pseudo-class overlays.

Per-frame responsibilities:

  • updateFlags: recompute hovered / pressed from the current pointer.
  • computeNextState: derive the UIState enum consumed by the resolver.
  • fireCallbacks: dispatch onPress / onRelease / onClick and onRightClick based on the current frame's pointer transitions.
  • handleKeyInput: translate Enter / Space into onClick for the focused keyboard-activatable node.

Click routing uses a press-then-release model: pressTarget is set on button-down, releaseTarget on button-up, and onClick fires only if both agree. This prevents clicks from firing when the pointer is released over a different node (e.g. drag off a button).