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`
This commit is contained in:
parent
4209fcaeda
commit
5972879dec
@ -104,7 +104,6 @@ impl Plugin for UiPlugin {
|
|||||||
.register_type::<UiImage>()
|
.register_type::<UiImage>()
|
||||||
.register_type::<Val>()
|
.register_type::<Val>()
|
||||||
.register_type::<widget::Button>()
|
.register_type::<widget::Button>()
|
||||||
.register_type::<widget::ImageMode>()
|
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PreUpdate,
|
CoreStage::PreUpdate,
|
||||||
ui_focus_system.label(UiSystem::Focus).after(InputSystem),
|
ui_focus_system.label(UiSystem::Focus).after(InputSystem),
|
||||||
@ -127,7 +126,7 @@ impl Plugin for UiPlugin {
|
|||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
widget::image_node_system
|
widget::update_image_calculated_size_system
|
||||||
.before(UiSystem::Flex)
|
.before(UiSystem::Flex)
|
||||||
// Potential conflicts: `Assets<Image>`
|
// Potential conflicts: `Assets<Image>`
|
||||||
// They run independently since `widget::image_node_system` will only ever observe
|
// They run independently since `widget::image_node_system` will only ever observe
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
//! This module contains basic node bundles used to build UIs
|
//! This module contains basic node bundles used to build UIs
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
widget::{Button, ImageMode},
|
widget::Button, BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style,
|
||||||
BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style, UiImage, ZIndex,
|
UiImage, ZIndex,
|
||||||
};
|
};
|
||||||
use bevy_ecs::bundle::Bundle;
|
use bevy_ecs::bundle::Bundle;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
@ -67,8 +67,6 @@ pub struct ImageBundle {
|
|||||||
pub node: Node,
|
pub node: Node,
|
||||||
/// Describes the style including flexbox settings
|
/// Describes the style including flexbox settings
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
/// Configures how the image should scale
|
|
||||||
pub image_mode: ImageMode,
|
|
||||||
/// The calculated size based on the given image
|
/// The calculated size based on the given image
|
||||||
pub calculated_size: CalculatedSize,
|
pub calculated_size: CalculatedSize,
|
||||||
/// The background color, which serves as a "fill" for this node
|
/// The background color, which serves as a "fill" for this node
|
||||||
|
|||||||
@ -1,29 +1,16 @@
|
|||||||
use crate::{CalculatedSize, Size, UiImage, Val};
|
use crate::{CalculatedSize, Size, UiImage, Val};
|
||||||
use bevy_asset::Assets;
|
use bevy_asset::Assets;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
component::Component,
|
query::Without,
|
||||||
query::{With, Without},
|
|
||||||
reflect::ReflectComponent,
|
|
||||||
system::{Query, Res},
|
system::{Query, Res},
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
|
||||||
use bevy_render::texture::Image;
|
use bevy_render::texture::Image;
|
||||||
use bevy_text::Text;
|
use bevy_text::Text;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// Describes how to resize the Image node
|
|
||||||
#[derive(Component, Debug, Default, Clone, Reflect, Serialize, Deserialize)]
|
|
||||||
#[reflect(Component, Serialize, Deserialize)]
|
|
||||||
pub enum ImageMode {
|
|
||||||
/// Keep the aspect ratio of the image
|
|
||||||
#[default]
|
|
||||||
KeepAspect,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Updates calculated size of the node based on the image provided
|
/// Updates calculated size of the node based on the image provided
|
||||||
pub fn image_node_system(
|
pub fn update_image_calculated_size_system(
|
||||||
textures: Res<Assets<Image>>,
|
textures: Res<Assets<Image>>,
|
||||||
mut query: Query<(&mut CalculatedSize, &UiImage), (With<ImageMode>, Without<Text>)>,
|
mut query: Query<(&mut CalculatedSize, &UiImage), Without<Text>>,
|
||||||
) {
|
) {
|
||||||
for (mut calculated_size, image) in &mut query {
|
for (mut calculated_size, image) in &mut query {
|
||||||
if let Some(texture) = textures.get(&image.texture) {
|
if let Some(texture) = textures.get(&image.texture) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user