Skip to content

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.

feat(gui): animate sidebar folders and the rows that move

RoversX373e5dfd52ef
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 12c6ef63..c1e8a8f2 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -168,6 +168,7 @@ pub mod resize;
pub(crate) mod share;
mod selection;
mod sidebar_hover;
+mod sidebar_disclosure;
mod sidebar_make_way;
mod sidebar_slide;
mod space_swipe;
@@ -3336,6 +3337,12 @@ pub struct TermWindow {
sidebar_row_drag: Option<SidebarRowDragState>,
sidebar_row_landing: Option<DragLanding<SidebarRowKind>>,
sidebar_make_way: sidebar_make_way::SidebarMakeWay,
+ folder_chevrons: sidebar_disclosure::FolderChevrons,
+ sidebar_row_places: sidebar_make_way::RowPlaces,
+ /// A folder's rows as they are recorded, to be replayed faded while it
+ /// opens and closes; kept unless it grew large, so that a frame records
+ /// into the last one's buffers.
+ sidebar_folder_rows: crate::quad::HeapQuadAllocator,
/// Content views (e.g. SSH hosts) shown as synthetic tabs.
content_views: Vec<ContentViewTab>,
active_content_view_id: Option<ContentViewId>,
@@ -5361,6 +5368,9 @@ impl TermWindow {
sidebar_row_drag: None,
sidebar_row_landing: None,
sidebar_make_way: Default::default(),
+ folder_chevrons: Default::default(),
+ sidebar_row_places: Default::default(),
+ sidebar_folder_rows: Default::default(),
pane_tab_landing: None,
content_views: vec![],
active_content_view_id: None,
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index 4e93ed0e..12c1b5d0 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -5954,6 +5954,12 @@ impl crate::TermWindow {
.context("paint_pane_tab_drag_overlay")?;
self.paint_sidebar_row_drag_overlay()
.context("paint_sidebar_row_drag_overlay")?;
+ // Once a frame, after every sidebar this frame painted.
+ let now = Instant::now();
+ if self.folder_chevrons.step(now) {
+ self.update_next_frame_time(Some(now + Duration::from_millis(16)));
+ }
+ self.sidebar_row_places.end_frame();
self.paint_file_drag_ghost()
.context("paint_file_drag_ghost")?;
// Last, so the tag sits above every chrome surface it might overhang.
diff --git a/wezterm-gui/src/termwindow/sidebar_disclosure.rs b/wezterm-gui/src/termwindow/sidebar_disclosure.rs
new file mode 100644
index 00000000..ac0a5515
--- /dev/null
+++ b/wezterm-gui/src/termwindow/sidebar_disclosure.rs
@@ -0,0 +1,256 @@
+//! The chevron beside a sidebar folder's add button: there only while the
+//! pointer is over the folder's row, and turning as the folder opens and
+//! closes.
+//!
+//! Only folders painted since the last step are kept, so the table is no
+//! bigger than the folders on screen and lets go of the rest at once.
+
+use std::collections::HashMap;
+use std::time::{Duration, Instant};
+
+/// The rotation frames the chevron's sprite is cut into, a full turn's worth:
+/// a quarter turn, from pointing right to pointing down, takes a quarter of
+/// them.
+pub(crate) const CHEVRON_FRAMES: u8 = 48;
+/// Time constant of the ease: most of the way in three of these.
+const TAU: Duration = Duration::from_millis(50);
+/// Close enough to where it is going.
+const NEAR: f32 = 0.01;
+
+/// Which list a folder's id is from: a project's and a reference group's
+/// need not differ.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(crate) enum FolderKind {
+ Project,
+ RefGroup,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+struct Chevron {
+ shown: f32,
+ show_to: f32,
+ open: f32,
+ open_to: f32,
+ /// The step it was last painted before.
+ painted: u64,
+}
+
+#[derive(Debug, Default)]
+pub(crate) struct FolderChevrons {
+ projects: HashMap<String, Chevron>,
+ groups: HashMap<String, Chevron>,
+ /// Counts the steps; a chevron painted since the last one carries it.
+ step: u64,
+ last_tick: Option<Instant>,
+ /// Until the next step, every folder is drawn where it is going.
+ landing: bool,
+}
+
+impl FolderChevrons {
+ fn of_kind(&mut self, kind: FolderKind) -> &mut HashMap<String, Chevron> {
+ match kind {
+ FolderKind::Project => &mut self.projects,
+ FolderKind::RefGroup => &mut self.groups,
+ }
+ }
+
+ /// Where `id`'s chevron is in the frame being painted, heading for
+ /// `shown` and `open`: how far it has faded in and how far it has turned
+ /// towards open, each 0 to 1. A folder not met before starts where it is
+ /// going, so nothing turns as the sidebar first appears.
+ pub fn aim(&mut self, kind: FolderKind, id: &str, shown: bool, open: bool) -> (f32, f32) {
+ let show_to = if shown { 1.0 } else { 0.0 };
+ let open_to = if open { 1.0 } else { 0.0 };
+ let step = self.step;
+ let landing = self.landing;
+ let chevrons = self.of_kind(kind);
+ if let Some(chevron) = chevrons.get_mut(id) {
+ chevron.show_to = show_to;
+ chevron.open_to = open_to;
+ chevron.painted = step;
+ if landing {
+ chevron.open = open_to;
+ }
+ return (chevron.shown, chevron.open);
+ }
+ chevrons.insert(
+ id.to_string(),
+ Chevron {
+ shown: show_to,
+ show_to,
+ open: open_to,
+ open_to,
+ painted: step,
+ },
+ );
+ (show_to, open_to)
+ }
+
+ /// How far open `id` is drawn, if it was painted lately.
+ pub fn open_of(&self, kind: FolderKind, id: &str) -> Option<f32> {
+ if self.landing {
+ return None;
+ }
+ let chevrons = match kind {
+ FolderKind::Project => &self.projects,
+ FolderKind::RefGroup => &self.groups,
+ };
+ chevrons.get(id).map(|chevron| chevron.open)
+ }
+
+ /// Draw every folder where it is going in the next frame, without
+ /// the turn: for a jump to a row inside one, which needs the list as it
+ /// will be.
+ pub fn land(&mut self) {
+ self.landing = true;
+ }
+
+ /// A folder is opening or closing: its rows, and the list after them,
+ /// are on their way somewhere.
+ pub fn folding(&self) -> bool {
+ self.projects
+ .values()
+ .chain(self.groups.values())
+ .any(|chevron| chevron.open != chevron.open_to)
+ }
+
+ /// Advance the chevrons painted since the last step and forget the rest.
+ /// Returns whether any is still moving.
+ pub fn step(&mut self, now: Instant) -> bool {
+ self.landing = false;
+ let step = self.step;
+ self.step += 1;
+ self.projects.retain(|_, chevron| chevron.painted == step);
+ self.groups.retain(|_, chevron| chevron.painted == step);
+ // A starved frame must not land as one huge jump.
+ let dt = self.last_tick.map_or(Duration::from_millis(16), |last| {
+ now.saturating_duration_since(last)
+ .min(Duration::from_millis(100))
+ });
+ let k = 1.0 - (-(dt.as_secs_f32() / TAU.as_secs_f32())).exp();
+ let mut moving = false;
+ for chevron in self.projects.values_mut().chain(self.groups.values_mut()) {
+ moving |= ease(&mut chevron.shown, chevron.show_to, k);
+ moving |= ease(&mut chevron.open, chevron.open_to, k);
+ }
+ self.last_tick = moving.then_some(now);
+ moving
+ }
+}
+
+/// The rotation frame for a chevron turned `open` of the way to open.
+pub(crate) fn chevron_frame(open: f32) -> u8 {
+ let quarter = f32::from(CHEVRON_FRAMES / 4);
+ (open.clamp(0.0, 1.0) * quarter).round() as u8
+}
+
+/// Whether `value` changed: the step that lands it on `to` counts, so that
+/// the frame showing it there is still asked for.
+fn ease(value: &mut f32, to: f32, k: f32) -> bool {
+ if *value == to {
+ return false;
+ }
+ if (to - *value).abs() <= NEAR {
+ *value = to;
+ } else {
+ *value += (to - *value) * k;
+ }
+ true
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn settle(chevrons: &mut FolderChevrons, id: &str, shown: bool, open: bool) {
+ let mut now = Instant::now();
+ for _ in 0..200 {
+ chevrons.aim(FolderKind::Project, id, shown, open);
+ now += Duration::from_millis(16);
+ if !chevrons.step(now) {
+ return;
+ }
+ }
+ panic!("the chevron never settled");
+ }
+
+ #[test]
+ fn a_folder_met_for_the_first_time_does_not_move() {
+ let mut chevrons = FolderChevrons::default();
+ assert_eq!(
+ chevrons.aim(FolderKind::Project, "a", false, true),
+ (0.0, 1.0)
+ );
+ assert!(!chevrons.step(Instant::now()));
+ }
+
+ #[test]
+ fn a_chevron_fades_in_under_the_pointer_and_out_again() {
+ let mut chevrons = FolderChevrons::default();
+ chevrons.aim(FolderKind::Project, "a", false, true);
+ chevrons.step(Instant::now());
+ chevrons.aim(FolderKind::Project, "a", true, true);
+ assert!(chevrons.step(Instant::now()));
+ let (shown, _) = chevrons.aim(FolderKind::Project, "a", true, true);
+ assert!(shown > 0.0 && shown < 1.0);
+ settle(&mut chevrons, "a", true, true);
+ assert_eq!(chevrons.aim(FolderKind::Project, "a", true, true).0, 1.0);
+ settle(&mut chevrons, "a", false, true);
+ assert_eq!(chevrons.aim(FolderKind::Project, "a", false, true).0, 0.0);
+ }
+
+ #[test]
+ fn closing_a_folder_turns_its_chevron_back_to_pointing_right() {
+ let mut chevrons = FolderChevrons::default();
+ chevrons.aim(FolderKind::Project, "a", true, true);
+ chevrons.step(Instant::now());
+ settle(&mut chevrons, "a", true, false);
+ assert_eq!(
+ chevron_frame(chevrons.aim(FolderKind::Project, "a", true, false).1),
+ 0
+ );
+ settle(&mut chevrons, "a", true, true);
+ assert_eq!(
+ chevron_frame(chevrons.aim(FolderKind::Project, "a", true, true).1),
+ CHEVRON_FRAMES / 4
+ );
+ }
+
+ #[test]
+ fn the_last_frame_asked_for_shows_the_folder_where_it_was_going() {
+ let mut chevrons = FolderChevrons::default();
+ chevrons.aim(FolderKind::Project, "a", true, true);
+ chevrons.step(Instant::now());
+ let mut now = Instant::now();
+ for _ in 0..200 {
+ let painted = chevrons.aim(FolderKind::Project, "a", false, false);
+ now += Duration::from_millis(16);
+ if !chevrons.step(now) {
+ assert_eq!(painted, (0.0, 0.0));
+ return;
+ }
+ }
+ panic!("the chevron never settled");
+ }
+
+ #[test]
+ fn a_landed_folder_is_drawn_open_at_once() {
+ let mut chevrons = FolderChevrons::default();
+ chevrons.aim(FolderKind::Project, "a", true, false);
+ chevrons.step(Instant::now());
+ chevrons.land();
+ assert_eq!(chevrons.open_of(FolderKind::Project, "a"), None);
+ assert_eq!(chevrons.aim(FolderKind::Project, "a", true, true).1, 1.0);
+ chevrons.step(Instant::now());
+ assert_eq!(chevrons.open_of(FolderKind::Project, "a"), Some(1.0));
+ }
+
+ #[test]
+ fn a_folder_no_longer_painted_is_forgotten() {
+ let mut chevrons = FolderChevrons::default();
+ chevrons.aim(FolderKind::Project, "a", true, true);
+ chevrons.step(Instant::now());
+ chevrons.step(Instant::now());
+ assert!(chevrons.projects.is_empty());
+ }
+}
diff --git a/wezterm-gui/src/termwindow/sidebar_make_way.rs b/wezterm-gui/src/termwindow/sidebar_make_way.rs
index f3321a44..ede5a9da 100644
--- a/wezterm-gui/src/termwindow/sidebar_make_way.rs
+++ b/wezterm-gui/src/termwindow/sidebar_make_way.rs
@@ -72,6 +72,23 @@ impl SidebarMakeWay {
}
}
+ /// Rows the list itself has just moved by `by`, a row taken away or
+ /// added above them: drawn where they were, going on from there.
+ pub fn glide(&mut self, id: &str, by: f32) {
+ self.shifts
+ .entry(id.to_string())
+ .or_insert(Shift {
+ drawn: 0.0,
+ going: 0.0,
+ })
+ .drawn += by;
+ }
+
+ /// Nothing is moving aside or settling.
+ pub fn is_idle(&self) -> bool {
+ self.shifts.is_empty()
+ }
+
/// The drag is over. With `moved`, the list has just changed to what the
/// rows were heading for, so each is now at home in a new place, still
/// drawn where it was: it goes on from there rather than jumping. Without
@@ -96,6 +113,8 @@ impl SidebarMakeWay {
let mut moving = false;
for shift in self.shifts.values_mut() {
if (shift.going - shift.drawn).abs() <= NEAR {
+ // Landing counts: the frame that shows it landed is owed.
+ moving |= shift.drawn != shift.going;
shift.drawn = shift.going;
} else {
shift.drawn += (shift.going - shift.drawn) * k;
@@ -109,10 +128,292 @@ impl SidebarMakeWay {
}
}
+/// Where the list laid out each of its rows in the paint before, so that a
+/// row the list itself moves -- one taken away or added above it, or the row
+/// itself pinned or put back -- can be drawn going there rather than
+/// jumping. Holds the rows of one Space as last painted, updated in place, so
+/// it is no bigger than the list and a frame allocates only for rows it has
+/// not seen.
+#[derive(Debug, Default)]
+pub(crate) struct RowPlaces {
+ space: String,
+ places: HashMap<String, Place>,
+ /// Counts the paints.
+ paint: u64,
+ /// Whether the list was painted in the frame under way.
+ painted: bool,
+ /// Whether this paint has nothing before it to compare with.
+ fresh: bool,
+ /// Where the list was scrolled to in the last paint.
+ scroll: f32,
+ /// Whether this paint's list is scrolled as the last one's was.
+ steady: bool,
+ /// Whether a row has appeared in this paint, above the rows still to
+ /// be noted.
+ grown: bool,
+}
+
+#[derive(Debug, Clone)]
+struct Place {
+ /// The part of the list `was` and `is` are counted in.
+ within: String,
+ was: f32,
+ is: f32,
+ /// The same two counted from the top of the list.
+ was_in_list: f32,
+ is_in_list: f32,
+ paint: u64,
+}
+
+impl RowPlaces {
+ /// A paint of `space`'s list, scrolled to `scroll`, starts. Rows the
+ /// last paint did not lay out are let go of. Nothing is compared in a
+ /// paint scrolled from where the last one was: a list that shrank under
+ /// its scrolled end is pulled down by as much as its rows go up, so on
+ /// screen they have not moved.
+ pub fn begin(&mut self, space: &str, scroll: f32) {
+ self.fresh = self.space != space || self.places.is_empty();
+ if self.space != space {
+ self.space.clear();
+ self.space.push_str(space);
+ self.places.clear();
+ }
+ let last = self.paint;
+ self.places.retain(|_, place| place.paint == last);
+ self.paint += 1;
+ self.painted = true;
+ self.steady = (scroll - self.scroll).abs() < NEAR;
+ self.scroll = scroll;
+ self.grown = false;
+ }
+
+ /// A frame is done. One that did not paint the list (the sidebar away,
+ /// say) lets go of every row: the list may move while nobody watches.
+ pub fn end_frame(&mut self) {
+ if !std::mem::take(&mut self.painted) {
+ self.places.clear();
+ }
+ }
+
+ /// `id` is laid out at `place` in this paint, counted from the top of
+ /// `within` (a folder, say), and at `in_list` from the top of the list.
+ /// Returns how far up it is to be drawn from there, as far up as the
+ /// list has moved it since the paint before. `carried` is how far its
+ /// part of the list was just sent the same way, which a row staying in
+ /// it shares and a row new to it does not.
+ ///
+ /// After a row new to the list, the rows going down to make room for it
+ /// would slide over it, so they and the rest are put in place at once:
+ /// all but one come from another part of the list, which is going far.
+ pub fn note(
+ &mut self,
+ id: &str,
+ within: &str,
+ place: f32,
+ in_list: f32,
+ carried: f32,
+ ) -> Option<f32> {
+ let paint = self.paint;
+ let Some(known) = self.places.get_mut(id) else {
+ self.places.insert(
+ id.to_string(),
+ Place {
+ within: within.to_string(),
+ was: place,
+ is: place,
+ was_in_list: in_list,
+ is_in_list: in_list,
+ paint,
+ },
+ );
+ self.grown |= !self.fresh;
+ return None;
+ };
+ if known.paint != paint {
+ known.was = known.is;
+ known.was_in_list = known.is_in_list;
+ known.paint = paint;
+ }
+ known.is = place;
+ known.is_in_list = in_list;
+ let crossed = known.within != within;
+ let by = if crossed {
+ known.within.clear();
+ known.within.push_str(within);
+ known.was_in_list - in_list - carried
+ } else {
+ known.was - place
+ };
+ let crowded = self.grown && !crossed;
+ (self.steady && !crowded && by.abs() >= NEAR).then_some(by)
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
+ /// One frame painting the list once, noting `rows` as (id, within,
+ /// place, place in the list, carried).
+ fn paint(
+ places: &mut RowPlaces,
+ scroll: f32,
+ rows: &[(&str, &str, f32, f32, f32)],
+ ) -> Vec<Option<f32>> {
+ places.begin("s", scroll);
+ let moved = rows
+ .iter()
+ .map(|(id, within, place, in_list, carried)| {
+ places.note(id, within, *place, *in_list, *carried)
+ })
+ .collect();
+ places.end_frame();
+ moved
+ }
+
+ #[test]
+ fn a_row_the_list_moves_is_reported_once() {
+ let mut places = RowPlaces::default();
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "", 40.0, 40.0, 0.0)]),
+ [None]
+ );
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "", 20.0, 20.0, 0.0)]),
+ [Some(20.0)]
+ );
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "", 20.0, 20.0, 0.0)]),
+ [None]
+ );
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "", 60.0, 60.0, 0.0)]),
+ [Some(-40.0)]
+ );
+ }
+
+ #[test]
+ fn a_row_painted_twice_in_a_paint_is_reported_both_times() {
+ let mut places = RowPlaces::default();
+ paint(&mut places, 0.0, &[("b", "", 40.0, 40.0, 0.0)]);
+ let row = ("b", "", 20.0, 20.0, 0.0);
+ assert_eq!(
+ paint(&mut places, 0.0, &[row, row]),
+ [Some(20.0), Some(20.0)]
+ );
+ }
+
+ #[test]
+ fn rows_of_another_space_are_not_compared() {
+ let mut places = RowPlaces::default();
+ paint(&mut places, 0.0, &[("b", "", 40.0, 40.0, 0.0)]);
+ places.begin("t", 0.0);
+ assert_eq!(places.note("b", "", 20.0, 20.0, 0.0), None);
+ }
+
+ #[test]
+ fn a_frame_without_the_list_lets_go_of_its_rows() {
+ let mut places = RowPlaces::default();
+ paint(&mut places, 0.0, &[("b", "", 40.0, 40.0, 0.0)]);
+ places.end_frame();
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "", 20.0, 20.0, 0.0)]),
+ [None]
+ );
+ }
+
+ #[test]
+ fn a_row_pinned_goes_from_where_it_was_in_the_list() {
+ let mut places = RowPlaces::default();
+ paint(&mut places, 0.0, &[("b", "folder", 20.0, 100.0, 0.0)]);
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "", 20.0, 20.0, 0.0)]),
+ [Some(80.0)]
+ );
+ // Put back into a folder sent 10 up itself: the row's own share is
+ // the rest of the way.
+ assert_eq!(
+ paint(&mut places, 0.0, &[("b", "folder", 20.0, 110.0, 10.0)]),
+ [Some(-100.0)]
+ );
+ }
+
+ #[test]
+ fn a_list_scrolled_since_the_paint_before_reports_no_move() {
+ let mut places = RowPlaces::default();
+ paint(&mut places, 40.0, &[("b", "", 60.0, 60.0, 0.0)]);
+ assert_eq!(
+ paint(&mut places, 20.0, &[("b", "", 40.0, 40.0, 0.0)]),
+ [None]
+ );
+ assert_eq!(
+ paint(&mut places, 20.0, &[("b", "", 40.0, 40.0, 0.0)]),
+ [None]
+ );
+ }
+
+ #[test]
+ fn rows_after_a_new_row_are_not_pushed_down_over_it() {
+ let mut places = RowPlaces::default();
+ paint(
+ &mut places,
+ 0.0,
+ &[("a", "", 0.0, 0.0, 0.0), ("c", "", 20.0, 20.0, 0.0)],
+ );
+ assert_eq!(
+ paint(
+ &mut places,
+ 0.0,
+ &[
+ ("a", "", 0.0, 0.0, 0.0),
+ ("b", "", 20.0, 20.0, 0.0),
+ ("c", "", 40.0, 40.0, 0.0)
+ ],
+ ),
+ [None, None, None]
+ );
+ }
+
+ #[test]
+ fn the_first_pin_sends_the_pinned_row_alone() {
+ let mut places = RowPlaces::default();
+ paint(
+ &mut places,
+ 0.0,
+ &[
+ ("label", "", 0.0, 0.0, 0.0),
+ ("folder", "", 20.0, 20.0, 0.0),
+ ("c", "folder", 20.0, 40.0, 0.0),
+ ("d", "folder", 40.0, 60.0, 0.0),
+ ],
+ );
+ // The Pinned heading appears and c goes under it: the rest is put
+ // where it goes, and c alone comes up from its folder.
+ assert_eq!(
+ paint(
+ &mut places,
+ 0.0,
+ &[
+ ("pinned", "", 0.0, 0.0, 0.0),
+ ("c", "", 20.0, 20.0, 0.0),
+ ("label", "", 40.0, 40.0, 0.0),
+ ("folder", "", 60.0, 60.0, 0.0),
+ ("d", "folder", 20.0, 80.0, 0.0),
+ ],
+ ),
+ [None, Some(20.0), None, None, None]
+ );
+ }
+
+ #[test]
+ fn a_glided_row_settles_home() {
+ let mut way = SidebarMakeWay::default();
+ way.glide("b", 20.0);
+ assert_eq!(way.shift_of("b"), 20.0);
+ settle(&mut way);
+ assert!(way.is_idle());
+ }
+
const LIST: [&str; 4] = ["a", "b", "c", "d"];
fn shifts(source: &str, before: Option<&str>) -> Vec<(String, f32)> {
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index 9e89e98d..5124dc7c 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -1,6 +1,8 @@
use crate::quad::{
- HeapQuadAllocator, QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait,
+ HeapQuadAllocator, QuadClipRect, QuadTrait, TripleLayerQuadAllocator,
+ TripleLayerQuadAllocatorTrait,
};
+use crate::termwindow::sidebar_disclosure::{FolderChevrons, FolderKind};
use crate::termwindow::render::corners::{
BOTTOM_LEFT_ROUNDED_CORNER, BOTTOM_RIGHT_ROUNDED_CORNER, TOP_LEFT_ROUNDED_CORNER,
TOP_RIGHT_ROUNDED_CORNER,
@@ -57,6 +59,20 @@ const WORKSPACE_SECTION_LABEL_GAP: usize = 12;
/// `workspace_sidebar_hidden_statuses` cannot be cleared from the UI.
const SHOW_SIDEBAR_VIEW_OPTIONS: bool = false;
+/// The largest recording of a folder's rows kept for the next frame.
+const FOLDER_ROWS_KEEP_BYTES: usize = 1 << 20;
+/// The Workspaces heading, as the rows that glide know it.
+const WORKSPACES_LABEL_KEY: &str = "section:workspaces";
+/// The Pinned heading likewise, which never moves but can appear.
+const PINNED_LABEL_KEY: &str = "section:pinned";
+
+/// How far open a folder is drawn: where its animation has got to, or
+/// settled where it is.
+fn folder_open(chevrons: &FolderChevrons, kind: FolderKind, id: &str, collapsed: bool) -> f32 {
+ chevrons
+ .open_of(kind, id)
+ .unwrap_or(if collapsed { 0.0 } else { 1.0 })
+}
/// Room between New Thread's row and the list under it.
const TOP_ACTION_BOTTOM_GAP: usize = 16;
@@ -70,7 +86,6 @@ const TOP_ACTION_BOTTOM_GAP: usize = 16;
/// `SESSION_ROW_MIN_HEIGHT` too.
const TOP_ACTION_MAX_HEIGHT: usize = 58;
const SESSION_ROW_MIN_HEIGHT: usize = 66;
-const SESSION_ROW_SIDE_PADDING: usize = 10;
const SESSION_ACTION_MIN_SIZE: usize = 48;
const SESSION_ACTION_MAX_SIZE: usize = 52;
const SESSION_ACTION_ICON_INSET: usize = 12;
@@ -461,6 +476,7 @@ impl crate::TermWindow {
/// gap on any display whose ui scale is not exactly 1 (e.g. Linux 96dpi
/// at 0.5), inflating max_scroll past the painted content.
fn workspace_sidebar_list_height(
+ chevrons: &FolderChevrons,
view: &workspace_threads::WorkspaceThreadsView,
shared_rows: usize,
row_height: usize,
@@ -497,20 +513,32 @@ impl crate::TermWindow {
match folder {
workspace_threads::SidebarFolder::Project(index) => {
if let Some(project) = view.projects.get(*index) {
- if !project.threads_collapsed {
- height = height.saturating_add(
- project.threads.len().saturating_mul(row_height + row_gap),
- );
- }
+ let open = folder_open(
+ chevrons,
+ FolderKind::Project,
+ &project.id,
+ project.threads_collapsed,
+ );
+ height = height.saturating_add(
+ (project.threads.len().saturating_mul(row_height + row_gap) as f32
+ * open)
+ .round() as usize,
+ );
}
}
workspace_threads::SidebarFolder::RefGroup(index) => {
if let Some(group) = view.ref_groups.get(*index) {
- if !group.collapsed {
- height = height.saturating_add(
- group.threads.len().saturating_mul(row_height + row_gap),
- );
- }
+ let open = folder_open(
+ chevrons,
+ FolderKind::RefGroup,
+ &group.key,
+ group.collapsed,
+ );
+ height = height.saturating_add(
+ (group.threads.len().saturating_mul(row_height + row_gap) as f32
+ * open)
+ .round() as usize,
+ );
}
}
}
@@ -526,7 +554,9 @@ impl crate::TermWindow {
height.saturating_sub(row_gap)
}
+ #[allow(clippy::too_many_arguments)]
fn workspace_sidebar_scroll_height(
+ chevrons: &FolderChevrons,
view: &workspace_threads::WorkspaceThreadsView,
shared_rows: usize,
row_height: usize,
@@ -536,6 +566,7 @@ impl crate::TermWindow {
viewport_height: usize,
) -> usize {
let height = Self::workspace_sidebar_list_height(
+ chevrons,
view,
shared_rows,
row_height,
@@ -1354,6 +1385,7 @@ impl crate::TermWindow {
let view = self.workspace_sidebar_view(&active_workspace, &workspaces);
let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let total_height = Self::workspace_sidebar_scroll_height(
+ &self.folder_chevrons,
&view,
self.shared_with_us_rows(),
layout.row_height,
@@ -1410,6 +1442,7 @@ impl crate::TermWindow {
let view = self.workspace_sidebar_view(&active_workspace, &workspaces);
let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let total_height = Self::workspace_sidebar_scroll_height(
+ &self.folder_chevrons,
&view,
self.shared_with_us_rows(),
layout.row_height,
@@ -2127,9 +2160,18 @@ impl crate::TermWindow {
}
let list_top = layout.list_top;
let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
+ // The live list only: a Library card or a Space swiped to is not the
+ // list a row was taken out of, and shows its folders as they are.
+ let rows_tracked = !card && self.workspace_sidebar_preview_space_id.is_none();
+ let still_folders = FolderChevrons::default();
let max_scroll = {
let viewport_height = content_bottom.saturating_sub(list_top);
let total_height = Self::workspace_sidebar_scroll_height(
+ if rows_tracked {
+ &self.folder_chevrons
+ } else {
+ &still_folders
+ },
&view,
self.shared_with_us_rows(),
session_row_height,
@@ -2165,6 +2207,15 @@ impl crate::TermWindow {
top + session_row_height as f32 > list_top_f && top < content_bottom_f
};
let mut virtual_y = 0usize;
+ // Nothing glides while rows are moving for another reason.
+ let rows_glide = rows_tracked
+ && carried.is_none()
+ && self.sidebar_make_way.is_idle()
+ && !self.folder_chevrons.folding();
+ if rows_tracked {
+ let space = self.workspace_sidebar_space_id().to_string();
+ self.sidebar_row_places.begin(&space, scroll_offset);
+ }
// The row of the thread this window shows, wherever it is, for the
// pill that brings it back into sight.
let mut current_row: Option<CurrentRow> = None;
@@ -2187,6 +2238,15 @@ impl crate::TermWindow {
let list_quads_start = layers.heap_mark();
if !view.pinned_threads.is_empty() {
+ self.note_sidebar_row(
+ PINNED_LABEL_KEY,
+ "",
+ virtual_y,
+ virtual_y,
+ 0.0,
+ rows_tracked,
+ rows_glide,
+ );
let label_top = list_top_f + virtual_y as f32 - scroll_offset;
let label_bottom = label_top + session_row_height as f32;
let label_is_visible = label_bottom > list_top_f && label_top < content_bottom_f;
@@ -2225,10 +2285,21 @@ impl crate::TermWindow {
let pinned_width = item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2);
let pinned_status_x = pinned_x + self.ui_px(SIDEBAR_INSET);
for session in &view.pinned_threads {
+ self.note_sidebar_row(
+ &session.id,
+ "",
+ virtual_y,
+ virtual_y,
+ 0.0,
+ rows_tracked,
+ rows_glide,
+ );
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
let row_bottom = row_top + session_row_height as f32;
let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;
- let y = row_top.floor().max(0.0) as usize;
+ let y = (row_top + self.sidebar_make_way.shift_of(&session.id))
+ .floor()
+ .max(0.0) as usize;
let hit_y = row_top.max(list_top_f).floor().max(0.0) as usize;
let hit_bottom = row_bottom.min(content_bottom_f).ceil().max(hit_y as f32) as usize;
let hit_height = hit_bottom.saturating_sub(hit_y).max(1);
@@ -2411,11 +2482,22 @@ impl crate::TermWindow {
if !view.pinned_threads.is_empty() {
virtual_y += self.ui_px(WORKSPACE_SECTION_LABEL_GAP);
}
+ self.note_sidebar_row(
+ WORKSPACES_LABEL_KEY,
+ "",
+ virtual_y,
+ virtual_y,
+ 0.0,
+ rows_tracked,
+ rows_glide,
+ );
let label_top = list_top_f + virtual_y as f32 - scroll_offset;
let label_bottom = label_top + session_row_height as f32;
let label_is_visible = label_bottom > list_top_f && label_top < content_bottom_f;
if label_is_visible {
- let label_y = label_top.floor().max(0.0) as usize;
+ let label_y = (label_top + self.sidebar_make_way.shift_of(WORKSPACES_LABEL_KEY))
+ .floor()
+ .max(0.0) as usize;
let button_y =
label_y + ((session_row_height.saturating_sub(section_button_size)) / 2);
let button_x = item_x
@@ -2487,6 +2569,16 @@ impl crate::TermWindow {
let Some(project) = view.projects.get(*folder_project_index) else {
continue;
};
+ let folder_place = virtual_y;
+ let folder_glided = self.note_sidebar_row(
+ &project.id,
+ "",
+ folder_place,
+ folder_place,
+ 0.0,
+ rows_tracked,
+ rows_glide,
+ );
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
let row_bottom = row_top + session_row_height as f32;
let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;
@@ -2498,15 +2590,17 @@ impl crate::TermWindow {
let hit_height = hit_bottom.saturating_sub(hit_y).max(1);
let disclosure_size = icon_size.min(22);
- let disclosure_x = item_x + self.ui_px(SIDEBAR_INSET);
- let project_icon_x = disclosure_x + disclosure_size + 4;
+ let project_icon_x = item_x + self.ui_px(SIDEBAR_INSET);
let project_text_x = project_icon_x + icon_size + self.ui_px(SIDEBAR_ICON_GAP);
let project_action_size =
section_button_size.min(session_row_height.saturating_sub(8));
let project_action_x = item_x
.saturating_add(item_width)
.saturating_sub(project_action_size + self.ui_px(SIDEBAR_INSET));
- let project_text_right = project_action_x;
+ // The chevron sits by the add button, there under the pointer.
+ let disclosure_x = project_action_x
+ .saturating_sub(disclosure_size + self.ui_px(SIDEBAR_INSET) / 2);
+ let project_text_right = disclosure_x;
if project.is_archived {
// A revealed archived row: dimmed, inert, no chevron and
@@ -2547,6 +2641,19 @@ impl crate::TermWindow {
continue;
}
+ let row_hovered = !suppress_hover
+ && carried.is_none()
+ && self.is_pointer_over_ui_rect(item_x, hit_y, item_width, hit_height);
+ let (chevron_shown, project_open) = if rows_tracked {
+ self.folder_chevrons.aim(
+ FolderKind::Project,
+ &project.id,
+ row_hovered,
+ !project.threads_collapsed,
+ )
+ } else {
+ (0.0, if project.threads_collapsed { 0.0 } else { 1.0 })
+ };
if row_is_visible {
self.ui_items.push(UIItem {
x: item_x,
@@ -2568,17 +2675,19 @@ impl crate::TermWindow {
height: disclosure_size,
item_type: UIItemType::ProjectToggleThreads(project.id.clone()),
});
- self.paint_sidebar_icon(
+ let chevron_hovered = row_hovered
+ && self.is_pointer_over_ui_rect(
+ disclosure_x,
+ disclosure_y,
+ disclosure_size,
+ disclosure_size,
+ );
+ self.paint_folder_chevron(
layers,
- if project.threads_collapsed {
- SvgIcon::ChevronRight
- } else {
- SvgIcon::ChevronDown
- },
- disclosure_x,
- disclosure_y,
- disclosure_size,
- muted_fg,
+ (disclosure_x, disclosure_y, disclosure_size),
+ chevron_shown,
+ project_open,
+ if chevron_hovered { foreground } else { muted_fg },
)?;
self.paint_sidebar_project_icon(
layers,
@@ -2659,16 +2768,31 @@ impl crate::TermWindow {
virtual_y += session_row_height + row_gap;
- if !project.threads_collapsed {
- let session_x = item_x
- + self.ui_px(SIDEBAR_INSET) * 3
- + self.ui_px(SESSION_ROW_SIDE_PADDING);
- let session_width = item_width.saturating_sub(
- self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING) * 2,
- );
- let session_status_x = session_x + self.ui_px(SIDEBAR_INSET) + 2;
+ if project_open > 0.0 {
+ // Opening or closing, the rows fade with the folder and
+ // what follows moves by as much of them as is open.
+ let rows_start = virtual_y;
+ let into = &mut *layers;
+ let mut rows = std::mem::take(&mut self.sidebar_folder_rows);
+ rows.recycle();
+ let layers = &mut TripleLayerQuadAllocator::Heap(&mut rows);
+ // Lined up with the folder's icon, as pinned rows are.
+ let session_x = item_x + self.ui_px(SIDEBAR_INSET);
+ let session_width = item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2);
+ let session_status_x = session_x + self.ui_px(SIDEBAR_INSET);
for session in &project.threads {
+ // Within its folder: a folder moved as a whole moves
+ // its rows by its own shift.
+ self.note_sidebar_row(
+ &session.id,
+ &project.id,
+ virtual_y - folder_place,
+ virtual_y,
+ folder_glided,
+ rows_tracked,
+ rows_glide,
+ );
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
let row_bottom = row_top + session_row_height as f32;
let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;
@@ -2868,7 +2992,20 @@ impl crate::TermWindow {
virtual_y += session_row_height + row_gap;
}
- } else if current_row.is_none() {
+ self.show_folder_rows(
+ into,
+ &rows,
+ project_open,
+ &mut virtual_y,
+ rows_start,
+ list_top_f + rows_start as f32 - scroll_offset + folder_shift,
+ (list_top_f, content_bottom_f),
+ )?;
+ if rows.resident_bytes() <= FOLDER_ROWS_KEEP_BYTES {
+ self.sidebar_folder_rows = rows;
+ }
+ }
+ if project.threads_collapsed && current_row.is_none() {
// Folded away: where it would be once its folder opens.
if let Some((index, session)) =
project.threads.iter().enumerate().find(|(_, session)| {
@@ -2895,6 +3032,16 @@ impl crate::TermWindow {
let Some(group) = view.ref_groups.get(*folder_group_index) else {
continue;
};
+ let folder_place = virtual_y;
+ let folder_glided = self.note_sidebar_row(
+ &group.key,
+ "",
+ folder_place,
+ folder_place,
+ 0.0,
+ rows_tracked,
+ rows_glide,
+ );
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
let row_bottom = row_top + session_row_height as f32;
let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;
@@ -2909,8 +3056,7 @@ impl crate::TermWindow {
let hit_height = hit_bottom.saturating_sub(hit_y).max(1);
let disclosure_size = icon_size.min(22);
- let disclosure_x = item_x + self.ui_px(SIDEBAR_INSET);
- let group_icon_x = disclosure_x + disclosure_size + 4;
+ let group_icon_x = item_x + self.ui_px(SIDEBAR_INSET);
let group_text_x = group_icon_x + icon_size + self.ui_px(SIDEBAR_ICON_GAP);
let icon_y = y + ((session_row_height.saturating_sub(icon_size)) / 2);
let disclosure_y = y + ((session_row_height.saturating_sub(disclosure_size)) / 2);
@@ -2920,6 +3066,21 @@ impl crate::TermWindow {
let group_action_x = item_x
.saturating_add(item_width)
.saturating_sub(group_action_size + self.ui_px(SIDEBAR_INSET));
+ let disclosure_x = group_action_x
+ .saturating_sub(disclosure_size + self.ui_px(SIDEBAR_INSET) / 2);
+ let row_hovered = !suppress_hover
+ && carried.is_none()
+ && self.is_pointer_over_ui_rect(item_x, hit_y, item_width, hit_height);
+ let (chevron_shown, group_open) = if rows_tracked {
+ self.folder_chevrons.aim(
+ FolderKind::RefGroup,
+ &group.key,
+ row_hovered,
+ !group.collapsed,
+ )
+ } else {
+ (0.0, if group.collapsed { 0.0 } else { 1.0 })
+ };
if row_is_visible {
let group_key = format!("{group_space_id}::{}", group.key);
// The hover tag carries the provenance the project-name
@@ -2957,16 +3118,13 @@ impl crate::TermWindow {
});
}
if row_paints {
- self.paint_sidebar_icon(
+ // The whole row opens and closes the group, so the
+ // chevron only says which way it will go.
+ self.paint_folder_chevron(
layers,
- if group.collapsed {
- SvgIcon::ChevronRight
- } else {
- SvgIcon::ChevronDown
- },
- disclosure_x,
- disclosure_y,
- disclosure_size,
+ (disclosure_x, disclosure_y, disclosure_size),
+ chevron_shown,
+ group_open,
muted_fg,
)?;
// A server folder is the server itself, not a link to
@@ -2998,7 +3156,7 @@ impl crate::TermWindow {
muted_fg.mul_alpha(0.6)
};
let text_avail =
- group_action_x.saturating_sub(group_text_x + self.ui_px(SIDEBAR_INSET));
+ disclosure_x.saturating_sub(group_text_x + self.ui_px(SIDEBAR_INSET));
self.paint_sidebar_name(
layers,
&ui_font,
@@ -3068,33 +3226,46 @@ impl crate::TermWindow {
}
virtual_y += session_row_height + row_gap;
- if group.collapsed {
- if current_row.is_none() {
- if let Some((index, reference)) =
- group.threads.iter().enumerate().find(|(_, reference)| {
- self.is_workspace_sidebar_thread_selected(&reference.thread, false)
- })
- {
- current_row = Some(CurrentRow::new(
- virtual_y + index * (session_row_height + row_gap),
- Some((
- Fold::RefGroup(format!("{group_space_id}::{}", group.key)),
- virtual_y.saturating_sub(session_row_height + row_gap),
- )),
- thread_icon(&reference.thread),
- ));
- }
+ if group.collapsed && current_row.is_none() {
+ if let Some((index, reference)) =
+ group.threads.iter().enumerate().find(|(_, reference)| {
+ self.is_workspace_sidebar_thread_selected(&reference.thread, false)
+ })
+ {
+ current_row = Some(CurrentRow::new(
+ virtual_y + index * (session_row_height + row_gap),
+ Some((
+ Fold::RefGroup(format!("{group_space_id}::{}", group.key)),
+ virtual_y.saturating_sub(session_row_height + row_gap),
+ )),
+ thread_icon(&reference.thread),
+ ));
}
+ }
+ if group_open <= 0.0 {
continue;
}
- let session_x =
- item_x + self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING);
- let session_width = item_width.saturating_sub(
- self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING) * 2,
- );
- let session_status_x = session_x + self.ui_px(SIDEBAR_INSET) + 2;
+ // As with a project's rows: faded and folded as it opens
+ // and closes.
+ let rows_start = virtual_y;
+ let into = &mut *layers;
+ let mut rows = std::mem::take(&mut self.sidebar_folder_rows);
+ rows.recycle();
+ let layers = &mut TripleLayerQuadAllocator::Heap(&mut rows);
+ let session_x = item_x + self.ui_px(SIDEBAR_INSET);
+ let session_width = item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2);
+ let session_status_x = session_x + self.ui_px(SIDEBAR_INSET);
for reference in &group.threads {
let session = &reference.thread;
+ self.note_sidebar_row(
+ &session.id,
+ &group.key,
+ virtual_y - folder_place,
+ virtual_y,
+ folder_glided,
+ rows_tracked,
+ rows_glide,
+ );
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
let row_bottom = row_top + session_row_height as f32;
let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;
@@ -3287,6 +3458,18 @@ impl crate::TermWindow {
virtual_y += session_row_height + row_gap;
}
+ self.show_folder_rows(
+ into,
+ &rows,
+ group_open,
+ &mut virtual_y,
+ rows_start,
+ list_top_f + rows_start as f32 - scroll_offset + folder_shift,
+ (list_top_f, content_bottom_f),
+ )?;
+ if rows.resident_bytes() <= FOLDER_ROWS_KEEP_BYTES {
+ self.sidebar_folder_rows = rows;
+ }
}
}
@@ -4714,25 +4897,12 @@ impl crate::TermWindow {
let mut rests_selected = false;
let mut content = HeapQuadAllocator::default();
let mut layers = TripleLayerQuadAllocator::Heap(&mut content);
- // A folder header's chevron and name; says where its icon goes.
+ // A folder header's name; says where its icon goes. Its chevron
+ // shows only under the pointer, which a carried row is not under.
let folder_row = |layers: &mut TripleLayerQuadAllocator,
- collapsed: bool,
fg: LinearRgba|
-> anyhow::Result<(usize, usize)> {
- let disclosure_size = icon_size.min(22);
- self.paint_sidebar_icon(
- layers,
- if collapsed {
- SvgIcon::ChevronRight
- } else {
- SvgIcon::ChevronDown
- },
- inset,
- height.saturating_sub(disclosure_size) / 2,
- disclosure_size,
- chrome.secondary_text,
- )?;
- let icon_x = inset + disclosure_size + 4;
+ let icon_x = inset;
let text_x = icon_x + icon_size + self.ui_px(SIDEBAR_ICON_GAP);
self.paint_sidebar_name(
layers,
@@ -4790,7 +4960,7 @@ impl crate::TermWindow {
return Ok(());
};
let fg = chrome.secondary_text;
- let (x, y) = folder_row(&mut layers, project.threads_collapsed, fg)?;
+ let (x, y) = folder_row(&mut layers, fg)?;
self.paint_sidebar_project_icon(&mut layers, project, x, y, icon_size, fg)?;
}
SidebarRowKind::RefGroup(key) => {
@@ -4802,7 +4972,7 @@ impl crate::TermWindow {
} else {
chrome.secondary_text.mul_alpha(0.6)
};
- let (x, y) = folder_row(&mut layers, group.collapsed, fg)?;
+ let (x, y) = folder_row(&mut layers, fg)?;
let icon = if group.server_folder {
SvgIcon::Server
} else {
@@ -4950,6 +5120,121 @@ impl crate::TermWindow {
self.cached_ui_text_advance(font, &metrics, text)
}
+ /// `id` is laid out at `place` in the live list, counted from the top of
+ /// `within` (a folder's id, or "" for the list itself), and at `in_list`
+ /// from the top of the list. Moved there by the list since the frame
+ /// before, it glides from where it was; `carried` is how far its folder
+ /// was just sent gliding. Returns how far it was sent itself.
+ #[allow(clippy::too_many_arguments)]
+ fn note_sidebar_row(
+ &mut self,
+ id: &str,
+ within: &str,
+ place: usize,
+ in_list: usize,
+ carried: f32,
+ tracked: bool,
+ glide: bool,
+ ) -> f32 {
+ if !tracked {
+ return 0.0;
+ }
+ let moved = self.sidebar_row_places.note(
+ id,
+ within,
+ place as f32,
+ in_list as f32,
+ carried,
+ );
+ match moved {
+ Some(by) if glide => {
+ self.sidebar_make_way.glide(id, by);
+ by
+ }
+ _ => 0.0,
+ }
+ }
+
+ /// A folder's rows, recorded apart: replayed as faded as the folder is
+ /// closed, and the list after them pulled up by as much of them as is.
+ ///
+ /// Cut to as much of them as is open, from `top` on screen and within
+ /// `list` (its top and bottom), so that the list coming up after them
+ /// never runs over what is still fading.
+ #[allow(clippy::too_many_arguments)]
+ fn show_folder_rows(
+ &self,
+ layers: &mut TripleLayerQuadAllocator,
+ rows: &HeapQuadAllocator,
+ open: f32,
+ virtual_y: &mut usize,
+ rows_start: usize,
+ top: f32,
+ list: (f32, f32),
+ ) -> anyhow::Result<()> {
+ if open >= 1.0 {
+ return rows.apply_to(layers);
+ }
+ let height = (virtual_y.saturating_sub(rows_start) as f32 * open).round();
+ *virtual_y = rows_start + height as usize;
+ let clip_top = top.max(list.0);
+ let clip_bottom = (top + height).min(list.1);
+ if clip_bottom <= clip_top {
+ return Ok(());
+ }
+ let clip = QuadClipRect::from_top_left_pixels(
+ 0.0,
+ clip_top,
+ self.dimensions.pixel_width as f32,
+ clip_bottom,
+ &self.dimensions,
+ );
+ rows.apply_to_clipped(layers, clip, open)
+ }
+
+ /// A folder's chevron by its add button: faded in as far as the pointer
+ /// has brought it, turned as far as the folder has opened.
+ fn paint_folder_chevron(
+ &self,
+ layers: &mut TripleLayerQuadAllocator,
+ (x, y, size): (usize, usize, usize),
+ shown: f32,
+ turned: f32,
+ color: LinearRgba,
+ ) -> anyhow::Result<()> {
+ use crate::termwindow::sidebar_disclosure::{chevron_frame, CHEVRON_FRAMES};
+ if shown <= 0.0 {
+ return Ok(());
+ }
+ let left_offset = self.dimensions.pixel_width as f32 / 2.0;
+ let top_offset = self.dimensions.pixel_height as f32 / 2.0;
+ let gl_state = self.render_state.as_ref().unwrap();
+ let sprite = gl_state
+ .glyph_cache
+ .borrow_mut()
+ .cached_rotated_svg_icon(
+ SvgIcon::ChevronRight,
+ size,
+ chevron_frame(turned),
+ CHEVRON_FRAMES,
+ )?
+ .texture_coords();
+ let color = color.mul_alpha(shown);
+ let mut quad = layers.allocate(2)?;
+ quad.set_position(
+ x as f32 - left_offset,
+ y as f32 - top_offset,
+ x as f32 + size as f32 - left_offset,
+ y as f32 + size as f32 - top_offset,
+ );
+ quad.set_texture(sprite);
+ quad.set_fg_color(color);
+ quad.set_alt_color_and_mix_value(color, 0.0);
+ quad.set_hsv(None);
+ quad.set_grayscale();
+ Ok(())
+ }
+
pub(crate) fn paint_sidebar_icon(
&self,
layers: &mut TripleLayerQuadAllocator,
diff --git a/wezterm-gui/src/termwindow/ui/sidebar_jump.rs b/wezterm-gui/src/termwindow/ui/sidebar_jump.rs
index d651ebf4..e7d53c58 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar_jump.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar_jump.rs
@@ -178,6 +178,12 @@ impl crate::TermWindow {
}
jump.pressed_at = Some(Instant::now());
jump.reveal = true;
+ if jump.fold.is_some() {
+ // The row is to be scrolled to in the next frame, in the list as
+ // it is with its folder open, so the folder does not unfold.
+ self.folder_chevrons.land();
+ }
+ let jump = &mut self.sidebar_jump;
match jump.fold.take() {
Some(Fold::Project(project_id)) => {
crate::workspace_threads::expand_project_threads(&project_id);