add scrollarea

This commit is contained in:
2026-10-29 19:23:06 +07:00
parent 4ae6a23cd9
commit cc22baca6e
12 changed files with 388 additions and 10 deletions
+27 -4
View File
@@ -51,6 +51,8 @@ pub struct Theme {
pub elevations: Elevations,
/// Overlay transition timing; gpui's animation primitives do the rest.
pub motion: Motion,
/// Overlay scrollbar geometry.
pub scrollbar: Scrollbar,
/// The platform's native root font size; rem-based sizing scales with it.
pub root_font_size: Pixels,
pub sizes: SizeTable,
@@ -82,8 +84,8 @@ impl Default for Radius {
}
}
/// One drop shadow of a floating layer, transcribed from the platform's
/// native overlay shadows.
/// One drop shadow of a floating layer,
/// transcribed from the platform's native overlay shadows.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Elevation {
pub offset_y: Pixels,
@@ -149,6 +151,27 @@ impl Default for Motion {
}
}
/// Overlay scrollbar geometry, transcribed from the platform's overlay crollbars.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Scrollbar {
/// The painted thumb's thickness.
pub width: Pixels,
/// Edge padding between the thumb and the viewport it floats over.
pub inset: Pixels,
/// The thumb never shrinks below this length, so it stays grabbable.
pub min_thumb: Pixels,
}
impl Default for Scrollbar {
fn default() -> Self {
Self {
width: px(8.),
inset: px(2.),
min_thumb: px(24.),
}
}
}
/// A named control size class.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Size {
@@ -176,8 +199,7 @@ pub struct ControlMetrics {
pub avatar_size: Pixels,
}
/// The control metrics for every size class, derived from the theme's root
/// font size so controls scale with the platform's native type.
/// The control metrics for every size class.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SizeTable {
pub small: ControlMetrics,
@@ -246,6 +268,7 @@ impl Theme {
radius: resolved.radius,
elevations: resolved.elevations,
motion: resolved.motion,
scrollbar: resolved.scrollbar,
root_font_size: resolved.root_font_size,
sizes: resolved.sizes,
accessibility: resolved.accessibility,