Skip to content

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

Polish sidebar transfer cards and tooltips

Melae2f49dd89de
diff --git a/src/files/app.zig b/src/files/app.zig
index 5c02fff..478533e 100644
--- a/src/files/app.zig
+++ b/src/files/app.zig
@@ -802,6 +802,7 @@ pub const App = struct {
pub const drawPackPlaceIcon = app_sidebar_paint.drawPackPlaceIcon;
pub const renderSidebar = app_sidebar_paint.renderSidebar;
pub const sidebarLayout = app_sidebar_paint.sidebarLayout;
+ pub const sidebarContentWidth = app_sidebar_paint.sidebarContentWidth;
pub const sidebarHeaderAt = app_sidebar_paint.sidebarHeaderAt;
pub const sidebarHeaderBounds = app_sidebar_paint.sidebarHeaderBounds;
pub const sidebarBodyY = app_sidebar_paint.sidebarBodyY;
diff --git a/src/files/app_draw.zig b/src/files/app_draw.zig
index ebeb824..793032b 100644
--- a/src/files/app_draw.zig
+++ b/src/files/app_draw.zig
@@ -76,6 +76,17 @@ pub fn drawProgressBar(
c.cairo_fill(cr);
}
+/// A subtle individual surface for compact transfer entries in the sidebar.
+pub fn drawSidebarTransferSurface(cr: *c.cairo_t, area: anytype) void {
+ if (area.w <= 0 or area.h <= 0) return;
+ roundedRect(cr, area.x, area.y, area.w, area.h, 7);
+ setSource(cr, withAlpha(ui_theme.global.app_item_hover, 0.12));
+ c.cairo_fill_preserve(cr);
+ setSource(cr, withAlpha(ui_theme.global.sidebarForeground(), 0.12));
+ c.cairo_set_line_width(cr, 1);
+ c.cairo_stroke(cr);
+}
+
/// Shared compact row for file and torrent transfers.
pub fn drawTransferProgressRow(
cr: *c.cairo_t,
diff --git a/src/files/app_pointer.zig b/src/files/app_pointer.zig
index 635e714..216b3c3 100644
--- a/src/files/app_pointer.zig
+++ b/src/files/app_pointer.zig
@@ -152,7 +152,17 @@ pub fn handleMotion(self: *App, x: f64, y: f64) void {
if (self.menu != null) {
if (self.menuHit(x, y)) |row| self.menu_selected = row;
}
- if (old_hover != self.hoverKey()) self.invalidateHover(old_hover, self.hoverKey());
+ const new_hover = self.hoverKey();
+ if (old_hover != new_hover) {
+ self.invalidateHover(old_hover, new_hover);
+ } else if (new_hover == std.math.maxInt(usize) - 2001 or
+ new_hover == std.math.maxInt(usize) - 2002)
+ {
+ // Sidebar transfer tooltips follow the pointer even while their
+ // owning hover key remains unchanged. Repaint to clear the old
+ // tooltip position before drawing it at the new one.
+ self.invalidate();
+ }
if (self.sidebar_scroll_drag.active) {
if (self.sidebarScrollbar()) |bar| {
diff --git a/src/files/app_sidebar_paint.zig b/src/files/app_sidebar_paint.zig
index 3f3d6c1..62cbaf4 100644
--- a/src/files/app_sidebar_paint.zig
+++ b/src/files/app_sidebar_paint.zig
@@ -147,11 +147,11 @@ pub fn sidebarLayout(self: *App) app_model.SidebarLayout {
/// The content width used by sidebar painting: the scrollbar track when it
/// exists, otherwise the final target width while the panel is animating.
-fn sidebarContentWidth(self: *App) f64 {
+pub fn sidebarContentWidth(self: *App) f64 {
return if (self.sidebarScrollbar()) |bar|
@as(f64, @floatCast(bar.track.x))
else
- @as(f64, @floatFromInt(self.sidebarTargetWidth()));
+ @as(f64, @floatFromInt(@min(self.sidebarTargetWidth(), self.sidebarWidth())));
}
/// The visible header bounds after applying the same right edge as painting
@@ -483,7 +483,7 @@ pub fn fileOpsBox(self: *App) shell_ui.Rect {
return .{
.x = 12,
.y = @floatFromInt(card.y + card.header_height + self.torrentSidebarHeight() + app_model.SidebarLayout.gap),
- .w = @floatFromInt(@max(0, self.sidebarWidth() - 24 - self.scrollbarGutter())),
+ .w = @floatCast(@max(0, self.sidebarContentWidth() - 24)),
.h = 52,
};
}
@@ -561,6 +561,8 @@ pub fn renderFileOpsSidebar(self: *App, cr: *c.cairo_t) void {
const area = fileOpsBox(self);
if (area.w < 120) return;
+ @import("app_draw.zig").drawSidebarTransferSurface(cr, area);
+
const palette = ui_theme.shellPalette();
const fraction: ?f64 = if (progress.total_bytes_known and progress.total_bytes > 0)
@min(1.0, @as(f64, @floatFromInt(progress.transferred_bytes)) / @as(f64, @floatFromInt(progress.total_bytes)))
diff --git a/src/files/app_torrents.zig b/src/files/app_torrents.zig
index 92f4f55..62a9139 100644
--- a/src/files/app_torrents.zig
+++ b/src/files/app_torrents.zig
@@ -129,7 +129,7 @@ fn sidebarBox(self: *App) Rect {
return .{
.x = 12,
.y = @floatFromInt(card.y + card.header_height),
- .w = @floatFromInt(@max(0, self.sidebarWidth() - 24 - self.scrollbarGutter())),
+ .w = @floatCast(@max(0, self.sidebarContentWidth() - 24)),
.h = @floatFromInt(self.torrentSidebarHeight()),
};
}
@@ -193,6 +193,7 @@ pub fn renderTorrentSidebar(self: *App, cr: *c.cairo_t) void {
if (self.chooser != null) return;
if (self.torrents.items().len == 0) return;
const area = sidebarBox(self);
+ draw.drawSidebarTransferSurface(cr, area);
var label: []const u8 = tr("Transfers");
var fraction: ?f64 = null;
var pause_icon: ?sidebar_controls.Icon = null;