add(element/scrollable): implement content provider
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m49s

However this is only working for the same size as the parent container
(i.e. same `Size`). The `.resize` event for the `Container` of the
scrollable element needs to be the necessary and/or required size for
the contents (regardless of the screen viewport).
This commit is contained in:
2025-02-17 19:58:25 +01:00
parent 7b690d387b
commit 7891af6c6f
5 changed files with 125 additions and 19 deletions

View File

@@ -11,11 +11,14 @@ const log = std.log.scoped(.container);
/// Border configuration struct
pub const Border = packed struct {
// corners:
pub const rounded_border: [6]u21 = .{ '╭', '─', '╮', '│', '╰', '╯' };
pub const squared_border: [6]u21 = .{ '┌', '─', '┐', '│', '└', '┘' };
// separator.line:
pub const line: [2]u21 = .{ '│', '─' };
pub const dotted: [2]u21 = .{ '┆', '┄' };
pub const double: [2]u21 = .{ '║', '═' };
/// Color to use for the border
color: Color = .default,
/// Configure the corner type to be used for the border
@@ -277,6 +280,7 @@ pub fn Container(comptime Event: type) type {
size.rows,
});
this.size = size;
try this.element.handle(event);
if (this.elements.items.len == 0) break :resize;
@@ -397,6 +401,7 @@ pub fn Container(comptime Event: type) type {
this.properties.border.contents(cells, this.size, this.properties.layout, @truncate(this.elements.items.len));
this.properties.rectangle.contents(cells, this.size);
// NOTE: Layout has no contents to provide, hence no content method is called (or even exists in the `Layout` struct)
try this.element.content(cells, this.size);