feat(engine): tooltip infrastructure with hover delay (foundation only)
A new ui_tooltip module owns a Tooltip(Cow<'static, str>) component that turns any UI node into a hover-revealing help target. Bevy 0.18's required-components attribute auto-inserts an Interaction so callers just attach Tooltip and the rest is wired. A single overlay entity is reparented above the focus ring (new Z_TOOLTIP token = Z_FOCUS_RING + 10) and tracked from the hovered target's GlobalTransform + ComputedNode. The chained Update systems start a hover timer on Interaction::Hovered, show the overlay once MOTION_TOOLTIP_DELAY_SECS (0.5s) has elapsed, hide it the moment hover ends, and refresh the text when the hover target switches without an intervening unhover. Tested headless under MinimalPlugins with a 200ms ManualDuration ticker — Bevy clamps Time<Virtual>'s max_delta to 250ms by default, so a one-shot 1s step doesn't actually advance the clock past the threshold; the tests step five times to exercise both pre- and post-delay invariants. This commit ships the infrastructure only — no entity in the engine has Tooltip attached yet. A follow-up applies tooltips to the HUD readouts and action bar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -275,6 +275,23 @@ pub const MOTION_SCORE_PULSE_SECS: f32 = 0.25;
|
||||
/// 400 ms.
|
||||
pub const MOTION_LOADING_TICK_SECS: f32 = 0.40;
|
||||
|
||||
/// Hover delay before a tooltip appears, in seconds. Long enough that
|
||||
/// players gliding the cursor across the HUD don't see flicker; short
|
||||
/// enough that "stop and read" feels responsive. Not run through
|
||||
/// [`scaled_duration`] — `AnimSpeed` controls gameplay motion, not the
|
||||
/// hover-discoverability budget for help text.
|
||||
pub const MOTION_TOOLTIP_DELAY_SECS: f32 = 0.5;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Z-index — tooltip layer
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Z-layer for tooltips. Sits one rung above the focus ring so a
|
||||
/// tooltip rendered over a focused button is never occluded by the
|
||||
/// button's outline. Still below `Z_WIN_CASCADE` and `Z_TOAST` so the
|
||||
/// celebration and notification layers stay on top.
|
||||
pub const Z_TOOLTIP: i32 = Z_FOCUS_RING + 10;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -342,6 +359,7 @@ mod tests {
|
||||
Z_PAUSE_DIALOG,
|
||||
Z_ONBOARDING,
|
||||
Z_FOCUS_RING,
|
||||
Z_TOOLTIP,
|
||||
Z_WIN_CASCADE,
|
||||
Z_TOAST,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user