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

Code before:
    pub fn horizontal_scrollbar(&self) -> Option<(Rect, [f32; 2])> {
        if self.scrollbar_size.y <= 0. {
            return None;
        }
        let content_inset = self.content_inset();
        let half_size = 0.5 * self.size;
        let min_x = -half_size.x + content_inset.left;
        let max_x = half_size.x - content_inset.right - self.scrollbar_size.x;
        let max_y = half_size.y - content_inset.bottom;
        let min_y = max_y - 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.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,
            ),
        ))
    }

Review comment (suggestion):
```suggestion
    /// Compute the bounds of the vertical scrollbar and the thumb
```

Code after:
        if self.scrollbar_size.y <= 0. {
            return None;
        }
        let content_inset = self.content_inset();
        let half_size = 0.5 * self.size;
        let min_x = -half_size.x + content_inset.left;
        let max_x = half_size.x - content_inset.right - self.scrollbar_size.x;
        let max_y = half_size.y - content_inset.bottom;
        let min_y = max_y - 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.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,
            ),
        ))
    }
}