feat: allow conversion of Widget.Box to renderer.Layer.Options

This commit is contained in:
CJ van den Berg 2025-10-24 16:20:19 +02:00
parent ca05f24873
commit 6cc45d76cf
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -1,4 +1,5 @@
const Plane = @import("renderer").Plane;
const Layer = @import("renderer").Layer;
const Self = @This();
@ -35,6 +36,15 @@ pub fn from(n: Plane) Self {
};
}
pub fn to_layer(self: Self) Layer.Options {
return .{
.y = @intCast(self.y),
.x = @intCast(self.x),
.h = @intCast(self.h),
.w = @intCast(self.w),
};
}
pub fn is_abs_coord_inside(self: Self, y: usize, x: usize) bool {
return y >= self.y and y < self.y + self.h and x >= self.x and x < self.x + self.w;
}