mod(container): make reposition public and split from resize
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m3s

This commit is contained in:
2025-03-13 19:48:31 +01:00
parent dddc09b4ce
commit 54af974c2b
14 changed files with 38 additions and 19 deletions

View File

@@ -83,6 +83,7 @@ pub fn Scrollable(Event: type) type {
.ptr = this,
.vtable = &.{
.resize = resize,
.reposition = reposition,
.handle = handle,
.content = content,
},
@@ -94,10 +95,15 @@ pub fn Scrollable(Event: type) type {
this.size = size;
// TODO scrollbar space - depending on configuration and only if necessary?
this.container.resize(.{}, this.size);
this.container.resize(this.size);
this.container_size = this.container.size;
}
fn reposition(ctx: *anyopaque, _: Point) void {
const this: *@This() = @ptrCast(@alignCast(ctx));
this.container.reposition(.{});
}
fn handle(ctx: *anyopaque, event: Event) !void {
const this: *@This() = @ptrCast(@alignCast(ctx));
switch (event) {
@@ -229,7 +235,8 @@ test "scrollable vertical" {
var renderer: testing.Renderer = .init(allocator, size);
defer renderer.deinit();
container.resize(.{}, size);
container.resize(size);
container.reposition(.{});
try renderer.render(Container(event.SystemEvent), &container);
try testing.expectEqualCells(.{}, renderer.size, @import("test/element/scrollable.vertical.top.zon"), renderer.screen);
@@ -306,7 +313,8 @@ test "scrollable horizontal" {
var renderer: testing.Renderer = .init(allocator, size);
defer renderer.deinit();
container.resize(.{}, size);
container.resize(size);
container.reposition(.{});
try renderer.render(Container(event.SystemEvent), &container);
try testing.expectEqualCells(.{}, renderer.size, @import("test/element/scrollable.horizontal.left.zon"), renderer.screen);