Clarify bevy::ui::Node field and documentation (#5995)
				
					
				
			# Objective Fixes #5820 ## Solution Change field name and documentation from `bevy::ui::Node` struct --- ## Changelog `bevy::ui::Node` `size` field has renamed to `calculated_size` ## Migration Guide All references to the old `size` name has been changed, to access `bevy::ui::Node` `size` field use `calculated_size`
This commit is contained in:
		
							parent
							
								
									92ba6224b9
								
							
						
					
					
						commit
						05c7babba2
					
				@ -293,8 +293,8 @@ pub fn flex_node_system(
 | 
			
		||||
            to_logical(layout.size.height),
 | 
			
		||||
        );
 | 
			
		||||
        // only trigger change detection when the new value is different
 | 
			
		||||
        if node.size != new_size {
 | 
			
		||||
            node.size = new_size;
 | 
			
		||||
        if node.calculated_size != new_size {
 | 
			
		||||
            node.calculated_size = new_size;
 | 
			
		||||
        }
 | 
			
		||||
        let mut new_position = transform.translation;
 | 
			
		||||
        new_position.x = to_logical(layout.location.x + layout.size.width / 2.0);
 | 
			
		||||
 | 
			
		||||
@ -144,7 +144,7 @@ pub fn ui_focus_system(
 | 
			
		||||
 | 
			
		||||
                let position = global_transform.translation();
 | 
			
		||||
                let ui_position = position.truncate();
 | 
			
		||||
                let extents = node.size / 2.0;
 | 
			
		||||
                let extents = node.calculated_size / 2.0;
 | 
			
		||||
                let mut min = ui_position - extents;
 | 
			
		||||
                let mut max = ui_position + extents;
 | 
			
		||||
                if let Some(clip) = clip {
 | 
			
		||||
 | 
			
		||||
@ -206,7 +206,7 @@ pub fn extract_uinodes(
 | 
			
		||||
            background_color: color.0,
 | 
			
		||||
            rect: Rect {
 | 
			
		||||
                min: Vec2::ZERO,
 | 
			
		||||
                max: uinode.size,
 | 
			
		||||
                max: uinode.calculated_size,
 | 
			
		||||
            },
 | 
			
		||||
            image,
 | 
			
		||||
            atlas_size: None,
 | 
			
		||||
@ -292,11 +292,11 @@ pub fn extract_text_uinodes(
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        // Skip if size is set to zero (e.g. when a parent is set to `Display::None`)
 | 
			
		||||
        if uinode.size == Vec2::ZERO {
 | 
			
		||||
        if uinode.calculated_size == Vec2::ZERO {
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        let text_glyphs = &text_layout_info.glyphs;
 | 
			
		||||
        let alignment_offset = (uinode.size / -2.0).extend(0.0);
 | 
			
		||||
        let alignment_offset = (uinode.calculated_size / -2.0).extend(0.0);
 | 
			
		||||
 | 
			
		||||
        let mut color = Color::WHITE;
 | 
			
		||||
        let mut current_section = usize::MAX;
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,16 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
 | 
			
		||||
#[reflect(Component, Default)]
 | 
			
		||||
pub struct Node {
 | 
			
		||||
    /// The size of the node as width and height in pixels
 | 
			
		||||
    pub size: Vec2,
 | 
			
		||||
    /// automatically calculated by [`super::flex::flex_node_system`]
 | 
			
		||||
    pub(crate) calculated_size: Vec2,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Node {
 | 
			
		||||
    /// The calculated node size as width and height in pixels
 | 
			
		||||
    /// automatically calculated by [`super::flex::flex_node_system`]
 | 
			
		||||
    pub fn size(&self) -> Vec2 {
 | 
			
		||||
        self.calculated_size
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// An enum that describes possible types of value in flexbox layout options
 | 
			
		||||
 | 
			
		||||
@ -108,7 +108,7 @@ fn update_clipping(
 | 
			
		||||
        Overflow::Visible => clip,
 | 
			
		||||
        Overflow::Hidden => {
 | 
			
		||||
            let node_center = global_transform.translation().truncate();
 | 
			
		||||
            let node_rect = Rect::from_center_size(node_center, node.size);
 | 
			
		||||
            let node_rect = Rect::from_center_size(node_center, node.calculated_size);
 | 
			
		||||
            Some(clip.map_or(node_rect, |c| c.intersect(node_rect)))
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -308,9 +308,9 @@ fn mouse_scroll(
 | 
			
		||||
        for (mut scrolling_list, mut style, children, uinode) in &mut query_list {
 | 
			
		||||
            let items_height: f32 = children
 | 
			
		||||
                .iter()
 | 
			
		||||
                .map(|entity| query_item.get(*entity).unwrap().size.y)
 | 
			
		||||
                .map(|entity| query_item.get(*entity).unwrap().size().y)
 | 
			
		||||
                .sum();
 | 
			
		||||
            let panel_height = uinode.size.y;
 | 
			
		||||
            let panel_height = uinode.size().y;
 | 
			
		||||
            let max_scroll = (items_height - panel_height).max(0.);
 | 
			
		||||
            let dy = match mouse_wheel_event.unit {
 | 
			
		||||
                MouseScrollUnit::Line => mouse_wheel_event.y * 20.,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user