1
0
chip8-zig/src/vertical-layout.zig

39 lines
903 B
Zig

const Self = @This();
const rl = @import("raylib");
bounds: rl.Rectangle,
gap: f32,
used_height: f32,
pub fn init(gap: f32, bounds: rl.Rectangle) Self {
return Self{
.bounds = bounds,
.gap = gap,
.used_height = 0
};
}
pub fn row_sized(self: *Self, width: f32, height: f32) rl.Rectangle {
const rect = rl.Rectangle{
.x = self.bounds.x,
.y = self.bounds.y + self.used_height,
.width = width,
.height = height,
};
self.used_height += height + self.gap;
return rect;
}
pub fn row(self: *Self, height: f32) rl.Rectangle {
return self.row_sized(self.bounds.width, height);
}
pub fn row_full(self: *Self) rl.Rectangle {
const left_height = self.bounds.height - self.used_height;
return self.row_sized(self.bounds.width, left_height);
}
pub fn add_gap(self: *Self, gap: f32) void {
self.used_height += gap;
}