summaryrefslogtreecommitdiff
path: root/anim/src/stage.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/stage.zig')
-rw-r--r--anim/src/stage.zig37
1 files changed, 33 insertions, 4 deletions
diff --git a/anim/src/stage.zig b/anim/src/stage.zig
index 31a149a..595b9f5 100644
--- a/anim/src/stage.zig
+++ b/anim/src/stage.zig
@@ -10,18 +10,31 @@ const theme = ui.theme;
const Split = theme.layout.Split;
const Rect = theme.Rect;
-pub const Part = enum { band, source, disasm, registers, stack, backtrace };
+pub const Part = enum { band, view, source, disasm, registers, stack, backtrace };
pub const Stage = struct {
first: Split,
moves: [8]Move = undefined,
count: usize = 0,
+ /// Seconds into the band's lens rising from its bytes (`Context.establish`,
+ /// `ties.rise`); far past it, for a scene that does not raise one.
+ rise: anim.Value,
+ /// 1, or less while a relayout fades the drawing out and in round its move.
+ drawing: anim.Value,
+ /// 1, or less while the camera visits the drawing and its view is cleared.
+ view: anim.Value,
+ /// While the camera visits the stack: the moment whose window it holds
+ /// still (negative: none), and how many `free` words above its rsp it shows.
+ hold: anim.Value,
+ hold_free: anim.Value,
+ /// 0 to 1 as the window goes from where it was to where it is held (and back).
+ hold_in: anim.Value,
const Move = struct { from: Split, to: Split, p: anim.Value };
/// A stage at `split`, made where a scene's components can keep a pointer to it.
pub fn init(s: *anim.Frame, split: Split) *Stage {
- return s.new(Stage{ .first = split });
+ return s.new(Stage{ .first = split, .rise = s.value(std.math.floatMax(f32)), .drawing = s.value(1), .view = s.value(1), .hold = s.value(-1), .hold_free = s.value(0), .hold_in = s.value(0) });
}
/// The split the stage ends in, after every move so far.
@@ -34,7 +47,23 @@ pub const Stage = struct {
const p = s.value(0);
st.moves[st.count] = .{ .from = st.last(), .to = to, .p = p };
st.count += 1;
+ // The drawing fades out (12 f), the panels move, it fades in at its new size.
+ s.play(.{st.drawing.to(0)}, .{ .seconds = theme.time.quick, .ease = anim.ease.linear });
s.play(.{p.to(1)}, .{ .seconds = theme.time.relayout, .ease = anim.ease.linear });
+ s.play(.{st.drawing.to(1)}, .{ .seconds = theme.time.quick, .ease = anim.ease.linear });
+ }
+
+ /// Holds the stack's window still as it is at moment `at`, with `free`
+ /// words above its rsp for pushes to fill: for the camera's visit.
+ pub fn holdStack(st: *Stage, s: *anim.Frame, at: u64, free: u32) void {
+ s.play(.{ st.hold.to(@floatFromInt(at)), st.hold_free.to(@floatFromInt(free)) }, .{ .seconds = 0 });
+ // It scrolls there by whole rows, as a window does.
+ s.play(.{st.hold_in.to(1)}, .{ .seconds = theme.time.move, .ease = anim.ease.linear });
+ }
+
+ pub fn releaseStack(st: *Stage, s: *anim.Frame) void {
+ s.play(.{st.hold_in.to(0)}, .{ .seconds = theme.time.move, .ease = anim.ease.linear });
+ s.play(.{st.hold.to(-1)}, .{ .seconds = 0 });
}
/// The split as it stands at this instant.
@@ -67,7 +96,7 @@ pub const Stage = struct {
fn between(a: Split, b: Split, p: f32) Split {
var out = b;
- inline for (.{ "band", "source", "disasm", "registers", "stack", "backtrace" }) |name| {
+ inline for (.{ "band", "view", "source", "disasm", "registers", "stack", "backtrace" }) |name| {
const x = @field(a, name);
const y = @field(b, name);
@field(out, name) = .{ .x = std.math.lerp(x.x, y.x, p), .y = std.math.lerp(x.y, y.y, p), .w = std.math.lerp(x.w, y.w, p), .h = std.math.lerp(x.h, y.h, p) };
@@ -79,6 +108,6 @@ fn between(a: Split, b: Split, p: f32) Split {
test "a relayout passes through the splits it joins" {
const sp = theme.layout.split;
const half = between(sp.beside, sp.subject, 0.5);
- try std.testing.expectEqual(@as(f32, 200), half.band.h);
+ try std.testing.expectEqual(@as(f32, 224), half.band.h);
try std.testing.expectEqual(sp.subject.stack, between(sp.beside, sp.subject, 1).stack);
}