╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
462 try self.scroll.build(allocator, scroll_constraint, root_focus); 463 } 464 465 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 466 _ = allocator; 467 const current_tab = self.currentTabIndex() orelse return; 468 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 469 const tab_id = self.tab_ids.keys()[new_tab]; 470 root_focus.setFocus(tab_id); 471 const tabs_child = self.tabsChild(); 472 const tabs_rect = tabs_child.rect orelse return; 473 const tab = tabs_child.widget.box.children.get(tab_id) orelse return; 474 var rect = tab.rect orelse return; 475 rect.x += tabs_rect.x; 476 rect.y += tabs_rect.y; 477 self.scroll.scrollToRect(rect); 478 } 479 } 480 481 pub fn clearGrid(self: *View) void { 482 self.scroll.clearGrid(); 483 } 484 485 pub fn getGrid(self: View) ?Grid { 486 return self.scroll.getGrid(); 487 } 488 489 pub fn getFocus(self: *View) *Focus { 490 return self.scroll.getFocus(); 491 } 492 493 pub fn getSelectedIndex(self: View) ?usize { 494 return self.currentTabIndex(); 495 } 496 497 fn currentTabIndex(self: View) ?usize { 498 if (self.scroll.child.box.focus.child_id != self.tabs_id) return null; 499 const child_id = self.tabsChild().widget.box.focus.child_id orelse return null; 500 return self.tab_ids.getIndex(child_id); 501 } 502 503 fn tabsChild(self: *const View) *wgt.Box(ui.Widget).Child { 504 return self.scroll.child.box.children.getPtr(self.tabs_id) orelse unreachable; 505 } 506 }; 507