refactor: compare widgets via the .ptr memeber instead of via their addresses

Widget is a handle type. Sort of a smart pointer. Comparing their addresses
is brittle because it requires keeping Widget pointers stable. This is
nonsense because Widget identity is actually determined by the actual
widget object it points to.

This big refactor elimits the requirement that Widget addresses remain
stable to work properly with Widget.walk and Widget.get.
This commit is contained in:
CJ van den Berg 2026-02-23 21:44:24 +01:00
parent 2266c92eab
commit cdd6fee9d6
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
9 changed files with 59 additions and 52 deletions

View file

@ -107,8 +107,8 @@ pub fn handle_resize(self: *Self, pos: Widget.Box) void {
self.update_scrollbar();
}
pub fn walk(self: *Self, walk_ctx: *anyopaque, f: Widget.WalkFn, w: *Widget) bool {
return self.menu.container_widget.walk(walk_ctx, f) or f(walk_ctx, w);
pub fn walk(self: *Self, walk_ctx: *anyopaque, f: Widget.WalkFn) bool {
return self.menu.container_widget.walk(walk_ctx, f) or f(walk_ctx, Widget.to(self));
}
pub fn add_item(self: *Self, entry_: Entry) !void {