Skip to content

RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process

Track transfer ghost opacity during copy

Mel43b5c0463fd7
diff --git a/src/files/app_items.zig b/src/files/app_items.zig
index 991505a..580967f 100644
--- a/src/files/app_items.zig
+++ b/src/files/app_items.zig
@@ -171,9 +171,37 @@ pub fn renderFileItems(self: *App, cr: *c.cairo_t, viewport_h: i32) void {
}
self.renderInlineTorrent(cr, idx);
self.renderAudioButton(cr, idx);
+ var ghost_alpha: f64 = 0.20;
+ if (item.transfer_ghost and !item.is_dir) {
+ if (job_progress) |progress| {
+ if ((progress.state == .running or progress.state == .paused) and
+ progress.current_file_path_len > 0 and
+ progress.current_file_size > 0 and
+ std.mem.eql(
+ u8,
+ progress.current_file_path[0..progress.current_file_path_len],
+ item.path,
+ ))
+ {
+ const fraction = @min(
+ 1.0,
+ @as(f64, @floatFromInt(progress.current_file_bytes)) /
+ @as(f64, @floatFromInt(progress.current_file_size)),
+ );
+ const step = @min(
+ @as(usize, 5),
+ @as(usize, @intFromFloat(fraction * 5.0)),
+ );
+ const opacity_steps = [_]f64{
+ 0.20, 0.36, 0.52, 0.68, 0.84, 1.0,
+ };
+ ghost_alpha = opacity_steps[step];
+ }
+ }
+ }
if (fade_item) {
c.cairo_pop_group_to_source(cr);
- c.cairo_paint_with_alpha(cr, if (cut) 0.45 else 0.48);
+ c.cairo_paint_with_alpha(cr, if (cut) 0.45 else ghost_alpha);
}
}
}
diff --git a/src/files/app_listing.zig b/src/files/app_listing.zig
index 573ca42..62fbc70 100644
--- a/src/files/app_listing.zig
+++ b/src/files/app_listing.zig
@@ -202,14 +202,25 @@ fn damageJobProgress(
!std.mem.eql(u8, previous_file_path, current_file_path) and
std.mem.eql(u8, item.path, previous_file_path));
if (active_file) {
- const icon = self.itemIconRect(index);
- const ring_size = @min(26.0, icon.w);
- self.addDamageRegion(self.clipToViewport(.{
- .x = icon.x + (icon.w - ring_size) / 2 - 2,
- .y = icon.y + (icon.w - ring_size) / 2 - 2,
- .w = ring_size + 4,
- .h = ring_size + 4,
- }));
+ if (item.transfer_ghost) {
+ const row_y = self.viewTop() + self.itemInset() +
+ @divTrunc(index, columns) * self.rowHeight() - self.scroll_y;
+ self.addDamageRegion(self.clipToViewport(.{
+ .x = @floatFromInt(self.sidebarWidth()),
+ .y = @floatFromInt(row_y),
+ .w = @floatFromInt(self.w - self.sidebarWidth() - self.scrollbarGutter()),
+ .h = @floatFromInt(self.cardHeight()),
+ }));
+ } else {
+ const icon = self.itemIconRect(@intCast(index));
+ const ring_size = @min(26.0, icon.w);
+ self.addDamageRegion(self.clipToViewport(.{
+ .x = icon.x + (icon.w - ring_size) / 2 - 2,
+ .y = icon.y + (icon.w - ring_size) / 2 - 2,
+ .w = ring_size + 4,
+ .h = ring_size + 4,
+ }));
+ }
}
}
if (path_count > 0) {