bevy/crates/bevy_ui/src
ickshonpe d195116426
Improved UI scrolling support and bug fixes (#20093)
# Objective

#### Goals
* Stop layout updates from overwriting `ScrollPosition`.
* Make `ScrollPosition` respect scale factor.
* Automatically allocate space for a scrollbar on an axis when
`OverflowAxis::Scroll` is set.
 
#### Non-Goals
* Overflow-auto support (I was certain Taffy had this already, but
apparently I was hallucinating).
* Implement any sort of scrollbar widgets.
* Stability (not needed because no overflow-auto support).
* Maybe in the future we could make a `ScrollbarWidth` enum to more
closely match the CSS API with its auto/narrow/none options. For now
`scrollbar_width` is just an `f32` which matches Taffy's API.

## Solution

* Layout updates no longer overwrite `ScrollPosition`'s value.
* Added the field `scrollbar_width: f32` to `Node`. This is sent to
`Taffy` which will automatically allocate space for scrollbars with this
width in the layout as needed.
* Added the fields `scrollbar_width: f32` and `scroll_position: Vec2` to
`ComputedNode`. These are updated automatically during layout.
* `ScrollPosition` now respects scale factor.
* `ScrollPosition` is no longer automatically added to every UI node
entity by `ui_layout_system`. If every node needs it, it should just be
required by (or be a field on) `Node`. Not sure if that's necessary or
not.

## Testing
For testing you can look at:
* The `scrollbars` example, which should work as before.
* The new example `drag_to_scroll`.
* The `scroll` example which automatically allocates space for
scrollbars on the left hand scrolling list. Did not implement actual
scrollbars so you'll just see a gap atm.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-07-15 17:33:04 +00:00
..
experimental Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
layout Improved UI scrolling support and bug fixes (#20093) 2025-07-15 17:33:04 +00:00
widget Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
accessibility.rs Specialized UI transform (#16615) 2025-06-09 19:05:49 +00:00
focus.rs FIX - RelativeCursorPosition Changed<> query filter (#20102) 2025-07-13 19:44:40 +00:00
geometry.rs Rename Position to UiPosition in bevy_ui (#19422) 2025-05-29 14:52:44 +00:00
gradients.rs Rename the InterpolationColorSpace variants to match Color. (#20142) 2025-07-14 22:30:43 +00:00
interaction_states.rs Core Checkbox (#19665) 2025-06-20 16:37:18 +00:00
lib.rs bevy_ui_render crate (#18703) 2025-07-03 23:36:35 +00:00
measurement.rs Use CosmicFontSystem in public bevy_text APIs and remove cosmic_text re-export (#16063) 2024-10-23 20:05:28 +00:00
picking_backend.rs OverrideClip interaction fix (#20064) 2025-07-11 05:02:36 +00:00
stack.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
ui_material.rs bevy_ui_render crate (#18703) 2025-07-03 23:36:35 +00:00
ui_node.rs Improved UI scrolling support and bug fixes (#20093) 2025-07-15 17:33:04 +00:00
ui_transform.rs Specialized UI transform (#16615) 2025-06-09 19:05:49 +00:00
update.rs Improved UI scrolling support and bug fixes (#20093) 2025-07-15 17:33:04 +00:00