RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Add proximity lighting to Files sidebar rows
Mel816edd95f5f9
diff --git a/src/files/app.zig b/src/files/app.zigindex 968c71f..2af0c65 100644--- a/src/files/app.zig+++ b/src/files/app.zig@@ -481,6 +481,7 @@ pub const App = struct {pub const hoveredToolbarButton = app_hover.hoveredToolbarButton;pub const toolbarButtonProximity = app_hover.toolbarButtonProximity;pub const damageToolbarProximity = app_hover.damageToolbarProximity;+ pub const damageSidebarProximity = app_hover.damageSidebarProximity;pub const stepHover = app_hover.stepHover;pub const damageHighlight = app_hover.damageHighlight;pub const unionRect = app_hover.unionRect;diff --git a/src/files/app_hover.zig b/src/files/app_hover.zigindex 3bc7a8c..6a9dcd2 100644--- a/src/files/app_hover.zig+++ b/src/files/app_hover.zig@@ -502,6 +502,54 @@ pub fn damageToolbarProximity(self: *App, old_x: f64, old_y: f64, new_x: f64, neif (damage) |rect| self.addDamage(rect);}+/// Repaint sidebar rows whose pointer-proximity light may have changed.+pub fn damageSidebarProximity(self: *App, old_x: f64, old_y: f64, new_x: f64, new_y: f64) void {+ const reach = ui_theme.global.border_glow_reach;+ if (!button_widget.proximityGlowVisible(ui_theme.global)) return;++ var damage: ?header.Rect = null;+ const layout = self.sidebarLayout();+ for (0..self.rowCount()) |index| {+ if (!self.placeVisible(index)) continue;++ const card_index: usize = if (index < self.deviceBase()) 0 else 1;+ const card = layout.cards[card_index];+ if (!card.expanded) continue;++ const source_top = if (card_index == 0)+ self.contentTop() - self.sidebar_scroll+ else+ self.pinRowY(self.pins.items.items.len) + 24;+ var row = self.placeRect(index);+ row.y += @floatFromInt(card.y + card.header_height - source_top);++ const rect: button_widget.Rect = .{+ .x = @floatCast(row.x),+ .y = @floatCast(row.y),+ .w = @floatCast(row.w),+ .h = @floatCast(row.h),+ };+ const clip: button_widget.Rect = .{+ .x = 8,+ .y = @floatFromInt(card.y + card.header_height),+ .w = @floatFromInt(@max(0, self.sidebarWidth() - self.scrollbarGutter() - 16)),+ .h = @floatFromInt(card.body_height),+ };+ const before = button_widget.sampleProximity(rect, @floatCast(old_x), @floatCast(old_y), clip);+ const after = button_widget.sampleProximity(rect, @floatCast(new_x), @floatCast(new_y), clip);+ if (@min(before.distance, after.distance) > reach) continue;++ const row_damage: header.Rect = .{+ .x = row.x,+ .y = row.y,+ .w = row.w,+ .h = row.h,+ };+ damage = if (damage) |current| unionRect(current, row_damage) else row_damage;+ }+ if (damage) |rect| self.addDamage(rect);+}+/// Samples the hover highlights and queues damage for what moved or/// faded. Once per loop, before painting: the painters draw the sampled/// `frame`, so a partial repaint and a complete one agree.diff --git a/src/files/app_pointer.zig b/src/files/app_pointer.zigindex 49b0e59..91d2ffb 100644--- a/src/files/app_pointer.zig+++ b/src/files/app_pointer.zig@@ -136,6 +136,7 @@ pub fn handleMotion(self: *App, x: f64, y: f64) void {self.updateDialogSurface();self.updateItemSurface();self.damageToolbarProximity(old_x, old_y, x, y);+ self.damageSidebarProximity(old_x, old_y, x, y);if (self.selection_band != null) self.updateSelectionBand();if (self.text_dragging) {self.placeCaret(x, true);diff --git a/src/files/app_sidebar_paint.zig b/src/files/app_sidebar_paint.zigindex 3533b10..d11cff8 100644--- a/src/files/app_sidebar_paint.zig+++ b/src/files/app_sidebar_paint.zig@@ -68,6 +68,40 @@ fn drawSidebarHeader(}}+/// Draws the theme-configured edge light in the section's legacy row+/// coordinate space. The pointer is translated to match the Cairo context.+fn drawSidebarRowProximity(+ self: *App,+ cr: *c.cairo_t,+ index: usize,+ card: app_model.SidebarCardGeometry,+ source_top: i32,+) void {+ const row = self.placeRect(index);+ const translation = card.y + card.header_height - source_top;+ const clip: shell_ui.Rect = .{+ .x = 8,+ .y = @floatFromInt(source_top),+ .w = @floatFromInt(@max(0, self.sidebarWidth() - self.scrollbarGutter() - 16)),+ .h = @floatFromInt(card.body_height),+ };+ shell_ui.drawProximityGlow(+ cr,+ .{+ .x = @floatCast(row.x),+ .y = @floatCast(row.y),+ .w = @floatCast(row.w),+ .h = @floatCast(row.h),+ },+ ui_theme.global.app_sidebar_item_radius,+ .{+ .x = self.mouse_x,+ .y = self.mouse_y - @as(f64, @floatFromInt(translation)),+ },+ clip,+ );+}+/// The shared accordion geometry. Body sizes come from the existing section/// implementations; only the selected visible card receives its body.pub fn sidebarLayout(self: *App) app_model.SidebarLayout {@@ -150,6 +184,8 @@ pub fn renderDevices(self: *App, cr: *c.cairo_t, content_width: f64) void {const row = self.placeRect(index);shell_ui.drawSidebarSelected(cr, .{ .x = @floatCast(row.x), .y = @floatCast(row.y), .w = @floatCast(row.w), .h = @floatCast(row.h) });}+ const disks_card = self.sidebarLayout().cards[@intFromEnum(app_model.SidebarSection.disks)];+ drawSidebarRowProximity(self, cr, index, disks_card, self.pinRowY(self.pins.items.items.len) + 24);if (shell_ui.Layer.begin(cr, .{ .x = 21, .y = @floatCast(y + 3), .w = 24, .h = 24 })) |icon_layer| {var layer = icon_layer;layer.renderer.drawIcon(0, 0, 24, 24, .{ .id = if (volume.kind == .stick) .usb_stick else .drive, .color = withAlpha(ui_theme.global.app_icon, alpha) });@@ -286,12 +322,6 @@ pub fn renderSidebar(self: *App, cr: *c.cairo_t) void {const old_top = self.contentTop() - self.sidebar_scroll;c.cairo_save(cr);c.cairo_translate(cr, 0, @floatFromInt(places_card.y + places_card.header_height - old_top));- // The hover glide remains aligned with the existing Places rows.- const glide = self.nav_hover.frame;- if (glide.alpha > 0) {- const box = self.navHighlight(glide);- shell_ui.drawSidebarHover(cr, .{ .x = @floatCast(box.x), .y = @floatCast(box.y), .w = @floatCast(box.w), .h = @floatCast(box.h) }, glide.alpha);- }for (0..self.deviceBase()) |i| {if (!self.placeVisible(i)) continue;const y: f64 = @floatFromInt(self.placeY(i));@@ -309,6 +339,7 @@ pub fn renderSidebar(self: *App, cr: *c.cairo_t) void {const row = self.placeRect(i);shell_ui.drawSidebarSelected(cr, .{ .x = @floatCast(row.x), .y = @floatCast(row.y), .w = @floatCast(row.w), .h = @floatCast(row.h) });}+ drawSidebarRowProximity(self, cr, i, places_card, old_top);setSource(cr, withAlpha(ui_theme.global.app_icon, alpha));if (!self.drawPackPlaceIcon(cr, i, y, alpha)) {if (i < places_start) {