pub struct GridCalc {
pub x: i32,
pub y: i32,
pub cols: usize,
pub col_w: i32,
pub row_h: i32,
pub col_gap: i32,
pub row_gap: i32,
}Expand description
Pure-geometry grid calculator for manual widget layouts.
Unlike Grid, this does not own widgets — it only computes
cell Rects from (row, col) indices, making it suitable for
custom widgets that do their own drawing and hit-testing.
let g = GridCalc::new(10, 20, 2, 100, 40).gap(4, 2);
let r = g.cell(1, 0);
assert_eq!(r, Rect { x: 10, y: 62, width: 100, height: 40 });Fields§
§x: i32Top-left origin X.
y: i32Top-left origin Y.
cols: usizeNumber of columns.
col_w: i32Width of each cell.
row_h: i32Height of each cell.
col_gap: i32Horizontal gap between columns.
row_gap: i32Vertical gap between rows.
Implementations§
Source§impl GridCalc
impl GridCalc
Sourcepub const fn new(x: i32, y: i32, cols: usize, col_w: i32, row_h: i32) -> Self
pub const fn new(x: i32, y: i32, cols: usize, col_w: i32, row_h: i32) -> Self
Create a grid calculator with the given origin, column count, and cell size.
Sourcepub const fn cell(&self, row: usize, col: usize) -> Rect
pub const fn cell(&self, row: usize, col: usize) -> Rect
Return the Rect for the cell at (row, col).
Sourcepub const fn row_span(&self, row: usize) -> Rect
pub const fn row_span(&self, row: usize) -> Rect
Return a Rect spanning all columns for the given row.
Sourcepub const fn total_width(&self) -> i32
pub const fn total_width(&self) -> i32
Total width of the grid (all columns + gaps).
Sourcepub const fn total_height(&self, rows: usize) -> i32
pub const fn total_height(&self, rows: usize) -> i32
Total height of the grid for the given number of rows.
Auto Trait Implementations§
impl Freeze for GridCalc
impl RefUnwindSafe for GridCalc
impl Send for GridCalc
impl Sync for GridCalc
impl Unpin for GridCalc
impl UnsafeUnpin for GridCalc
impl UnwindSafe for GridCalc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more