From 6cc45d76cf4c98d462f9d2008e6bdcd1308034d7 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 24 Oct 2025 16:20:19 +0200 Subject: [PATCH] feat: allow conversion of Widget.Box to renderer.Layer.Options --- src/tui/Box.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tui/Box.zig b/src/tui/Box.zig index cb31862..c11b441 100644 --- a/src/tui/Box.zig +++ b/src/tui/Box.zig @@ -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; }