mirror of
https://github.com/bevyengine/bevy.git
synced 2026-07-01 08:12:51 -04:00
6dca76afcf
# Objective Allow UI elements to be positioned relative to the viewport rather than their parent element. Fixes #9564 ## Solution - New UI marker component `FixedNode`. Requires `Node` and `OverrideClip`. - `FixedNode` entities are treated as UI roots in layout, even if they have a parent. - `FixedNode`s don't inherit their parent's layout, clipping or transform context. - During the taffy layout updates children with `FixedNode` are skipped. - Added a couple of basic helper functions to `UiSurface`, mainly there to make the tests a little less painful. - Added a fairly comprehensive range of new tests, including tests with `GhostNode`s. - In the Taffy layout (stored in `UiSurface`) there is nothing to distinguish `FixedNode`s and root nodes, so they are treated identically during updates. -- The original suggestion was to implement it as a `PositionType::Fixed` variant that could used with `Node`, but I think that would be much more complicated without support from Taffy. Being able to just directly query for and filter out `FixedNode` entities directly makes the implementation much simpler and more efficient. ## Testing Basic example which shows events bubbling up to the parent from the fixed node: ``` cargo run --example fixed_node ``` There are also a number of new tests in the `layout` module. ``` cargo test -p bevy_ui --lib --features ghost_nodes ``` --------- Co-authored-by: François Mockers <francois.mockers@vleue.com>
12 lines
497 B
Markdown
12 lines
497 B
Markdown
---
|
|
title: "FixedNode"
|
|
authors: ["@Ickshonpe"]
|
|
pull_requests: [24323]
|
|
---
|
|
|
|
`FixedNode` is a new marker component for Bevy UI.
|
|
|
|
A UI node entity with the `FixedNode` component is positioned relative to the target camera's viewport rather than its parent element. `FixedNode`s don't inherit their parent's layout, clipping or transform context.
|
|
|
|
In the Taffy layout (stored in `UiSurface`) there is nothing to distinguish `FixedNode`s and root nodes, so they are treated identically during updates.
|