Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding PositionType::Fixed #11926

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Exanc
Copy link

@Exanc Exanc commented Feb 17, 2024

Objective

Fixes #9564

Add PositionType::Fixed to help with the creation of popups.
"Fixed" nodes will be positioned relative to the windows and ignore every nodes in the graph.

Solution

When converting from bevy_ui::ui_node::PositionType::Fixed to taffy::style::Position the Absolute variant is used as their behavior is very similar (c.f.: MDN).

When the bevy_ui::layout::ui_layout_system system is ran, it keeps a set off all fixed_nodes to be used by update_uinode_geometry_recursive, subtracting a node's parent position from it's absolute position.

Changelog

  • Added bevy_ui::ui_node::PositionType::Fixed

Notes

For now, PositionType::Fixed is relative to the windows but calculation of properties such as size or width are still done relative to the parent. Thus, not mimicking CSS's way off handling fixed objects, this can be counteracted by using Val::vh(...).

Some tests may be necessary, but I would like some feedback first on what exact effects of position: fixed we want to mimic.

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@Exanc
Copy link
Author

Exanc commented Feb 17, 2024

After some thinking, mimicking more effects of position: fixed seems to be adding more unnecessary complexity, there are always ways around limitations for users and as said in the discord, were not trying to perfectly mimic CSS.

@Exanc Exanc changed the title Draft: Adding PositionType::Fixed Adding PositionType::Fixed Feb 17, 2024
@alice-i-cecile alice-i-cecile added C-Enhancement A new feature A-UI Graphical user interfaces, styles, layouts, and widgets X-Controversial There is active debate or serious implications around merging this PR labels Feb 18, 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-Enhancement A new feature X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PositionType::Fixed
2 participants