mod: replace Layout.content with Layout.render
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 30s

The App.Renderer is used for the new `Layout.render` method. Each layout
renders itself now with corresponding renderers which might only update
parts of the screen, etc.
This commit is contained in:
2024-11-10 14:34:28 +01:00
parent b32556720e
commit b314ff7813
12 changed files with 112 additions and 92 deletions

View File

@@ -10,8 +10,11 @@
//!
//! Each `Widget` may cache its content and should if the contents will not
//! change for a long time.
const std = @import("std");
const isTaggedUnion = @import("event.zig").isTaggedUnion;
const log = std.log.scoped(.widget);
pub fn Widget(comptime Event: type) type {
if (!isTaggedUnion(Event)) {
@compileError("Provided user event `Event` for `Layout(comptime Event: type)` is not of type `union(enum)`.");
@@ -31,6 +34,12 @@ pub fn Widget(comptime Event: type) type {
// Handle the provided `Event` for this `Widget`.
pub fn handle(this: *WidgetType, event: Event) ?Event {
switch (event) {
.resize => |size| {
log.debug("received size: .{{ .cols = {d}, .rows = {d} }}", .{ size.cols, size.rows });
},
else => {},
}
return this.vtable.handle(this, event);
}