Added bounds protection to Alignment Window initialization
This commit is contained in:
parent
26cd121a75
commit
32a4b4baab
1 changed files with 2 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
const Window = @import("../Window.zig");
|
const Window = @import("../Window.zig");
|
||||||
|
|
||||||
pub fn center(parent: Window, cols: usize, rows: usize) Window {
|
pub fn center(parent: Window, cols: usize, rows: usize) Window {
|
||||||
const y_off = (parent.height / 2) - (rows / 2);
|
const y_off = (parent.height / 2) -| (rows / 2);
|
||||||
const x_off = (parent.width / 2) - (cols / 2);
|
const x_off = (parent.width / 2) -| (cols / 2);
|
||||||
return parent.initChild(x_off, y_off, .{ .limit = cols }, .{ .limit = rows });
|
return parent.initChild(x_off, y_off, .{ .limit = cols }, .{ .limit = rows });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue