bevy/crates
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
..
bevy_a11y Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_animation Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_anti_aliasing Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
bevy_app Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_asset Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_audio remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_camera Add doc examples to viewport_to_world(_2d) (#20096) 2025-07-14 21:24:28 +00:00
bevy_color Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_core_pipeline Use RenderStartup for all basic cases in bevy_core_pipeline. (#20002) 2025-07-15 07:10:43 +00:00
bevy_core_widgets Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_derive
bevy_dev_tools Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_diagnostic Add max_history_length to EntityCountDiagnosticsPlugin (#20085) 2025-07-12 23:00:38 +00:00
bevy_dylib
bevy_ecs Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_encase_derive
bevy_feathers Rename the InterpolationColorSpace variants to match Color. (#20142) 2025-07-14 22:30:43 +00:00
bevy_gilrs remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_gizmos Use RenderStartup in bevy_sprite. (#20147) 2025-07-15 06:30:34 +00:00
bevy_gltf Fix glTF light orientation (#20122) 2025-07-14 13:20:18 +00:00
bevy_image Add zstd release note (#20053) 2025-07-14 20:53:26 +00:00
bevy_input Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_input_focus Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_internal make optional crates for mesh, camera, and light (#19997) 2025-07-07 07:35:32 +00:00
bevy_light Allow NotShadowCaster to be used with HierarchyPropagatePlugin. (#20120) 2025-07-14 21:55:12 +00:00
bevy_log Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_macro_utils
bevy_math Rhombus sampling (#20082) 2025-07-14 21:05:42 +00:00
bevy_mesh remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_mikktspace
bevy_pbr Fix AmbientLight::affects_lightmapped_meshes not working (#20083) 2025-07-14 21:13:10 +00:00
bevy_picking Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_platform bevy_platform: clippy without default features (#19860) 2025-06-29 17:12:57 +00:00
bevy_ptr
bevy_reflect Streamline GetOwnership/FromArg/IntoReturn (#20126) 2025-07-14 21:57:34 +00:00
bevy_remote formatting fix in bevy_remote cargo.toml (#20033) 2025-07-08 17:02:02 +00:00
bevy_render Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_scene Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_solari Fix link to bevy_solari logo (#20097) 2025-07-14 21:25:44 +00:00
bevy_sprite Use RenderStartup in bevy_sprite. (#20147) 2025-07-15 06:30:34 +00:00
bevy_state Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_tasks Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_text Text2d bounding box fix (#20148) 2025-07-15 17:14:49 +00:00
bevy_time Document repeating timer tick behavior (#20137) 2025-07-14 22:31:31 +00:00
bevy_transform Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_ui Improved UI scrolling support and bug fixes (#20093) 2025-07-15 17:33:04 +00:00
bevy_ui_render Rename the InterpolationColorSpace variants to match Color. (#20142) 2025-07-14 22:30:43 +00:00
bevy_utils Make Parallel<T> more T: !Default accessible (#17943) 2025-07-07 20:22:20 +00:00
bevy_window Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_winit Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00