╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
278 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 279 _ = allocator; 280 const current_tab = self.currentTabIndex() orelse return; 281 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 282 const tab_id = self.tab_ids.keys()[new_tab]; 283 root_focus.setFocus(tab_id); 284 const tabs_child = self.tabsChild(); 285 const tabs_rect = tabs_child.rect orelse return; 286 const tab = tabs_child.widget.box.children.get(tab_id) orelse return; 287 var rect = tab.rect orelse return; 288 rect.x += tabs_rect.x; 289 rect.y += tabs_rect.y; 290 self.scroll.scrollToRect(rect); 291 } 292 } 293 294 pub fn clearGrid(self: *View) void { 295 self.scroll.clearGrid(); 296 } 297 298 pub fn getGrid(self: View) ?Grid { 299 return self.scroll.getGrid(); 300 } 301 302 pub fn getFocus(self: *View) *Focus { 303 return self.scroll.getFocus(); 304 } 305 306 pub fn getSelectedIndex(self: View) ?usize { 307 return self.currentTabIndex(); 308 } 309 310 fn currentTabIndex(self: View) ?usize { 311 if (self.scroll.child.box.focus.child_id != self.tabs_id) return null; 312 const child_id = self.tabsChild().widget.box.focus.child_id orelse return null; 313 return self.tab_ids.getIndex(child_id); 314 } 315 316 fn tabsChild(self: *const View) *wgt.Box(ui.Widget).Child { 317 return self.scroll.child.box.children.getPtr(self.tabs_id) orelse unreachable; 318 } 319 }; 320