Added bounds protection to Alignment Window initialization

This commit is contained in:
00JCIV00 2024-02-27 14:24:11 -05:00 committed by Tim Culverhouse
parent 26cd121a75
commit 32a4b4baab

View file

@ -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 });
} }