╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
424 scroll_constraint.min_size.width = viewport_width; 425 try self.scroll.build(allocator, scroll_constraint, root_focus); 426 } 427 428 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 429 _ = allocator; 430 const current_tab = self.currentTabIndex() orelse return; 431 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 432 const tab_id = self.tab_ids.keys()[new_tab]; 433 root_focus.setFocus(tab_id); 434 const tabs_child = self.tabsChild(); 435 const tabs_rect = tabs_child.rect orelse return; 436 const tab = tabs_child.widget.box.children.get(tab_id) orelse return; 437 var rect = tab.rect orelse return; 438 rect.x += tabs_rect.x; 439 rect.y += tabs_rect.y; 440 self.scroll.scrollToRect(rect); 441 } 442 } 443 444 pub fn clearGrid(self: *View) void { 445 self.scroll.clearGrid(); 446 } 447 448 pub fn getGrid(self: View) ?Grid { 449 return self.scroll.getGrid(); 450 } 451 452 pub fn getFocus(self: *View) *Focus { 453 return self.scroll.getFocus(); 454 } 455 456 pub fn getSelectedIndex(self: View) ?usize { 457 return self.currentTabIndex(); 458 } 459 460 fn currentTabIndex(self: View) ?usize { 461 if (self.scroll.child.box.focus.child_id != self.tabs_id) return null; 462 const child_id = self.tabsChild().widget.box.focus.child_id orelse return null; 463 return self.tab_ids.getIndex(child_id); 464 } 465 466 fn tabsChild(self: *const View) *wgt.Box(ui.Widget).Child { 467 return self.scroll.child.box.children.getPtr(self.tabs_id) orelse unreachable; 468 } 469 }; 470