Skip to main content

azul_layout/solver3/
scrollbar.rs

1use azul_core::geom::LogicalSize;
2
3/// Information about scrollbar requirements and dimensions
4#[derive(Debug, Clone, Default)]
5#[repr(C)]
6pub struct ScrollbarRequirements {
7    pub needs_horizontal: bool,
8    pub needs_vertical: bool,
9    pub scrollbar_width: f32,
10    pub scrollbar_height: f32,
11}
12
13impl ScrollbarRequirements {
14    /// Checks if the presence of scrollbars reduces the available inner size,
15    /// which would necessitate a reflow of the content.
16    pub fn needs_reflow(&self) -> bool {
17        self.scrollbar_width > 0.0 || self.scrollbar_height > 0.0
18    }
19
20    /// Takes a size (representing a content-box) and returns a new size
21    /// reduced by the dimensions of any active scrollbars.
22    pub fn shrink_size(&self, size: LogicalSize) -> LogicalSize {
23        LogicalSize {
24            width: (size.width - self.scrollbar_width).max(0.0),
25            height: (size.height - self.scrollbar_height).max(0.0),
26        }
27    }
28}