bevy/examples/ui
Carter Anderson 1553ee98ff Switch ChildOf back to tuple struct (#18672)
# Objective

In #17905 we swapped to a named field on `ChildOf` to help resolve
variable naming ambiguity of child vs parent (ex: `child_of.parent`
clearly reads as "I am accessing the parent of the child_of
relationship", whereas `child_of.0` is less clear).

Unfortunately this has the side effect of making initialization less
ideal. `ChildOf { parent }` reads just as well as `ChildOf(parent)`, but
`ChildOf { parent: root }` doesn't read nearly as well as
`ChildOf(root)`.

## Solution

Move back to `ChildOf(pub Entity)` but add a `child_of.parent()`
function and use it for all accesses. The downside here is that users
are no longer "forced" to access the parent field with `parent`
nomenclature, but I think this strikes the right balance.

Take a look at the diff. I think the results provide strong evidence for
this change. Initialization has the benefit of reading much better _and_
of taking up significantly less space, as many lines go from 3 to 1, and
we're cutting out a bunch of syntax in some cases.

Sadly I do think this should land in 0.16 as the cost of doing this
_after_ the relationships migration is high.
2025-04-03 21:45:43 +02:00
..
borders.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
box_shadow.rs Rename UiBoxShadowSamples to BoxShadowSamples. (#16505) 2024-12-03 19:43:26 +00:00
button.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
directional_navigation.rs Unified picking cleanup (#18401) 2025-03-18 21:48:22 +01:00
display_and_visibility.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
flex_layout.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
font_atlas_debug.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
ghost_nodes.rs Switch ChildOf back to tuple struct (#18672) 2025-04-03 21:45:43 +02:00
grid.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
overflow_clip_margin.rs UiImage -> ImageNode, UiImageSize -> ImageNodeSize (#16271) 2024-11-07 21:52:58 +00:00
overflow_debug.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00
overflow.rs UiImage -> ImageNode, UiImageSize -> ImageNodeSize (#16271) 2024-11-07 21:52:58 +00:00
relative_cursor_position.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
render_ui_to_texture.rs Rename TargetCamera to UiTargetCamera (#17403) 2025-01-19 19:56:57 +00:00
scroll.rs Unified picking cleanup (#18401) 2025-03-18 21:48:22 +01:00
size_constraints.rs Renamed EventWriter::send methods to write. (#17977) 2025-02-23 21:18:52 +00:00
tab_navigation.rs Unified picking cleanup (#18401) 2025-03-18 21:48:22 +01:00
text_debug.rs Fix non-crate typos (#18219) 2025-03-11 06:17:48 +00:00
text_wrap_debug.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
text.rs Basic UI text shadows (#17559) 2025-02-05 19:29:37 +00:00
transparency_ui.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
ui_material.rs ui_material example webgl2 fix (#17852) 2025-02-13 20:52:26 +00:00
ui_scaling.rs Remove everything except Instant from bevy_utils::time (#17158) 2025-01-05 20:36:08 +00:00
ui_texture_atlas_slice.rs BorderRect maintenance (#16727) 2024-12-12 04:33:44 +00:00
ui_texture_atlas.rs UiImage -> ImageNode, UiImageSize -> ImageNodeSize (#16271) 2024-11-07 21:52:58 +00:00
ui_texture_slice_flip_and_tile.rs BorderRect maintenance (#16727) 2024-12-12 04:33:44 +00:00
ui_texture_slice.rs BorderRect maintenance (#16727) 2024-12-12 04:33:44 +00:00
viewport_debug.rs Fix non-crate typos (#18219) 2025-03-11 06:17:48 +00:00
window_fallthrough.rs Fix non-crate typos (#18219) 2025-03-11 06:17:48 +00:00
z_index.rs Updated comment: ZIndex::Local(0) -> ZIndex(0). (#16585) 2024-12-01 20:09:09 +00:00