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:
parent
2266c92eab
commit
cdd6fee9d6
9 changed files with 59 additions and 52 deletions
|
|
@ -201,8 +201,8 @@ pub fn update(self: *Self) void {
|
|||
self.menu.update();
|
||||
}
|
||||
|
||||
pub fn walk(self: *Self, walk_ctx: *anyopaque, f: Widget.WalkFn, w: *Widget) bool {
|
||||
return self.menu.walk(walk_ctx, f) or f(walk_ctx, w);
|
||||
pub fn walk(self: *Self, walk_ctx: *anyopaque, f: Widget.WalkFn) bool {
|
||||
return self.menu.walk(walk_ctx, f) or f(walk_ctx, Widget.to(self));
|
||||
}
|
||||
|
||||
pub fn receive(_: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue