╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
246 (box.children.getPtr(self.gap_id) orelse unreachable).hidden = !wrap; 247 248 var scroll_constraint = constraint; 249 scroll_constraint.min_size.width = viewport_width; 250 try self.scroll.build(allocator, scroll_constraint, root_focus); 251 } 252 253 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 254 _ = allocator; 255 const current_tab = self.currentTabIndex() orelse return; 256 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 257 const tab_id = self.tab_ids.keys()[new_tab]; 258 root_focus.setFocus(tab_id); 259 const tabs_child = self.tabsChild(); 260 const tabs_rect = tabs_child.rect orelse return; 261 const tab = tabs_child.widget.box.children.get(tab_id) orelse return; 262 var rect = tab.rect orelse return; 263 rect.x += tabs_rect.x; 264 rect.y += tabs_rect.y; 265 self.scroll.scrollToRect(rect); 266 } 267 } 268 269 pub fn clearGrid(self: *View) void { 270 self.scroll.clearGrid(); 271 } 272 273 pub fn getGrid(self: View) ?Grid { 274 return self.scroll.getGrid(); 275 } 276 277 pub fn getFocus(self: *View) *Focus { 278 return self.scroll.getFocus(); 279 } 280 281 pub fn getSelectedIndex(self: View) ?usize { 282 return self.currentTabIndex(); 283 } 284 285 fn currentTabIndex(self: View) ?usize { 286 if (self.scroll.child.box.focus.child_id != self.tabs_id) return null; 287 const child_id = self.tabsChild().widget.box.focus.child_id orelse return null; 288 return self.tab_ids.getIndex(child_id); 289 } 290 291 fn tabsChild(self: *const View) *wgt.Box(ui.Widget).Child { 292 return self.scroll.child.box.children.getPtr(self.tabs_id) orelse unreachable; 293 } 294 }; 295