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§
- Content
Edge - The edge of a viewport that content can scroll in from.
- Content
Frame - 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
NavShellslot, orregionin a painted app) and never fills it.
Constants§
- EDGE_
ALPHA_ STEPS - Alphas
edge_ontries, 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
fillitself: a stroke that sits entirely on the surface needs no knowledge of what is behind it. - card_on
cardfor a translucentfill(an accent wash, a hover tint): the edge derives from what the eye sees —fillcomposited overground— 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
edgeof the viewportrect: thegroundthe 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 (aScrollablewithwith_edge_fadedoes both). The replacement for a media scrim, aDestOutmask or a hand-made gradient at the end of a list. - edge_
delta - How far
edgemovessurfaceonce painted on it, in relative-luminance units — the measurement HIG §9.5 asks every chrome border to pass. Uses the same compositor asColors::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). WalksEDGE_ALPHA_STEPSuntil the edge visibly registers (tokens::colors::HAIRLINE_MIN_DELTA). - edge_
on_ with edge_onat 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 callshadowinstead, 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 thecrate::chrome::panel_borderedge on a crisp inset outline — HIG §9.5’s Panel row, so an app never spells the fill + stroke pair itself. Rows inside it useseparatorwith ans3inset andcrate::chrome::selection_tier_onagainst the panel ground. - region
- Paint
region’s ground overrectand 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, insetinsetfrom both ends (HIG §9.5:spacing.s3, never full-bleed into a corner radius), centred ony. - separator_
rect - The one device-pixel row a separator centred on
yoccupies:yis snapped so a caller passing a whole-pixel coordinate gets a crisp rule, not a two-row smear at half alpha (which would fall underHAIRLINE_MIN_DELTAeven though the colour itself registers). - shadow
- Paint the drop shadow an elevation token describes, following
rect’s own cornerradius— a true Gaussian blur of the surface’s own rounded outline, unlikesoft_shadow’s square-corner-SDF approximation. - shadow_
bounds - Every pixel
shadowcan paint underrect, antialiasing included, inrect’s coordinates;Nonewhen 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
blurradius means. - vertical_
separator - A 1 px vertical separator between two columns or panes, derived against
surfacelikeseparator, insetinsetfrom both ends and centred onx. The column rule of a painted split, a gutter beside a list.