diff options
Diffstat (limited to 'anim/src/context.zig')
| -rw-r--r-- | anim/src/context.zig | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/anim/src/context.zig b/anim/src/context.zig index 9b466da..8e0156d 100644 --- a/anim/src/context.zig +++ b/anim/src/context.zig @@ -465,6 +465,23 @@ pub const Stack = struct { above: i32 = 0, /// Which box of its stage it is in: the map's `more` holds the stack continued. part: @import("stage.zig").Part = .stack, + /// The introduction's: its offsets, roles and spans come in a `column` at a time. + reveal: ?Reveal = null, + + /// The stack built a `column` at a time (design/README.md, 6. Verbs: + /// `column`; motion.md, chapter II): each part a clock the scene plays + /// (frames, negative before it begins), its rows coming in top down as + /// shown, 2 f apart, 12 f each; until then under the page. + pub const Reveal = struct { + offsets: anim.Value, + roles: anim.Value, + spans: anim.Value, + + /// How much of row (or span) `k`'s part is still under the page, its clock at `clock`. + fn hidden(clock: f32, k: f32) f32 { + return 1 - std.math.clamp((clock - 2 * @max(k, 0)) / 12, 0, 1); + } + }; pub fn draw(k: *const Stack, f: *sk.Frame, placed: anim.Placed) void { const box = k.stage.box(placed, k.part); @@ -710,6 +727,13 @@ pub const Stack = struct { const y = top + (@as(f32, @floatFromInt(n)) + slide) * m.row; if (y + m.row < body.y or y > box.h) continue; const addr = window[0] +% @as(u64, @bitCast(n * 8)); + // Not come in yet (`reveal`): the offset under the page (from past the pins to 172), the role with its row. + const hide_offset = if (k.reveal) |rv| Reveal.hidden(placed.value(rv.offsets), (y - top) / m.row) else 0; + const hide_role = if (k.reveal) |rv| Reveal.hidden(placed.value(rv.roles), (y - top) / m.row) else 0; + // The page laid over them is opaque whatever the panel's own fade (a faded page over faded text leaves some). + var page_u = u; + page_u.at.pose.opacity = 1; + defer if (hide_offset > 0) page_u.faded(hide_offset).fill(.{ .x = 120, .y = y, .w = theme.metric.slot.offset + 4 - 120, .h = m.row }, theme.color.page); // Who points here: a pin in the lane, landing with its link. const names = pins(u, now, is, was, addr, travel); var marks: rows.Marks = .{ .lead = lead, .first = now.writtenWatched(addr, 8, .memory, 0, watched_from, watched_to) }; @@ -779,6 +803,11 @@ pub const Stack = struct { const fades = ran < 1 and !std.meta.eql(word_was, word_is); if (fades) _ = rows.slot(vs.faded(1 - ran), y, room_w, now.before(), addr, below_rsp, &.{}, 0, marks, role.name, role.local, role_was); const hops = rows.slot(if (fades) vs.faded(ran) else vs, y, room_w, if (fades) now.moment() else now.shownAt(addr, 8), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local, role_was); + if (hide_role > 0) { + // The role drawn, and the one it crossfades from while it does. + const role_w = @max(if (role_was.going < 1) u.width(.mono, size, role_at[0].name) else 0, u.width(.mono, size, role.name)); + if (role_w > 0) page_u.faded(hide_role).fill(.{ .x = room_w - theme.metric.slot.room - role_w - 2, .y = y, .w = role_w + 4, .h = m.row }, theme.color.page); + } // An arc's ends are rows on show (the row above the window, there for a slide, is not). if (y + m.row > top + 1 and y < box.h - m.pad - 1) at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {}; const what_was: zt.telescope.Role = if (k_role < roles[0].len) roles[0][k_role].role else .none; @@ -843,12 +872,25 @@ pub const Stack = struct { pinAmount(u, x, top + place * m.row, names_, if (is.rsp < was.rsp) u.print("-{x}", .{bytes}) else u.print("+{x}", .{bytes}), amount_shows); // The rows it crossed, a 3-unit vermilion bracket in the outer arc lane. if (crossed > 0.05) u.faded(amount_shows).bracket(theme.metric.arc.lanes[0], top + @min(place, old) * m.row + 2, top + @max(place, old) * m.row - 2, theme.mark(.write).solid, theme.metric.bracket.tie, 1, false); + } else if (lone != null and joinsBefore(pins(u, now, is, was, is.named(name) orelse 0, travel).names, name)) { + // Joining a pin in front of a name there (rbp onto rsp's row): its own head goes as it lands + // (the joined pin has one head, after the last name), never in the advance's frame. + const y_pin = top + place * m.row; + u.text(.mono_bold, size, x, theme.baseline(y_pin, m.row, size), name, t.primary); + const head = theme.metric.pin; + const hx = x + u.width(.mono, size, name) + head.row_gap; + const mid = y_pin + m.row / 2; + const v_head = u.faded(1 - goes(now, was, is, name)); + sk.draw.polygon(u.f, &.{ .{ hx + head.row_head[0], mid }, .{ hx, mid - head.row_head[1] / 2 }, .{ hx, mid + head.row_head[1] / 2 } }, v_head.at.pen(.{ .fill = ui.rgb(theme.color.region.stack) })); } else u.pinRow(x, top + place * m.row, names_, theme.color.region.stack); } - for (spans[0..n_spans]) |sp| if (sp.shows > 0) if (sp.was) |was_name| { - rows.span(v.faded(1 - renamed), map.content(box.w), sp.y0, sp.y1, was_name, sp.newest, sp.open); - rows.span(v.faded(renamed), map.content(box.w), sp.y0, sp.y1, sp.name, sp.newest, sp.open); - } else rows.span(v.faded(sp.shows), map.content(box.w), sp.y0, sp.y1, sp.name, sp.newest, sp.open); + for (spans[0..n_spans], 0..) |sp, i| if (sp.shows > 0) { + const sv = if (k.reveal) |rv| v.faded(1 - Reveal.hidden(placed.value(rv.spans), @floatFromInt(i))) else v; + if (sp.was) |was_name| { + rows.span(sv.faded(1 - renamed), map.content(box.w), sp.y0, sp.y1, was_name, sp.newest, sp.open); + rows.span(sv.faded(renamed), map.content(box.w), sp.y0, sp.y1, sp.name, sp.newest, sp.open); + } else rows.span(sv.faded(sp.shows), map.content(box.w), sp.y0, sp.y1, sp.name, sp.newest, sp.open); + }; veiled(u, box, now.veil); if (k.part == .stack) map.strip(.stack, u, box); } @@ -896,6 +938,12 @@ pub const Stack = struct { } /// Where `name` goes in a row pin of `others` and it, in the registers' order. + /// Whether `name` joining the pin of `others` comes before one of them (pwndbg's order). + fn joinsBefore(others: []const []const u8, name: []const u8) bool { + for (others) |o| if (index(o).? > index(name).?) return true; + return false; + } + fn pinPlace(u: ui.Ui, others: []const []const u8, name: []const u8) f32 { const size = theme.size.mono.context; var x: f32 = theme.metric.slot.lane; |
