Skip to content

Add ui navigation system (RFC 41)#5378

Closed
nicopap wants to merge 30 commits intobevyengine:mainfrom
nicopap:ui-navigation
Closed

Add ui navigation system (RFC 41)#5378
nicopap wants to merge 30 commits intobevyengine:mainfrom
nicopap:ui-navigation

Conversation

@nicopap
Copy link
Contributor

@nicopap nicopap commented Jul 19, 2022

Objective

TODO

This is a WIP.

  • Figure out how to call the new crate and how it interacts with the name of the existing one (cursor_navigation)
  • Get bevy_ui to compile
  • Consider replacing the seeds bundles by a single component.
  • Documentation pass: remove absolute links to rust items, rework the bevy_ui_navigation README
  • Add a Hoverable component
  • Get all pre-existing examples to work with the new focus system
  • Add a custom navigation example with skill tree and dynamic menus
  • Get all new examples to work
  • [POSTPONED] Multicursor story see discord discussion
  • Serious design consideration on handling Hover + Focused in combination
  • Green CI

(TODO for myself):

  • Docs on NavRequestSystem is misleading
  • IOS example is probably broken

Differences with bevy-ui-navigation

  • The marking module and marking menus are gone
  • bevy_ui-related systems are now defined in bevy_ui
  • The event_helpers module is gone, replaced by the NavEventReaderExt::nav_iter trait extension method on EventReader<NavEvent> and the NavEventReader methods.
  • Some renaming occurred (dormantprioritized, NavMenu → MenuSetting)
  • Reworked the seeds module to make it much simpler

Changelog

  • Added focus management for gamepads
  • Decoupled input from focus management
  • Decoupled focus management from bevy_ui
  • Enables user-specified input handling for UI interaction
  • Added an optional menu tree management system
  • Added many examples demonstrating usage of the new navigation capabilities, including a procedural name generator menu backed by 2d sprites.

Migration Guide

  • Replace all usages of Interaction with Focusable, and instead of matching on the component itself, match on the return value of the focusable.state() method.
  • Hovering state is now accessed through the Hover component, instead of Interaction.
  • Interaction::Clicked has no Focusable equivalent, you should use EventReader<NavEvent> instead now.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets X-Needs-SME This type of work requires an SME to approve it. labels Jul 19, 2022
@alice-i-cecile alice-i-cecile self-requested a review July 19, 2022 13:43
@nicopap
Copy link
Contributor Author

nicopap commented Jul 23, 2022

@Weibye
Copy link
Contributor

Weibye commented Jul 29, 2022

Edit: left comment on wrong PR

nicopap added a commit to nicopap/ui-navigation that referenced this pull request Jul 31, 2022
This backports changes in bevyengine/bevy#5378
into bevy-ui-navigation.

Closes #29 (update to bevy 0.8) which:
- Fixes #28 (default selection is wrong)
- Fixes #27 (poor docs on `Locked`)
- Fixes #25 (typo in doc)
@nicopap nicopap force-pushed the ui-navigation branch 2 times, most recently from 00972fa to 0c877bc Compare August 9, 2022 13:07
* now bevy_ui compiles
* dormant → prioritized
* NavMenu → MenuSetting
* MoveParam → MenuNavigationStrategy
* Remove `focus` module of bevy_ui (superseded by bevy_ui_navigation)
* Replace the seed system by a simple MenuBuilder component
* Add Reflect derives to bevy_ui_navigation types
* implement the bevy_ui input for navigation (may include handling of
  clipping)
* Minor refactors (cmds → commands etc.)
* Remove moveable UI camera handling (since it is currently impossible)
- Add back FocusPolicy
- Add a Hover component
- Use the old focus system instead of the new mouse input system
- Use `Hover` for mouse hover in various examples
- Use `nav_iter` to simplify dealing with EventReader<NavEvent>
also:
- rename seeds => menu
- update examples README
- stub new examples
- Move focusable type definitions to its own module, unbloats the
  resolve.rs file
- Move some free functions in resolve.rs to methods of NavQueries,
  it makes more sense this way
- Move the focus update logic to a method of MutQueries,
  this allows re-using it in both list_nav_requests and
  set_initial_focusable
  - Fixes issue where path was not properly activated if the initial
    focused element with already deeply nested in a menu.
- Add test and helper methods for this to work
- Add a mut commands field to MutQueries, this allows simplifying the
  parameters on the new methods of MutQueries
- Add tests and helpers to check how good we survive the death of
  focused elements
- Removed stubs for tests we don't expect to pass in the first draft of
  this PR
- move insert_tree_menus to menu.rs
- Remove serde derives now that enum reflection is merged
The user now can mark a Focusable as blocked, preventing navigation to
it (with a few noted exception).

This might be useful if the user intend to dynamically hide/show parts
of the UI and want to prevent navigation hidden focusable entities.
Focus following mouse cursor is contrary to the way most UI frameworks
handle focus. This as the default behavior is surprising. Furthermore,
the default systems do not provide a more traditional mouse focus
handler.

This commit adds a way to have a more traditional mouse focus system and
makes it the default.

Now, focus changes to the hovered element only when the mouse button is
pressed, or when it is released if the currently hovered element wasn't
focused yet.

We also add a `focus_follows_cursor` field to the `InputMapping` to
allow users to switch to the older behavior.

This also makes it much easier to handle situations when we click on a
button that changes focus.

A major downside is that the user must now implement themselves hover
highlight.
@bas-ie
Copy link
Contributor

bas-ie commented Oct 4, 2024

Backlog cleanup: closing due to inactivity, and in the context of extensive work (and planned work) already underway in the UI space.

@bas-ie bas-ie closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible X-Needs-SME This type of work requires an SME to approve it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants