diff options
Diffstat (limited to 'src/gui')
| -rw-r--r-- | src/gui/gui.zig | 325 |
1 files changed, 76 insertions, 249 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 8415d64e..ba0fa4fa 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -3873,11 +3873,7 @@ test "a click at the window's corner lands in the corner cell with a post chain const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 }); defer core.deinit(); try std.testing.expect(core.settings.post.set(.crt, "", true)); - var g: Gui = undefined; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; + var g = testGui(10, 20, 6, 12); const geometry: WindowGeometry = .{ .window_w = 400, .window_h = 240, .pixel_w = 800, .pixel_h = 480 }; const last = mouseCellWithGeometry(&g, core, 399.9, 239.9, geometry).?; try std.testing.expectEqual(@as(u16, 79), last.col); @@ -5713,16 +5709,8 @@ test "a wheel over codex in a terminal reaches its pty as the mouse reports it a var frame: std.heap.ArenaAllocator = .init(gpa); defer frame.deinit(); _ = try core.render(frame.allocator()); - var g: Gui = undefined; - g.scroll_pane = null; - g.scroll_delta = 0; - g.scroll_lag = 0; - g.scroll_edge_len = 0; - g.scroll_notch = 0; - g.program_wheel = 0; - g.glide = .{}; + var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - g.cell_h = 20; var in: Input = .{ .core = core }; var sent: std.ArrayList(u8) = .empty; defer sent.deinit(gpa); @@ -5897,12 +5885,8 @@ test "a notch scrolls the core at once and the picture glides after it, a wrappe var now: u64 = std.time.ns_per_s; core.advance(now); var s = try core.render(arena.allocator()); - var g: Gui = undefined; - g.glide = .{}; + var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - g.scroll_delta = 0; - g.scroll_lag = 0; - g.scroll_edge_len = 0; const r = core.rects[core.active]; g.scroll_pane = core.active; g.scroll_col = r.x + 10; @@ -5968,12 +5952,8 @@ test "a wheel's caret rides with its line, the text's own glide, never a spring core.advance(now); _ = arena.reset(.retain_capacity); var s = try core.render(arena.allocator()); - var g: Gui = undefined; - g.glide = .{}; + var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - g.scroll_delta = 0; - g.scroll_lag = 0; - g.scroll_edge_len = 0; const r = core.rects[core.active]; g.scroll_pane = core.active; g.scroll_col = r.x + 10; @@ -6072,16 +6052,8 @@ test "every scroll glides on one law: a half page, a page, the far jumps, a run defer arena.deinit(); core.advance(std.time.ns_per_s); _ = try core.render(arena.allocator()); - var g: Gui = undefined; - g.glide = .{}; + var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - g.scroll_notch = 0; - g.scroll_pane = null; - g.scroll_delta = 0; - g.scroll_lag = 0; - g.scroll_edge_len = 0; - g.sel_glow = .{}; - g.hover_glow = .{}; const body_h: f32 = @floatFromInt(core.rects[core.active].h - core.panes[core.active].?.tag_rows); const ctrl = struct { fn key(cp: u21) pardes.Key { @@ -6152,16 +6124,8 @@ test "a held key moves the view at the stream's own rate, never a bounce a line, defer arena.deinit(); core.advance(std.time.ns_per_s); _ = try core.render(arena.allocator()); - var g: Gui = undefined; - g.glide = .{}; + var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - g.scroll_notch = 0; - g.scroll_pane = null; - g.scroll_delta = 0; - g.scroll_lag = 0; - g.scroll_edge_len = 0; - g.sel_glow = .{}; - g.hover_glow = .{}; // j held from the top: a repeat every second frame, the view following // a line a repeat once the caret is at its last rows. var script: [48]GlideRun.Step = undefined; @@ -6331,8 +6295,7 @@ fn holdContext(g: *Gui, surface: *const pardes.Surface, id: usize, held: u16, bh test "a scroll's shifted rows start under the context rows, and its scissor below their band" { var surface: pardes.Surface = .{}; - var g: Gui = undefined; - g.tagline_height = 12; + var g = testGui(10, 20, 6, 12); g.scroll_rect = .{ .x = 0, .y = 0, .w = 40, .h = 20 }; g.scroll_body_y = 1; g.scroll_body_h = 19; @@ -7434,9 +7397,7 @@ fn cellFontRole(cell: *const pardes.Cell) pardes.FontRole { } test "concealed terminal text emits no ink on opaque or transparent ground" { - var g: Gui = undefined; - g.space_slot = .{ .u = 0, .v = 0 }; - g.words = .{}; + var g = testGui(10, 20, 6, 12); var cell: pardes.Cell = .{ .default = false, .style = .{ .invisible = true, .ul = .single } }; cell.text[0] = 'X'; for ([_]Ground{ .opaqueRgb(bg_default), .{ .rgb = bg_default, .clear = true } }) |page| { @@ -7883,18 +7844,8 @@ test "every pixel of a grip column is band, button or ring, and the button sits pane.file.?.revision = pane.file.?.saved_revision + @intFromBool(dirty); core.sync(); const s = try core.render(core.scratch.allocator()); - var g: Gui = undefined; - g.words = .{}; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(m.w, m.h, m.w, m.tag); defer g.decor.deinit(gpa); - g.cell_w = m.w; - g.cell_h = m.h; - g.tagline_width = m.w; - g.tagline_height = m.tag; - g.space_slot = .{ .u = 0, .v = 0 }; const layout = fixedCellLayout(&g); const win_w: f32 = @floatFromInt(60 * m.w); const win_h: f32 = @floatFromInt(20 * m.h); @@ -7972,9 +7923,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits test "a rising pane past its mark stays inside its box" { // Bouncy, a vertical rise at its highest overshoot: drawn past its box, // clipped to it. - var g: Gui = undefined; - g.cell_w = 10; - g.cell_h = 20; + var g = testGui(10, 20, 6, 12); var track: pardes.animation.Track = .{ .serial = 3, .phase = .opening, .effect = .vertical, .motion = @backingInt(pardes.animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = 0, .y = 10, .w = 40, .h = 10 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 10 } }; var peak: u16 = 0; var highest: f32 = 1e9; @@ -7994,13 +7943,7 @@ test "a rising pane past its mark stays inside its box" { test "small tagline fonts leave no background gutters between adjacent tags" { const chrome: pardes.Chrome = .{}; - var g: Gui = undefined; - g.words = .{}; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 8; - g.tagline_height = 16; - g.space_slot = .{ .u = 0, .v = 0 }; + var g = testGui(10, 20, 8, 16); const cell: pardes.Cell = .{ .default = false, .style = .{ .font_role = .tagline } }; var instances: [6]CellInstance = undefined; var next: u32 = 0; @@ -8133,11 +8076,7 @@ fn emitInstance( } test "block cursor alone overrides transparent cell background" { - var g: Gui = undefined; - g.words = .{}; - g.cell_w = 10; - g.cell_h = 20; - g.space_slot = .{ .u = 0, .v = 0 }; + var g = testGui(10, 20, 6, 12); const cell: pardes.Cell = .{}; var instances: [2]CellInstance = undefined; for ([_]bool{ false, true }, 0..) |cursor, i| { @@ -8147,13 +8086,7 @@ test "block cursor alone overrides transparent cell background" { } test "lapis dots only the page's own ground and shadows only a file name, never a cursor" { - var g: Gui = undefined; - g.words = .{}; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 8; - g.tagline_height = 16; - g.space_slot = .{ .u = 0, .v = 0 }; + var g = testGui(10, 20, 8, 16); const page: [3]u8 = .{ 0x0a, 0x10, 0x30 }; const name: [3]u8 = .{ 0xe8, 0xc4, 0x6a }; var chrome: pardes.Chrome = .{ .page = page, .decor_dots = .{ 1, 2, 3 }, .decor_dot_alpha = 0x22, .decor_title = .{ 4, 5, 6 }, .name_ink = name, .active_name_ink = name }; @@ -8195,16 +8128,8 @@ test "lapis plaques stay in their tag's band, clear of every grip; only the focu core.sync(); const s = try core.render(core.scratch.allocator()); try std.testing.expect(s.chrome.decor_box_border != null and s.chrome.decor_checker != null and s.chrome.decor_dots != null and s.chrome.decor_title != null); - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(16, 32, 12, 22); defer g.decor.deinit(gpa); - g.cell_w = 16; - g.cell_h = 32; - g.tagline_width = 12; - g.tagline_height = 22; display_scale = 1; var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true); @@ -8297,16 +8222,8 @@ test "insert cursor overlays without replacing the character beneath it" { var cells: [25]pardes.Cell = @splat(.{}); cells[3 * 5 + 2] = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 32, 48, 64 } }, .font_role = .tagline } }; const surface: pardes.Surface = .{ .cols = 5, .rows = 5, .cells = &cells, .cursor = .{ .x = 2, .y = 3, .bar = true } }; - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 8, 8); defer g.decor.deinit(std.testing.allocator); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 8; - g.tagline_height = 8; try cursorDecor(&g, std.testing.allocator, &surface, fixedCellLayout(&g), 100, 100); try std.testing.expectEqual(@as(usize, 1), g.decor.items.len); const bar = g.decor.items[0]; @@ -8577,29 +8494,62 @@ fn cellSlot(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role: return words.slots.items[text_start + at - start]; } +/// A Gui for the tests that build cells, decor or a scroll without a +/// window: these metrics, every other field its default. What needs SDL, a +/// font or the atlas is undefined (textTestGui adds a font and an atlas). +fn testGui(cell_w: u32, cell_h: u32, tagline_width: u32, tagline_height: u32) Gui { + return .{ + .window = undefined, + .device = undefined, + .swapchain_format = undefined, + .pipeline = undefined, + .pipeline_over = undefined, + .decor_pipeline = undefined, + .overlay_pipeline = undefined, + .image_pipeline = undefined, + .atlas_tex = undefined, + .atlas_sampler = undefined, + .linear_sampler = undefined, + .atlas_xfer = undefined, + .overlay_vbuf = undefined, + .overlay_vxfer = undefined, + .overlay_vertices = &.{}, + .image_vbuf = undefined, + .image_vxfer = undefined, + .font = undefined, + .px = 0, + .tagline_px = 0, + .tagline_percent = 0, + .tagline_width = tagline_width, + .tagline_height = tagline_height, + .cell_w = cell_w, + .cell_h = cell_h, + .ascent = 0, + .tagline_baseline = 0, + .atlas_stage = &.{}, + .glyphs = undefined, + }; +} + /// A Gui that can shape and rasterize `font` at `px`, and nothing else. From /// here on the fonts allocate from std.testing.allocator (the caller puts /// font_allocator back), so the test counts what they leak. fn textTestGui(font: *c.UIFont, px: f32) !Gui { c.ui_font_prime(font); font_allocator = std.testing.allocator; - var g: Gui = undefined; - g.font = font; - g.fallback_count = 0; - g.px = px; var cw: c_int = 0; var ch: c_int = 0; - c.ui_font_cell_metrics(font, px, &cw, &ch, &g.ascent); - g.cell_w = @intCast(cw); - g.cell_h = @intCast(ch); - const tag = taglineRaster(font, px, g.cell_w, g.cell_h, 82); + var ascent: c_int = 0; + c.ui_font_cell_metrics(font, px, &cw, &ch, &ascent); + const tag = taglineRaster(font, px, @intCast(cw), @intCast(ch), 82); + var g = testGui(@intCast(cw), @intCast(ch), tag.width, tag.height); + g.font = font; + g.px = px; + g.ascent = ascent; g.tagline_px = tag.px; - g.tagline_width = tag.width; - g.tagline_height = tag.height; g.tagline_baseline = tag.baseline; g.atlas_stage = try std.testing.allocator.alloc(u8, atlas_w * atlas_h); g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); - g.words = .{}; resetGlyphAtlas(&g); return g; } @@ -8795,14 +8745,12 @@ fn centerGlyphInk(out: [*]u8, width: usize, height: usize) void { test "pane indicator cached ink centers bearings styles and sizes" { const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; defer c.ui_font_free(font); - var g: Gui = undefined; + var g = testGui(10, 20, 6, 12); g.font = font; - g.fallback_count = 0; g.atlas_stage = try std.testing.allocator.alloc(u8, atlas_w * atlas_h); defer std.testing.allocator.free(g.atlas_stage); g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); defer g.glyphs.deinit(); - g.words = .{}; for ([_]f32{ 13, 27, 40 }) |px| { g.px = px; var cw: c_int = 0; @@ -8865,21 +8813,13 @@ test "pane indicator halves share dissolve changes and safe exhausted atlas" { const font = c.ui_font_new(font_ttf.ptr, @intCast(font_ttf.len)).?; defer c.ui_font_free(font); - var g: Gui = undefined; + var g = testGui(10, 20, 8, 16); g.font = font; - g.fallback_count = 0; g.px = 20; g.tagline_px = 16; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 8; - g.tagline_height = 16; - g.space_slot = .{ .u = 0, .v = 0 }; - g.pen_x = 0; g.pen_y = atlas_h; g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator); defer g.glyphs.deinit(); - g.words = .{}; defer g.words.deinit(std.testing.allocator); for ([_]bool{ false, true }) |old| { var instances: [4]CellInstance = undefined; @@ -9790,15 +9730,7 @@ test "a lift never touches a tag, a grip or a header, on a light theme or a dark if (layer.id == core.active) active = layer.bg else other = layer.bg; }; try std.testing.expect(!std.mem.eql(u8, &active.?, &other.?)); - var g: Gui = undefined; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, settled, &groups, fixedCellLayout(&g), 800, 480, true); @@ -10465,13 +10397,7 @@ fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const test "decor less its holes covers each pixel of the rest once and none of the holes" { const gpa = std.testing.allocator; - var g: Gui = undefined; - g.cell_w = 1; - g.cell_h = 1; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(1, 1, 1, 1); defer g.decor.deinit(gpa); const holes = [_][4]f32{ .{ 3, 2, 9, 6 }, .{ 5, 4, 12, 8 }, .{ 30, 30, 40, 40 } }; try addDecorExcept(&g, gpa, .{ 1, 1, 11, 10 }, &holes, .{ 1, 2, 3 }, null, 16, 12); @@ -10661,16 +10587,8 @@ test "a theme's own rules and scrollbar are drawn at its widths: acme's 2px blac try std.testing.expectEqual(@as(u8, 2), s.chrome.rule_px); // acme's 12px, at GripWidth's 150% default. try std.testing.expectEqual(@as(u8, 18), s.chrome.rail_px); - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(16, 20, 10, 12); defer g.decor.deinit(gpa); - g.cell_w = 16; - g.cell_h = 20; - g.tagline_width = 10; - g.tagline_height = 12; var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 480, true); const px = struct { @@ -10699,16 +10617,8 @@ test "the scrollbar thumb moves by the pixel and follows a glide" { const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); defer core.deinit(); const pane = try core.setTestFile(std.mem.asBytes(&@as([1000][5]u8, @splat("line\n".*)))); - var g: Gui = undefined; - g.decor = .empty; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; const thumb = struct { // The thumb's top, in window pixels. fn top(gui: *Gui, p: *pardes.Pardes) !f32 { @@ -10753,16 +10663,8 @@ test "the rule between stacked panes stays in the tag band's slack, at any tagli if (region.kind == .tag and region.rect.y > 2) break region; } else return error.TestExpectedStackedTag; for ([_]u32{ 12, 20 }) |tagline_h| { - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, tagline_h); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = tagline_h; var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true); const top = @as(f32, @floatFromInt(lower.rect.y)) * 20; @@ -10791,16 +10693,8 @@ test "an empty column is ruled on both sides, as between two filled ones" { try std.testing.expectEqual(@as(usize, 3), core.ncol); try std.testing.expectEqual(@as(usize, 0), core.col_n[1]); const s = try core.render(core.scratch.allocator()); - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; const layout = fixedCellLayout(&g); var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, s, &groups, layout, 800, 480, true); @@ -10830,16 +10724,8 @@ test "at a 2x display every logical pixel is two: rules, the tag rule, the grip' for ([_]f32{ 1, 2 }) |scale| { display_scale = scale; defer display_scale = 1; - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(16, 32, 12, 24); defer g.decor.deinit(gpa); - g.cell_w = 16; - g.cell_h = 32; - g.tagline_width = 12; - g.tagline_height = 24; var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true); const w = struct { @@ -10897,16 +10783,8 @@ test "decor is read from the regions, each pane's in its own group" { try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false)); core.sync(); const s = try core.render(core.scratch.allocator()); - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; const layout = fixedCellLayout(&g); const ndc = struct { fn x(px: f32) f32 { @@ -10965,16 +10843,8 @@ test "a pane on the move casts a shadow on the other panes' bodies alone, most a for (0..40) |_| core.update(.tick); core.sync(); const s = try core.render(core.scratch.allocator()); - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; const layout = fixedCellLayout(&g); const serial = core.panes[1].?.serial; var strengths: [3]f32 = @splat(0); @@ -11021,16 +10891,8 @@ test "the selection glows round its block, on the body only, fading in over 100 cell.style.bg = .{ .rgb = s.chrome.sel_bg }; }; s.cursor = null; - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; g.sel_glow = .{ .now_ns = std.time.ns_per_s }; var strengths: [2]f32 = .{ 0, 0 }; for ([_]u64{ 0, 150 * std.time.ns_per_ms }, 0..) |later, i| { @@ -11076,17 +10938,8 @@ test "a hovered word glows along its foot, never over the cursor, fading in over cell.style.bg = .{ .rgb = tint }; } s.cursor = .{ .x = body.rect.x + 8, .y = row }; - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; - g.sel_glow = .{}; g.hover_glow = .{ .now_ns = std.time.ns_per_s }; var strongest: f32 = 0; for ([_]u64{ 0, 90 * std.time.ns_per_ms }) |later| { @@ -11122,18 +10975,8 @@ test "occlusion shades each body's edges, inside it, never a tag, a grip or the } else return error.NoBody; // The cursor on the body's top-left cell, where the shade is. s.cursor = .{ .x = body.rect.x, .y = body.rect.y }; - var g: Gui = undefined; - g.decor = .empty; - g.glide = .{}; - g.scroll_pane = null; - g.scroll_lag = 0; + var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; - g.sel_glow = .{}; - g.hover_glow = .{}; var groups = makeGroups(&.{}, false); try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true); const r = bodyPixels(body, fixedCellLayout(&g)); @@ -11415,11 +11258,7 @@ test "pet overlay stays beyond workspace text and keeps going while its tag is e cells[i].len = 1; cells[i].default = false; } - var g: Gui = undefined; - g.pet_state = .{}; - g.cell_h = 20; - g.tagline_height = 16; - g.tagline_width = 8; + var g = testGui(10, 20, 8, 16); var vertices: [pet.max_vertices]OverlayVertex = undefined; var builder: OverlayBuilder = .{ .vertices = &vertices, .win_w = 800, .win_h = 480 }; appendWorkspacePet(&g, core, &surface, &builder); @@ -11734,13 +11573,7 @@ fn envU16(env: *std.process.Environ.Map, name: []const u8) ?u16 { } test "compact body layer rendering fills recovered rows and clips the final glyph" { - var g: Gui = undefined; - g.words = .{}; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; - g.space_slot = .{ .u = 0, .v = 0 }; + var g = testGui(10, 20, 6, 12); var cells: [24]pardes.Cell = @splat(.{}); var layer: pardes.Layer = .{ .viewport = .{ .x = 3, .y = 2, .w = 2, .h = 5 }, @@ -11774,13 +11607,7 @@ test "compact body layer rendering fills recovered rows and clips the final glyp } test "compact tag layers fill available width and clip at their physical edge" { - var g: Gui = undefined; - g.words = .{}; - g.cell_w = 10; - g.cell_h = 20; - g.tagline_width = 6; - g.tagline_height = 12; - g.space_slot = .{ .u = 0, .v = 0 }; + var g = testGui(10, 20, 6, 12); var cells: [6]pardes.Cell = @splat(.{}); const layer: pardes.Layer = .{ .kind = .pane, .id = 0, .serial = 7, .viewport = .{ .x = 2, .y = 3, .w = 3, .h = 1 }, .cols = 6, .rows = 1, .cells = &cells, .bg = .{ 20, 30, 40 } }; var instances: [8]CellInstance = undefined; |
