diff options
Diffstat (limited to 'src/Presentation.zig')
| -rw-r--r-- | src/Presentation.zig | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/Presentation.zig b/src/Presentation.zig index 3fc9be44..fc6de5b6 100644 --- a/src/Presentation.zig +++ b/src/Presentation.zig @@ -12,13 +12,8 @@ const Box = animation.Box; const Track = animation.Track; const Phase = animation.Phase; const Transition = animation.Transition; -const CellArea = animation.CellArea; -const CharSource = animation.CharSource; -const charSource = animation.charSource; -const dissolveRevealed = animation.dissolveRevealed; const openingBox = animation.openingBox; const closingBox = animation.closingBox; -const paintOrder = animation.paintOrder; const panelBox = layout.panelBox; const Presentation = @This(); @@ -452,8 +447,8 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u closing -= 1; const track = self.shown_closing[closing]; if (!track.active()) continue; - if (boxContainsCell(track.contentBox(), col, row) and - boxContainsCell(track.presented(), col, row)) return null; + if (track.contentBox().contains(col, row) and + track.presented().contains(col, row)) return null; } const phases = [_]Phase{ .opening, .moving }; for (phases) |phase| { @@ -468,8 +463,8 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u .slide, .zoom => { const shown = track.presented(); // Past its mark, the neighbour's cells stay the neighbour's. - if (pastMark(track) and !boxContainsCell(track.to, col, row)) continue; - if (shown.w <= 0 or shown.h <= 0 or !boxContainsCell(shown, col, row)) continue; + if (pastMark(track) and !track.to.contains(col, row)) continue; + if (shown.w <= 0 or shown.h <= 0 or !shown.contains(col, row)) continue; const x = @as(f32, @floatFromInt(col)) + 0.5; const y = @as(f32, @floatFromInt(row)) + 0.5; const u = std.math.clamp((x - shown.x) / shown.w, 0, 0.999_999); @@ -483,9 +478,9 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u }, .vertical => { const clip = track.contentBox(); - if (!boxContainsCell(clip, col, row)) continue; + if (!clip.contains(col, row)) continue; const shown = track.presented(); - if (shown.w <= 0 or shown.h <= 0 or !boxContainsCell(shown, col, row)) + if (shown.w <= 0 or shown.h <= 0 or !shown.contains(col, row)) return null; const x = @as(f32, @floatFromInt(col)) + 0.5; const y = @as(f32, @floatFromInt(row)) + 0.5; @@ -497,7 +492,7 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u }; }, .dissolve, .ascii => { - if (!boxContainsCell(track.to, col, row)) continue; + if (!track.to.contains(col, row)) continue; const cell_diff = self.cellDiff(cols, rows, col, row); if (!cell_diff.changed()) return .{ .col = col, .row = row }; @@ -508,7 +503,7 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u @as(f32, @floatFromInt(row)) + 0.5 - track.to.y, )); const visible = switch (track.effect) { - .dissolve => dissolveRevealed( + .dissolve => animation.dissolveRevealed( track.serial, relative_col, relative_row, @@ -523,16 +518,16 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u return if (visible) .{ .col = col, .row = row } else null; }, .edges, .fall, .wave, .curtain, .scramble, .typewriter => { - if (!boxContainsCell(track.to, col, row)) continue; - const area = CellArea.of(track.to); + if (!track.to.contains(col, row)) continue; + const area = animation.CellArea.of(track.to); const settled = std.meta.eql( - charSource( + animation.charSource( track, col -| area.x0, row -| area.y0, area, ), - CharSource.settled, + animation.CharSource.settled, ); return if (settled) .{ .col = col, .row = row } else null; }, @@ -544,17 +539,11 @@ pub fn pointer(self: *const Presentation, cols: u16, rows: u16, col: u16, row: u const track = maybe orelse continue; if (!track.active() or (track.effect != .slide and track.effect != .zoom and track.effect != .vertical)) continue; - if (boxContainsCell(track.to, col, row)) return null; + if (track.to.contains(col, row)) return null; } return .{ .col = col, .row = row }; } -fn boxContainsCell(box: Box, col: u16, row: u16) bool { - const x = @as(f32, @floatFromInt(col)) + 0.5; - const y = @as(f32, @floatFromInt(row)) + 0.5; - return x >= box.x and x < box.x + box.w and y >= box.y and y < box.y + box.h; -} - pub fn cancel(self: *Presentation) void { self.tracks = @splat(null); self.closing_len = 0; @@ -585,7 +574,7 @@ fn prepareDiff(self: *Presentation, gpa: std.mem.Allocator, surface: *const pard while (row < surface.rows) : (row += 1) { var col: u16 = 0; while (col < surface.cols) : (col += 1) { - if (!boxContainsCell(track.to, col, row)) continue; + if (!track.to.contains(col, row)) continue; const index = @as(usize, row) * surface.cols + col; switch (self.diffs[index]) { .ascii => |diff| longest = @max(longest, diff.frameCount()), @@ -624,7 +613,7 @@ pub fn submit(self: *Presentation, p: *Pardes, s: *pardes.Surface) !void { s.previous_regions = self.previous_regions[0..self.previous_nregions]; s.cell_diffs = self.diffs; } - s.npanel_tracks = paintOrder( + s.npanel_tracks = animation.paintOrder( &self.tracks, self.closing[0..self.closing_len], &s.panel_tracks, |
