diff options
Diffstat (limited to 'anim/src/loupe.zig')
| -rw-r--r-- | anim/src/loupe.zig | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/anim/src/loupe.zig b/anim/src/loupe.zig index 623e966..65a9463 100644 --- a/anim/src/loupe.zig +++ b/anim/src/loupe.zig @@ -54,9 +54,15 @@ pub const Loupe = struct { /// `open`: its pointer framed as read; the stem draws and the loupe /// rises with it, its shadow growing; its target's frame lands last. + /// It may open again after a `close`. (Its clock runs on past the + /// open, for the strikes in it: `opening` counts open's lengths.) pub fn open(l: *const Loupe, s: *anim.Frame) void { - s.play(.{l.opening.to(1)}, .{ .seconds = time.open, .ease = anim.ease.linear }); + const start = s.cursor; + s.play(.{ l.opening.to(0), l.closing.to(0) }, .{ .seconds = 0 }); + s.play(.{l.opening.to(open_lengths)}, .{ .seconds = open_lengths * time.open, .ease = anim.ease.linear }); + s.cursor = start + time.open; } + const open_lengths = 8; /// `close`: the stem draws back and the loupe sinks, fading as it falls. pub fn close(l: *const Loupe, s: *anim.Frame) void { @@ -99,14 +105,24 @@ pub const Loupe = struct { const b = back.apply(.{ px[2], px[3] }); pointer = .{ .x = a[0], .y = a[1], .w = b[0] - a[0], .h = b[1] - a[1] }; target = row.fields.base; + // From the band's view it lies over the stack, never the registers (what a step changes there is what the captions are about). + const stack = l.stage.box(u.at, .stack); + const h = theme.layout.panelH(k.rows); + return .{ .box = .{ .x = stack.x, .y = stack.y + stack.h - h, .w = k.width, .h = h }, .pointer = pointer, .target = target, .first = target, .ink = rows.ink(rows.regionOf(moment, target)) }; }, } if (target == 0) return null; // shortcut: it keeps to the stage and does not yet move past the current marks or a changed row; the scene picks a pointer whose loupe covers neither. const stage = theme.canvas.stage; const h = theme.layout.panelH(k.rows); - const x = std.math.clamp(@max(pointer.x - k.hang, right), stage.x, stage.x + stage.w - k.width); - const y = @min(pointer.y + pointer.h - 1, stage.y + stage.h - h); + var x = std.math.clamp(@max(pointer.x - k.hang, right), stage.x, stage.x + stage.w - k.width); + var y = @min(pointer.y + pointer.h - 1, stage.y + stage.h - h); + // A deeper one with no room to the right hangs under the one it opens from, both whole. + if (l.from == .field and x < right) { + const parent = l.from.field.loupe.place(u, now).?.box; + x = parent.x; + y = @min(parent.y + parent.h + k.shadow[0][1], stage.y + stage.h - h); + } return .{ .box = .{ .x = x, .y = y, .w = k.width, .h = h }, .pointer = pointer, .target = target, .first = (target & ~@as(u64, 15)) - 16 * (k.rows / 2), .ink = rows.ink(rows.regionOf(moment, target)) }; } @@ -171,7 +187,10 @@ pub const Loupe = struct { const top = m.tag + m.pad; v.clip(.{ .x = 0, .y = m.tag, .w = b.w, .h = b.h - m.tag }); // By the scene's fields: the rows that hold them, the rest `more`. - if (l.from == .row) hexdump.fielded(.{ .u = v, .rows = k.rows, .box = b }, now, top, l.from.row.fields) else hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad }); + // Its fields strike once it has opened, 6 f after it and 6 f apart. + var fields = if (l.from == .row) l.from.row.fields else undefined; + if (l.from == .row and now.walking()) fields.struck = opened - time.open - cursors.write_apart; + if (l.from == .row) hexdump.fielded(.{ .u = v, .rows = k.rows, .box = b }, now, top, fields) else hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad }); v.unclip(); // Its target, framed bright: each field of the struct, or the word. const framed = std.math.clamp((since - time.stem - time.frame) / time.frame, 0, 1); @@ -183,8 +202,18 @@ pub const Loupe = struct { for (o.type.record.fields) |field| frameRun(w, row_y, shift, o.addr + field.offset - (p.target & ~@as(u64, 15)), field.type.size() orelse 8); } else frameRun(w, row_y, shift, p.target % 16, 8); } - // The stem: a bracket under the pointer's digits, lying on the tag, drawn head first. const drawn = cursors.standard(std.math.clamp(since / time.stem, 0, 1)) * (1 - closed); + // From a row of the band's view: the stem leaves the row's left, goes down the gutter's right lane, into the tag. + if (l.from == .row) { + const view = l.stage.box(placed, .view); + const mid = p.pointer.y + p.pointer.h / 2; + const lane = view.x - k.lane; + u.faded(@min(rise * 2, 1)).route(&.{ .{ view.x, mid }, .{ lane, mid }, .{ lane, b.y + lower + m.tag / 2 }, .{ b.x - 2, b.y + lower + m.tag / 2 } }, p.ink, .{ .width = theme.stroke.line, .head = .{ 10, 10 }, .radius = 4, .progress = drawn }); + return; + } + // Hung under the one it opens from: the stem goes down from the pointer to its tag. + if (b.y > p.pointer.y + p.pointer.h + 1) u.faded(@min(rise * 2, 1)).fill(.{ .x = p.pointer.x + 8, .y = p.pointer.y + p.pointer.h - 3, .w = k.stem, .h = (b.y + lower - (p.pointer.y + p.pointer.h - 3)) * drawn }, p.ink); + // The stem: a bracket under the pointer's digits, lying on the tag, drawn head first. u.faded(@min(rise * 2, 1)).fill(.{ .x = p.pointer.x - 2, .y = p.pointer.y + p.pointer.h - 3, .w = (p.pointer.w + 4) * drawn, .h = k.stem }, p.ink); } }; |
