Skip to content

Commit 5972879

Browse files
committed
Remove ImageMode (#6674)
# Objective Delete `ImageMode`. It doesn't do anything except mislead people into thinking it controls the aspect ratio of images somehow. Fixes #3933 and #6637 ## Solution Delete `ImageMode` ## Changelog Removes the `ImageMode` enum. Removes the `image_mode` field from `ImageBundle` Removes the `With<ImageMode>` query filter from `image_node_system` Renames `image_node_system` to` update_image_calculated_size_system`
1 parent 4209fca commit 5972879

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

crates/bevy_ui/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ impl Plugin for UiPlugin {
104104
.register_type::<UiImage>()
105105
.register_type::<Val>()
106106
.register_type::<widget::Button>()
107-
.register_type::<widget::ImageMode>()
108107
.add_system_to_stage(
109108
CoreStage::PreUpdate,
110109
ui_focus_system.label(UiSystem::Focus).after(InputSystem),
@@ -127,7 +126,7 @@ impl Plugin for UiPlugin {
127126
)
128127
.add_system_to_stage(
129128
CoreStage::PostUpdate,
130-
widget::image_node_system
129+
widget::update_image_calculated_size_system
131130
.before(UiSystem::Flex)
132131
// Potential conflicts: `Assets<Image>`
133132
// They run independently since `widget::image_node_system` will only ever observe

crates/bevy_ui/src/node_bundles.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! This module contains basic node bundles used to build UIs
22
33
use crate::{
4-
widget::{Button, ImageMode},
5-
BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style, UiImage, ZIndex,
4+
widget::Button, BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style,
5+
UiImage, ZIndex,
66
};
77
use bevy_ecs::bundle::Bundle;
88
use bevy_render::{
@@ -67,8 +67,6 @@ pub struct ImageBundle {
6767
pub node: Node,
6868
/// Describes the style including flexbox settings
6969
pub style: Style,
70-
/// Configures how the image should scale
71-
pub image_mode: ImageMode,
7270
/// The calculated size based on the given image
7371
pub calculated_size: CalculatedSize,
7472
/// The background color, which serves as a "fill" for this node

crates/bevy_ui/src/widget/image.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
use crate::{CalculatedSize, Size, UiImage, Val};
22
use bevy_asset::Assets;
33
use bevy_ecs::{
4-
component::Component,
5-
query::{With, Without},
6-
reflect::ReflectComponent,
4+
query::Without,
75
system::{Query, Res},
86
};
9-
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
107
use bevy_render::texture::Image;
118
use bevy_text::Text;
12-
use serde::{Deserialize, Serialize};
13-
14-
/// Describes how to resize the Image node
15-
#[derive(Component, Debug, Default, Clone, Reflect, Serialize, Deserialize)]
16-
#[reflect(Component, Serialize, Deserialize)]
17-
pub enum ImageMode {
18-
/// Keep the aspect ratio of the image
19-
#[default]
20-
KeepAspect,
21-
}
229

2310
/// Updates calculated size of the node based on the image provided
24-
pub fn image_node_system(
11+
pub fn update_image_calculated_size_system(
2512
textures: Res<Assets<Image>>,
26-
mut query: Query<(&mut CalculatedSize, &UiImage), (With<ImageMode>, Without<Text>)>,
13+
mut query: Query<(&mut CalculatedSize, &UiImage), Without<Text>>,
2714
) {
2815
for (mut calculated_size, image) in &mut query {
2916
if let Some(texture) = textures.get(&image.texture) {

0 commit comments

Comments
 (0)