Repository: bevyengine/bevy
File: crates/bevy_ui/src/ui_node.rs (Rust)

Code before:
        let gutter = Rect {
            min: Vec2::new(min_x, min_y),
            max: Vec2::new(max_x, max_y),
        };
        Some((
            gutter,
            Self::compute_thumb(
                gutter.min.x,
                self.content_size.x,
                gutter.size().x,
                self.scroll_position.x,
            ),
        ))
    }

    /// Compute the bounds of the horizontal scrollbar and the thumb
    /// in object-centered coordinates.
    pub fn vertical_scrollbar(&self) -> Option<(Rect, [f32; 2])> {
        if self.scrollbar_size.x <= 0. {
            return None;
        }
        let content_inset = self.content_inset();
        let half_size = 0.5 * self.size;
        let max_x = half_size.x - content_inset.right;
        let min_x = max_x - self.scrollbar_size.x;
        let min_y = -half_size.y + content_inset.top;
        let max_y = half_size.y - content_inset.bottom - self.scrollbar_size.y;
        let gutter = Rect {
            min: Vec2::new(min_x, min_y),
            max: Vec2::new(max_x, max_y),
        };
        Some((
            gutter,
            Self::compute_thumb(
                gutter.min.y,
                self.content_size.y,
                gutter.size().y,
                self.scroll_position.y,
            ),
        ))
    }
}

impl ComputedNode {
    pub const DEFAULT: Self = Self {
        stack_index: 0,
        size: Vec2::ZERO,
        content_size: Vec2::ZERO,
        scrollbar_size: Vec2::ZERO,
        scroll_position: Vec2::ZERO,
        outline_width: 0.,

Review comment (suggestion):
Same comment here about your other PR and the timing of merges for the removal of `- self.scrollbar_size.y`

Code after:
            min: Vec2::new(min_x, min_y),
            max: Vec2::new(max_x, max_y),
        };
        Some((
            gutter,
            Self::compute_thumb(
                gutter.min.x,
                self.content_size.x,
                gutter.size().x,
                self.scroll_position.x,
            ),
        ))
    }

    /// Compute the bounds of the vertical scrollbar and the thumb
    /// in object-centered coordinates.
    pub fn vertical_scrollbar(&self) -> Option<(Rect, [f32; 2])> {
        if self.scrollbar_size.x <= 0. {
            return None;
        }
        let content_inset = self.content_inset();
        let half_size = 0.5 * self.size;
        let max_x = half_size.x - content_inset.right;
        let min_x = max_x - self.scrollbar_size.x;
        let min_y = -half_size.y + content_inset.top;
        let max_y = half_size.y - content_inset.bottom - self.scrollbar_size.y;
        let gutter = Rect {
            min: Vec2::new(min_x, min_y),
            max: Vec2::new(max_x, max_y),
        };
        Some((
            gutter,
            Self::compute_thumb(
                gutter.min.y,
                self.content_size.y,
                gutter.size().y,
                self.scroll_position.y,
            ),
        ))
    }
}

impl ComputedNode {
    pub const DEFAULT: Self = Self {
        stack_index: 0,
        size: Vec2::ZERO,
        content_size: Vec2::ZERO,
        scrollbar_size: Vec2::ZERO,
        scroll_position: Vec2::ZERO,
        outline_width: 0.,
        outline_offset: 0.,