mod(nav): button automatically resizes as necessary
This commit is contained in:
@@ -61,7 +61,6 @@ pub fn main() !void {
|
||||
var button: NavigationButton(.about) = .init(&app.model, &app.queue);
|
||||
try header.append(try .init(allocator, .{
|
||||
.size = .{
|
||||
.dim = .{ .x = 5 + 2 },
|
||||
.grow = .vertical,
|
||||
},
|
||||
}, button.element()));
|
||||
@@ -71,7 +70,6 @@ pub fn main() !void {
|
||||
var button: NavigationButton(.blog) = .init(&app.model, &app.queue);
|
||||
try header.append(try .init(allocator, .{
|
||||
.size = .{
|
||||
.dim = .{ .x = 4 + 2 },
|
||||
.grow = .vertical,
|
||||
},
|
||||
}, button.element()));
|
||||
|
||||
@@ -22,12 +22,17 @@ pub fn NavigationButton(App: type) fn (std.meta.FieldEnum(App.Event)) type {
|
||||
return .{
|
||||
.ptr = this,
|
||||
.vtable = &.{
|
||||
.minSize = minSize,
|
||||
.handle = handle,
|
||||
.content = content,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
fn minSize(_: *anyopaque, _: *const App.Model, _: zterm.Point) zterm.Point {
|
||||
return .{ .x = @tagName(page).len + 2 };
|
||||
}
|
||||
|
||||
fn handle(ctx: *anyopaque, _: *App.Model, event: App.Event) !void {
|
||||
const this: *@This() = @ptrCast(@alignCast(ctx));
|
||||
switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user