bevy/crates
ickshonpe 56d5591028
Multiple box shadow support (#16502)
# Objective

Add support for multiple box shadows on a single `Node`.

## Solution

* Rename `BoxShadow` to `ShadowStyle` and remove its `Component` derive.
* Create a new `BoxShadow` component that newtypes a `Vec<ShadowStyle>`.
* Add a `new` constructor method to `BoxShadow` for single shadows.
* Change `extract_shadows` to iterate through a list of shadows per
node.

Render order is determined implicitly from the order of the shadows
stored in the `BoxShadow` component, back-to-front.
Might be more efficient to use a `SmallVec<[ShadowStyle; 1]>` for the
list of shadows but not sure if the extra friction is worth it.

## Testing

Added a node with four differently coloured shadows to the `box_shadow`
example.

---

## Showcase

```
cargo run --example box_shadow
```

<img width="460" alt="four-shadow"
src="https://github.com/user-attachments/assets/2f728c47-33b4-42e1-96ba-28a774b94b24">

## Migration Guide

Bevy UI now supports multiple shadows per node. A new struct
`ShadowStyle` is used to set the style for each shadow. And the
`BoxShadow` component is changed to a tuple struct wrapping a vector
containing a list of `ShadowStyle`s. To spawn a node with a single
shadow you can use the `new` constructor function:
```rust
commands.spawn((
    Node::default(),
    BoxShadow::new(
        Color::BLACK.with_alpha(0.8),
        Val::Percent(offset.x),
        Val::Percent(offset.y),
        Val::Percent(spread),
        Val::Px(blur),
    )
));
```

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-12-01 21:30:08 +00:00
..
bevy_a11y Remove accesskit re-export from bevy_a11y (#16257) 2024-11-08 21:01:16 +00:00
bevy_animation Fix newline in AnimationEvaluationState docs (#16542) 2024-11-28 17:13:21 +00:00
bevy_app Clarify that bevy_app::App.world() (and mut variant) returns the main SubApp's World (#16527) 2024-11-27 16:09:09 +00:00
bevy_asset Support creating asset directories (#16220) 2024-11-04 22:06:00 +00:00
bevy_audio AudioPlayer::new() (#16287) 2024-11-08 01:51:50 +00:00
bevy_color Fix MSRVs for standalone crates (#16333) 2024-11-17 09:38:13 +00:00
bevy_core Support on_thread_spawn and on_thread_destroy for TaskPoolPlugin (#13045) 2024-11-11 20:00:01 +00:00
bevy_core_pipeline Fix CAS toggle broken by retained render world (#16533) 2024-11-27 23:38:09 +00:00
bevy_derive move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00
bevy_dev_tools Headless by features (#16401) 2024-11-16 21:33:37 +00:00
bevy_diagnostic Revert "Update sysinfo version to 0.32.1 (#16517)" (#16523) 2024-11-26 22:44:23 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Getting QueryState from immutable World reference (#16434) 2024-12-01 20:09:29 +00:00
bevy_encase_derive Update `glam to 0.29, encase` to 0.10. (#15249) 2024-09-23 19:44:02 +00:00
bevy_gilrs Use Name component for gamepad (#16233) 2024-11-05 00:30:48 +00:00
bevy_gizmos Use normal constructors for EasingCurve, FunctionCurve, ConstantCurve (#16367) 2024-11-13 15:30:05 +00:00
bevy_gltf Make bevy_gltf compile without bevy_animation feature (#16551) 2024-11-30 00:04:30 +00:00
bevy_hierarchy Fix bevy_hierarchy failing to compile without reflect feature (#16428) 2024-11-19 01:28:42 +00:00
bevy_image use wgpu patch 23.0.1 (#16513) 2024-11-25 22:47:31 +00:00
bevy_input Revert most of #16222 and add gamepad accessors (#16425) 2024-11-19 00:00:16 +00:00
bevy_internal Fix the picking backend features not actually disabling the features (#16470) 2024-11-22 18:14:16 +00:00
bevy_log Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_macro_utils Modify derive_label to support no_std environments (#15465) 2024-09-27 20:23:26 +00:00
bevy_math feat: mark some functions in bevy_math as const (#16439) 2024-11-22 18:26:47 +00:00
bevy_mesh use wgpu patch 23.0.1 (#16513) 2024-11-25 22:47:31 +00:00
bevy_mikktspace Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_pbr Fix meshlet private item regression (#16404) 2024-11-16 22:06:26 +00:00
bevy_picking Fix the picking backend features not actually disabling the features (#16470) 2024-11-22 18:14:16 +00:00
bevy_ptr Fix MSRVs for standalone crates (#16333) 2024-11-17 09:38:13 +00:00
bevy_reflect Update example link (#16581) 2024-12-01 09:47:22 +00:00
bevy_remote Expose BRP system scheduling and add system set (#16400) 2024-11-16 23:34:06 +00:00
bevy_render Add .contains_aabb for Frustum (#16022) 2024-12-01 21:30:01 +00:00
bevy_scene fix: add reflect to SceneInstanceReady and other observers/events (#16018) 2024-10-20 13:51:41 +00:00
bevy_sprite Add flags to SpritePlugin and UiPlugin to allow disabling their picking backend (without needing to disable features). (#16473) 2024-11-22 18:16:34 +00:00
bevy_state enable_state_scoped_entities() as a derive attribute (#16180) 2024-12-01 20:09:36 +00:00
bevy_tasks Support on_thread_spawn and on_thread_destroy for TaskPoolPlugin (#13045) 2024-11-11 20:00:01 +00:00
bevy_text Skip empty spans when updating text buffers (#16524) 2024-11-27 03:28:43 +00:00
bevy_time Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_transform Improved the global transform api to access rotation and scale (#16211) 2024-11-04 15:35:16 +00:00
bevy_ui Multiple box shadow support (#16502) 2024-12-01 21:30:08 +00:00
bevy_utils AnimatedField and Rework Evaluators (#16484) 2024-11-27 22:19:55 +00:00
bevy_window Support prefers_home_indicator_hidden (#16005) 2024-10-31 16:09:30 +00:00
bevy_winit Reduce iOS cpu usage (#16548) 2024-11-29 00:34:40 +00:00