summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.zig994
1 files changed, 186 insertions, 808 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index e97e6e38..24b15b35 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -425,18 +425,10 @@ const CellInstance = extern struct {
br: f32,
bg: f32,
bb: f32,
- panel_x0: f32 = 0,
- panel_y0: f32 = 0,
- panel_x1: f32 = 0,
- panel_y1: f32 = 0,
- present_x0: f32 = 0,
- present_y0: f32 = 0,
- present_x1: f32 = 0,
- present_y1: f32 = 0,
+ /// The flags (the high bits, ui.vert.glsl), and the theme's dots'
+ /// offset (G13's parallax) as a float's bits.
effect: u32 = 0,
- progress_bits: u32 = @bitCast(@as(f32, 1)),
serial: u32 = 0,
- cell_coord: u32 = 0,
/// A clip rectangle in target pixels; x1 < x0 is none (ui.vert.glsl).
clip_x0: f32 = 0,
clip_y0: f32 = 0,
@@ -463,21 +455,8 @@ const ImageInstance = extern struct {
v0: f32,
u1: f32,
v1: f32,
- panel_x0: f32 = 0,
- panel_y0: f32 = 0,
- panel_x1: f32 = 0,
- panel_y1: f32 = 0,
- present_x0: f32 = 0,
- present_y0: f32 = 0,
- present_x1: f32 = 0,
- present_y1: f32 = 0,
- effect: u32 = 0,
- progress_bits: u32 = @bitCast(@as(f32, 1)),
- serial: u32 = 0,
- cell_coord: u32 = 0,
};
-const old_layer_bit: u32 = 0x8000_0000;
const clear_bg_bit: u32 = 0x4000_0000;
const opaque_bg_bit: u32 = 0x2000_0000;
/// Decor that is a checker (decor.frag.glsl).
@@ -487,123 +466,16 @@ const checker_bit: u32 = 0x0800_0000;
const dotted_bit: u32 = 0x1000_0000;
const title_bit: u32 = 0x0800_0000;
-const SavedImagePlace = struct {
- key: pardes.ImageCacheKey,
- pane: u8,
- serial: u32,
- native: pardes.NativePlacement,
- x: u16,
- y: u16,
- w: u16,
- h: u16,
- iw: usize,
- ih: usize,
-
- fn from(place: pardes.ImagePlace) SavedImagePlace {
- return .{
- .key = place.cacheKey(),
- .pane = place.pane,
- .serial = place.serial,
- .native = place.native,
- .x = place.x,
- .y = place.y,
- .w = place.w,
- .h = place.h,
- .iw = place.iw,
- .ih = place.ih,
- };
- }
-
- fn cacheKey(place: SavedImagePlace) pardes.ImageCacheKey {
- return place.key;
- }
-};
-
const PreparedImage = struct {
- place: SavedImagePlace,
+ place: pardes.ImagePlace,
texture: *c.SDL_GPUTexture,
- track: ?pardes.animation.Track = null,
- clip: ?pardes.animation.Box = null,
- old_layer: bool = false,
};
-test "saved native placement retains identity and geometry but no producer bytes" {
- try std.testing.expect(!@hasField(SavedImagePlace, "rgba"));
- const current: pardes.ImagePlace = .{
- .pane = 3,
- .serial = 91,
- .x = 4,
- .y = 5,
- .w = 6,
- .h = 7,
- .rgba = &.{ 1, 2, 3, 4 },
- .iw = 1,
- .ih = 1,
- };
- const saved = SavedImagePlace.from(current);
- try std.testing.expect(sameSavedPlacement(saved, current));
- try std.testing.expect(placeIntersectsBox(saved, .{ .x = 8, .y = 8, .w = 4, .h = 4 }));
- try std.testing.expect(!placeIntersectsBox(saved, .{ .x = 20, .y = 20, .w = 2, .h = 2 }));
-}
-
-test "shader instance ABI carries aligned transition vectors" {
- try std.testing.expectEqual(@as(usize, 120), @sizeOf(CellInstance));
- try std.testing.expectEqual(@as(usize, 104), @offsetOf(CellInstance, "clip_x0"));
- try std.testing.expectEqual(@as(usize, 56), @offsetOf(CellInstance, "panel_x0"));
- try std.testing.expectEqual(@as(usize, 72), @offsetOf(CellInstance, "present_x0"));
- try std.testing.expectEqual(@as(usize, 88), @offsetOf(CellInstance, "effect"));
- try std.testing.expectEqual(@as(usize, 80), @sizeOf(ImageInstance));
- try std.testing.expectEqual(@as(usize, 32), @offsetOf(ImageInstance, "panel_x0"));
- try std.testing.expectEqual(@as(usize, 48), @offsetOf(ImageInstance, "present_x0"));
- try std.testing.expectEqual(@as(usize, 64), @offsetOf(ImageInstance, "effect"));
- try std.testing.expectEqual(@as(usize, 32), @sizeOf([8]f32));
-
- const tracks = [_]pardes.animation.Track{
- .{ .pane = 0, .phase = .opening, .effect = .slide },
- .{ .pane = 1, .phase = .moving, .effect = .slide },
- .{ .pane = 2, .phase = .moving, .effect = .slide },
- };
- // Tier 0, the tracks as the core ordered them, then tiers 4 and 5.
- const groups = makeGroups(&tracks, true);
- try std.testing.expectEqual(@as(usize, 7), groups.len);
- try std.testing.expect(groups.items[0].track == null);
- try std.testing.expectEqual(@as(u8, 0), groups.items[1].track.?.pane);
- try std.testing.expectEqual(@as(u8, 1), groups.items[2].track.?.pane);
- try std.testing.expectEqual(@as(u8, 2), groups.items[3].track.?.pane);
- try std.testing.expectEqual(@as(usize, 4), groups.notices);
- try std.testing.expectEqual(@as(usize, 5), groups.guides);
- try std.testing.expectEqual(@as(usize, 6), groups.ink);
- for ([_]usize{ groups.notices, groups.guides, groups.ink }) |index| try std.testing.expect(groups.items[index].track == null);
-}
-
-test "GUI paint plan snaps history effects without a frozen grid" {
- const tracks = [_]pardes.animation.Track{
- .{ .pane = 0, .phase = .opening, .effect = .ascii },
- .{ .pane = 1, .phase = .closing, .effect = .vertical },
- };
- try std.testing.expectEqual(@as(usize, 0), makeGroups(&tracks, false).tracks);
- const ready = makeGroups(&tracks, true);
- try std.testing.expectEqual(@as(usize, 2), ready.tracks);
- try std.testing.expectEqual(pardes.animation.Phase.opening, ready.items[1].track.?.phase);
- try std.testing.expectEqual(pardes.animation.Phase.closing, ready.items[2].track.?.phase);
-}
-
-test "closing tombstone overlays but never owns canonical cells" {
- const closing: pardes.animation.Track = .{
- .pane = 0,
- .phase = .closing,
- .effect = .vertical,
- .from = .{ .x = 2, .y = 3, .w = 10, .h = 4 },
- .to = .{ .x = 2, .y = -1, .w = 10, .h = 4 },
- };
- const groups = makeGroups(&.{closing}, true);
- try std.testing.expectEqual(@as(usize, 0), groupAt(&groups, 4, 4));
- // A still pane's notice stays under the tombstone sliding over it.
- const notice: pardes.Layer = .{ .kind = .notice, .viewport = .{ .x = 4, .y = 4, .w = 3, .h = 1 }, .rows = 1 };
- try std.testing.expectEqual(@as(usize, 0), noticeGroup(&groups, &notice));
- try std.testing.expectEqual(makeGroups(&.{}, false).notices, noticeGroup(&makeGroups(&.{}, false), &notice));
- try std.testing.expectEqual(@as(usize, 1), groups.tracks);
- try std.testing.expectEqual(pardes.animation.Phase.closing, groups.items[1].track.?.phase);
+test "the shader instance ABI: the flags after the colours, the clip after them" {
+ try std.testing.expectEqual(@as(usize, 80), @sizeOf(CellInstance));
+ try std.testing.expectEqual(@as(usize, 56), @offsetOf(CellInstance, "effect"));
+ try std.testing.expectEqual(@as(usize, 64), @offsetOf(CellInstance, "clip_x0"));
+ try std.testing.expectEqual(@as(usize, 32), @sizeOf(ImageInstance));
}
fn updateCoreResize(core: *pardes.Pardes, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) bool {
@@ -1098,10 +970,8 @@ const Gui = struct {
image_vxfer: ?*c.SDL_GPUTransferBuffer = null,
image_capacity: u32 = 0,
native_images: std.AutoHashMapUnmanaged(pardes.ImageCacheKey, *c.SDL_GPUTexture) = .empty,
- presented_images: std.ArrayListUnmanaged(SavedImagePlace) = .empty,
prepared_images: std.ArrayListUnmanaged(PreparedImage) = .empty,
- /// renderFrame's cover of the grid (coverFrame): this frame's, then the
- /// frame a panel transition is leaving.
+ /// renderFrame's cover of the grid (coverFrame).
cover: std.ArrayListUnmanaged(Cover) = .empty,
/// renderFrame's decor instances, group by group (buildDecor).
decor: std.ArrayListUnmanaged(CellInstance) = .empty,
@@ -1221,7 +1091,7 @@ const Gui = struct {
/// The Gui's fields that are each window's own, one a view (views.zig):
/// the window and its presenting, its scroll and glide, its pointer, its
-/// blink, its images as presented, its capture. The
+/// blink, its images, its capture. The
/// device, the atlas, the font and the pipelines are every window's. The
/// Gui holds the live window's; the others wait in `Shell.windows`.
const window_fields = [_][:0]const u8{
@@ -1231,7 +1101,7 @@ const window_fields = [_][:0]const u8{
"scroll_lag", "scroll_edge", "scroll_edge_len", "scroll_notch", "program_wheel",
"glide", "pace_ns", "frame_arrival_ns",
"blink_due", "cursor_quad_alpha", "pointer_present", "pointer_shape",
- "pointer_cell", "presented_images", "prepared_images", "touch",
+ "pointer_cell", "prepared_images", "touch",
"live_ctrl", "live_alt", "applied_window_opacity", "capture_tex", "capture_tex_w",
"capture_tex_h", "capture_xfer", "capture_xfer_size", "captured", "capture_dir",
};
@@ -1274,7 +1144,6 @@ fn releaseWindowParts(g: *Gui, gpa: std.mem.Allocator) void {
if (g.capture_xfer) |transfer| c.SDL_ReleaseGPUTransferBuffer(g.device, transfer);
g.glide.deinit(gpa);
gpa.free(g.scroll_edge);
- g.presented_images.deinit(gpa);
g.prepared_images.deinit(gpa);
}
@@ -1405,12 +1274,9 @@ fn fixedCellLayout(g: *const Gui) CellLayout {
return .{ .w = @floatFromInt(g.cell_w), .h = @floatFromInt(g.cell_h), .x_off = 0, .y_off = 0 };
}
-const boxContains = pardes.animation.Box.contains;
-
-/// What one tier draws, or one track in tiers 2 and 3 (docs/render-pipeline.md
-/// §3.4), in this order: its cells, its images, then its decor.
+/// What one group draws, in this order: its cells, its images, then its
+/// decor.
const Group = struct {
- track: ?pardes.animation.Track = null,
cell_start: u32 = 0,
cell_count: u32 = 0,
image_start: u32 = 0,
@@ -1422,61 +1288,17 @@ const Group = struct {
under_count: u32 = 0,
};
-/// The frame's draw groups, bottom to top: tier 0 (the page and the panes
-/// standing still), a group for each track in paint order (tier 2 moving and
-/// opening, tier 3 closing), tier 4 (floating: the notices, then the guides
-/// and the debug box, which the core paints over them) and tier 5 (ink: the
-/// bar cursors; the cursor's glide draws after it). Tier 1 is the
-/// focus lift, which does not exist yet.
+/// The frame's draw groups, bottom to top: the page and the panes, the
+/// notices floating over them, the guides and the debug box the core paints
+/// over those, and ink (the bar cursors; the cursor's glide draws after it).
const Groups = struct {
- items: [pardes.MAX_PANES * 2 + 4]Group = @splat(.{}),
- /// Groups 1 through `tracks` are the tracks'.
- tracks: usize = 0,
+ items: [4]Group = @splat(.{}),
notices: usize = 1,
guides: usize = 2,
ink: usize = 3,
len: usize = 4,
};
-fn makeGroups(tracks: []const pardes.animation.Track, has_diff: bool) Groups {
- var groups: Groups = .{};
- for (tracks) |track| {
- if (!track.active()) continue;
- if (track.effect.needsPreviousGrid() and !has_diff) continue;
- std.debug.assert(groups.tracks < pardes.MAX_PANES * 2);
- groups.tracks += 1;
- groups.items[groups.tracks].track = track;
- }
- groups.notices = groups.tracks + 1;
- groups.guides = groups.tracks + 2;
- groups.ink = groups.tracks + 3;
- groups.len = groups.tracks + 4;
- return groups;
-}
-
-/// The group of the track whose pane covers this cell, else tier 0.
-fn groupAt(groups: *const Groups, col: u16, row: u16) usize {
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- if (group.track.?.phase == .closing) continue;
- if (boxContains(group.track.?.to, col, row)) return index;
- }
- return 0;
-}
-
-fn groupOf(groups: *const Groups, serial: u32) usize {
- for (groups.items[1..][0..groups.tracks], 1..) |group, index|
- if (group.track.?.serial == serial) return index;
- return 0;
-}
-
-/// A notice floats over the panes and its pane's picture (tier 4) while
-/// nothing moves; while anything does it stays in its own pane's group, under
-/// whatever pane slides, opens or closes over it.
-fn noticeGroup(groups: *const Groups, layer: *const pardes.Layer) usize {
- if (groups.tracks > 0) return groupAt(groups, layer.viewport.x, layer.viewport.y);
- return groups.notices;
-}
-
/// What draws a grid cell, marked once a frame from the layers and the
/// regions (coverFrame), so the cell loops read it rather than search.
const Cover = packed struct(u16) {
@@ -1548,69 +1370,6 @@ fn coverFrame(cover: []Cover, cols: u16, rows: u16, body_layers: []const pardes.
};
}
-fn panelCellCoord(track: pardes.animation.Track, col: u16, row: u16) u32 {
- const source = track.contentBox();
- const x0: u16 = @intFromFloat(@max(0.0, @floor(source.x)));
- const y0: u16 = @intFromFloat(@max(0.0, @floor(source.y)));
- return @as(u32, row -| y0) << 16 | @as(u32, col -| x0);
-}
-
-fn panelGridSize(track: pardes.animation.Track) u32 {
- const source = track.contentBox();
- const cols: u16 = @intFromFloat(@min(@as(f32, std.math.maxInt(u16)), @max(1.0, @ceil(source.w))));
- const rows: u16 = @intFromFloat(@min(@as(f32, std.math.maxInt(u16)), @max(1.0, @ceil(source.h))));
- return @as(u32, rows) << 16 | @as(u32, cols);
-}
-
-fn ndcBox(box: pardes.animation.Box, layout: CellLayout, win_w: f32, win_h: f32) [4]f32 {
- const px0 = layout.x_off + box.x * layout.w;
- const py0 = layout.y_off + box.y * layout.h;
- const px1 = px0 + box.w * layout.w;
- const py1 = py0 + box.h * layout.h;
- return .{
- px0 / win_w * 2.0 - 1.0,
- 1.0 - py0 / win_h * 2.0,
- px1 / win_w * 2.0 - 1.0,
- 1.0 - py1 / win_h * 2.0,
- };
-}
-
-/// A new instance's transition fields for `track`, which moves its pane;
-/// with none it keeps its defaults (still, all of it shown).
-fn setTransitionFields(
- instance: anytype,
- track: ?pardes.animation.Track,
- layout: CellLayout,
- win_w: f32,
- win_h: f32,
- cell_coord: u32,
-) void {
- const active = track orelse return;
- const final = ndcBox(active.contentBox(), layout, win_w, win_h);
- const presented = ndcBox(active.visualBox(), layout, win_w, win_h);
- instance.panel_x0 = final[0];
- instance.panel_y0 = final[1];
- instance.panel_x1 = final[2];
- instance.panel_y1 = final[3];
- instance.present_x0 = presented[0];
- instance.present_y0 = presented[1];
- instance.present_x1 = presented[2];
- instance.present_y1 = presented[3];
- instance.effect = @backingInt(active.effect);
- instance.progress_bits = @bitCast(active.amount());
- instance.serial = active.serial;
- instance.cell_coord = cell_coord;
- // A vertical transition shows its pane only inside the box it grows
- // into, in whole pixels.
- if (@hasField(@TypeOf(instance.*), "clip_x0") and active.effect == .vertical) {
- const box = active.contentBox();
- instance.clip_x0 = std.math.clamp(@floor(box.x * layout.w), 0, win_w);
- instance.clip_y0 = std.math.clamp(@floor(box.y * layout.h), 0, win_h);
- instance.clip_x1 = std.math.clamp(@ceil((box.x + box.w) * layout.w), instance.clip_x0, win_w);
- instance.clip_y1 = std.math.clamp(@ceil((box.y + box.h) * layout.h), instance.clip_y0, win_h);
- }
-}
-
pub fn run(init: std.process.Init, opts: pardes.Options, headless: bool) !void {
return runNative(init, opts, headless, null);
}
@@ -1895,7 +1654,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
defer {
clearNativeImages(&g);
g.native_images.deinit(gpa);
- g.presented_images.deinit(gpa);
g.prepared_images.deinit(gpa);
g.cover.deinit(gpa);
g.decor.deinit(gpa);
@@ -2133,7 +1891,6 @@ fn localSession(
shell.windowed = 1;
shell.stopPtys();
clearNativeImages(g);
- g.presented_images.clearRetainingCapacity();
g.prepared_images.clearRetainingCapacity();
nc.native_images = true;
nc.native_image_patches = true;
@@ -3114,21 +2871,25 @@ fn gridCellAtDimensions(
var point: MouseCell = .{ .col = @intFromFloat(@min(@floor(@max(x, 0) / @max(body_w, 1)), 10_000)), .row = row };
// On the rule over this row, which is where two panes meet if they do.
point.rule_above = row > 0 and @max(y, 0) - @as(f32, @floatFromInt(row)) * @max(body_h, 1) < dp(rule_grab_px);
- if (core.presentation.pointerFractional(core.screen_w, core.screen_h, x / @max(body_w, 1), y / @max(body_h, 1))) |mapped| {
- for (core.surface.tagLayers()) |*layer| {
- if (layer.tagHit(mapped.x * body_w, mapped.y * body_h, body_w, body_h, tagline_w, @floatFromInt(core.row_metrics.tagline_h))) |hit| {
- point.tag_hit = hit;
- break;
- }
+ if (onGrid(core, x / @max(body_w, 1), y / @max(body_h, 1))) for (core.surface.tagLayers()) |*layer| {
+ if (layer.tagHit(x, y, body_w, body_h, tagline_w, @floatFromInt(core.row_metrics.tagline_h))) |hit| {
+ point.tag_hit = hit;
+ break;
}
- }
+ };
return point;
}
+/// Whether a point, in cells, is on the grid.
+fn onGrid(core: *const pardes.Pardes, x: f32, y: f32) bool {
+ return std.math.isFinite(x) and std.math.isFinite(y) and x >= 0 and y >= 0 and
+ x < @as(f32, @floatFromInt(core.screen_w)) and y < @as(f32, @floatFromInt(core.screen_h));
+}
+
fn gridCellAtPixels(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32) MouseCell {
var point = gridCellAtDimensions(core, x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width));
- if (core.presentation.pointerFractional(core.screen_w, core.screen_h, x / @as(f32, @floatFromInt(g.cell_w)), y / @as(f32, @floatFromInt(g.cell_h)))) |mapped| for (core.surface.bodyLayers()) |*layer| {
- if (layer.bodyHit(mapped.x * @as(f32, @floatFromInt(g.cell_w)), mapped.y * @as(f32, @floatFromInt(g.cell_h)), @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width), @floatFromInt(g.tagline_height))) |hit| {
+ if (onGrid(core, x / @as(f32, @floatFromInt(g.cell_w)), y / @as(f32, @floatFromInt(g.cell_h)))) for (core.surface.bodyLayers()) |*layer| {
+ if (layer.bodyHit(x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width), @floatFromInt(g.tagline_height))) |hit| {
point.body_hit = hit;
break;
}
@@ -3141,7 +2902,6 @@ test "tagline pointer mapping retains physical grips and carries logical text co
defer core.deinit();
core.update(.{ .resize = .{ .cols = 60, .rows = 12 } });
core.update(.{ .command = "Newcol" });
- core.presentation.enabled = false;
core.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 12 };
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
@@ -4302,16 +4062,14 @@ fn postPresent(ctx: ?*anyopaque) void {
const s = shellOf(ctx);
s.follow();
const g = s.gui orelse return;
- // No image (a minimized window) shows no tracks; time still passes and
- // the pump advances it all the same.
+ // No image (a minimized window): nothing was drawn to point at.
if (!s.presented) return;
- const frame = s.surface orelse return;
- // A client's view live: the window's frame is acknowledged when its
- // own view is live and drawn.
+ // A client's view live: the window's frame counts when its own view is
+ // live and drawn.
if (s.core.view != s.gview) return;
var in: Input = .{ .core = s.core };
refreshPresentedPointer(g, &in);
- s.core.acknowledgePanelPresentation(frame.panelTracks());
+ s.core.presented();
}
fn guiNow(ctx: ?*anyopaque) u64 {
@@ -5226,8 +4984,6 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
const pane = if (gliding) glide.pane else g.scroll_pane orelse return 0;
const lag = if (gliding) glide.follow.offset else g.scroll_lag;
if (lag == 0) return 0;
- for (surface.panelTracks()) |track|
- if (track.active() and track.pane == pane) return 0;
const r = if (gliding) glide.rect else g.scroll_rect;
const bh = if (gliding) glide.body_h else g.scroll_body_h;
const y0 = if (gliding) glide.body_y else g.scroll_body_y;
@@ -5257,7 +5013,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
const row_cursor: ?usize = if (surface.cursor) |cu| if (cu.y == row) cu.x else null else null;
var col = x0;
while (col < x0 + bw) : (col += 1) {
- emitInstance(g, instances, base + n, col, row, shifted, win_w, win_h, null, cellFontRole(&line[col]), line, col, row_cursor, false, @as(u32, row) * surface.cols + col == caret, page);
+ emitInstance(g, instances, base + n, col, row, shifted, win_w, win_h, cellFontRole(&line[col]), line, col, row_cursor, @as(u32, row) * surface.cols + col == caret, page);
n += 1;
}
}
@@ -5267,7 +5023,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
const erow: u16 = if (lag > 0) y0 + bh else y0 - 1;
var i: u16 = 0;
while (i < bw) : (i += 1) {
- emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, null, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, false, page);
+ emitInstance(g, instances, base + n, x0 + i, erow, shifted, win_w, win_h, cellFontRole(&g.scroll_edge[i]), g.scroll_edge[0..bw], i, null, false, page);
n += 1;
}
}
@@ -5286,7 +5042,7 @@ fn emitScrollRows(g: *Gui, instances: [*]CellInstance, base: u32, surface: *cons
// emitInstance takes an unsigned row: move the layout instead.
at.y_off += @as(f32, @floatFromInt(at_row - @as(i32, y0))) * layout.h;
for (0..bw) |c_i| {
- emitInstance(g, instances, base + n, x0 + @as(u16, @intCast(c_i)), y0, at, win_w, win_h, null, cellFontRole(&cells[c_i]), cells, c_i, null, false, false, page);
+ emitInstance(g, instances, base + n, x0 + @as(u16, @intCast(c_i)), y0, at, win_w, win_h, cellFontRole(&cells[c_i]), cells, c_i, null, false, page);
n += 1;
}
}
@@ -5363,51 +5119,6 @@ fn surfaceHasNativeKey(surface: *const pardes.Surface, key: pardes.ImageCacheKey
return false;
}
-fn snapshotHasNativeKey(g: *const Gui, key: pardes.ImageCacheKey) bool {
- for (g.presented_images.items) |place|
- if (place.key.eql(key)) return true;
- return false;
-}
-
-fn rememberPresentedImages(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface) void {
- var next: std.ArrayListUnmanaged(SavedImagePlace) = .empty;
- var adopted = false;
- defer if (!adopted) next.deinit(gpa);
- next.ensureTotalCapacity(gpa, surface.images.items.len) catch return;
- for (surface.images.items) |place| {
- if (validImageBytes(place) == null or !g.native_images.contains(place.cacheKey())) continue;
- next.appendAssumeCapacity(SavedImagePlace.from(place));
- }
- var old = g.presented_images;
- g.presented_images = next;
- adopted = true;
- old.deinit(gpa);
-}
-
-fn sameSavedPlacement(saved: SavedImagePlace, current: pardes.ImagePlace) bool {
- return saved.key.eql(current.cacheKey()) and
- saved.pane == current.pane and saved.serial == current.serial and
- saved.x == current.x and saved.y == current.y and
- saved.w == current.w and saved.h == current.h and
- saved.iw == current.iw and saved.ih == current.ih and
- std.meta.eql(saved.native, current.native);
-}
-
-fn snapshotContainsPlacement(g: *const Gui, current: pardes.ImagePlace) bool {
- for (g.presented_images.items) |saved|
- if (sameSavedPlacement(saved, current)) return true;
- return false;
-}
-
-fn placeIntersectsBox(place: SavedImagePlace, box: pardes.animation.Box) bool {
- const x0: f32 = @floatFromInt(place.x);
- const y0: f32 = @floatFromInt(place.y);
- const x1: f32 = @floatFromInt(@as(u32, place.x) + place.w);
- const y1: f32 = @floatFromInt(@as(u32, place.y) + place.h);
- return x0 < box.x + box.w and x1 > box.x and
- y0 < box.y + box.h and y1 > box.y;
-}
-
fn validImageBytes(place: pardes.ImagePlace) ?u32 {
if (place.iw == 0 or place.ih == 0 or
place.iw > std.math.maxInt(u32) or place.ih > std.math.maxInt(u32)) return null;
@@ -5419,13 +5130,13 @@ fn validImageBytes(place: pardes.ImagePlace) ?u32 {
const NativeBounds = struct { w: u32, h: u32 };
-fn nativeBounds(g: *const Gui, place: SavedImagePlace) ?NativeBounds {
+fn nativeBounds(g: *const Gui, place: pardes.ImagePlace) ?NativeBounds {
const bound_w = std.math.mul(u32, place.w, g.cell_w) catch return null;
const bound_h = std.math.mul(u32, place.h, g.cell_h) catch return null;
return .{ .w = bound_w, .h = bound_h };
}
-fn nativePlaceGeometry(g: *const Gui, place: SavedImagePlace) ?pardes.image.NativeGeometry {
+fn nativePlaceGeometry(g: *const Gui, place: pardes.ImagePlace) ?pardes.image.NativeGeometry {
if (comptime pardes.pdf_enabled) {
if (place.native.geometry) |geometry| return geometry;
const bounds = nativeBounds(g, place) orelse return null;
@@ -5442,7 +5153,7 @@ fn nativePlaceGeometry(g: *const Gui, place: SavedImagePlace) ?pardes.image.Nati
return null;
}
-fn nativePlaceDrawable(g: *const Gui, place: SavedImagePlace) bool {
+fn nativePlaceDrawable(g: *const Gui, place: pardes.ImagePlace) bool {
if (comptime pardes.pdf_enabled) return nativePlaceGeometry(g, place) != null;
const bounds = nativeBounds(g, place) orelse return false;
return pardes.image.containGeometry(place.iw, place.ih, bounds.w, bounds.h) != null;
@@ -5468,10 +5179,6 @@ fn uploadNativeTexture(
try uploadTextureRows(g, cmd, texture, place.rgba[patch.y * row ..][0 .. patch.h * row], place.iw, patch.y, patch.h);
try g.native_images.put(gpa, key, texture);
_ = g.native_images.remove(base);
- // A transition snapshot of the last frame follows its texture.
- for (g.presented_images.items) |*saved| if (saved.key.eql(base)) {
- saved.key = key;
- };
return;
};
@@ -5524,30 +5231,16 @@ fn uploadTextureRows(
c.SDL_EndGPUCopyPass(copy);
}
-fn appendPreparedImage(
- g: *Gui,
- gpa: std.mem.Allocator,
- place: SavedImagePlace,
- track: ?pardes.animation.Track,
- clip: ?pardes.animation.Box,
- old_layer: bool,
-) void {
- const texture = g.native_images.get(place.key) orelse return;
+fn appendPreparedImage(g: *Gui, gpa: std.mem.Allocator, place: pardes.ImagePlace) void {
+ const texture = g.native_images.get(place.cacheKey()) orelse return;
if (!nativePlaceDrawable(g, place)) return;
- g.prepared_images.append(gpa, .{
- .place = place,
- .texture = texture,
- .track = track,
- .clip = clip,
- .old_layer = old_layer,
- }) catch {};
+ g.prepared_images.append(gpa, .{ .place = place, .texture = texture }) catch {};
}
fn emitPreparedImage(
g: *Gui,
instance: *ImageInstance,
prepared: PreparedImage,
- layout: CellLayout,
win_w: f32,
win_h: f32,
) bool {
@@ -5586,15 +5279,6 @@ fn emitPreparedImage(
.v1 = 1,
};
}
- setTransitionFields(
- instance,
- prepared.track,
- layout,
- win_w,
- win_h,
- if (prepared.track) |active| panelGridSize(active) else 0,
- );
- if (prepared.old_layer) instance.effect |= old_layer_bit;
return true;
}
@@ -5617,8 +5301,7 @@ fn prepareNativeImages(
var stale_len: usize = 0;
var iterator = g.native_images.iterator();
while (iterator.next()) |entry| {
- if (surfaceHasNativeKey(surface, entry.key_ptr.*) or
- snapshotHasNativeKey(g, entry.key_ptr.*)) continue;
+ if (surfaceHasNativeKey(surface, entry.key_ptr.*)) continue;
stale[stale_len] = entry.key_ptr.*;
stale_len += 1;
if (stale_len == stale.len) break;
@@ -5628,47 +5311,11 @@ fn prepareNativeImages(
}
g.prepared_images.clearRetainingCapacity();
- for (groups.items[0..groups.len], 0..) |*group, group_index| {
- group.image_start = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
- const track = group.track;
-
- if (track) |active| {
- if (active.phase == .closing) {
- for (g.presented_images.items) |saved| {
- if (saved.serial != active.serial) continue;
- appendPreparedImage(g, gpa, saved, active, null, false);
- }
- } else if (active.effect == .dissolve) {
- for (g.presented_images.items) |saved| {
- if (!placeIntersectsBox(saved, active.contentBox())) continue;
- appendPreparedImage(g, gpa, saved, active, active.contentBox(), true);
- }
- }
- }
-
- if (track == null or track.?.phase != .closing) {
- for (surface.images.items) |current| {
- if (validImageBytes(current) == null or
- groupOf(groups, current.serial) != group_index) continue;
- const saved = SavedImagePlace.from(current);
- const current_track = if (track) |active| switch (active.effect) {
- .dissolve => if (snapshotContainsPlacement(g, current)) null else active,
- else => active,
- } else null;
- appendPreparedImage(g, gpa, saved, current_track, null, false);
- }
- }
- if (group_index == 0) for (groups.items[1..][0..groups.tracks]) |tracked| {
- const active = tracked.track.?;
- if (active.effect != .vertical or active.phase != .opening) continue;
- for (g.presented_images.items) |saved| {
- if (!placeIntersectsBox(saved, active.contentBox())) continue;
- appendPreparedImage(g, gpa, saved, null, active.contentBox(), false);
- }
- };
- const image_end = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
- group.image_count = image_end - group.image_start;
- }
+ // The pictures are the page's: the other groups float over them.
+ for (surface.images.items) |place|
+ if (validImageBytes(place) != null) appendPreparedImage(g, gpa, place);
+ groups.items[0].image_start = 0;
+ groups.items[0].image_count = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
const capacity = std.math.cast(u32, g.prepared_images.items.len) orelse return false;
if (capacity == 0) return true;
@@ -5678,10 +5325,9 @@ fn prepareNativeImages(
const instances: [*]ImageInstance = @ptrCast(@alignCast(ptr));
const win_w: f32 = @floatFromInt(sw);
const win_h: f32 = @floatFromInt(sh);
- const layout = fixedCellLayout(g);
var idx: u32 = 0;
for (g.prepared_images.items) |prepared| {
- if (!emitPreparedImage(g, &instances[idx], prepared, layout, win_w, win_h)) continue;
+ if (!emitPreparedImage(g, &instances[idx], prepared, win_w, win_h)) continue;
idx += 1;
}
c.SDL_UnmapGPUTransferBuffer(g.device, g.image_vxfer.?);
@@ -5695,18 +5341,7 @@ fn prepareNativeImages(
return true;
}
-fn imageScissor(
- g: *const Gui,
- prepared: PreparedImage,
- max_w: u32,
- max_h: u32,
-) c.SDL_Rect {
- if (prepared.clip) |box| return panelBoxScissor(g, box, max_w, max_h);
- if (prepared.track) |active| {
- const box = if (active.effect == .vertical) active.contentBox() else active.visualBox();
- return panelBoxScissor(g, box, max_w, max_h);
- }
- const place = prepared.place;
+fn imageScissor(g: *const Gui, place: pardes.ImagePlace) c.SDL_Rect {
return .{
.x = @intCast(@as(u32, place.x) * g.cell_w),
.y = @intCast(@as(u32, place.y) * g.cell_h),
@@ -5715,38 +5350,18 @@ fn imageScissor(
};
}
-fn panelBoxScissor(g: *const Gui, box: pardes.animation.Box, max_w: u32, max_h: u32) c.SDL_Rect {
- const x0: i32 = @intFromFloat(@floor(box.x * @as(f32, @floatFromInt(g.cell_w))));
- const y0: i32 = @intFromFloat(@floor(box.y * @as(f32, @floatFromInt(g.cell_h))));
- const x1: i32 = @intFromFloat(@ceil((box.x + box.w) * @as(f32, @floatFromInt(g.cell_w))));
- const y1: i32 = @intFromFloat(@ceil((box.y + box.h) * @as(f32, @floatFromInt(g.cell_h))));
- const clipped_x0 = std.math.clamp(x0, 0, @as(i32, @intCast(max_w)));
- const clipped_y0 = std.math.clamp(y0, 0, @as(i32, @intCast(max_h)));
- const clipped_x1 = std.math.clamp(x1, clipped_x0, @as(i32, @intCast(max_w)));
- const clipped_y1 = std.math.clamp(y1, clipped_y0, @as(i32, @intCast(max_h)));
- return .{
- .x = clipped_x0,
- .y = clipped_y0,
- .w = clipped_x1 - clipped_x0,
- .h = clipped_y1 - clipped_y0,
- };
-}
-
fn drawNativeImagesGpu(
g: *Gui,
rp: ?*c.SDL_GPURenderPass,
- surface: *const pardes.Surface,
batch: Group,
whole: c.SDL_Rect,
) void {
const pass = rp orelse return;
c.SDL_BindGPUGraphicsPipeline(pass, g.image_pipeline);
- const max_w = @as(u32, surface.cols) * g.cell_w;
- const max_h = @as(u32, surface.rows) * g.cell_h;
var idx = batch.image_start;
const end = batch.image_start + batch.image_count;
for (g.prepared_images.items[batch.image_start..end]) |prepared| {
- const clip = imageScissor(g, prepared, max_w, max_h);
+ const clip = imageScissor(g, prepared.place);
if (clip.w > 0 and clip.h > 0) {
c.SDL_SetGPUScissor(pass, &clip);
const sampler = c.SDL_GPUTextureSamplerBinding{ .texture = prepared.texture, .sampler = g.linear_sampler };
@@ -5833,11 +5448,10 @@ fn renderFrame(
cell_decor.nplaques += 1;
}
}
- var groups = makeGroups(surface.panelTracks(), surface.hasPanelDiff());
- // While panes move the cells' cursors are not drawn; the focused one is
- // the overlay's quad, riding with its pane (draw.glideCursor), as it is
- // while it glides or blinks. One or the other every frame (none only at
- // a blink's off half).
+ var groups: Groups = .{};
+ // While the cursor glides or blinks the cells' cursors are not drawn;
+ // the focused one is the overlay's quad. One or the other every frame
+ // (none only at a blink's off half).
const blink_alpha: f32 = if (blinkNow(g, chrome)) |b| b.alpha else 1;
// While a glide moves the text, the caret is its quad, drawn from its
// own springs, not a cell of the moving rows.
@@ -5848,7 +5462,7 @@ fn renderFrame(
const pdf_focus = if (core.panes[core.active]) |pane| pane.hasPdf() else false;
if (!pdf_focus) core.frames.scroll = g.glide.follow.offset;
core.frames.caret = caretRow(g, surface) orelse 0;
- const cursors_shown = groups.tracks == 0 and !quad_mode;
+ const cursors_shown = !quad_mode;
var overlay_count = buildOverlay(g, surface, sw, sh);
if (overlay_count != 0 and !uploadOverlayGpu(g, cmd, overlay_count))
overlay_count = 0;
@@ -5861,13 +5475,9 @@ fn renderFrame(
}
const cells: u32 = @as(u32, surface.cols) * surface.rows;
- try g.cover.resize(gpa, @as(usize, cells) * 2);
+ try g.cover.resize(gpa, cells);
const covered = g.cover.items[0..cells];
coverFrame(covered, surface.cols, surface.rows, surface.bodyLayers(), surface.tagLayers(), surface.regionList());
- // Only a panel transition paints the grid under the layers it leaves.
- const previous_covered = g.cover.items[cells..];
- if (groups.tracks != 0)
- coverFrame(previous_covered, surface.cols, surface.rows, surface.previous_body_layers, surface.previous_tag_layers, surface.previous_regions);
try buildDecor(g, gpa, surface, &groups, layout, win_w, win_h, cursors_shown);
const page = chrome.page orelse bg_default;
@@ -5890,71 +5500,25 @@ fn renderFrame(
while (col < surface.cols) : (col += 1) {
const at = @as(usize, row) * surface.cols + col;
if (covered[at].layer and !covered[at].floating) continue;
- const group_index = if (covered[at].floating) groups.guides else groupAt(&groups, col, row);
- const track = groups.items[group_index].track;
- const data_effect = if (track) |active| active.effect == .dissolve else false;
- const data_diff = data_effect and gripCellChanged(surface, covered, previous_covered, col, row);
- const instance_count = if (data_diff)
- cellInstanceCount(&surface.previous_cells[at]) + cellInstanceCount(&surface.cells[at])
- else
- cellInstanceCount(&surface.cells[at]);
- groups.items[group_index].cell_count = std.math.add(u32, groups.items[group_index].cell_count, instance_count) catch return error.GpuCapacity;
- }
- }
- for (groups.items[1..][0..groups.tracks]) |*group| {
- const track = group.track.?;
- const duplicate_under = track.effect == .vertical and track.phase == .opening;
- if (!duplicate_under and track.phase != .closing) continue;
- row = 0;
- while (row < surface.rows) : (row += 1) {
- var col: u16 = 0;
- while (col < surface.cols) : (col += 1) {
- if (!boxContains(track.contentBox(), col, row)) continue;
- const at = @as(usize, row) * surface.cols + col;
- if (previous_covered[at].layer) continue;
- const destination = if (duplicate_under) &groups.items[0] else group;
- destination.cell_count = std.math.add(u32, destination.cell_count, cellInstanceCount(&surface.previous_cells[at])) catch return error.GpuCapacity;
- }
+ const group_index = if (covered[at].floating) groups.guides else 0;
+ groups.items[group_index].cell_count = std.math.add(u32, groups.items[group_index].cell_count, cellInstanceCount(&surface.cells[at])) catch return error.GpuCapacity;
}
}
for (surface.bodyLayers()) |*layer| {
if (layer.rows == 0) continue;
- const group = &groups.items[groupAt(&groups, layer.viewport.x, layer.viewport.y)];
+ const group = &groups.items[0];
const bottom = @as(f32, @floatFromInt(layer.viewport.y + layer.viewport.h)) * layout.h;
for (0..layer.rows) |lr| {
if (layer.rowTop(@intCast(lr), layout.h, @floatFromInt(g.tagline_height)) >= bottom) break;
group.cell_count += layer.cols + @as(u32, if (lr < layer.context_rows) 1 else 0) + @as(u32, @intFromBool(layer.hasContextBorderAfter(lr)));
}
}
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_body_layers) |*layer| {
- if (layer.rows == 0 or layer.serial != track.serial) continue;
- const destination = &groups.items[if (under) 0 else index];
- const bottom = @as(f32, @floatFromInt(layer.viewport.y + layer.viewport.h)) * layout.h;
- for (0..layer.rows) |lr| {
- if (layer.rowTop(@intCast(lr), layout.h, @floatFromInt(g.tagline_height)) >= bottom) break;
- destination.cell_count += layer.cols + @as(u32, if (lr < layer.context_rows) 1 else 0) + @as(u32, @intFromBool(layer.hasContextBorderAfter(lr)));
- }
- }
- }
for (surface.tagLayers()) |*layer| {
if (layer.rows == 0) continue;
- const group_index = if (layer.kind == .notice) noticeGroup(&groups, layer) else groupAt(&groups, layer.viewport.x, layer.viewport.y);
+ const group_index = if (layer.kind == .notice) groups.notices else 0;
groups.items[group_index].cell_count += (tagLayerCellCount(g, layer) + 1) * layer.rows;
}
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_tag_layers) |*layer| {
- if (layer.rows == 0 or layer.kind != .pane or layer.serial != track.serial) continue;
- groups.items[if (under) 0 else index].cell_count += (tagLayerCellCount(g, layer) + 1) * layer.rows;
- }
- }
- var cell_next: [pardes.MAX_PANES * 2 + 4]u32 = @splat(0);
+ var cell_next: [4]u32 = @splat(0);
var cell_total: u32 = 0;
for (groups.items[0..groups.len], 0..) |*group, index| {
group.cell_start = cell_total;
@@ -5984,12 +5548,7 @@ fn renderFrame(
while (col < surface.cols) : (col += 1) {
const at = @as(usize, row) * surface.cols + col;
if (covered[at].layer and !covered[at].floating) continue;
- const group_index = if (covered[at].floating) groups.guides else groupAt(&groups, col, row);
- const track = groups.items[group_index].track;
- const data_effect = if (track) |active| active.effect == .dissolve else false;
- const data_diff = data_effect and gripCellChanged(surface, covered, previous_covered, col, row);
- // The new cell, then (a dissolve) the old one fading out over
- // it, as the old layers come after the new ones.
+ const group_index = if (covered[at].floating) groups.guides else 0;
emitSurfaceCell(
g,
chrome,
@@ -6000,106 +5559,33 @@ fn renderFrame(
layout,
win_w,
win_h,
- if (data_effect and !data_diff) null else track,
line,
line_cover,
col,
line_cursor,
- false,
cursors_shown and at == cursor_idx and !cursor_bar and bodyLayerIn(surface.bodyLayers(), col, row) == null,
page,
);
- if (data_diff) emitSurfaceCell(
- g,
- chrome,
- instances,
- &cell_next[group_index],
- col,
- row,
- layout,
- win_w,
- win_h,
- track,
- surface.previous_cells[@as(usize, row) * surface.cols ..][0..surface.cols],
- previous_covered[@as(usize, row) * surface.cols ..][0..surface.cols],
- col,
- null,
- true,
- false,
- page,
- );
}
}
// Body layers first: a notice chip over a tree-sitter context band
// is a tag layer, and instances paint in emission order.
for (surface.bodyLayers()) |*layer| {
if (layer.rows == 0) continue;
- const group_index = groupAt(&groups, layer.viewport.x, layer.viewport.y);
- emitBodyLayer(g, instances, &cell_next[group_index], layer, win_w, win_h, groups.items[group_index].track, page, cursors_shown, false, chrome.topbar_rule);
+ emitBodyLayer(g, instances, &cell_next[0], layer, win_w, win_h, page, cursors_shown, chrome.topbar_rule);
}
for (surface.tagLayers()) |*layer| {
if (layer.rows == 0) continue;
- const track_index = groupAt(&groups, layer.viewport.x, layer.viewport.y);
- // A notice floats over the panes, moving with its own.
- const group_index = if (layer.kind == .notice) noticeGroup(&groups, layer) else track_index;
+ // A notice floats over the panes.
+ const group_index = if (layer.kind == .notice) groups.notices else 0;
const start = cell_next[group_index];
- emitTagLayer(g, instances, &cell_next[group_index], layer, win_w, win_h, groups.items[track_index].track, page, cursors_shown, false);
+ emitTagLayer(g, instances, &cell_next[group_index], layer, win_w, win_h, page, cursors_shown);
// A notice dropping past its row (a flavour's overshoot) stays
// inside its pane's body.
if (layer.kind == .notice and layer.slide > 0) if (bodyBottom(surface, layer.id, layout)) |bottom| {
for (instances[start..cell_next[group_index]]) |*instance| clipInstance(instance, .{ -1e9, -1e9, 1e9, bottom }, win_w, win_h);
};
}
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_tag_layers) |*layer| {
- if (layer.rows == 0 or layer.kind != .pane or layer.serial != track.serial) continue;
- emitTagLayer(g, instances, &cell_next[if (under) 0 else index], layer, win_w, win_h, if (under) null else track, page, false, track.effect == .dissolve);
- }
- }
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const under = track.effect == .vertical and track.phase == .opening;
- if (!under and track.phase != .closing and track.effect != .dissolve) continue;
- for (surface.previous_body_layers) |*layer| {
- if (layer.rows == 0 or layer.serial != track.serial) continue;
- emitBodyLayer(g, instances, &cell_next[if (under) 0 else index], layer, win_w, win_h, if (under) null else track, page, false, track.effect == .dissolve, chrome.topbar_rule);
- }
- }
- for (groups.items[1..][0..groups.tracks], 1..) |group, index| {
- const track = group.track.?;
- const duplicate_under = track.effect == .vertical and track.phase == .opening;
- if (!duplicate_under and track.phase != .closing) continue;
- row = 0;
- while (row < surface.rows) : (row += 1) {
- var col: u16 = 0;
- while (col < surface.cols) : (col += 1) {
- if (!boxContains(track.contentBox(), col, row)) continue;
- if (previous_covered[@as(usize, row) * surface.cols + col].layer) continue;
- emitSurfaceCell(
- g,
- chrome,
- instances,
- &cell_next[if (duplicate_under) 0 else index],
- col,
- row,
- layout,
- win_w,
- win_h,
- if (duplicate_under) null else track,
- surface.previous_cells[@as(usize, row) * surface.cols ..][0..surface.cols],
- previous_covered[@as(usize, row) * surface.cols ..][0..surface.cols],
- col,
- null,
- false,
- false,
- page,
- );
- }
- }
- }
for (groups.items[0..groups.len], 0..) |group, index|
std.debug.assert(cell_next[index] == group.cell_start + group.cell_count);
// The body's context rows, which its scroll leaves where they are.
@@ -6155,9 +5641,8 @@ fn renderFrame(
const has_shifted = index == 0 and shifted != 0;
if ((group.cell_count != 0 or has_shifted) and g.vbuf != null) {
// Blended over what is under: a theme's plaques show through
- // blank tag cells; a dissolve's old cells fade over its new.
- const dissolving = if (group.track) |active| active.effect == .dissolve else false;
- c.SDL_BindGPUGraphicsPipeline(rp, if (cell_decor.inked_clear or dissolving) g.pipeline_over else g.pipeline);
+ // blank tag cells.
+ c.SDL_BindGPUGraphicsPipeline(rp, if (cell_decor.inked_clear) g.pipeline_over else g.pipeline);
const samp_binding = c.SDL_GPUTextureSamplerBinding{ .texture = g.atlas_tex, .sampler = g.atlas_sampler };
c.SDL_BindGPUFragmentSamplers(rp, 0, &samp_binding, 1);
if (group.cell_count != 0) {
@@ -6174,7 +5659,7 @@ fn renderFrame(
c.SDL_SetGPUScissor(rp, &whole);
}
}
- if (group.image_count != 0) drawNativeImagesGpu(g, rp, surface, group, whole);
+ if (group.image_count != 0) drawNativeImagesGpu(g, rp, group, whole);
if (group.decor_count > group.under_count and g.vbuf != null) {
c.SDL_BindGPUGraphicsPipeline(rp, g.decor_pipeline);
// Ink keeps its colour at any WindowOpacity.
@@ -6188,9 +5673,7 @@ fn renderFrame(
c.SDL_EndGPURenderPass(rp);
command_consumed = true;
- const shown = try finishFrame(g, gpa, cmd, frame_target, if (groups.tracks != 0) groups.items[1].track.?.frame else null);
- if (shown and groups.tracks == 0) rememberPresentedImages(g, gpa, surface);
- return shown;
+ return finishFrame(g, gpa, cmd, frame_target);
}
const Target = struct { texture: *c.SDL_GPUTexture, w: u32, h: u32 };
@@ -6220,9 +5703,9 @@ fn acquireTarget(g: *Gui, cmd: *c.SDL_GPUCommandBuffer, capture_w: u32, capture_
}
/// Submits the frame: captured, handed to the soft presenter, or presented.
-fn finishFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: Target, transition: ?u16) !bool {
+fn finishFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: Target) !bool {
if (g.capture) {
- try captureFrame(g, gpa, cmd, target.texture, target.w, target.h, transition);
+ try captureFrame(g, gpa, cmd, target.texture, target.w, target.h);
return true;
}
if (g.soft_present) {
@@ -6397,7 +5880,7 @@ fn tagLayerCellCount(g: *const Gui, layer: *const pardes.Layer) u32 {
return @min(layer.cols, (pixels + g.tagline_width - 1) / g.tagline_width);
}
-fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, track: ?pardes.animation.Track, page: [3]u8, show_cursor: bool, old_layer: bool) void {
+fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, page: [3]u8, show_cursor: bool) void {
const bw: f32 = @floatFromInt(g.cell_w);
const bh: f32 = @floatFromInt(g.cell_h);
const tw: f32 = @floatFromInt(g.tagline_width);
@@ -6414,7 +5897,7 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
for (0..layer.rows) |index| {
const y = layer.viewport.y + @as(u16, @intCast(index));
const top = @as(f32, @floatFromInt(y)) * bh;
- emitInstance(g, instances, next.*, 0, y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .body, (&background)[0..1], 0, null, old_layer, false, page);
+ emitInstance(g, instances, next.*, 0, y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page);
// A theme's plaque is drawn under the band: the band's own ground
// lets it show (tagPlaques).
if (cell_decor.nplaques != 0 and cell_decor.inPlaque(left + 0.5, top + 0.5)) plaqueThrough(instances, next.*);
@@ -6424,7 +5907,7 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
const line_cursor: ?usize = if (layer.cursor) |cu| (if (cu.y == index) cu.x else null) else null;
for (0..tagLayerCellCount(g, layer)) |col| {
const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == index else false;
- emitInstance(g, instances, next.*, @intCast(col), y, .{ .w = tw, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, track, .tagline, cells, col, line_cursor, old_layer, cursor, page);
+ emitInstance(g, instances, next.*, @intCast(col), y, .{ .w = tw, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, .tagline, cells, col, line_cursor, cursor, page);
clipInstance(&instances[next.*], .{ -1e9, if (slide != 0) top else -1e9, right, 1e9 }, win_w, win_h);
next.* += 1;
}
@@ -6439,7 +5922,7 @@ fn bodyLayerIn(layers: []const pardes.Layer, col: u16, row: u16) ?*const pardes.
return null;
}
-fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, track: ?pardes.animation.Track, page: [3]u8, show_cursor: bool, old_layer: bool, border_rgb: [3]u8) void {
+fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const pardes.Layer, win_w: f32, win_h: f32, page: [3]u8, show_cursor: bool, border_rgb: [3]u8) void {
const bw: f32 = @floatFromInt(g.cell_w);
const bh: f32 = @floatFromInt(g.cell_h);
const tw: f32 = @floatFromInt(g.tagline_width);
@@ -6458,7 +5941,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const
if (header) {
var background: pardes.Cell = .{ .default = false, .style = layer.cells[index * layer.cols].style };
background.style.font_role = .body;
- emitInstance(g, instances, next.*, 0, 0, .{ .w = @as(f32, @floatFromInt(layer.viewport.w)) * bw, .h = height, .x_off = left, .y_off = top }, win_w, win_h, track, .body, (&background)[0..1], 0, null, old_layer, false, page);
+ emitInstance(g, instances, next.*, 0, 0, .{ .w = @as(f32, @floatFromInt(layer.viewport.w)) * bw, .h = height, .x_off = left, .y_off = top }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page);
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, bottom }, win_w, win_h);
next.* += 1;
}
@@ -6468,7 +5951,7 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const
if (left + @as(f32, @floatFromInt(col)) * width >= right) break;
const cursor = if (layer.cursor) |cu| show_cursor and !cu.bar and cu.x == col and cu.y == row else false;
const glyph_top = top - (if (header) @as(f32, @floatFromInt(taglineBandOffset(0, win_h, g.cell_h, g.tagline_height))) else 0);
- emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, track, role, line, col, line_cursor, old_layer, cursor, page);
+ emitInstance(g, instances, next.*, 0, 0, .{ .w = width, .h = height, .x_off = left + @as(f32, @floatFromInt(col)) * width, .y_off = glyph_top }, win_w, win_h, role, line, col, line_cursor, cursor, page);
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, bottom }, win_w, win_h);
next.* += 1;
}
@@ -6479,23 +5962,13 @@ fn emitBodyLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const
.h = 1,
.x_off = left,
.y_off = top + height - 1,
- }, win_w, win_h, track, .body, (&border)[0..1], 0, null, old_layer, false, page);
+ }, win_w, win_h, .body, (&border)[0..1], 0, null, false, page);
clipInstance(&instances[next.*], .{ -1e9, -1e9, right, bottom }, win_w, win_h);
next.* += 1;
}
}
}
-/// A dissolving cell changes with its grip's glyph, which is the cell its
-/// grip offset to the left, in this frame's grip or the last one's.
-fn gripCellChanged(surface: *const pardes.Surface, covered: []const Cover, previous_covered: []const Cover, col: u16, row: u16) bool {
- if (surface.panelCellChanged(col, row)) return true;
- const at = @as(usize, row) * surface.cols + col;
- for ([_]Cover{ covered[at], previous_covered[at] }) |cover|
- if (cover.grip and surface.panelCellChanged(col -| cover.grip_offset, row)) return true;
- return false;
-}
-
/// acme's Scrollwid column at a pane's or column's left edge, in window
/// pixels: where its button sits over its scrollbar, one width for both
/// (`rail_px` at acme's 17px font, scaled with the tagline, and always
@@ -6576,12 +6049,10 @@ fn emitSurfaceCell(
body_layout: CellLayout,
win_w: f32,
win_h: f32,
- track: ?pardes.animation.Track,
line: []const pardes.Cell,
line_cover: []const Cover,
at: usize,
cursor: ?usize,
- old_layer: bool,
is_cursor: bool,
page: [3]u8,
) void {
@@ -6595,7 +6066,7 @@ fn emitSurfaceCell(
// The smaller font changes the ink, not the chrome's coverage. Painting
// this underlay at tagline height leaves page-colored gutters between
// adjacent workspace, column and pane tags at TaglineSize < 100.
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .body, (&band_base)[0..1], 0, null, old_layer, false, page);
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .body, (&band_base)[0..1], 0, null, false, page);
// Over a theme's plaque the underlay lets it show (tagPlaques),
// in a grip's cell too where the plaque reaches into it past the
// button (which is drawn over the cells).
@@ -6611,9 +6082,9 @@ fn emitSurfaceCell(
blank.text[0] = ' ';
blank.len = 1;
if (here.pane_grip)
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, (&blank)[0..1], 0, null, old_layer, false, page)
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .tagline, (&blank)[0..1], 0, null, false, page)
else
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, .tagline, line, at, cursor, old_layer, is_cursor, page);
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .tagline, line, at, cursor, is_cursor, page);
// A grip's glyph is the cell at its left edge, and a blank one is
// no glyph: its marks are decor.
const glyph = &line[at - @min(here.grip_offset, at)];
@@ -6687,7 +6158,7 @@ fn emitSurfaceCell(
next.* += 1;
return;
}
- emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, track, role, line, at, cursor, old_layer, is_cursor, page);
+ emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, role, line, at, cursor, is_cursor, page);
next.* += 1;
}
@@ -6712,7 +6183,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits
const cover = try gpa.alloc(Cover, @as(usize, s.cols) * s.rows);
defer gpa.free(cover);
coverFrame(cover, s.cols, s.rows, s.bodyLayers(), s.tagLayers(), s.regionList());
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, layout, win_w, win_h, true);
const grip = s.region(.grip, 0).?;
// The grip column's pixels, band first, then its cells, then decor.
@@ -6742,7 +6213,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits
const row: u16 = grip.rect.y + @as(u16, @intCast(line));
const at = @as(usize, row) * s.cols;
var next: u32 = 0;
- emitSurfaceCell(&g, &s.chrome, &instances, &next, col, row, layout, win_w, win_h, null, s.cells[at..][0..s.cols], cover[at..][0..s.cols], col, null, false, false, bg_default);
+ emitSurfaceCell(&g, &s.chrome, &instances, &next, col, row, layout, win_w, win_h, s.cells[at..][0..s.cols], cover[at..][0..s.cols], col, null, false, bg_default);
for (instances[0..next]) |i| paint.quad(pixels, i.x0, i.y0, i.x1, i.y1, .{ i.br, i.bg, i.bb }, win_w, win_h, x_px, y_px, w_px, h_px);
};
for (g.decor.items) |i| if (i.fr >= 1 and i.clip_x1 < i.clip_x0) paint.quad(pixels, i.x0, i.y0, i.x1, i.y1, .{ i.br, i.bg, i.bb }, win_w, win_h, x_px, y_px, w_px, h_px);
@@ -6780,27 +6251,6 @@ test "every pixel of a grip column is band, button or ring, and the button sits
pane.file.?.revision = pane.file.?.saved_revision;
}
-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 = 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;
- while (track.frame < track.frames()) : (track.frame += 1) {
- if (track.presented().y < highest) {
- highest = track.presented().y;
- peak = track.frame;
- }
- }
- track.frame = peak;
- try std.testing.expect(track.presented().y < 0);
- var instance: CellInstance = std.mem.zeroes(CellInstance);
- setTransitionFields(&instance, track, fixedCellLayout(&g), 800, 480, 0);
- try std.testing.expectEqual(@as(f32, 0), instance.clip_y0);
- try std.testing.expectEqual(@as(f32, 200), instance.clip_y1);
-}
-
test "small tagline fonts leave no background gutters between adjacent tags" {
const chrome: pardes.Chrome = .{};
var g = testGui(10, 20, 8, 16);
@@ -6809,7 +6259,7 @@ test "small tagline fonts leave no background gutters between adjacent tags" {
var next: u32 = 0;
for (0..3) |row| {
// Column 1: past the anchor's inset edge at the column's left.
- emitSurfaceCell(&g, &chrome, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], &.{.{}}, 0, null, false, false, bg_default);
+ emitSurfaceCell(&g, &chrome, &instances, &next, 1, @intCast(row), fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{}}, 0, null, false, bg_default);
const base = instances[row * 2];
const ink = instances[row * 2 + 1];
try std.testing.expectApproxEqAbs(@as(f32, 20.0 / 480.0 * 2), base.y0 - base.y1, 0.0001);
@@ -6822,14 +6272,10 @@ test "small tagline fonts leave no background gutters between adjacent tags" {
// Column 0 is an anchor's edge: its ink is inset by the band's margin
// (2 px here) and its underlay still covers the whole cell.
next = 0;
- emitSurfaceCell(&g, &chrome, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], &.{.{ .anchor = true }}, 0, null, false, false, bg_default);
+ emitSurfaceCell(&g, &chrome, &instances, &next, 0, 1, fixedCellLayout(&g), 800, 480, (&cell)[0..1], &.{.{ .anchor = true }}, 0, null, false, bg_default);
try std.testing.expectApproxEqAbs(@as(f32, 10.0 / 800.0 * 2), instances[0].x1 - instances[0].x0, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 8.0 / 800.0 * 2), instances[1].x1 - instances[1].x0, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 8) / atlas_w, instances[1].u1 - instances[1].u0, 0.0001);
- next = 0;
- emitSurfaceCell(&g, &chrome, &instances, &next, 0, 2, fixedCellLayout(&g), 800, 480, null, (&cell)[0..1], &.{.{}}, 0, null, true, false, bg_default);
- try std.testing.expectEqual(@as(u32, 2), next);
- try std.testing.expectApproxEqAbs(@as(f32, 16.0 / 480.0 * 2), instances[1].y0 - instances[1].y1, 0.0001);
}
fn emitInstance(
@@ -6841,12 +6287,10 @@ fn emitInstance(
layout: CellLayout,
win_w: f32,
win_h: f32,
- track: ?pardes.animation.Track,
role: pardes.FontRole,
line: []const pardes.Cell,
at: usize,
cursor: ?usize,
- old_layer: bool,
is_cursor: bool,
page: [3]u8,
) void {
@@ -6887,15 +6331,6 @@ fn emitInstance(
.bg = @as(f32, @floatFromInt(resolved.bg[1])) / 255.0,
.bb = @as(f32, @floatFromInt(resolved.bg[2])) / 255.0,
};
- setTransitionFields(
- &instances[idx],
- track,
- fixedCellLayout(g),
- win_w,
- win_h,
- if (track) |active| panelCellCoord(active, col, row) else 0,
- );
- if (old_layer) instances[idx].effect |= old_layer_bit;
// A block cursor is foreground UI ink, even though its color is carried
// in the reversed cell background. Keep it visible at WindowOpacity 0.
if (is_cursor) instances[idx].effect |= opaque_bg_bit;
@@ -6927,7 +6362,7 @@ test "block cursor alone overrides transparent cell background" {
const cell: pardes.Cell = .{};
var instances: [2]CellInstance = undefined;
for ([_]bool{ false, true }, 0..) |cursor, i| {
- emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, null, .body, (&cell)[0..1], 0, null, false, cursor, bg_default);
+ emitInstance(&g, &instances, @intCast(i), 0, 0, fixedCellLayout(&g), 800, 480, .body, (&cell)[0..1], 0, null, cursor, bg_default);
try std.testing.expectEqual(cursor, instances[i].effect & opaque_bg_bit != 0);
}
}
@@ -6953,14 +6388,14 @@ test "lapis dots only the page's own ground and shadows only a file name, never
.{ .cell = title, .role = .tagline, .cursor = true, .dotted = false, .shadowed = false },
.{ .cell = plain_tag, .role = .tagline, .cursor = false, .dotted = false, .shadowed = false },
}) |case| {
- emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, null, case.role, (&case.cell)[0..1], 0, null, false, case.cursor, page);
+ emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, case.role, (&case.cell)[0..1], 0, null, case.cursor, page);
try std.testing.expectEqual(case.dotted, instances[0].effect & dotted_bit != 0);
try std.testing.expectEqual(case.shadowed, instances[0].effect & title_bit != 0);
}
// A theme without decor marks nothing.
chrome = .{ .page = page };
cell_decor = CellDecor.of(&chrome);
- emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, null, .body, (&on_page)[0..1], 0, null, false, false, page);
+ emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, .body, (&on_page)[0..1], 0, null, false, page);
try std.testing.expectEqual(@as(u32, 0), instances[0].effect & (dotted_bit | title_bit));
}
@@ -6978,7 +6413,7 @@ test "lapis plaques stay in their tag's band, clear of every grip; only the focu
var g = testGui(16, 32, 12, 22);
defer g.decor.deinit(gpa);
display_scale = 1;
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true);
const layout = fixedCellLayout(&g);
const under = g.decor.items[groups.items[0].decor_start..][0..groups.items[0].under_count];
@@ -7632,24 +7067,14 @@ test "pane indicator cached ink centers bearings styles and sizes" {
try std.testing.expectEqual(@as(?Slot, null), cachedGlyph(&g, .{ .face = 0, .glyph = c.ui_font_glyph(font, '^'), .role = .tagline, .centered = true }));
}
-test "pane indicator halves share dissolve changes and safe exhausted atlas" {
+test "pane indicator halves are safe on an exhausted atlas" {
var cells: [12]pardes.Cell = @splat(.{ .default = false, .style = .{ .font_role = .tagline } });
cells[0].text[0] = '$';
- var previous = cells;
- previous[0].text[0] = '^';
- var diffs: [12]pardes.PanelCellDiff = @splat(.unchanged);
- diffs[0] = pardes.PanelCellDiff.between(&previous[0], &cells[0]);
- const surface: pardes.Surface = .{ .cols = 6, .rows = 2, .cells = &cells, .previous_cells = &previous, .cell_diffs = &diffs };
- // A grip two cells wide at the top left, in both frames.
+ // A grip two cells wide at the top left.
const grip = [_]pardes.Region{.{ .kind = .grip, .serial = 1, .rect = .{ .x = 0, .y = 0, .w = 2, .h = 1 } }};
var cover: [12]Cover = undefined;
- var previous_cover: [12]Cover = undefined;
coverFrame(&cover, 6, 2, &.{}, &.{}, &grip);
- coverFrame(&previous_cover, 6, 2, &.{}, &.{}, &grip);
- try std.testing.expect(gripCellChanged(&surface, &cover, &previous_cover, 0, 0));
- try std.testing.expect(gripCellChanged(&surface, &cover, &previous_cover, 1, 0));
- try std.testing.expect(!gripCellChanged(&surface, &cover, &previous_cover, 2, 0));
- try std.testing.expect(!cover[2].grip);
+ try std.testing.expect(cover[0].grip and cover[1].grip and !cover[2].grip);
// A column's grip is a button too, cut the same way (it has no glyph).
coverFrame(&cover, 6, 2, &.{}, &.{}, &.{.{ .kind = .column_grip, .rect = .{ .x = 0, .y = 0, .w = 2, .h = 1 } }});
try std.testing.expect(cover[0].grip);
@@ -7666,16 +7091,13 @@ test "pane indicator halves share dissolve changes and safe exhausted atlas" {
g.glyphs = std.AutoHashMap(GlyphKey, Slot).init(std.testing.allocator);
defer g.glyphs.deinit();
defer g.words.deinit(std.testing.allocator);
- for ([_]bool{ false, true }) |old| {
- var instances: [4]CellInstance = undefined;
- var next: u32 = 0;
- for (0..2) |col| {
- emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, null, cells[0..6], cover[0..6], col, null, old, false, bg_default);
- try std.testing.expectEqual(@as(f32, 0), instances[col * 2 + 1].u0);
- try std.testing.expectEqual(old, instances[col * 2 + 1].effect & old_layer_bit != 0);
- }
- try std.testing.expectEqual(@as(u32, 4), next);
+ var instances: [4]CellInstance = undefined;
+ var next: u32 = 0;
+ for (0..2) |col| {
+ emitSurfaceCell(&g, &chrome, &instances, &next, @intCast(col), 0, fixedCellLayout(&g), 100, 100, cells[0..6], cover[0..6], col, null, false, bg_default);
+ try std.testing.expectEqual(@as(f32, 0), instances[col * 2 + 1].u0);
}
+ try std.testing.expectEqual(@as(u32, 4), next);
}
// Underline and strikethrough stay inside the existing atlas slot, so text
@@ -7854,10 +7276,8 @@ const cell_input: VertexInput = .{ .pitch = @sizeOf(CellInstance), .rate = c.SDL
.{ .location = 1, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "u0") },
.{ .location = 2, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "fr") },
.{ .location = 3, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "br") },
- .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "panel_x0") },
- .{ .location = 5, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "present_x0") },
- .{ .location = 6, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT4, .offset = @offsetOf(CellInstance, "effect") },
- .{ .location = 7, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "clip_x0") },
+ .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT2, .offset = @offsetOf(CellInstance, "effect") },
+ .{ .location = 5, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "clip_x0") },
} };
const overlay_input: VertexInput = .{ .pitch = @sizeOf(OverlayVertex), .rate = c.SDL_GPU_VERTEXINPUTRATE_VERTEX, .attrs = &.{
@@ -7868,9 +7288,6 @@ const overlay_input: VertexInput = .{ .pitch = @sizeOf(OverlayVertex), .rate = c
const image_input: VertexInput = .{ .pitch = @sizeOf(ImageInstance), .rate = c.SDL_GPU_VERTEXINPUTRATE_INSTANCE, .attrs = &.{
.{ .location = 0, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "x0") },
.{ .location = 1, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "u0") },
- .{ .location = 2, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "panel_x0") },
- .{ .location = 3, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(ImageInstance, "present_x0") },
- .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT4, .offset = @offsetOf(ImageInstance, "effect") },
} };
/// A pipeline drawing triangles into `color_format`: `vert`, and `frag`
@@ -8133,10 +7550,9 @@ fn latencyNote(comptime fmt: []const u8, args: anytype) void {
_ = libc.write(latency_fd, line.ptr, line.len);
}
-/// Writes the frame to latest.ppm in the capture directory, and a panel
-/// transition's frame `transition` to transition-<frame>.ppm too, so a test
-/// can hold one partway (test/process/window.zig).
-fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: *c.SDL_GPUTexture, sw: u32, sh: u32, transition: ?u16) !void {
+/// Writes the frame to latest.ppm in the capture directory, and in a
+/// series to frame-<n>.ppm too.
+fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: *c.SDL_GPUTexture, sw: u32, sh: u32) !void {
const size = c.SDL_CalculateGPUTextureFormatSize(g.swapchain_format, sw, sh, 1);
if (size == 0) {
_ = c.SDL_SubmitGPUCommandBuffer(cmd);
@@ -8156,8 +7572,7 @@ fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, t
const pixels: [*]const u8 = @ptrCast(mapped);
try writeCapturePpm(g, gpa, pixels[0..size], sw, sh, "latest");
var name: [24]u8 = undefined;
- // unreachable below: "transition-" or "frame-" and a u32 fit 24
- if (transition) |frame| try writeCapturePpm(g, gpa, pixels[0..size], sw, sh, std.fmt.bufPrint(&name, "transition-{d}", .{frame}) catch unreachable);
+ // unreachable below: "frame-" and a u32 fit 24
if (g.capture_series) try writeCapturePpm(g, gpa, pixels[0..size], sw, sh, std.fmt.bufPrint(&name, "frame-{d:0>5}", .{g.captured}) catch unreachable);
g.captured +%= 1;
}
@@ -8230,9 +7645,8 @@ fn writeCapturePpm(g: *Gui, gpa: std.mem.Allocator, pixels: []const u8, width: u
}
/// One flat, hard-edged rectangle of decor, in window pixels: clipped to the
-/// window and dropped when empty, as the triangle overlay drew it, and moved
-/// by `track` as its pane's cells are.
-fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32, y1_in: f32, rgb: [3]u8, alpha: f32, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void {
+/// window and dropped when empty, as the triangle overlay drew it.
+fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32, y1_in: f32, rgb: [3]u8, alpha: f32, win_w: f32, win_h: f32) !void {
const x0 = std.math.clamp(@min(x0_in, x1_in), 0.0, win_w);
const x1 = std.math.clamp(@max(x0_in, x1_in), 0.0, win_w);
const y0 = std.math.clamp(@min(y0_in, y1_in), 0.0, win_h);
@@ -8240,7 +7654,7 @@ fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32,
if (x1 <= x0 or y1 <= y0) return;
// decor.frag.glsl reads the colour from the ground and the coverage
// from the ink's red.
- var instance: CellInstance = .{
+ try g.decor.append(gpa, .{
.x0 = (x0 / win_w) * 2.0 - 1.0,
.y0 = 1.0 - (y0 / win_h) * 2.0,
.x1 = (x1 / win_w) * 2.0 - 1.0,
@@ -8255,17 +7669,15 @@ fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32,
.br = @as(f32, @floatFromInt(rgb[0])) / 255.0,
.bg = @as(f32, @floatFromInt(rgb[1])) / 255.0,
.bb = @as(f32, @floatFromInt(rgb[2])) / 255.0,
- };
- setTransitionFields(&instance, track, fixedCellLayout(g), win_w, win_h, 0);
- try g.decor.append(gpa, instance);
+ });
}
/// A checker (decor.frag.glsl): squares of `px` window pixels in `a` and
/// `b` from the quad's corner (lapis's scroll track); `stripes`, bands of
/// `px` across it instead (lapis's focused title bar), `a` first.
-fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f32, a: [3]u8, b: [3]u8, px: f32, stripes: bool, track: ?pardes.animation.Track, win_w: f32, win_h: f32) !void {
+fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f32, a: [3]u8, b: [3]u8, px: f32, stripes: bool, win_w: f32, win_h: f32) !void {
const first = g.decor.items.len;
- try addDecor(g, gpa, x0, y0, x1, y1, a, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y0, x1, y1, a, 1, win_w, win_h);
if (g.decor.items.len == first) return;
const instance = &g.decor.items[first];
instance.u0 = px;
@@ -8289,9 +7701,9 @@ fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 {
}
/// The frame's decor, group by group (docs/render-pipeline.md §3.4), all of it
-/// read from the regions and the palette: the page's rules and the still
-/// panes' rails, rules and grip marks in tier 0, a moving or closing pane's
-/// in its track's group, notice rules in tier 4, bar cursors in tier 5.
+/// read from the regions and the palette: the page's rules and the panes'
+/// rails, rules and grip marks with the page, notice rules with the
+/// notices, bar cursors with the ink.
fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, groups: *Groups, layout: CellLayout, win_w: f32, win_h: f32, cursors_shown: bool) !void {
g.decor.clearRetainingCapacity();
const chrome = &surface.chrome;
@@ -8299,20 +7711,13 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
for (groups.items[0..groups.len], 0..) |*group, index| {
group.decor_start = @intCast(g.decor.items.len);
defer group.decor_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start;
- // Under the cells: a theme's tag plaques, this group's panes' (and
- // the column and workspace tags with the still ones).
- if (index <= groups.tracks) {
- const closing = if (group.track) |active| active.phase == .closing else false;
- try tagPlaques(g, gpa, if (closing) surface.previous_regions else regions, groups, index, chrome, layout, win_w, win_h, group.track);
- }
+ // Under the cells: a theme's tag plaques.
+ if (index == 0) try tagPlaques(g, gpa, regions, chrome, layout, win_w, win_h);
group.under_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start;
- // The grips' buttons before any rule: the rules over their rows cut
- // them, and the band round them never covers a rule.
- if (index <= groups.tracks) {
- const closing = if (group.track) |active| active.phase == .closing else false;
- try gripDecor(g, gpa, if (closing) surface.previous_regions else regions, if (closing) surface.previous_cells else surface.cells, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, group.track);
- }
if (index == 0) {
+ // The grips' buttons before any rule: the rules over their rows
+ // cut them, and the band round them never covers a rule.
+ try gripDecor(g, gpa, regions, surface.cells, chrome, layout, surface.cols, surface.rows, win_w, win_h);
const top = for (regions) |region| {
if (region.kind == .workspace_tag) break region.rect.h;
} else 0;
@@ -8325,13 +7730,13 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
const height: u32 = @intFromFloat(@max(1, @min(rulePx(chrome), @as(f32, @floatFromInt((g.cell_h -| g.tagline_height) * 2)))));
if (top != 0 and top < surface.rows and tag_under and height != 0) {
const y0: f32 = @floatFromInt(top * g.cell_h - height / 2);
- try addDecor(g, gpa, 0, y0, win_w, y0 + @as(f32, @floatFromInt(height)), chrome.topbar_rule, 1, null, win_w, win_h);
+ try addDecor(g, gpa, 0, y0, win_w, y0 + @as(f32, @floatFromInt(height)), chrome.topbar_rule, 1, win_w, win_h);
}
// The column bar is ruled off from the panes under it.
for (regions) |bar| {
if (bar.kind != .column_grip) continue;
const y = @as(f32, @floatFromInt(bar.rect.y + bar.rect.h)) * layout.h;
- try addDecor(g, gpa, 0, y - rulePx(chrome), win_w, y, chrome.border, 1, null, win_w, win_h);
+ try addDecor(g, gpa, 0, y - rulePx(chrome), win_w, y, chrome.border, 1, win_w, win_h);
break;
}
// A tag on the last row runs on through the pixels under the grid.
@@ -8340,17 +7745,10 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
.grip, .tag, .column_grip, .column_tag, .workspace_tag => if (region.rect.h != 0 and region.rect.y + region.rect.h == surface.rows) break true,
else => {},
} else false;
- if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, null, win_w, win_h);
- }
- if (index <= groups.tracks) {
- const track = group.track;
- // A closing pane is gone: its chrome is the last frame's.
- const closing = if (track) |active| active.phase == .closing else false;
- const placed = if (closing) surface.previous_regions else regions;
- const ticks: []const pardes.RailTick = if (closing) &.{} else surface.rail_ticks[0..surface.nrail_ticks];
- try paneDecor(g, gpa, placed, ticks, groups, index, chrome, layout, surface.cols, surface.rows, win_w, win_h, track);
+ if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, win_w, win_h);
+ try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], chrome, layout, surface.cols, surface.rows, win_w, win_h);
// A single spine runs down each column, through every tag and body.
- if (index == 0) for (regions) |column| {
+ for (regions) |column| {
if (column.kind != .column) continue;
const x = @as(f32, @floatFromInt(column.rect.x)) * layout.w;
const y0 = @as(f32, @floatFromInt(column.rect.y)) * layout.h;
@@ -8358,15 +7756,15 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
const y1 = if (win_h - grid_y1 < layout.h) @max(grid_y1, win_h) else grid_y1;
// None at the window's edge: nothing to rule apart there.
if (column.rect.x == 0) continue;
- if (y1 > y0) try addDecor(g, gpa, x, y0, x + rulePx(chrome), y1, chrome.border, 1, null, win_w, win_h);
- };
+ if (y1 > y0) try addDecor(g, gpa, x, y0, x + rulePx(chrome), y1, chrome.border, 1, win_w, win_h);
+ }
}
// A notice chip is tagline hung over the body's top rows, so it is
// ruled off from the text beneath it the way a tag is: the same
// colour and thickness along its bottom, running to the window's
// edge when it does, fading up and dissolving with its band.
- for (surface.tagLayers()) |*layer| {
- if (layer.rows == 0 or layer.kind != .notice or noticeGroup(groups, layer) != index) continue;
+ if (index == groups.notices) for (surface.tagLayers()) |*layer| {
+ if (layer.rows == 0 or layer.kind != .notice) continue;
const x0 = @as(f32, @floatFromInt(layer.viewport.x)) * layout.w;
const x1 = x0 + @as(f32, @floatFromInt(layer.viewport.w)) * layout.w;
const rule_x1 = if (win_w - x1 < layout.w) @max(x1, win_w) else x1;
@@ -8375,20 +7773,19 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
// rule comes with it, and shows only once it is below that cut.
const rule_y = top + (1 + layer.slide) * layout.h;
if (rule_y - dp(1) < top) continue;
- const track = groups.items[groupAt(groups, layer.viewport.x, layer.viewport.y)].track;
- try addDecor(g, gpa, x0, rule_y - dp(1), rule_x1, rule_y, chrome.border, layer.fade, track, win_w, win_h);
- }
+ try addDecor(g, gpa, x0, rule_y - dp(1), rule_x1, rule_y, chrome.border, layer.fade, win_w, win_h);
+ };
if (index == groups.ink and cursors_shown) try cursorDecor(g, gpa, surface, layout, win_w, win_h);
}
}
/// Each pane's rule between its tag and body, and its scroll rail: a page
/// coloured gutter with a thin track and its thumb, running down through the
-/// pixels past the last whole row. Only the panes of group `index`.
-fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, groups: *const Groups, index: usize, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void {
+/// pixels past the last whole row.
+fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
const page = chrome.page orelse bg_default;
for (regions) |rail| {
- if (rail.kind != .rail or rail.rect.h == 0 or groupOf(groups, rail.serial) != index) continue;
+ if (rail.kind != .rail or rail.rect.h == 0) continue;
const tag = for (regions) |region| {
if (region.kind == .tag and region.owner == rail.owner) break region;
} else continue;
@@ -8402,7 +7799,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const rule_x1 = if (win_w - x1 < layout.w) @max(x1, win_w) else x1;
const tag_bottom = tag.rect.y > rail.rect.y;
const rule_y = @as(f32, @floatFromInt(if (tag_bottom) tag.rect.y else tag.rect.y + tag.rect.h)) * layout.h;
- try addDecor(g, gpa, x0, if (tag_bottom) rule_y else rule_y - dp(1), rule_x1, if (tag_bottom) rule_y + dp(1) else rule_y, chrome.tag_rule orelse mixRgb(chrome.tag_bg, page), 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, if (tag_bottom) rule_y else rule_y - dp(1), rule_x1, if (tag_bottom) rule_y + dp(1) else rule_y, chrome.tag_rule orelse mixRgb(chrome.tag_bg, page), 1, win_w, win_h);
// Stacked panes are ruled apart as columns are, where one pane's
// body meets the next one's tag (acme's Border).
{
@@ -8418,10 +7815,10 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const spare = g.cell_h -| g.tagline_height;
if (stacked and !tag_bottom) {
const room = taglineBandOffset(pane_top, win_h, g.cell_h, g.tagline_height);
- try addDecor(g, gpa, x0, y, rule_x1, y + @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), chrome.border, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y, rule_x1, y + @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), chrome.border, 1, win_w, win_h);
} else if (stacked and pane_top > 0) {
const room = spare - taglineBandOffset(pane_top - 1, win_h, g.cell_h, g.tagline_height);
- try addDecor(g, gpa, x0, y - @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), rule_x1, y, chrome.border, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y - @max(1, @min(rulePx(chrome), @as(f32, @floatFromInt(room)))), rule_x1, y, chrome.border, 1, win_w, win_h);
}
}
@@ -8435,11 +7832,11 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
// grip's button; the thumb is a pixel short of its right edge, so
// the track edges it.
const column = scrollColumn(g, chrome, rail.rect.x, layout);
- try addDecor(g, gpa, x0, y0, x0 + layout.w, y1, page, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y0, x0 + layout.w, y1, page, 1, win_w, win_h);
if (chrome.decor_checker) |gold|
- try addPattern(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, gold, dp(@floatFromInt(@max(1, chrome.decor_checker_px))), false, track, win_w, win_h)
+ try addPattern(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, gold, dp(@floatFromInt(@max(1, chrome.decor_checker_px))), false, win_w, win_h)
else
- try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, win_w, win_h);
if (rail.thumb_h != 0 and rail.thumb_span > 0) {
// In pixels, not rows, and with the picture while it glides
// or lags behind the core's rows (both in rows of the body).
@@ -8451,11 +7848,11 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const at = rail.thumb_at + lag * rail.thumb_span / @as(f32, @floatFromInt(rail.rect.h));
const thumb_y0 = y0 + std.math.clamp(at * track_px, 0, track_px - size);
const thumb_y1 = if (thumb_y0 + size >= body_y1 - 0.5) y1 else thumb_y0 + size;
- try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, win_w, win_h);
} else if (rail.thumb_h != 0) {
const thumb_y0 = @as(f32, @floatFromInt(rail.rect.y + rail.thumb_y)) * layout.h;
const thumb_y1 = if (rail.thumb_y + rail.thumb_h == rail.rect.h) y1 else @as(f32, @floatFromInt(rail.rect.y + rail.thumb_y + rail.thumb_h)) * layout.h;
- try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], thumb_y0, column[1] - dp(1), thumb_y1, chrome.scroll_thumb, 1, win_w, win_h);
}
// A query's places' ticks over the track and thumb, where its matches
// are in the file (Places.addTicks); the current one last, on top.
@@ -8465,7 +7862,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const at = @as(f32, @floatFromInt(tick.at)) / @as(f32, @floatFromInt(pardes.panes.Places.tick_scale));
const h = if (tick.current) dp(3) else dp(2);
const ty = y0 + std.math.clamp(at * track_px, 0, track_px - h);
- try addDecor(g, gpa, column[0], ty, column[1], ty + h, if (tick.current) chrome.match_current else chrome.match_tick, 1, track, win_w, win_h);
+ try addDecor(g, gpa, column[0], ty, column[1], ty + h, if (tick.current) chrome.match_current else chrome.match_tick, 1, win_w, win_h);
};
}
}
@@ -8585,7 +7982,7 @@ fn dp(logical: f32) f32 {
/// its words on plates of the tag's ground (their cells stay opaque; the
/// spaces between let the stripes through, emitInstance); a column or the
/// workspace takes a quieter box, a one-pixel frame and a two-pixel shadow.
-fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, groups: *const Groups, index: usize, chrome: *const pardes.Chrome, layout: CellLayout, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void {
+fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, chrome: *const pardes.Chrome, layout: CellLayout, win_w: f32, win_h: f32) !void {
const border_rgb = chrome.decor_box_border orelse return;
if (cell_decor.plaques_off) return;
const page = chrome.page orelse bg_default;
@@ -8596,8 +7993,6 @@ fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, g
if (pane != panes) continue;
if (!pane and tag.kind != .column_tag and tag.kind != .workspace_tag) continue;
if (tag.rect.w == 0 or tag.rect.h == 0) continue;
- if (pane and groupOf(groups, tag.serial) != index) continue;
- if (!pane and index != 0) continue;
const plaque = plaqueBox(g, chrome, regions, tag, layout, win_w, win_h) orelse continue;
const b = plaque.border;
const sh = plaque.shadow;
@@ -8607,34 +8002,34 @@ fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, g
// opaque, so that is the same picture drawn once, not four times.
const shadow: [4]f32 = .{ plaque.box[0] + sh[0], plaque.box[1] + sh[1], plaque.box[2] + sh[0], plaque.box[3] + sh[1] };
const inner: [4]f32 = .{ plaque.box[0] + b, plaque.box[1] + b, plaque.box[2] - b, plaque.box[3] - b };
- try addDecorExcept(g, gpa, plaque.band, &.{ plaque.box, shadow }, page, track, win_w, win_h);
+ try addDecorExcept(g, gpa, plaque.band, &.{ plaque.box, shadow }, page, win_w, win_h);
const shadow_rgb = chrome.decor_box_shadow orelse border_rgb;
- try addDecorExcept(g, gpa, shadow, &.{plaque.box}, if (pane) shadow_rgb else mixRgb(shadow_rgb, page), track, win_w, win_h);
- try addDecorExcept(g, gpa, plaque.box, &.{inner}, border_rgb, track, win_w, win_h);
+ try addDecorExcept(g, gpa, shadow, &.{plaque.box}, if (pane) shadow_rgb else mixRgb(shadow_rgb, page), win_w, win_h);
+ try addDecorExcept(g, gpa, plaque.box, &.{inner}, border_rgb, win_w, win_h);
if (pane and tag.active and chrome.decor_box_stripe != null)
- try addPattern(g, gpa, inner[0], inner[1], inner[2], inner[3], chrome.decor_box_stripe.?, fill, dp(@floatFromInt(@max(1, chrome.decor_box_stripe_px))), true, track, win_w, win_h)
+ try addPattern(g, gpa, inner[0], inner[1], inner[2], inner[3], chrome.decor_box_stripe.?, fill, dp(@floatFromInt(@max(1, chrome.decor_box_stripe_px))), true, win_w, win_h)
else
- try addDecor(g, gpa, inner[0], inner[1], inner[2], inner[3], fill, 1, track, win_w, win_h);
+ try addDecor(g, gpa, inner[0], inner[1], inner[2], inner[3], fill, 1, win_w, win_h);
};
}
/// Flat decor over `rect` (window pixels) less each of `holes`: up to four
/// strips round the first hole's part of it, each less the rest.
-fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const [4]f32, rgb: [3]u8, track: ?pardes.animation.Track, win_w: f32, win_h: f32) std.mem.Allocator.Error!void {
+fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const [4]f32, rgb: [3]u8, win_w: f32, win_h: f32) std.mem.Allocator.Error!void {
if (rect[0] >= rect[2] or rect[1] >= rect[3]) return;
- if (holes.len == 0) return addDecor(g, gpa, rect[0], rect[1], rect[2], rect[3], rgb, 1, track, win_w, win_h);
+ if (holes.len == 0) return addDecor(g, gpa, rect[0], rect[1], rect[2], rect[3], rgb, 1, win_w, win_h);
const hole = holes[0];
const x0 = @max(rect[0], hole[0]);
const y0 = @max(rect[1], hole[1]);
const x1 = @min(rect[2], hole[2]);
const y1 = @min(rect[3], hole[3]);
- if (x0 >= x1 or y0 >= y1) return addDecorExcept(g, gpa, rect, holes[1..], rgb, track, win_w, win_h);
+ if (x0 >= x1 or y0 >= y1) return addDecorExcept(g, gpa, rect, holes[1..], rgb, win_w, win_h);
for ([_][4]f32{
.{ rect[0], rect[1], rect[2], y0 },
.{ rect[0], y1, rect[2], rect[3] },
.{ rect[0], y0, x0, y1 },
.{ x1, y0, rect[2], y1 },
- }) |strip| try addDecorExcept(g, gpa, strip, holes[1..], rgb, track, win_w, win_h);
+ }) |strip| try addDecorExcept(g, gpa, strip, holes[1..], rgb, win_w, win_h);
}
test "decor less its holes covers each pixel of the rest once and none of the holes" {
@@ -8642,7 +8037,7 @@ test "decor less its holes covers each pixel of the rest once and none of the ho
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);
+ try addDecorExcept(&g, gpa, .{ 1, 1, 11, 10 }, &holes, .{ 1, 2, 3 }, 16, 12);
for (0..12) |y| for (0..16) |x| {
const px: f32 = @as(f32, @floatFromInt(x)) + 0.5;
const py: f32 = @as(f32, @floatFromInt(y)) + 0.5;
@@ -8734,11 +8129,11 @@ fn tagBandAt(regions: []const pardes.Region, tag: pardes.Region, side: enum { ab
}
/// The two short bars on each row of a grip with no mode glyph there,
-/// centered in its anchor. Only the panes of group `index`.
-fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, cells: []const pardes.Cell, groups: *const Groups, index: usize, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32, track: ?pardes.animation.Track) !void {
+/// centered in its anchor.
+fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, cells: []const pardes.Cell, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
if (g.tagline_height < 6 or g.tagline_width < 3) return;
for (regions) |grip| {
- if ((grip.kind != .grip and grip.kind != .column_grip) or groupOf(groups, grip.serial) != index) continue;
+ if (grip.kind != .grip and grip.kind != .column_grip) continue;
if (grip.rect.h == 0 or grip.rect.y >= rows) continue;
const button = gripButton(g, chrome, grip.rect.x, grip.rect.y, layout);
// Round the button, its first row is the tag's band: nothing of the
@@ -8746,14 +8141,14 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
const band = if (grip.active) chrome.tag_focus_bg else chrome.tag_bg;
const left = @as(f32, @floatFromInt(grip.rect.x)) * layout.w;
const right = @as(f32, @floatFromInt(grip.rect.x + grip.rect.w)) * layout.w;
- try addDecor(g, gpa, left, button[1], button[0], button[3], band, 1, track, win_w, win_h);
+ try addDecor(g, gpa, left, button[1], button[0], button[3], band, 1, win_w, win_h);
// Right of it, a theme's plaque starts flush against it (plaqueBox).
const plaqued = chrome.decor_box_border != null and !cell_decor.plaques_off;
- if (!plaqued) try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, track, win_w, win_h);
+ if (!plaqued) try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, win_w, win_h);
// Its cells over the plaque's reach are let through (emitInstance):
// under the button's row, the band goes on as far as the plaque.
if (plaqued and grip.rect.h > 1)
- try addDecor(g, gpa, left, button[3], button[2], @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h, band, 1, track, win_w, win_h);
+ try addDecor(g, gpa, left, button[3], button[2], @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h, band, 1, win_w, win_h);
if (grip.kind != .grip) continue;
// acme's button ring, two pixels (ButtonBorder) inside the button:
// the focused one's in its own fill. An unfocused dirty one keeps a
@@ -8782,16 +8177,16 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
const ring = if (grip.active) chrome.grip_focus_ring else chrome.grip_border;
// acme's ButtonBorder: two logical pixels.
const b = dp(2);
- try addDecor(g, gpa, x0, y0, x1, y0 + b, ring, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0, y1 - b, x1, y1, ring, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0, y0 + b, x0 + b, y1 - b, ring, 1, track, win_w, win_h);
- try addDecor(g, gpa, x1 - b, y0 + b, x1, y1 - b, ring, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0, y0, x1, y0 + b, ring, 1, win_w, win_h);
+ try addDecor(g, gpa, x0, y1 - b, x1, y1, ring, 1, win_w, win_h);
+ try addDecor(g, gpa, x0, y0 + b, x0 + b, y1 - b, ring, 1, win_w, win_h);
+ try addDecor(g, gpa, x1 - b, y0 + b, x1, y1 - b, ring, 1, win_w, win_h);
if (grip.dirty and !grip.active) {
const gap = b + dp(1);
- try addDecor(g, gpa, x0 + b, y0 + b, x1 - b, y0 + gap, band, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0 + b, y1 - gap, x1 - b, y1 - b, band, 1, track, win_w, win_h);
- try addDecor(g, gpa, x0 + b, y0 + gap, x0 + gap, y1 - gap, band, 1, track, win_w, win_h);
- try addDecor(g, gpa, x1 - gap, y0 + gap, x1 - b, y1 - gap, band, 1, track, win_w, win_h);
+ try addDecor(g, gpa, x0 + b, y0 + b, x1 - b, y0 + gap, band, 1, win_w, win_h);
+ try addDecor(g, gpa, x0 + b, y1 - gap, x1 - b, y1 - b, band, 1, win_w, win_h);
+ try addDecor(g, gpa, x0 + b, y0 + gap, x0 + gap, y1 - gap, band, 1, win_w, win_h);
+ try addDecor(g, gpa, x1 - gap, y0 + gap, x1 - b, y1 - gap, band, 1, win_w, win_h);
}
}
// The marks are the first row's alone, where its cell is blank (no
@@ -8809,8 +8204,8 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
// The mode's two bars: a logical pixel thick, a pixel either side of
// the middle.
const bar = dp(1);
- try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, track, win_w, win_h);
- try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, track, win_w, win_h);
+ try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y - bar - dp(1)), @floor(center_x + half_w), @floor(center_y - dp(1)), rgb, 1, win_w, win_h);
+ try addDecor(g, gpa, @floor(center_x - half_w), @floor(center_y + dp(1)), @floor(center_x + half_w), @floor(center_y + dp(1) + bar), rgb, 1, win_w, win_h);
}
}
@@ -8829,7 +8224,7 @@ test "a theme's own rules and scrollbar are drawn at its widths: acme's 2px blac
try std.testing.expectEqual(@as(u8, 18), s.chrome.rail_px);
var g = testGui(16, 20, 10, 12);
defer g.decor.deinit(gpa);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 480, true);
const px = struct {
fn w(item: CellInstance) f32 {
@@ -8865,7 +8260,7 @@ test "the scrollbar thumb moves by the pixel and follows a glide" {
gui.decor.clearRetainingCapacity();
p.sync();
const s = try p.render(p.scratch.allocator());
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(gui, std.testing.allocator, s, &groups, fixedCellLayout(gui), 800, 480, true);
const ink = s.chrome.scroll_thumb;
for (gui.decor.items) |item| if (@abs(item.br - @as(f32, @floatFromInt(ink[0])) / 255) < 1e-3 and
@@ -8905,7 +8300,7 @@ test "the rule between stacked panes stays in the tag band's slack, at any tagli
for ([_]u32{ 12, 20 }) |tagline_h| {
var g = testGui(10, 20, 6, tagline_h);
defer g.decor.deinit(gpa);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true);
const top = @as(f32, @floatFromInt(lower.rect.y)) * 20;
const slack: f32 = @floatFromInt(@max(1, pardes.taglineBandOffset(lower.rect.y, 480, 20, tagline_h)));
@@ -8936,7 +8331,7 @@ test "an empty column is ruled on both sides, as between two filled ones" {
var g = testGui(10, 20, 6, 12);
defer g.decor.deinit(gpa);
const layout = fixedCellLayout(&g);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, layout, 800, 480, true);
const border = [3]f32{ @as(f32, @floatFromInt(s.chrome.border[0])) / 255, @as(f32, @floatFromInt(s.chrome.border[1])) / 255, @as(f32, @floatFromInt(s.chrome.border[2])) / 255 };
// Its left edge and its right edge (the next column's left): each a
@@ -8966,7 +8361,7 @@ test "at a 2x display every logical pixel is two: rules, the tag rule, the grip'
defer display_scale = 1;
var g = testGui(16, 32, 12, 24);
defer g.decor.deinit(gpa);
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true);
const w = struct {
fn of(item: CellInstance) f32 {
@@ -9015,7 +8410,7 @@ test "at a 2x display every logical pixel is two: rules, the tag rule, the grip'
}
}
-test "decor is read from the regions, each pane's in its own group" {
+test "decor is read from the regions" {
const gpa = std.testing.allocator;
const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 });
defer core.deinit();
@@ -9031,7 +8426,7 @@ test "decor is read from the regions, each pane's in its own group" {
return px / 800 * 2 - 1;
}
};
- var groups = makeGroups(&.{}, false);
+ var groups: Groups = .{};
try buildDecor(&g, gpa, s, &groups, layout, 800, 480, true);
// A spine one pixel wide at each column's left edge, down from under the
// workspace tag; a rail two pixels wide at each pane's.
@@ -9056,21 +8451,6 @@ test "decor is read from the regions, each pane's in its own group" {
_ = rail;
}
try std.testing.expectEqual(@as(u32, 0), groups.items[groups.notices].decor_count);
- const still = groups.items[0].decor_count;
-
- // Pane 1 moving: its rule and rail leave tier 0 for its track's group,
- // which moves them with it.
- const serial = core.panes[1].?.serial;
- const moving: pardes.animation.Track = .{ .pane = 1, .serial = serial, .phase = .moving, .effect = .slide, .from = .{ .x = 0, .y = 1, .w = 40, .h = 23 }, .to = .{ .x = 40, .y = 1, .w = 40, .h = 23 } };
- groups = makeGroups(&.{moving}, true);
- try buildDecor(&g, gpa, s, &groups, layout, 800, 480, groups.tracks == 0);
- const tracked = groups.items[1];
- try std.testing.expect(tracked.decor_count >= 4);
- try std.testing.expectEqual(still, groups.items[0].decor_count + tracked.decor_count);
- for (g.decor.items[tracked.decor_start..][0..tracked.decor_count]) |item|
- try std.testing.expectEqual(@as(u32, @backingInt(pardes.animation.Transition.slide)), item.effect);
- // Cursors stand still while panes move.
- try std.testing.expectEqual(@as(u32, 0), groups.items[groups.ink].decor_count);
}
test "a body tells its first line, and lapis's dots under it move a quarter as far" {
@@ -9178,7 +8558,7 @@ fn cursorBoxes(g: *const Gui, surface: *const pardes.Surface, layout: CellLayout
fn cursorDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, layout: CellLayout, win_w: f32, win_h: f32) !void {
var boxes: [max_cursors]CursorBox = undefined;
for (boxes[0..cursorBoxes(g, surface, layout, win_h, &boxes)]) |box|
- if (box.bar) try addDecor(g, gpa, box.x0, box.y0, box.x1, box.y1, box.rgb, 1, null, win_w, win_h);
+ if (box.bar) try addDecor(g, gpa, box.x0, box.y0, box.x1, box.y1, box.rgb, 1, win_w, win_h);
}
/// The triangle overlay: the cursor's glide, over everything.
@@ -9320,7 +8700,7 @@ test "compact body layer rendering fills recovered rows and clips the final glyp
layer.setContextLines(&.{ 0, 4, 5, 6 });
var instances: [32]CellInstance = undefined;
var next: u32 = 0;
- emitBodyLayer(&g, &instances, &next, &layer, 200, 200, null, bg_default, false, false, .{ 80, 90, 100 });
+ emitBodyLayer(&g, &instances, &next, &layer, 200, 200, bg_default, false, .{ 80, 90, 100 });
// Four compact header rows (48px), then three body rows: two complete
// and a third clipped to the remaining12px of the100px viewport.
try std.testing.expectEqual(@as(u32, 20), next);
@@ -9334,11 +8714,9 @@ test "compact body layer rendering fills recovered rows and clips the final glyp
try std.testing.expectApproxEqAbs(instances[19].v0 + @as(f32, 12) / atlas_h, instances[19].v1, 0.0001);
// A drag preview reserves the last physical column without changing cells.
layer.viewport.w = 1;
- for ([_]bool{ false, true }) |old| {
- next = 0;
- emitBodyLayer(&g, &instances, &next, &layer, 200, 200, null, bg_default, false, old, .{ 80, 90, 100 });
- for (instances[0..next]) |instance| try std.testing.expect(instance.x1 <= -0.6 + 0.0001);
- }
+ next = 0;
+ emitBodyLayer(&g, &instances, &next, &layer, 200, 200, bg_default, false, .{ 80, 90, 100 });
+ for (instances[0..next]) |instance| try std.testing.expect(instance.x1 <= -0.6 + 0.0001);
}
test "compact tag layers fill available width and clip at their physical edge" {
@@ -9347,14 +8725,14 @@ test "compact tag layers fill available width and clip at their physical edge" {
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;
var next: u32 = 0;
- emitTagLayer(&g, &instances, &next, &layer, 100, 100, null, bg_default, false, false);
+ emitTagLayer(&g, &instances, &next, &layer, 100, 100, bg_default, false);
// Five six-pixel cells fit in the three body-column viewport.
try std.testing.expectEqual(@as(u32, 6), next);
try std.testing.expectApproxEqAbs(@as(f32, -0.6), instances[1].x0, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 0), instances[5].x1, 0.0001);
g.tagline_width = 8;
next = 0;
- emitTagLayer(&g, &instances, &next, &layer, 100, 100, null, bg_default, false, false);
+ emitTagLayer(&g, &instances, &next, &layer, 100, 100, bg_default, false);
try std.testing.expectEqual(@as(u32, 5), next);
try std.testing.expectApproxEqAbs(@as(f32, 0), instances[4].x1, 0.0001);
try std.testing.expectApproxEqAbs(@as(f32, 6) / atlas_w, instances[4].u1 - instances[4].u0, 0.0001);