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 (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§

border
The border every surface carries under the theme’s shape role, as (width, ink), or None where the theme keeps the design language’s own hairlines (crate::tokens::BorderInk::Hairline).
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.
content_edge_fade_band
Where content_edge_fade paints over the viewport rect toward edge: what a scroller copies under it is not what the fade shows.
control_face
Paint a control’s face (a button, a field’s well, a segmented track, a toggle’s body) with the control role’s painter set (crate::part_paint::Part::ControlFace), then the theme’s border around it. The rest face (surfaces.raised) is drawn at rest, where a set may let the window ground through it and light it; a face of any other fill (a primary action, a selection, a hover lift) is drawn selected: those carry state, and their ink is measured on them, so the toolkit’s sets keep them opaque. Returns whether a border was drawn, which stands in for the control’s own rest edge.
corner_resize_grip
The resize handle in a resizable surface’s free corner: three short diagonal strokes hugging the corner of grip that anchor names (true for the left, top edge), in color.
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 inner hairline a floating surface carries on its outermost pixel row (crate::chrome::panel_border): white at 7 % on a dark material, black at 8 % on a light one, full strength on high contrast. Paint it after the surface’s body, at the surface’s own radius.
floating_shadow
The two-layer shadow of a floating surface: the tight contact layer that defines its edge, under the wide layer that reads as distance (crate::tokens::Elevation::contact, crate::tokens::Elevation::floating), both along the surface’s own rounded outline. alpha scales both, for a surface still arriving.
floating_shadow_bounds
Every pixel floating_shadow can paint for a surface at rect, the surface’s own included.
paint_border
Stroke the theme’s border (border) wholly inside body. Returns whether one was drawn, so a caller drops the hairline it stands in for.
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 its 1 px inner hairline (floating_edge) — 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. The shadow is floating_shadow, painted first by the caller.
panel_unsnapped
panel exactly where it is laid out, without snapping to the pixel grid: for chrome whose own place is fractional or moving — a window’s controls in a bar a strip carries, a surface arriving on a spring. A snap rounds the surface to the grid where it is drawn now; translated a frame later, it would stand up to half a pixel from the drawing it replays and from the glyphs it holds.
push_card_clip
Clip what is painted next to the inside of a card at rect with radius, until the caller’s scene.pop_layer(): content held past the card’s edge (a dragged marker, a scrolled drawing) is cut there instead of spilling over what surrounds the card.
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.
selectable_card
card, or for the selected one its fill with the selected_edge in place of the rest edge.
selected_edge
The selected object’s edge, in place of the rest edge card paints: at the same position, a heavier line in the accent drawn wholly inside the surface’s outline. One outline, with no gap and no ring outside it. Every selectable card or tile marks its selected state with it.
selected_edge_width
How wide the selected edge is: twice the rest edge, so it reads as the same outline made heavier.
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. Generic floating windows use this exact path, body and border, so their corner radii cannot drift apart. (App-owned call and navigation cards are floating cards: crate::widget::floating_surface::paint_card.)
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.