A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(gui): fade list and tab row edges in their own alpha
RoversXecd909d5460c
diff --git a/thinkterm-render/src/quad.rs b/thinkterm-render/src/quad.rsindex 28c358fe..0353f8ef 100644--- a/thinkterm-render/src/quad.rs+++ b/thinkterm-render/src/quad.rs@@ -584,6 +584,108 @@ impl BoxedQuad {}Some(clipped)}++ /// This quad, already cut to `clip`, faded towards its edges as `fade`+ /// says: handed to `out` whole where it is clear of the fades, and in+ /// strips across them otherwise, each with its corners' alpha taken+ /// down as far as the fade has got there.+ fn faded(self, clip: QuadClipRect, fade: QuadEdgeFade, out: &mut impl FnMut(Self)) {+ if !fade.along(FadeAxis::Horizontal) {+ return self.faded_along(clip, fade, FadeAxis::Vertical, out);+ }+ self.faded_along(clip, fade, FadeAxis::Vertical, &mut |strip: Self| {+ strip.faded_along(clip, fade, FadeAxis::Horizontal, out)+ });+ }++ /// `faded`, for the fades along one axis.+ fn faded_along(+ self,+ clip: QuadClipRect,+ fade: QuadEdgeFade,+ axis: FadeAxis,+ out: &mut impl FnMut(Self),+ ) {+ if !fade.along(axis) {+ return out(self);+ }+ let (left, top, right, bottom) = self.position;+ let (start, end) = match axis {+ FadeAxis::Vertical => (top, bottom),+ FadeAxis::Horizontal => (left, right),+ };+ // Where the fades' steps fall across this quad.+ let mut cuts = [0.0f32; 2 * QuadEdgeFade::STEPS];+ let mut count = 0;+ for (edge, run) in fade.ends(clip, axis) {+ if run == 0.0 {+ continue;+ }+ for step in 1..=QuadEdgeFade::STEPS {+ let at = edge + run * step as f32 / QuadEdgeFade::STEPS as f32;+ if at > start && at < end {+ cuts[count] = at;+ count += 1;+ }+ }+ }+ let cuts = &mut cuts[..count];+ cuts.sort_by(f32::total_cmp);+ let shown = |at| fade.shown_at(clip, axis, at);+ if cuts.is_empty() {+ // No step falls across it: the one strip is the quad itself.+ let (shown_start, shown_end) = (shown(start), shown(end));+ return self.faded_strip(axis, shown_start, shown_end, out);+ }++ let mut strip_start = start;+ for strip_end in cuts.iter().copied().chain(std::iter::once(end)) {+ let band = match axis {+ FadeAxis::Vertical => clip.with_vertical(strip_start, strip_end),+ FadeAxis::Horizontal => clip.with_horizontal(strip_start, strip_end),+ };+ if let Some(strip) = self.positioned_clipped(left, top, right, bottom, band) {+ strip.faded_strip(axis, shown(strip_start), shown(strip_end), out);+ }+ strip_start = strip_end;+ }+ }++ /// One strip of `faded_along`, shown `shown_start` at its start along+ /// `axis` and `shown_end` at its end: handed to `out` with its corners'+ /// alpha taken down that far, or not at all where it is gone.+ fn faded_strip(+ mut self,+ axis: FadeAxis,+ shown_start: f32,+ shown_end: f32,+ out: &mut impl FnMut(Self),+ ) {+ if shown_start <= 0.0 && shown_end <= 0.0 {+ return;+ }+ if shown_start < 1.0 || shown_end < 1.0 {+ let mut corners = self+ .fg_color_corners+ .as_deref()+ .copied()+ .unwrap_or([self.fg_color; VERTICES_PER_CELL]);+ let (starts, ends) = match axis {+ FadeAxis::Vertical => ([V_TOP_LEFT, V_TOP_RIGHT], [V_BOT_LEFT, V_BOT_RIGHT]),+ FadeAxis::Horizontal => ([V_TOP_LEFT, V_BOT_LEFT], [V_TOP_RIGHT, V_BOT_RIGHT]),+ };+ for corner in starts {+ corners[corner][3] *= shown_start;+ }+ for corner in ends {+ corners[corner][3] *= shown_end;+ }+ self.fg_color = corners[V_TOP_LEFT];+ self.fg_color_corners = Some(Box::new(corners));+ self.alt_color[3] *= (shown_start + shown_end) / 2.0;+ }+ out(self);+ }}fn lerp(start: f32, end: f32, amount: f32) -> f32 {@@ -707,6 +809,64 @@ impl QuadClipRect {}}+/// How a recording cut to a rect fades out towards the edges it is cut at:+/// whole from `top` pixels below the top edge, `bottom` above the bottom+/// one and so on, gone at the edge itself, eased between. Held in the+/// quads' own alpha, not painted over them, so it reads the same over any+/// ground, a see-through one too. Zero is a plain cut.+#[derive(Debug, Clone, Copy, Default, PartialEq)]+pub struct QuadEdgeFade {+ pub top: f32,+ pub bottom: f32,+ pub left: f32,+ pub right: f32,+}++/// Down or across.+#[derive(Debug, Clone, Copy, PartialEq)]+enum FadeAxis {+ Vertical,+ Horizontal,+}++impl QuadEdgeFade {+ /// The steps each fade is cut into: the ease runs straight between them.+ const STEPS: usize = 8;++ fn is_none(&self) -> bool {+ !self.along(FadeAxis::Vertical) && !self.along(FadeAxis::Horizontal)+ }++ fn along(&self, axis: FadeAxis) -> bool {+ match axis {+ FadeAxis::Vertical => self.top > 0.0 || self.bottom > 0.0,+ FadeAxis::Horizontal => self.left > 0.0 || self.right > 0.0,+ }+ }++ /// The fades at the start and the end of `axis` inside `clip`: where+ /// each edge is, and how far in from it the fade runs.+ fn ends(&self, clip: QuadClipRect, axis: FadeAxis) -> [(f32, f32); 2] {+ match axis {+ FadeAxis::Vertical => [(clip.top, self.top), (clip.bottom, -self.bottom)],+ FadeAxis::Horizontal => [(clip.left, self.left), (clip.right, -self.right)],+ }+ }++ /// How much of what is at `at` along `axis` shows, inside `clip`.+ fn shown_at(&self, clip: QuadClipRect, axis: FadeAxis, at: f32) -> f32 {+ let eased = |through: f32| {+ let t = through.clamp(0.0, 1.0);+ t * t * (3.0 - 2.0 * t)+ };+ self.ends(clip, axis)+ .into_iter()+ .filter(|(_, run)| *run != 0.0)+ .map(|(edge, run)| eased((at - edge) / run))+ .product()+ }+}+/// How many quads a [`HeapQuadAllocator`] held at some point during a paint.////// Splitting a recorded frame by screen position cannot distinguish a scrolling@@ -1004,6 +1164,82 @@ impl HeapQuadAllocator {}}+ /// Fade what has been recorded so far in across `band`, from gone at+ /// its top to whole at its bottom, as a ground-coloured fade painted+ /// over it would seem to -- in the quads' own alpha, so that it reads+ /// the same over a see-through ground. Quads above the band, below it,+ /// or centred beside it are left as they are, and so is any part of one+ /// above the band.+ pub fn fade_in_across(&mut self, band: QuadClipRect) {+ if band.bottom <= band.top {+ return;+ }+ let touches = |quad: &BoxedQuad| {+ let (left, top, right, bottom) = quad.position;+ let middle = (left + right) / 2.0;+ top < band.bottom && bottom > band.top && middle >= band.left && middle < band.right+ };+ let fade = QuadEdgeFade {+ top: band.bottom - band.top,+ ..Default::default()+ };+ for layer in [&mut self.layer0, &mut self.layer1, &mut self.layer2] {+ // Everything before the first quad the band touches stays where+ // it is; what follows is taken off and put back in its order.+ let Some(begin) = layer.iter().position(&touches) else {+ continue;+ };+ for quad in layer.split_off(begin) {+ if !touches(&quad) {+ layer.push(quad);+ continue;+ }+ let (left, top, right, bottom) = quad.position;+ let over = |top, bottom| QuadClipRect {+ left,+ top,+ right,+ bottom,+ };+ let above = quad.positioned_clipped(left, top, right, bottom, over(top, band.top));+ let within =+ quad.positioned_clipped(left, top, right, bottom, over(band.top, bottom));+ if let Some(above) = above {+ layer.push(above);+ }+ if let Some(within) = within {+ within.faded(over(band.top, f32::MAX), fade, &mut |strip| {+ layer.push(strip)+ });+ }+ }+ }+ }++ /// `clip_after`, faded out towards the edges it cuts at as `fade` says.+ pub fn cut_after(&mut self, mark: &HeapQuadMark, clip: QuadClipRect, fade: QuadEdgeFade) {+ if fade.is_none() {+ return self.clip_after(mark, clip);+ }+ for (layer_num, layer) in [+ (0, &mut self.layer0),+ (1, &mut self.layer1),+ (2, &mut self.layer2),+ ] {+ // What is faded goes on after the rest in its order, and the+ // quads it came from are dropped after: the layer keeps its+ // buffer.+ let begin = Self::layer_bounds(mark, layer_num).min(layer.len());+ let end = layer.len();+ for index in begin..end {+ if let Some(clipped) = layer[index].translated_clipped(0.0, 0.0, clip) {+ clipped.faded(clip, fade, &mut |strip| layer.push(strip));+ }+ }+ layer.drain(begin..end);+ }+ }+pub fn quad_count(&self) -> usize {self.layers().iter().map(|(_, quads)| quads.len()).sum()}@@ -1869,4 +2105,147 @@ mod recording_occlusion_tests {// below is gone.assert_eq!(tops, vec![(0.0, 100.0), (0.0, 10.0), (40.0, 70.0)]);}++ #[test]+ fn a_cut_faded_at_its_top_takes_alpha_down_towards_the_edge() {+ let mut heap = HeapQuadAllocator::default();+ let mark = heap.mark();+ {+ let mut quad = heap.allocate(0).unwrap();+ quad.set_position(0.0, -20.0, 100.0, 40.0);+ quad.set_fg_color(LinearRgba(1.0, 1.0, 1.0, 1.0));+ }+ heap.cut_after(+ &mark,+ rect(0.0, 0.0, 100.0, 100.0),+ QuadEdgeFade {+ top: 16.0,+ ..Default::default()+ },+ );+ let strips: Vec<(f32, f32, f32, f32)> = heap+ .layer0+ .iter()+ .map(|q| {+ let corners = q.fg_color_corners.as_deref().copied();+ let alpha = |corner: usize| corners.map_or(q.fg_color[3], |c| c[corner][3]);+ (+ q.position.1,+ q.position.3,+ alpha(V_TOP_LEFT),+ alpha(V_BOT_LEFT),+ )+ })+ .collect();+ // Cut at the edge, then strips across the fade getting more solid+ // downwards, then the rest whole.+ assert_eq!(strips.first().map(|s| (s.0, s.2)), Some((0.0, 0.0)));+ assert_eq!(strips.last().copied(), Some((16.0, 40.0, 1.0, 1.0)));+ assert_eq!(strips.len(), QuadEdgeFade::STEPS + 1);+ for pair in strips.windows(2) {+ assert_eq!(pair[0].1, pair[1].0, "the strips meet");+ assert_eq!(pair[0].3, pair[1].2, "the alpha runs on across them");+ assert!(pair[0].2 <= pair[0].3);+ }+ }++ #[test]+ fn a_cut_with_no_fade_is_a_plain_clip() {+ let mut heap = HeapQuadAllocator::default();+ let mark = heap.mark();+ for top in [-20.0, 40.0, 120.0] {+ heap.allocate(0)+ .unwrap()+ .set_position(0.0, top, 100.0, top + 30.0);+ }+ heap.cut_after(&mark, rect(0.0, 0.0, 100.0, 100.0), QuadEdgeFade::default());+ let tops: Vec<(f32, f32)> = heap+ .layer0+ .iter()+ .map(|q| (q.position.1, q.position.3))+ .collect();+ assert_eq!(tops, vec![(0.0, 10.0), (40.0, 70.0)]);+ }++ #[test]+ fn a_quad_clear_of_the_fades_is_kept_as_it_was() {+ let mut heap = HeapQuadAllocator::default();+ let mark = heap.mark();+ heap.allocate(1)+ .unwrap()+ .set_position(0.0, 40.0, 100.0, 60.0);+ heap.cut_after(+ &mark,+ rect(0.0, 0.0, 100.0, 100.0),+ QuadEdgeFade {+ top: 16.0,+ bottom: 16.0,+ ..Default::default()+ },+ );+ assert_eq!(heap.layer1.len(), 1);+ assert_eq!(heap.layer1[0].position, (0.0, 40.0, 100.0, 60.0));+ assert!(heap.layer1[0].fg_color_corners.is_none());+ }++ #[test]+ fn a_band_faded_in_leaves_what_is_above_and_beside_it() {+ let mut heap = HeapQuadAllocator::default();+ for (left, top) in [(0.0, -30.0), (0.0, 5.0), (200.0, 5.0), (0.0, 60.0)] {+ heap.allocate(0)+ .unwrap()+ .set_position(left, top, left + 100.0, top + 20.0);+ }+ heap.fade_in_across(rect(0.0, 0.0, 100.0, 40.0));+ let quads: Vec<((f32, f32, f32, f32), bool)> = heap+ .layer0+ .iter()+ .map(|q| (q.position, q.fg_color_corners.is_some()))+ .collect();+ // Above: whole. In the band: strips, faded. Beside it and below it:+ // whole, and still in their order after the strips.+ assert_eq!(quads.first(), Some(&((0.0, -30.0, 100.0, -10.0), false)));+ assert!(quads[1..quads.len() - 2].iter().all(|(_, faded)| *faded));+ assert_eq!(quads[quads.len() - 2], ((200.0, 5.0, 300.0, 25.0), false));+ assert_eq!(quads[quads.len() - 1], ((0.0, 60.0, 100.0, 80.0), false));+ }++ #[test]+ fn a_cut_faded_at_its_right_takes_alpha_down_towards_that_edge() {+ let mut heap = HeapQuadAllocator::default();+ let mark = heap.mark();+ {+ let mut quad = heap.allocate(0).unwrap();+ quad.set_position(60.0, 0.0, 140.0, 20.0);+ quad.set_fg_color(LinearRgba(1.0, 1.0, 1.0, 1.0));+ }+ heap.cut_after(+ &mark,+ rect(0.0, 0.0, 100.0, 100.0),+ QuadEdgeFade {+ right: 16.0,+ ..Default::default()+ },+ );+ let strips: Vec<(f32, f32, f32, f32)> = heap+ .layer0+ .iter()+ .map(|q| {+ let corners = q.fg_color_corners.as_deref().copied();+ let alpha = |corner: usize| corners.map_or(q.fg_color[3], |c| c[corner][3]);+ (+ q.position.0,+ q.position.2,+ alpha(V_TOP_LEFT),+ alpha(V_TOP_RIGHT),+ )+ })+ .collect();+ assert_eq!(strips.first().copied(), Some((60.0, 84.0, 1.0, 1.0)));+ assert_eq!(strips.last().map(|s| (s.1, s.3)), Some((100.0, 0.0)));+ for pair in strips.windows(2) {+ assert_eq!(pair[0].1, pair[1].0, "the strips meet");+ assert_eq!(pair[0].3, pair[1].2, "the alpha runs on across them");+ }+ }}diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex c1e8a8f2..536c7e1a 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -3443,9 +3443,13 @@ pub struct TermWindow {/// entry and sets it around the row loop, so it describes that paint and/// no other; a paint that bailed out before the list leaves it `None`.workspace_sidebar_list_quads: Option<(HeapQuadMark, HeapQuadMark)>,- /// The see-through left sidebar's recording buffer, kept from frame to- /// frame: no larger than `WORKSPACE_SIDEBAR_SCRATCH_KEEP_BYTES`, let go- /// when the sidebar collapses.+ /// A tab row's recording buffer, kept from frame to frame and from one+ /// row to the next: no larger than `TAB_ROW_SCRATCH_KEEP_BYTES`, and+ /// let go while the window is hidden.+ tab_row_scratch: HeapQuadAllocator,+ /// The left sidebar's recording buffer, kept from frame to frame: no+ /// larger than `WORKSPACE_SIDEBAR_SCRATCH_KEEP_BYTES`, let go when the+ /// sidebar collapses.workspace_sidebar_scratch: HeapQuadAllocator,workspace_sidebar_scrollbar_visible_until: Option<Instant>,/// The pill at the list's edge while the window's thread is out of@@ -4716,8 +4720,10 @@ impl TermWindow {render_state.dedicated_images.borrow_mut().clear();}self.line_quad_cache.borrow_mut().clear();- // Likewise the scratch recorder: a hidden window records no lines.+ // Likewise the scratch recorders: a hidden window records no lines,+ // nor tab rows.*self.line_quad_scratch.borrow_mut() = HeapQuadAllocator::default();+ self.tab_row_scratch = HeapQuadAllocator::default();// Nor renders cards.self.release_card_frame_buffers();// And the panes last painted, which would keep one closed since@@ -5415,6 +5421,7 @@ impl TermWindow {workspace_space_swipe_target_frame: None,workspace_space_swipe_tracked: false,workspace_sidebar_list_quads: None,+ tab_row_scratch: HeapQuadAllocator::default(),workspace_sidebar_scratch: HeapQuadAllocator::default(),workspace_space_swipe_push_active: false,workspace_space_swipe_direction: 0.0,diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex ba74d589..7422c1b1 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -1,5 +1,5 @@use crate::quad::{- HeapQuadAllocator, QuadClipRect, QuadTrait, TripleLayerQuadAllocator,+ HeapQuadAllocator, QuadClipRect, QuadEdgeFade, QuadTrait, TripleLayerQuadAllocator,TripleLayerQuadAllocatorTrait,};use crate::shapecache::{BorrowedShapeCacheKey, ShapedInfo};@@ -8,7 +8,7 @@ use crate::termwindow::ui::icons::SvgIcon;use crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons;use crate::termwindow::ui::tokens::{ICON_BUTTON_BORDER_WIDTH, SIDEBAR_INSET, TAB_CLOSE_HOVER_INSET, TAB_CLOSE_HOVER_RADIUS,- TAB_CONTENT_INSET, TAB_ICON_SIZE, TAB_ROW_START_PADDING, TAB_TITLE_FADE_GAP,+ TAB_CONTENT_INSET, TAB_ICON_SIZE, TAB_ROW_FADE_WIDTH, TAB_ROW_START_PADDING, TAB_TITLE_FADE_GAP,TAB_VERTICAL_PADDING, TITLE_FADE, WINDOW_TAB_ADD_BUTTON_RADIUS,WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET, WINDOW_TAB_GAP,WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP,@@ -33,6 +33,8 @@ const WINDOW_TAB_INSET: usize = 8;const WINDOW_TAB_ICON_GAP: usize = 8;const WINDOW_TAB_MIN_TEXT_COLS: usize = 3;const UI_SHAPE_CACHE_FONT_IDENTITY_BIT: u64 = 1u64 << 63;+/// The largest recording of a tab row kept for the next frame.+pub(crate) const TAB_ROW_SCRATCH_KEEP_BYTES: usize = 1 << 20;impl crate::TermWindow {@@ -153,6 +155,15 @@ impl crate::TermWindow {let cv_active = self.active_content_view_shown_in_tab_bar();let show_mux_tabs = !self.active_content_view_is_remote_thread();+ // The tabs are recorded, so that where the row runs on past its+ // viewport it can fade out in their own alpha: over a see-through+ // bar a fade of its ground would show as a band.+ let into = &mut *layers;+ let mut row = std::mem::take(&mut self.tab_row_scratch);+ row.recycle();+ let row_start = row.mark();+ let layers = &mut TripleLayerQuadAllocator::Heap(&mut row);+let tab_step = tab_width + self.ui_px(WINDOW_TAB_GAP);let mut tab_sequence_idx = 0usize;if show_mux_tabs {@@ -247,13 +258,12 @@ impl crate::TermWindow {// Dissolve the row into the bar wherever it runs on past the viewport,// so a clipped tab reads as continuing rather than as one sliced in- // half. Goes down after the tabs and before the trailing actions, which- // own the space beyond the boundary.- self.paint_tab_row_fades(- layers,- background,- content_row_y,- content_row_height,+ // half. What follows paints straight into the bar again.+ let layers = into;+ self.apply_tab_row(+ row,+ &row_start,+ &mut *layers,viewport_left,viewport_right,scroll_offset > 0.5,@@ -285,6 +295,45 @@ impl crate::TermWindow {Ok(ui_items)}+ /// Replay a tab `row` recorded from `start` into `layers`, cut at its+ /// viewport and fading out at the ends that run on past it; then keep+ /// its buffer for the next row, unless it grew large.+ #[allow(clippy::too_many_arguments)]+ pub(crate) fn apply_tab_row(+ &mut self,+ mut row: HeapQuadAllocator,+ start: &crate::quad::HeapQuadMark,+ layers: &mut TripleLayerQuadAllocator,+ viewport_left: usize,+ viewport_right: usize,+ fade_at_left: bool,+ fade_at_right: bool,+ ) -> anyhow::Result<()> {+ let width = self+ .ui_px(TAB_ROW_FADE_WIDTH)+ .min(viewport_right.saturating_sub(viewport_left) / 2) as f32;+ row.cut_after(+ start,+ QuadClipRect::from_top_left_pixels(+ viewport_left as f32,+ 0.0,+ viewport_right as f32,+ self.dimensions.pixel_height as f32,+ &self.dimensions,+ ),+ QuadEdgeFade {+ left: if fade_at_left { width } else { 0.0 },+ right: if fade_at_right { width } else { 0.0 },+ ..Default::default()+ },+ );+ let applied = row.apply_to(layers);+ if row.resident_bytes() <= TAB_ROW_SCRATCH_KEEP_BYTES {+ self.tab_row_scratch = row;+ }+ applied+ }+pub(crate) fn paint_window_tab_trailing_actions(&self,layers: &mut TripleLayerQuadAllocator,diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex 12c1b5d0..08c3a7e1 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -55,8 +55,7 @@ const MAX_PREVIEW_FILL: f32 = 1.5;/// Height of the pane layer divider the tab bar draws below itself, in the same/// device pixels the divider quad uses. Kept in step with `fancy_tab_bar`.const TAB_BAR_SEAM_HEIGHT: f32 = 1.0;-/// The largest recording buffer the see-through left sidebar keeps for the-/// next frame.+/// The largest recording buffer the left sidebar keeps for the next frame.const WORKSPACE_SIDEBAR_SCRATCH_KEEP_BYTES: usize = 8 << 20;/// How many cards may rebuild their recorded quads in one frame.@@ -5690,20 +5689,13 @@ impl crate::TermWindow {}}} else if capture_space_source {- // See-through, the sidebar's list is cut to its viewport, which- // takes a recording: record, then draw what was recorded.- if self.chrome_see_through() {- let mut sidebar_layers = TripleLayerQuadAllocator::Heap(&mut sidebar_frame);- self.paint_workspace_sidebar(&mut sidebar_layers)- .context("capture source workspace sidebar")?;- drop(sidebar_layers);- sidebar_frame.apply_to(&mut layer.quad_allocator())?;- } else {- let mut sidebar_layers = layer.tee_quad_allocator(&mut sidebar_frame);- self.paint_workspace_sidebar(&mut sidebar_layers)- .context("capture source workspace sidebar")?;- drop(sidebar_layers);- }+ // The sidebar's list is cut and faded at its ends, which takes+ // a recording: record, then draw what was recorded.+ let mut sidebar_layers = TripleLayerQuadAllocator::Heap(&mut sidebar_frame);+ self.paint_workspace_sidebar(&mut sidebar_layers)+ .context("capture source workspace sidebar")?;+ drop(sidebar_layers);+ sidebar_frame.apply_to(&mut layer.quad_allocator())?;self.workspace_space_swipe_source_frame =Some(crate::termwindow::CapturedSidebar {@@ -5739,9 +5731,9 @@ impl crate::TermWindow {self.replay_pane(&recorded, &mut layer.quad_allocator(), sliver).context("replay sliding workspace sidebar's edge")?;}- } else if self.chrome_see_through() {- // As above: the list is cut in a recording, one whose buffer- // is kept from frame to frame.+ } else {+ // As above: the list is cut and faded in a recording, one+ // whose buffer is kept from frame to frame.let mut recorded = std::mem::take(&mut self.workspace_sidebar_scratch);recorded.recycle();let mut sidebar_layers = TripleLayerQuadAllocator::Heap(&mut recorded);@@ -5756,11 +5748,6 @@ impl crate::TermWindow {self.workspace_sidebar_scratch = recorded;}applied?;- } else {- let mut sidebar_layers = layer.quad_allocator();- self.paint_workspace_sidebar(&mut sidebar_layers)- .context("paint_workspace_sidebar")?;- drop(sidebar_layers);}let mut chrome_layers = layer.quad_allocator();diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex 66a90159..2c8a7d27 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -888,6 +888,14 @@ impl crate::TermWindow {let tab_height = button_size;let tab_y = button_y;let tab_fg = if pos.is_active { foreground } else { muted_fg };+ // The tabs are recorded, so that where the strip runs on past its+ // viewport it can fade out in their own alpha: over a see-through+ // bar a fade of its ground would show as a band.+ let into = &mut *layers;+ let mut row = std::mem::take(&mut self.tab_row_scratch);+ row.recycle();+ let row_start = row.mark();+ let layers = &mut TripleLayerQuadAllocator::Heap(&mut row);for (idx, tab) in tabs.into_iter().enumerate() {if tab_width <= icon_size + self.ui_px(PANE_NAV_ICON_GAP) + button_size|| viewport_width == 0@@ -1121,11 +1129,10 @@ impl crate::TermWindow {// Dissolve the strip into the bar wherever it runs on past its// viewport, so a clipped tab reads as continuing rather than as one// sliced in half.- self.paint_tab_row_fades(- layers,- self.collapsed_bar_surface(),- tab_y,- tab_height,+ self.apply_tab_row(+ row,+ &row_start,+ into,tab_start,max_tab_right,scroll_offset > 0.5,@@ -1473,6 +1480,14 @@ impl crate::TermWindow {.collect(),None => vec![],};+ // The tabs are recorded, so that where the strip runs on past its+ // viewport it can fade out in their own alpha: over a see-through+ // bar a fade of its ground would show as a band.+ let into = &mut *layers;+ let mut row = std::mem::take(&mut self.tab_row_scratch);+ row.recycle();+ let row_start = row.mark();+ let layers = &mut TripleLayerQuadAllocator::Heap(&mut row);for place in places {if tab_width <= icon_size + self.ui_px(PANE_NAV_ICON_GAP) + button_size|| viewport_width == 0@@ -1766,11 +1781,10 @@ impl crate::TermWindow {// Dissolve the strip into the bar wherever it runs on past its// viewport, so a clipped tab reads as continuing rather than as one// sliced in half.- self.paint_tab_row_fades(- layers,- background,- pane_y.max(0.0) as usize,- nav_height,+ self.apply_tab_row(+ row,+ &row_start,+ into,tab_start,max_tab_right,scroll_offset > 0.5,diff --git a/wezterm-gui/src/termwindow/ui/mod.rs b/wezterm-gui/src/termwindow/ui/mod.rsindex e6f15b72..904f9658 100644--- a/wezterm-gui/src/termwindow/ui/mod.rs+++ b/wezterm-gui/src/termwindow/ui/mod.rs@@ -114,89 +114,6 @@ impl crate::TermWindow {Ok(())}- /// Dissolve a tab row into the bar at an edge the viewport cut.- ///- /// A tab sliced mid-body reads as a paint bug however honestly its corner- /// is squared off; ramping the bar's own colour over the last few pixels- /// turns the same cut into the row visibly continuing past the boundary.- /// Modelled on `ssh_hosts_view::paint_list_fades`, which does this for a- /// scrolling list's top and bottom.- ///- /// Painted on layer 2, above the tab surfaces and their icons, so it has to- /// go down after the tabs and before whatever owns the space beyond the- /// boundary.- #[allow(clippy::too_many_arguments)]- pub(crate) fn paint_tab_row_fades(- &self,- layers: &mut crate::quad::TripleLayerQuadAllocator,- background: ::window::color::LinearRgba,- row_y: usize,- row_height: usize,- viewport_left: usize,- viewport_right: usize,- fade_at_left: bool,- fade_at_right: bool,- ) -> anyhow::Result<()> {- use crate::ui::anim::Easing;- use anyhow::Context;- // The tabs are clipped at the viewport already; over a see-through- // bar this fade would only darken a band of it.- if self.chrome_see_through() {- return Ok(());- }-- if row_height == 0 || viewport_right <= viewport_left {- return Ok(());- }- let width = self- .ui_px(crate::termwindow::ui::tokens::TAB_ROW_FADE_WIDTH)- .min(viewport_right - viewport_left);- if width == 0 {- return Ok(());- }-- if fade_at_left {- for step in 0..width {- let progress = step as f32 / width as f32;- let alpha = 1.0 - Easing::Smooth.apply(progress);- self.filled_rectangle(- layers,- 2,- euclid::rect(- (viewport_left + step) as f32,- row_y as f32,- 1.0,- row_height as f32,- ),- background.mul_alpha(alpha),- )- .context("tab row leading fade")?;- }- }-- if fade_at_right {- let start = viewport_right - width;- for step in 0..width {- let progress = (step + 1) as f32 / width as f32;- let alpha = Easing::Smooth.apply(progress);- self.filled_rectangle(- layers,- 2,- euclid::rect(- (start + step) as f32,- row_y as f32,- 1.0,- row_height as f32,- ),- background.mul_alpha(alpha),- )- .context("tab row trailing fade")?;- }- }-- Ok(())- }-/// Left edge of a tab's close-button box, placed so the glyph inside it/// lands `TAB_CONTENT_INSET` from the tab's right edge — the same inset the/// leading icon keeps on the left. Derived rather than a fixed gap so thediff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rsindex 35319e67..3f656852 100644--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs@@ -10160,7 +10160,6 @@ impl crate::TermWindow {visible_height,row_metrics.row_height,);- let see_through = self.chrome_see_through();self.paint_right_sidebar_contents(layers, |this, layers| {let selected = this.right_sidebar_note@@ -10171,13 +10170,9 @@ impl crate::TermWindow {let row = &rows[index];let y = tree_top as f32 + (index * row_metrics.row_height) as f32- this.right_sidebar_note_tree_scroll_offset;- // Opaque, a row scrolled part-way out stays whole at the top,- // under the fade. See-through has no fade, so the row keeps its- // place and what is above the list is cut away after the loop.- let y = y- .floor()- .max(if see_through { 0.0 } else { tree_top as f32 })- as usize;+ // A row scrolled part-way out keeps its place: what is above+ // the list is cut away after the loop.+ let y = y.floor().max(0.0) as usize;let height = row_metrics.row_height.min(tree_bottom.saturating_sub(y));// What is hovered and clicked: the part inside the list.let hit_y = y.max(tree_top);@@ -10269,16 +10264,14 @@ impl crate::TermWindow {if active { foreground } else { muted_fg },)?;}- if see_through {- this.paint_right_sidebar_file_mask(- layers,- chrome,- content_x,- content_top,- content_width,- tree_top.saturating_sub(content_top),- )?;- }+ this.paint_right_sidebar_file_mask(+ layers,+ chrome,+ content_x,+ content_top,+ content_width,+ tree_top.saturating_sub(content_top),+ )?;Ok(())})?;@@ -18705,7 +18698,7 @@ impl crate::TermWindow {width: usize,height: usize,) -> anyhow::Result<()> {- if width == 0 || height == 0 || self.chrome_see_through() {+ if width == 0 || height == 0 {return Ok(());}let opaque_height = self.ui_px(12).min(height);@@ -18756,19 +18749,16 @@ impl crate::TermWindow {}/// Paints `contents` -- what a panel holds, over the ground it has- /// already painted -- into `layers`. See-through, they are recorded on- /// their own first, so that the scroll masks painted among them cut what- /// they cover out of what `contents` painted before them: painting the- /// ground over it again, as an opaque window does, would show as a darker- /// band. Nested, the inner block's masks cut only the inner block.+ /// already painted -- into `layers`. They are recorded on their own+ /// first, so that the scroll masks and fades painted among them cut and+ /// fade what `contents` painted before them: painting the ground over it+ /// again would show as a darker band over a see-through ground. Nested,+ /// the inner block's masks cut only the inner block.pub(crate) fn paint_right_sidebar_contents(&mut self,layers: &mut TripleLayerQuadAllocator,contents: impl FnOnce(&mut Self, &mut TripleLayerQuadAllocator) -> anyhow::Result<()>,) -> anyhow::Result<()> {- if !self.chrome_see_through() {- return contents(self, layers);- }let mut recorded = self.right_sidebar_contents_scratch.pop()@@ -18794,9 +18784,25 @@ impl crate::TermWindow {width: usize,height: usize,) -> anyhow::Result<()> {- // See-through, the list is cut where the mask begins instead: a fade- // of the ground over it would darken the ground.- if width == 0 || height == 0 || self.chrome_see_through() {+ if width == 0 || height == 0 {+ return Ok(());+ }+ // In what is being recorded, the list fades in its own alpha.+ if self.right_sidebar_recording_contents {+ if let TripleLayerQuadAllocator::Heap(contents) = layers {+ contents.fade_in_across(QuadClipRect::from_top_left_pixels(+ x as f32,+ y as f32,+ (x + width) as f32,+ (y + height) as f32,+ &self.dimensions,+ ));+ return Ok(());+ }+ }+ // Otherwise a fade of the ground over a see-through one would+ // darken it: the list is left cut where the mask begins.+ if self.chrome_see_through() {return Ok(());}diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 3e087aea..b67fe3f5 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -3677,14 +3677,28 @@ impl crate::TermWindow {}}- // See-through, a row scrolled under the header or the footer is cut- // off there: the covers painted over it opaque would show as darker- // bands. Only a recording can be cut, so the see-through callers- // record; anything else keeps the covers. So does a Library card,- // whose covers would square its corners.- let list_cut = match (see_through || card, list_quads_start, &mut *layers) {- (true, Some(start), TripleLayerQuadAllocator::Heap(heap)) => {- heap.clip_after(+ // A row scrolled under the header or the footer is cut off there,+ // and the list fades out towards the end it goes on past -- in the+ // rows' own alpha, so that it reads the same over a see-through+ // ground. Only a recording can be cut, so the callers record;+ // anything else gets covers painted over the ends instead.+ let list_height = content_bottom.saturating_sub(list_top);+ let list_fade = crate::quad::QuadEdgeFade {+ top: if scroll_offset > 0.0 {+ self.ui_px(SIDEBAR_TOP_FADE_HEIGHT).min(list_height / 2) as f32+ } else {+ 0.0+ },+ bottom: if settings_footer_height > 0 && scroll_offset < max_scroll {+ self.ui_px(SIDEBAR_SETTINGS_FADE_HEIGHT).min(list_height / 2) as f32+ } else {+ 0.0+ },+ ..Default::default()+ };+ let list_cut = match (list_quads_start, &mut *layers) {+ (Some(start), TripleLayerQuadAllocator::Heap(heap)) => {+ heap.cut_after(&start,crate::quad::QuadClipRect::from_top_left_pixels(panel_x as f32,@@ -3693,6 +3707,7 @@ impl crate::TermWindow {content_bottom_f,&self.dimensions,),+ list_fade,);true}@@ -3700,10 +3715,6 @@ impl crate::TermWindow {};self.workspace_sidebar_list_quads = list_quads_start.zip(layers.heap_mark());- // The fades over the ends of the list, wherever they read as fades:- // not over a see-through ground, where they would be bands.- let list_fades = !list_cut || (card && !see_through);-let header_mask_height = list_top.saturating_sub(panel_y);// Covers what the list left under the header, then paints the header// again over that. Not once the list is cut: the header painted first@@ -3927,28 +3938,6 @@ impl crate::TermWindow {}}- if max_scroll > 0.0 && scroll_offset > 0.0 && list_fades {- let fade_height = self- .ui_px(SIDEBAR_TOP_FADE_HEIGHT)- .min(content_bottom.saturating_sub(list_top));- for step in 0..fade_height {- let progress = step as f32 / fade_height as f32;- let alpha = 1.0 - progress * progress * (3.0 - 2.0 * progress);- self.filled_rectangle(- layers,- 2,- euclid::rect(- panel_x as f32,- (list_top + step) as f32,- panel_width as f32,- 1.0,- ),- sidebar_bg.mul_alpha(alpha),- )- .context("sidebar top scroll fade")?;- }- }-let bottom_mask_height = panel_y.saturating_add(panel_height).saturating_sub(content_bottom);@@ -3968,27 +3957,6 @@ impl crate::TermWindow {}if settings_footer_height > 0 {- let fade_height = self- .ui_px(SIDEBAR_SETTINGS_FADE_HEIGHT)- .min(settings_footer_y.saturating_sub(panel_y))- .min(content_bottom.saturating_sub(panel_y));- if max_scroll > 0.0 && fade_height > 0 && list_fades {- for step in 0..fade_height {- let progress = (step + 1) as f32 / fade_height as f32;- self.filled_rectangle(- layers,- 2,- euclid::rect(- panel_x as f32,- (settings_footer_y.saturating_sub(fade_height) + step) as f32,- panel_width as f32,- 1.0,- ),- sidebar_bg.mul_alpha(progress * progress * (3.0 - 2.0 * progress)),- )- .context("sidebar settings fade")?;- }- }// A Library card has no footer: what follows is set apart, for// the sidebar on its way into its card to let go of.if card {