Skip to main content

Module surface

Module surface 

Expand description

Shared surface-drawing primitives — how a card/panel casts a shadow.

shadow is the default: a true Gaussian blur of the surface’s own rounded outline, so the shadow is the same shape as the thing casting it and equally dense the whole way round.

soft_shadow is a baked-sprite falloff 9-sliced around the rect, kept only for effects with no outline to follow (the wheel disc’s bloom, a dragged card’s accent glow) — anything with a corner radius should use shadow instead, since the sprite’s corner term is a square-corner SDF that reads as a box with the corners rubbed out. Sprites are baked once per tint and cached.

Enums§

ContentEdge
The edge of a viewport that content can scroll in from.
ContentFrame
The boundary of authored content, independent of the pixels inside it.
Region
The regions a window is made of (HIG §9.2). Each has one ground, and the framework paints it: an app declares which region an area is (a NavShell slot, or region in a painted app) and never fills it.

Constants§

EDGE_ALPHA_STEPS
Alphas edge_on tries, ascending, until the hairline visibly moves the surface it is drawn on (HIG §9.5). Step 0 is the control hairline (chrome::shell::HAIRLINE_ALPHA); the ladder only climbs on grounds so dark or so light that a 26-alpha wash lands within rounding distance of the surface — relative luminance compresses at the dark end, so pure black needs more alpha for the same visible step.

Functions§

card
Fill a card / row / tile and give it its derived rest edge in one call — the one way an app or shell surface paints an edged surface. The edge derives from fill itself: a stroke that sits entirely on the surface needs no knowledge of what is behind it.
card_on
card for a translucent fill (an accent wash, a hover tint): the edge derives from what the eye sees — fill composited over ground — not from the wash’s own RGB. A 16 % accent wash on a light panel is still a light surface and wants a dark hairline; judged by the accent alone it would get a white one and vanish.
content_edge_fade
Fade content out toward edge of the viewport rect: the ground the content is drawn on, opaque at the edge and clear a short way in, eased so it has no start line. Paint it over the content, and only while more content can scroll in from that edge (a Scrollable with with_edge_fade does both). The replacement for a media scrim, a DestOut mask or a hand-made gradient at the end of a list.
edge_delta
How far edge moves surface once painted on it, in relative-luminance units — the measurement HIG §9.5 asks every chrome border to pass. Uses the same compositor as Colors::hairline_on / lift_target / window_edge, so one rounding model decides “visible” everywhere.
edge_on
The derived 1 px rest edge of a control, card or row: a hairline measured against the surface it is painted on, never a declared border_standard (which is one fixed colour per theme and disappears on a raised dark surface). Walks EDGE_ALPHA_STEPS until the edge visibly registers (tokens::colors::HAIRLINE_MIN_DELTA).
edge_on_with
edge_on at a fixed alpha, for callers that want the control hairline (HAIRLINE_ALPHA) or the panel edge (PANEL_BORDER_ALPHA) exactly.
edge_outline
The outline a crisp 1 px edge is stroked on: half a pixel inside rect, so a 1 px stroke covers exactly the outermost pixel row of the surface and never bleeds onto the ground beside it.
elevation
Paint an elevation-token shadow under rect, square-cornered. For callers with no radius to follow — anything rounded must call shadow instead, or it gets a shadow of a different shape than itself.
floating_drag_grip
Shared quiet drag affordance for a detachable soft surface.
floating_edge
The 1 px light edge a floating surface carries just inside its outline on a dark material (crate::tokens::Elevation::floating_edge); nothing on a light one. Paint it after the surface’s body and border, at the surface’s own radius: the edge’s radius is concentric with it.
panel
A floating Panel-role surface (menu, popover, sheet, toast) in one call: the floating material (crate::floating_surface::Material::Floating, the blurred backdrop under a panel-ground tint, opaque where blur is unavailable) with the crate::chrome::panel_border edge on a crisp inset outline — HIG §9.5’s Panel row, so an app never spells the fill + stroke pair itself. Rows inside it use separator with an s3 inset and crate::chrome::selection_tier_on against the panel ground.
region
Paint region’s ground over rect and return it, for the region’s contents to measure against (Theme::on_ground, Colors::lift_on, edge_on).
region_needs_edge
Whether a region tier is too close to the content ground to separate from it by tone alone.
separator
A 1 px separator between rows inside a surface: derived against surface, inset inset from both ends (HIG §9.5: spacing.s3, never full-bleed into a corner radius), centred on y.
separator_rect
The one device-pixel row a separator centred on y occupies: y is snapped so a caller passing a whole-pixel coordinate gets a crisp rule, not a two-row smear at half alpha (which would fall under HAIRLINE_MIN_DELTA even though the colour itself registers).
shadow
Paint the drop shadow an elevation token describes, following rect’s own corner radius — a true Gaussian blur of the surface’s own rounded outline, unlike soft_shadow’s square-corner-SDF approximation.
shadow_bounds
Every pixel shadow can paint under rect, antialiasing included, in rect’s coordinates; None when it paints nothing.
soft_outline
Shared silhouette for lightweight desktop floats. The asymmetry is only one or two logical pixels along each edge: enough to feel soft and held, never enough to look like a novelty blob. Body, border, app-owned call / navigation surfaces, and generic floating windows all use this exact path so their corner radii cannot drift apart.
soft_shadow
Paint a soft drop shadow for rect.
std_dev_for
The Gaussian standard deviation a CSS-style blur radius means.
vertical_separator
A 1 px vertical separator between two columns or panes, derived against surface like separator, inset inset from both ends and centred on x. The column rule of a painted split, a gutter beside a list.