summaryrefslogtreecommitdiff
path: root/anim/src/descent.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/descent.zig')
-rw-r--r--anim/src/descent.zig102
1 files changed, 65 insertions, 37 deletions
diff --git a/anim/src/descent.zig b/anim/src/descent.zig
index ff478df..ad3a5c5 100644
--- a/anim/src/descent.zig
+++ b/anim/src/descent.zig
@@ -123,8 +123,11 @@ pub const Descent = struct {
const now = d.cursor.now(placed);
const rec = d.cursor.rec;
const room = theme.layout.rowsIn(box.h);
- const before = layout(u, rec, now.stops[1], room, d.root);
- const after = layout(u, rec, now.stops[0], room, d.root);
+ // The panel growing or shrinking at rest (a column's change): the rows of
+ // its two heights' layouts glide between them, the rest fade at the edge; never empty.
+ const resize = if (now.resting()) d.stage.resizing(placed, .disasm) else null;
+ const before = layout(u, rec, now.stops[if (resize != null) 0 else 1], if (resize) |r| theme.layout.rowsIn(r.from) else room, d.root);
+ const after = layout(u, rec, now.stops[0], if (resize) |r| theme.layout.rowsIn(r.to) else room, d.root);
// On the map its box is as long as the rows it has wanted: not 69 for a function of 30.
if (ui.mapping) map.measure(.disasm, @max(before.items.len, after.items.len));
const going = now.advancing();
@@ -150,8 +153,10 @@ pub const Descent = struct {
// How far the rows both lists have are on their way, and how much
// of each that leaves or comes shows: the verb's timetable.
+ // At rest `going` is 1; a resize slides by its own progress.
+ const slide = if (resize) |r| r.p else going;
const move: f32 = switch (kind) {
- .same => cursors.glide(going),
+ .same => if (resize != null) slide else cursors.glide(going),
.down => cursors.glide(clamp01((tm - f(78)) / f(18))),
.through => cursors.glide(clamp01((tm - f(36)) / f(18))),
.up => cursors.glide(clamp01((tm - f(84)) / f(18))),
@@ -176,7 +181,7 @@ pub const Descent = struct {
const it = before.items[i];
if (find(after.items, it.key)) |_| continue;
const shows: f32 = switch (kind) {
- .same => 1 - clamp01(2 * going),
+ .same => 1 - clamp01(2 * slide),
.down => 1 - clamp01((tm - f(66)) / f(12)),
.through => 1 - clamp01((tm - f(24)) / f(12)),
.up => 1 - clamp01((tm - f(48) - @as(f32, @floatFromInt(leaving)) * f(2)) / f(12)),
@@ -199,7 +204,7 @@ pub const Descent = struct {
}
const head = it.what == .head;
const shows: f32 = switch (kind) {
- .same => clamp01(2 * going - 1),
+ .same => clamp01(2 * slide - 1),
.down => if (head) clamp01((tm - f(108)) / f(12)) else clamp01((tm - f(114) - @as(f32, @floatFromInt(arriving)) * f(2)) / f(12)),
.through => if (head) clamp01((tm - f(66)) / f(12)) else clamp01((tm - f(72) - @as(f32, @floatFromInt(arriving)) * f(2)) / f(12)),
.up => clamp01((tm - f(102)) / f(12)),
@@ -226,7 +231,7 @@ pub const Descent = struct {
.up => 1 - clamp01((tm - f(48)) / f(12)),
},
// The one it lands on, with the advance.
- if (kind == .same) 1 else clamp01(going * 2),
+ if (kind == .same) 1 else clamp01(going * 2 - 1),
};
// A crossing stepped over: the kernel's window opens under the call
// row, past the arguments hanging under it; the rows after them make
@@ -256,10 +261,10 @@ pub const Descent = struct {
// In one window the plaque slides from row to row, with the advance.
var mark: ?struct { y: f32, shows: f32 } = null;
if (kind == .same) {
- if (pc_y[0] != null and pc_y[1] != null) mark = .{ .y = std.math.lerp(pc_y[0].?, pc_y[1].?, cursors.standard(going)), .shows = 1 } else if (pc_y[1]) |y| {
- mark = .{ .y = y, .shows = clamp01(2 * going - 1) };
+ if (pc_y[0] != null and pc_y[1] != null) mark = .{ .y = std.math.lerp(pc_y[0].?, pc_y[1].?, if (resize != null) slide else cursors.standard(going)), .shows = 1 } else if (pc_y[1]) |y| {
+ mark = .{ .y = y, .shows = clamp01(2 * slide - 1) };
} else if (pc_y[0]) |y| {
- mark = .{ .y = y, .shows = 1 - clamp01(2 * going) };
+ mark = .{ .y = y, .shows = 1 - clamp01(2 * slide) };
}
}
const fire = now.fires(.disasm);
@@ -269,7 +274,8 @@ pub const Descent = struct {
}
// Which rows ran in the last three steps: the trail.
- const ran = recentRows(a, now, if (going >= 0.5) 0 else 1);
+ const ran_before = recentRows(a, now, 1);
+ const ran_after = recentRows(a, now, 0);
// The line the source panel is on, in the file it shows: rows of that file carry their numbers.
const current = rec.shown[marked];
const current_line = current.line;
@@ -280,7 +286,6 @@ pub const Descent = struct {
var last_line: ?u32 = null;
var last_window: ?u8 = null;
const dd: disasm.Disasm = .{ .cursor = d.cursor, .stage = d.stage };
- const base: usize = if (going >= 0.5) 0 else 1;
// Each window's blocks (`graph`), read once: a rule over each one's first row, its visits where the row has room.
var rules: [8]?graph.Rules = @splat(null);
for (placed_items.items) |p| {
@@ -306,39 +311,62 @@ pub const Descent = struct {
const window_items = windowOf(placed_items.items, p.item.window);
var addrs: [80]u64 = undefined;
var n: usize = 0;
- for (window_items) |w| if (w.item.what == .insn and n < addrs.len) {
+ // Its own rows that show: not another window's between them, nor a row gone at rest.
+ for (window_items) |w| if (w.item.what == .insn and w.item.window == p.item.window and w.shows > 0 and n < addrs.len) {
addrs[n] = w.item.key;
n += 1;
};
const lead = ui.shared(addrs[0..n]);
const wide = @as(f32, @floatFromInt(@max(ui.digits(row.addr), 7) - 7)) * adv;
- const line = if (row.outside or row.src != current.src) null else row.line;
- const state: disasm.Disasm.State = switch (p.item.state) {
- // The row the plaque has not reached yet is ahead.
- .current => if (p.old == null or p.old.?.state != .current) (if (going >= 0.5) .current else .ahead) else if (p.new == null or p.new.?.state != .current) (if (going < 0.5) .current else .ahead) else .current,
- .waiting => .{ .waiting = p.item.at },
- .pass => .{ .ran = .{ .k = 0, .at = p.item.at } },
- .plain => if (ranOf(ran, row.addr)) |r| .{ .ran = r } else .ahead,
- };
- // The marks at the row's left: the trail, the ring, the pass.
- switch (p.item.state) {
- .plain => if (ranOf(ran, row.addr)) |r| v.trail(c.mark, y, r.k),
- .pass => v.trail(c.mark, y, 0),
- .waiting => {
- // The ring comes as the plaque leaves; going up it becomes a trail bar.
- const ring: f32 = if (p.old != null and p.old.?.state == .waiting) (if (kind == .up) 1 - clamp01((tm - f(114)) / f(12)) else 1) else if (kind == .down) clamp01((tm - f(84)) / f(12)) else 1;
- ringAt(v.faded(ring), y);
- if (ring < 1) v.faded(1 - ring).trail(c.mark, y, 0);
- },
- .current => {},
+ // The row as before the advance and as after it (the pc's row, its trail,
+ // the line numbers of the file the source shows): where the two differ, the
+ // one crossfades to the other over the advance's middle, never in a frame.
+ const after_side = going >= 0.5;
+ const across: f32 = if (kind == .same and now.resting()) 1 else clamp01((going - 0.25) * 2);
+ var line: ?u32 = null;
+ var hangs: usize = 0;
+ const covers = if (p.twin) covered_before > 0 else covered > 0;
+ for ([2]bool{ !after_side, after_side }) |side| {
+ const ran_s = if (side) ran_after else ran_before;
+ const cur_s = rec.shown[now.marks[@intFromBool(side)]];
+ const line_s = if (row.outside or row.src != cur_s.src) null else row.line;
+ const state: disasm.Disasm.State = switch (p.item.state) {
+ // The row the plaque has not reached yet is ahead.
+ .current => if (p.old == null or p.old.?.state != .current) (if (side) .current else .ahead) else if (p.new == null or p.new.?.state != .current) (if (!side) .current else .ahead) else .current,
+ .waiting => .{ .waiting = p.item.at },
+ .pass => .{ .ran = .{ .k = 0, .at = p.item.at } },
+ .plain => if (ranOf(ran_s, row.addr)) |r| .{ .ran = r } else .ahead,
+ };
+ // The side the advance is on draws in full where the two are the same.
+ const main = side == after_side;
+ const other_line = if (row.outside or row.src != rec.shown[now.marks[@intFromBool(!side)]].src) null else row.line;
+ const ran_o = if (!side) ran_after else ran_before;
+ const same = std.meta.eql(line_s, other_line) and cur_s.line == rec.shown[now.marks[@intFromBool(!side)]].line and p.item.state != .current and std.meta.eql(ranOf(ran_s, row.addr), ranOf(ran_o, row.addr));
+ const alpha: f32 = if (same) (if (main) 1 else 0) else if (side) across else 1 - across;
+ if (main) line = line_s;
+ if (alpha <= 0) continue;
+ const vs = v.faded(alpha);
+ const base_s: usize = if (side) 0 else 1;
+ // The marks at the row's left: the trail, the ring, the pass.
+ switch (p.item.state) {
+ .plain => if (ranOf(ran_s, row.addr)) |r| vs.trail(c.mark, y, r.k),
+ .pass => vs.trail(c.mark, y, 0),
+ .waiting => {
+ // The ring comes as the plaque leaves; going up it becomes a trail bar.
+ const ring: f32 = if (p.old != null and p.old.?.state == .waiting) (if (kind == .up) 1 - clamp01((tm - f(114)) / f(12)) else 1) else if (kind == .down) clamp01((tm - f(84)) / f(12)) else 1;
+ ringAt(vs.faded(ring), y);
+ if (ring < 1) vs.faded(1 - ring).trail(c.mark, y, 0);
+ },
+ .current => {},
+ }
+ // A row drawn twice (crossfading) counts once for the arguments that hang over the rows under it.
+ const h = dd.insn(vs, now, row, y, map.content(box.w), widen0 + wide, line_s, line_s != last_line, cur_s.line, lead, state, base_s, covers, .{ addrs[0], addrs[n -| 1] }, null);
+ if (main) hangs = h;
+ const w = @min(p.item.window, rules.len - 1);
+ if (rules[w] == null) rules[w] = graph.Rules.init(u.f.scratch, rec, now.marks, .{ row.addr, row.addr }, going);
+ rules[w].?.draw(vs, row.addr, y, map.content(box.w), !covers and !row.outside and !dd.noted(vs, now, row, y, state, base_s, .{ addrs[0], addrs[n -| 1] }, null));
}
runs.add(line != null and line.? == current_line, y, y + m.row);
- // A row drawn twice (crossfading) counts once for the arguments that hang over the rows under it.
- const covers = if (p.twin) covered_before > 0 else covered > 0;
- const hangs = dd.insn(v, now, row, y, map.content(box.w), widen0 + wide, line, line != last_line, current_line, lead, state, base, covers, .{ addrs[0], addrs[n -| 1] }, null);
- const w = @min(p.item.window, rules.len - 1);
- if (rules[w] == null) rules[w] = graph.Rules.init(u.f.scratch, rec, now.marks, .{ row.addr, row.addr }, going);
- rules[w].?.draw(v, row.addr, y, map.content(box.w), !covers and !row.outside and !dd.noted(v, now, row, y, state, base, .{ addrs[0], addrs[n -| 1] }, null));
if (!p.twin) covered_before = covered;
covered = if (p.twin) @max(covered, hangs) else @max(covered -| 1, hangs);
last_line = line;