Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Remove ImageMode #6674

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl Plugin for UiPlugin {
.register_type::<UiImage>()
.register_type::<Val>()
.register_type::<widget::Button>()
.register_type::<widget::ImageMode>()
.add_system_to_stage(
CoreStage::PreUpdate,
ui_focus_system.label(UiSystem::Focus).after(InputSystem),
Expand Down
6 changes: 2 additions & 4 deletions crates/bevy_ui/src/node_bundles.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! This module contains basic node bundles used to build UIs

use crate::{
widget::{Button, ImageMode},
BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style, UiImage, ZIndex,
widget::Button, BackgroundColor, CalculatedSize, FocusPolicy, Interaction, Node, Style,
UiImage, ZIndex,
};
use bevy_ecs::bundle::Bundle;
use bevy_render::{
Expand Down Expand Up @@ -67,8 +67,6 @@ pub struct ImageBundle {
pub node: Node,
/// Describes the style including flexbox settings
pub style: Style,
/// Configures how the image should scale
pub image_mode: ImageMode,
/// The calculated size based on the given image
pub calculated_size: CalculatedSize,
/// The background color, which serves as a "fill" for this node
Expand Down
17 changes: 2 additions & 15 deletions crates/bevy_ui/src/widget/image.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
use crate::{CalculatedSize, Size, UiImage, Val};
use bevy_asset::Assets;
use bevy_ecs::{
component::Component,
query::{With, Without},
reflect::ReflectComponent,
query::Without,
system::{Query, Res},
};
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::texture::Image;
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
pub fn image_node_system(
ickshonpe marked this conversation as resolved.
Show resolved Hide resolved
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 {
if let Some(texture) = textures.get(&image.texture) {
Expand Down