╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Header.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
285 tabs_child.min_size = if (wrap) .{ .width = content_width, .height = null } else null; 286 (box.children.getPtr(self.gap_id) orelse unreachable).hidden = !wrap; 287 288 var scroll_constraint = constraint; 289 scroll_constraint.min_size.width = viewport_width; 290 try self.scroll.build(allocator, scroll_constraint, root_focus); 291 } 292 293 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 294 _ = allocator; 295 const current_tab = self.currentTabIndex() orelse return; 296 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 297 const tab_id = self.tab_ids.keys()[new_tab]; 298 root_focus.setFocus(tab_id); 299 const tabs_child = self.tabsChild(); 300 const tabs_rect = tabs_child.rect orelse return; 301 const tab = tabs_child.widget.box.children.get(tab_id) orelse return; 302 var rect = tab.rect orelse return; 303 rect.x += tabs_rect.x; 304 rect.y += tabs_rect.y; 305 self.scroll.scrollToRect(rect); 306 } 307 } 308 309 pub fn clearGrid(self: *View) void { 310 self.scroll.clearGrid(); 311 } 312 313 pub fn getGrid(self: View) ?Grid { 314 return self.scroll.getGrid(); 315 } 316 317 pub fn getFocus(self: *View) *Focus { 318 return self.scroll.getFocus(); 319 } 320 321 pub fn getSelectedIndex(self: View) ?usize { 322 return self.currentTabIndex(); 323 } 324 325 fn currentTabIndex(self: View) ?usize { 326 if (self.scroll.child.box.focus.child_id != self.tabs_id) return null; 327 const child_id = self.tabsChild().widget.box.focus.child_id orelse return null; 328 return self.tab_ids.getIndex(child_id); 329 } 330 331 fn tabsChild(self: *const View) *wgt.Box(ui.Widget).Child { 332 return self.scroll.child.box.children.getPtr(self.tabs_id) orelse unreachable; 333 } 334 }; 335