bevy/crates
Alice Cecile 145f5f4394
Add a simple directional UI navigation example (#17224)
# Objective

Gamepad / directional navigation needs an example, for both teaching and
testing purposes.

## Solution

- Add a simple grid-based example.
- Fix an intermittent panic caused by a race condition with bevy_a11y
- Clean up small issues noticed in bevy_input_focus


![image](https://github.com/user-attachments/assets/3a924255-0cd6-44a5-9bb7-b2c400a22d7e)

## To do: this PR

- [x] figure out why "enter" isn't doing anything
- [x] change button color on interaction rather than printing
- [x] add on-screen directions
- [x] move to an asymmetric grid to catch bugs
- [x] ~~fix colors not resetting on button press~~ lol this is mostly
just a problem with hacking `Interaction` for this
- [x] swap to using observers + bubbling, rather than `Interaction`

## To do: future work

- when I increase the button size, such that there is no line break, the
text on the buttons is no longer centered :( EDIT: this is
https://github.com/bevyengine/bevy/issues/16783
- add gamepad stick navigation
- add tools to find the nearest populated quadrant to make diagonal
inputs work
- add a `add_edges` method to `DirectionalNavigationMap`
- add a `add_grid` method to `DirectionalNavigationMap`
- make the example's layout more complex and realistic
- add tools to automatically generate this list
- add button shake on failed navigation rather than printing an error
- make Pressed events easier to mock: default fields, PointerId::Focus

## Testing

`cargo run --example directional_navigation`

---------

Co-authored-by: Rob Parrett <robparrett@gmail.com>
2025-01-09 21:15:28 +00:00
..
bevy_a11y Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_animation Allow tuple structs in animated_field! macro (#17234) 2025-01-08 19:04:32 +00:00
bevy_app Update downcast-rs to version 2 (#17223) 2025-01-07 21:33:40 +00:00
bevy_asset Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_audio bevy_audio: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17119) 2025-01-06 19:09:08 +00:00
bevy_color Add the original source for Oklab conversions (#17199) 2025-01-07 00:41:33 +00:00
bevy_core_pipeline Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_derive Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_dev_tools Upstream DebugPickingPlugin from bevy_mod_picking (#17177) 2025-01-07 05:19:50 +00:00
bevy_diagnostic bevy_diagnostic: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17186) 2025-01-06 19:29:59 +00:00
bevy_dylib Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_ecs Add compile-time dyn compatible checks for DynEq, DynHash (#17254) 2025-01-09 07:30:54 +00:00
bevy_encase_derive Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_gilrs bevy_gilrs: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17245) 2025-01-09 06:25:45 +00:00
bevy_gizmos Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_gltf Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_hierarchy Add Result handling to Commands and EntityCommands (#17043) 2025-01-07 16:50:52 +00:00
bevy_image Move TextureAtlas and friends into bevy_image (#17219) 2025-01-07 18:43:11 +00:00
bevy_input bevy_input: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17242) 2025-01-08 20:42:50 +00:00
bevy_input_focus Add a simple directional UI navigation example (#17224) 2025-01-09 21:15:28 +00:00
bevy_internal Added docs about MinimalPlugins looping as fast as possible. (#17241) 2025-01-09 06:28:06 +00:00
bevy_log bevy_log: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17246) 2025-01-09 06:26:04 +00:00
bevy_macro_utils Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_math Add basic directional (gamepad) navigation for UI (and non-UI) (#17102) 2025-01-06 18:51:44 +00:00
bevy_mesh bevy_mesh: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17218) 2025-01-09 06:29:36 +00:00
bevy_mikktspace Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_pbr Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_picking Make sprite picking opt-in (#17225) 2025-01-09 18:11:44 +00:00
bevy_ptr bevy_ptr: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17214) 2025-01-07 18:46:53 +00:00
bevy_reflect Update downcast-rs to version 2 (#17223) 2025-01-07 21:33:40 +00:00
bevy_remote Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_render Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_scene Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_sprite Make sprite picking opt-in (#17225) 2025-01-09 18:11:44 +00:00
bevy_state Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_tasks Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_text Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_time bevy_time: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17210) 2025-01-09 06:29:42 +00:00
bevy_transform Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_ui Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
bevy_utils Add compile-time dyn compatible checks for DynEq, DynHash (#17254) 2025-01-09 07:30:54 +00:00
bevy_window bevy_window: Apply #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17213) 2025-01-07 18:47:10 +00:00
bevy_winit Add a simple directional UI navigation example (#17224) 2025-01-09 21:15:28 +00:00