feat: add scrollbar for virtualized lists

This commit is contained in:
2026-11-04 13:05:39 +07:00
parent 4bfc816cbe
commit 50da1d4a9d
10 changed files with 1033 additions and 23 deletions
+5 -1
View File
@@ -225,7 +225,8 @@ impl Default for Motion {
}
}
/// Overlay scrollbar geometry, transcribed from the platform's overlay crollbars.
/// Overlay scrollbar presentation, transcribed from the platform's overlay
/// crollbars.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Scrollbar {
/// The painted thumb's thickness.
@@ -234,6 +235,8 @@ pub struct Scrollbar {
pub inset: Pixels,
/// The thumb never shrinks below this length, so it stays grabbable.
pub min_thumb: Pixels,
/// Whether the platform's scrollbars hide while idle.
pub autohide: bool,
}
impl Default for Scrollbar {
@@ -242,6 +245,7 @@ impl Default for Scrollbar {
width: px(8.),
inset: px(2.),
min_thumb: px(24.),
autohide: false,
}
}
}
+26 -1
View File
@@ -238,7 +238,10 @@ pub(crate) fn resolve(
radius,
elevations: Elevations::for_platform(system.source, variant),
motion: Motion::default(),
scrollbar: Scrollbar::default(),
scrollbar: Scrollbar {
autohide: system.source.scrollbar_autohide(),
..Scrollbar::default()
},
titlebar_height,
root_font_size,
sizes,
@@ -339,6 +342,28 @@ mod tests {
assert_eq!(resolved.sizes.small.text_size, px(11.05));
}
#[test]
fn scrollbar_autohide_follows_the_platform_source() {
let mut stated = system(ThemeVariant::Dark, PartialPalette::default(), None);
stated.source = SourceKind::Macos;
assert!(resolve(&stated, None, None).scrollbar.autohide);
stated.source = SourceKind::Gnome;
assert!(resolve(&stated, None, None).scrollbar.autohide);
stated.source = SourceKind::Omarchy;
assert!(resolve(&stated, None, None).scrollbar.autohide);
stated.source = SourceKind::Windows;
assert!(!resolve(&stated, None, None).scrollbar.autohide);
stated.source = SourceKind::Kde;
assert!(!resolve(&stated, None, None).scrollbar.autohide);
stated.source = SourceKind::Fallback;
assert!(!resolve(&stated, None, None).scrollbar.autohide);
}
#[test]
fn a_stated_input_height_overrides_the_derived_one_and_scales() {
let mut stated = system(ThemeVariant::Light, PartialPalette::default(), None);
+7
View File
@@ -36,6 +36,13 @@ impl SourceKind {
Self::Windows => "Windows 11 (UISettings)",
}
}
/// Overlay scrollbars hide while idle on macOS, GNOME, and Omarchy.
///
/// Windows and KDE keep theirs drawn.
pub fn scrollbar_autohide(self) -> bool {
matches!(self, Self::Macos | Self::Omarchy | Self::Gnome)
}
}
/// A partial palette with optional colors.