╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────╮ │73 new_repo: ui.NewRepo.View, │ │74 new_user: ui.NewUser.View, │ │75 user_login: ui.UserLogin.View, │ │76 - user_logout: ui.UserLogout.View, │ │76 + user_settings: ui.UserSettings.View, │ │77 footer: Footer, │ │78 │ │79 pub fn deinit(self: *Widget, allocator: std.mem.Allocator) void {│ ╰─────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │115 // whether moving up should return to the page header │ │116 pub fn atTop(self: *Widget, root_focus: *Focus) bool { │ │117 return switch (self.*) { │ │118 - inline .home_about, .home_users, .user_repos, .flow_box_scroll, .new_repo, .new_user, .user_login, .user_logout, .quit, .repo_files, .repo_commits, .diff_view, .repo_refs, .repo_issues, .repo_patches, .repo_discussions, .repo_events, .repo_undo, .repo_settings => |*view| view.atTop(), │ │118 + inline .home_about, .home_users, .user_repos, .flow_box_scroll, .new_repo, .new_user, .user_login, .user_settings, .quit, .repo_files, .repo_commits, .diff_view, .repo_refs, .repo_issues, .repo_patches, .repo_discussions, .repo_events, .repo_undo, .repo_settings => |*view| view.atTop(),│ │119 inline .repo_patch_detail => |*view| view.atTop(root_focus), │ │120 else => false, │ │121 }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1471 } │ │1472 }; │ │1473 │ │1474 +// keep `rect`, in a centered widget's space, in view within its scroll │ │1475 +pub fn scrollToCenteredRect(scroll: *wgt.Scroll(Widget), rect: layout.IRect) void { │ │1476 + const center = &scroll.child.center; │ │1477 + const center_grid = center.getGrid() orelse return; │ │1478 + const child_grid = center.child.getGrid() orelse return; │ │1479 + const offset_y: isize = @intCast((center_grid.size.height -| child_grid.size.height) / 2);│ │1480 + scroll.scrollToRect(.{ .x = rect.x, .y = rect.y + offset_y, .size = rect.size }); │ │1481 +} │ │1482 + │ │1483 pub const Center = struct { │ │1484 focus: *Focus, │ │1485 grid: ?Grid, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯