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