summaryrefslogtreecommitdiff
path: root/src/panel_animation.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/panel_animation.zig')
-rw-r--r--src/panel_animation.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/panel_animation.zig b/src/panel_animation.zig
index e0cb32d3..a77e5a34 100644
--- a/src/panel_animation.zig
+++ b/src/panel_animation.zig
@@ -116,8 +116,46 @@ pub const Box = extern struct {
pub fn eql(a: Box, b: Box) bool {
return a.x == b.x and a.y == b.y and a.w == b.w and a.h == b.h;
}
+
+ /// Whether a grid cell falls inside this box. Cells are whole, boxes are
+ /// fractional mid-animation, so the test is the cell's ORIGIN against a
+ /// half-open range: a box straddling a column owns it once its origin is
+ /// covered, and never owns it twice.
+ pub fn contains(box: Box, col: u16, row: u16) bool {
+ const x: f32 = @floatFromInt(col);
+ const y: f32 = @floatFromInt(row);
+ return x >= box.x and x < box.x + box.w and y >= box.y and y < box.y + box.h;
+ }
};
+/// The order every backend composites tracks in: moving panes first, then new
+/// panes, then inert closing tombstones on top. Returns how many were written.
+///
+/// A function rather than a loop inside `Pardes.render` because it is a RULE
+/// three hosts used to re-derive — macos.zig re-sorted the already-sorted list
+/// and tty/panel_compositor.zig walked the phases again — and a second sort
+/// that happens to agree is the one that silently stops agreeing. `render`
+/// calls this and every host receives the result verbatim.
+///
+/// Inactive tracks are dropped here, so a host never has to ask.
+pub fn paintOrder(live: []const ?Track, closing: []const Track, out: []Track) usize {
+ var len: usize = 0;
+ for ([_]Phase{ .moving, .opening }) |phase| for (live) |maybe| {
+ const track = maybe orelse continue;
+ if (!track.active() or track.phase != phase) continue;
+ if (len == out.len) return len;
+ out[len] = track;
+ len += 1;
+ };
+ for (closing) |track| {
+ if (!track.active()) continue;
+ if (len == out.len) return len;
+ out[len] = track;
+ len += 1;
+ }
+ return len;
+}
+
/// One POD record is enough for every backend. `from` and `to` are logical
/// cell boxes; frontends convert them to pixels only at their render edge.
pub const Track = extern struct {