╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
172 } else { 173 return null; 174 } 175 } 176 177 fn updateScroll(self: *WidgetList, index: usize) void { 178 const left_box = &self.scroll.child.box; 179 if (left_box.children.values()[index].rect) |rect| { 180 self.scroll.scrollToRect(rect); 181 } 182 } 183 }; 184 185 pub const Widget = union(enum) { 186 text: wgt.Text(Widget), 187 box: wgt.Box(Widget), 188 text_box: wgt.TextBox(Widget), 189 scroll: wgt.Scroll(Widget), 190 widget_list: WidgetList, 191 192 pub fn deinit(self: *Widget) void { 193 switch (self.*) { 194 inline else => |*case| case.deinit(), 195 } 196 } 197 198 pub fn build(self: *Widget, constraint: layout.Constraint, root_focus: *Focus) anyerror!void { 199 switch (self.*) { 200 inline else => |*case| try case.build(constraint, root_focus), 201 } 202 } 203 204 pub fn input(self: *Widget, key: inp.Key, root_focus: *Focus) anyerror!void { 205 switch (self.*) { 206 inline else => |*case| try case.input(key, root_focus), 207 } 208 } 209 210 pub fn clearGrid(self: *Widget) void { 211 switch (self.*) { 212 inline else => |*case| case.clearGrid(), 213 } 214 } 215 216 pub fn getGrid(self: Widget) ?Grid { 217 switch (self) { 218 inline else => |*case| return case.getGrid(), 219 } 220 } 221 222 pub fn getFocus(self: *Widget) *Focus { 223 switch (self.*) { 224 inline else => |*case| return case.getFocus(), 225 } 226 } 227 }; 228