╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Home.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
113 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 114 self.clearGrid(); 115 const header = &self.box.children.values()[header_index].widget.home_header; 116 const stack = &self.box.children.values()[stack_index].widget.stack; 117 118 // each header tab maps 1:1 to a stack child by position 119 if (header.getSelectedIndex()) |index| 120 stack.getFocus().child_id = stack.children.keys()[index]; 121 try self.box.build(allocator, constraint, root_focus); 122 } 123 124 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 125 const stack = &self.box.children.values()[stack_index].widget.stack; 126 if (self.getFocus().child_id) |child_id| { 127 if (self.box.children.getIndex(child_id)) |current_index| { 128 const child = &self.box.children.values()[current_index].widget; 129 var index = current_index; 130 131 const direction = inp.vertDirection(key); 132 133 switch (direction) { 134 .up => { 135 switch (child.*) { 136 .home_header => { 137 try child.input(allocator, key, root_focus); 138 }, 139 .stack => { 140 if (child.stack.getSelected()) |selected_widget| { 141 if (selected_widget.atTop(root_focus)) { 142 index = header_index; 143 } else { 144 try child.input(allocator, key, root_focus); 145 } 146 } 147 }, 148 else => {}, 149 } 150 }, 151 .down => { 152 switch (child.*) { 153 .home_header => { 154 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 155 .home_users => |*v| return v.focusHeader(root_focus), 156 else => {}, 157 }; 158 index = stack_index; 159 }, 160 .stack => { 161 try child.input(allocator, key, root_focus); 162 }, 163 else => {}, 164 } 165 }, 166 .none => { 167 try child.input(allocator, key, root_focus); 168 }, 169 } 170 171 if (index != current_index) { 172 root_focus.setFocus(self.box.children.keys()[index]); 173 } 174 } 175 } 176 } 177 178 pub fn clearGrid(self: *View) void { 179 self.box.clearGrid(); 180 } 181 182 pub fn getGrid(self: View) ?Grid { 183 return self.box.getGrid(); 184 } 185 186 pub fn getFocus(self: *View) *Focus { 187 return self.box.getFocus(); 188 } 189 }; 190