Skip to content

Commit

Permalink
UI: allow border radius to be optional for images and background (#12592
Browse files Browse the repository at this point in the history
)

# Objective

- #12500 broke images and background colors in UI. Try examples
`overflow`, `ui_scaling` or `ui_texture_atlas`

## Solution

- Makes the component `BorderRadius` optional in the query, as it's not
always present. Use `[0.; 4]` as border radius in the extracted node
when none was found
  • Loading branch information
mockersf committed Mar 20, 2024
1 parent f38895a commit 779e4c4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/bevy_ui/src/render/mod.rs
Expand Up @@ -193,7 +193,7 @@ pub fn extract_uinode_background_colors(
Option<&CalculatedClip>,
Option<&TargetCamera>,
&BackgroundColor,
&BorderRadius,
Option<&BorderRadius>,
)>,
>,
) {
Expand Down Expand Up @@ -224,8 +224,11 @@ pub fn extract_uinode_background_colors(
continue;
}

let border_radius =
resolve_border_radius(border_radius, uinode.size(), viewport_size, ui_scale.0);
let border_radius = if let Some(border_radius) = border_radius {
resolve_border_radius(border_radius, uinode.size(), viewport_size, ui_scale.0)
} else {
[0.; 4]
};

extracted_uinodes.uinodes.insert(
entity,
Expand Down Expand Up @@ -268,7 +271,7 @@ pub fn extract_uinode_images(
&UiImage,
Option<&TextureAtlas>,
Option<&ComputedTextureSlices>,
&BorderRadius,
Option<&BorderRadius>,
)>,
>,
) {
Expand Down Expand Up @@ -323,8 +326,11 @@ pub fn extract_uinode_images(
),
};

let border_radius =
resolve_border_radius(border_radius, uinode.size(), viewport_size, ui_scale.0);
let border_radius = if let Some(border_radius) = border_radius {
resolve_border_radius(border_radius, uinode.size(), viewport_size, ui_scale.0)
} else {
[0.; 4]
};

extracted_uinodes.uinodes.insert(
commands.spawn_empty().id(),
Expand Down

0 comments on commit 779e4c4

Please sign in to comment.