summaryrefslogtreecommitdiff
path: root/anim/src/cursor.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/cursor.zig')
-rw-r--r--anim/src/cursor.zig21
1 files changed, 16 insertions, 5 deletions
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig
index f0f90ff..9de02c1 100644
--- a/anim/src/cursor.zig
+++ b/anim/src/cursor.zig
@@ -394,10 +394,19 @@ pub const Cursor = struct {
/// or at the end of a continue (`wave`).
fn travel(c: Cursor, from: u64, to: u64, wave: bool) f32 {
const rec = c.rec;
- // The source's window moves with it: by whole lines, and never a cut.
- if (rec.viewFirst(c.levels.source_rows, rec.own[from]) != rec.viewFirst(c.levels.source_rows, rec.own[to])) return time.move;
+ const a = rec.shown[from];
+ const b = rec.shown[to];
+ // Another file: the source fades through (12 f out, 12 f in).
+ if (a.src != b.src) return time.move;
+ // The source's window moves with it: by whole lines, and never a cut;
+ // farther than its own height, its strip shows where it goes first
+ // (the window gliding there, 24 f), then the pane fades through.
+ const fit = c.levels.source_rows;
+ const windows = [2]u32{ rec.shownFirst(fit, a), rec.shownFirst(fit, b) };
+ if (@max(windows[0], windows[1]) - @min(windows[0], windows[1]) > fit) return 2 * time.move;
+ if (windows[0] != windows[1]) return time.move;
if (wave or jumps(rec, from, to)) return 2 * time.current_jump;
- const rows: f32 = @floatFromInt(@max(rec.own[from], rec.own[to]) - @min(rec.own[from], rec.own[to]));
+ const rows: f32 = @floatFromInt(@max(a.line, b.line) - @min(a.line, b.line));
return @min(time.step + time.step_per_row * @max(rows - 1, 0), time.step_max);
}
@@ -540,8 +549,10 @@ fn settled(s: *const anim.Frame, v: anim.Value) f32 {
/// (fades out there and in here) and does not slide: a call is not a
/// journey across the lines between.
pub fn jumps(rec: *const Recording, from: u64, to: u64) bool {
- const rows = @max(rec.own[from], rec.own[to]) - @min(rec.own[from], rec.own[to]);
- return rec.depths[from] != rec.depths[to] or rows > time.current_jump_rows;
+ const a = rec.shown[from];
+ const b = rec.shown[to];
+ const rows = @max(a.line, b.line) - @min(a.line, b.line);
+ return a.src != b.src or rec.depths[from] != rec.depths[to] or rows > time.current_jump_rows;
}
/// The cursor at one instant.