summaryrefslogtreecommitdiff
path: root/anim/src/segments.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/segments.zig')
-rw-r--r--anim/src/segments.zig42
1 files changed, 41 insertions, 1 deletions
diff --git a/anim/src/segments.zig b/anim/src/segments.zig
index a304993..fa30b76 100644
--- a/anim/src/segments.zig
+++ b/anim/src/segments.zig
@@ -269,10 +269,16 @@ pub const Segments = struct {
/// Frames into each cluster's `enlarge`, top down (negative: not begun).
rides: [6]anim.Value,
/// `ink`'s echoes: the band holding `addr` framed as read, `shows` of it.
- echoes: [16]Echo = undefined,
+ echoes: [24]Echo = undefined,
n_echoes: usize = 0,
+ /// Live (design/README.md, `segments`): rip a `row` pin at the end of
+ /// its band's row (`◂ rip`); rsp and rbp an `under` pin in the stack's
+ /// band, rbp's name left of the stub and rsp's right. Each 0 to 1, in
+ /// over the scene's 12 f rising 8.
+ pins: ?Pins = null,
pub const Echo = struct { addr: u64, shows: anim.Value };
+ pub const Pins = struct { rip: anim.Value, stack: anim.Value };
pub fn init(s: *anim.Frame, rec: *const Recording, at: u64) Segments {
var rides: [6]anim.Value = undefined;
@@ -369,6 +375,40 @@ pub const Segments = struct {
}
for (0..n) |i| g.enlarged(u, l, i, placed.value(g.rides[i]));
for (g.echoes[0..g.n_echoes]) |echo| g.echoed(u, l, echo.addr, placed.value(echo.shows));
+ if (g.pins) |pins| g.live(u, l, pins, placed);
+ }
+
+ /// The registers' pins (`pins`), at the moment `at`.
+ fn live(g: *const Segments, u: ui.Ui, l: Layout, pins: Pins, placed: anim.Placed) void {
+ const mono = theme.size.mono.context;
+ const rip = std.math.clamp(placed.value(pins.rip), 0, 1);
+ if (rip > 0) if (g.rowOf(u, l, g.rec.register(g.at, "rip"))) |y| {
+ const v = u.faded(rip).moved(0, (1 - rip) * theme.time.caption_rise);
+ const x = g.x + m.size_end + 14;
+ _ = v.pinEnd(x + theme.metric.pin.row_head[0] + theme.metric.pin.row_gap + v.width(.mono, mono, "rip"), y - 12, &.{"rip"}, region.code_);
+ };
+ const stack = std.math.clamp(placed.value(pins.stack), 0, 1);
+ if (stack > 0) if (Segments.place(l, g.rec.register(g.at, "rsp"))) |at| {
+ u.faded(stack).moved(0, (1 - stack) * theme.time.caption_rise).pinUnder(at[0], at[1] + 2, &.{ "rbp", "rsp" }, region.stack, mono);
+ };
+ }
+
+ /// The middle of the row of names of the unit holding `addr`, once its box has landed.
+ fn rowOf(_: *const Segments, u: ui.Ui, l: Layout, addr: u64) ?f32 {
+ for (l.space.clusters, 0..) |c, i| if (i < 6 and addr >= c.lo and addr < c.hi) {
+ const all = rows(l, i, u.f.scratch);
+ var targets: [64]f32 = undefined;
+ var ys: [64]f32 = undefined;
+ const n = @min(all.len, 64);
+ for (all[0..n], 0..) |r, k| targets[k] = r.target;
+ const room = share(l, i);
+ pool(targets[0..n], ys[0..n], room[0], room[1], m.pitch);
+ for (all[0..n], 0..) |r, k| if (r.kind == .unit) {
+ const un = l.space.units[r.unit];
+ if (addr >= un.lo and addr < un.hi) return ys[k];
+ };
+ };
+ return null;
}
/// The ink of a cluster's largest band (its line on the whole).