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§
- 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§
- border
- The border every surface carries under the theme’s shape role, as
(width, ink), orNonewhere 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
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. - content_
edge_ fade_ band - Where
content_edge_fadepaints over the viewportrecttowardedge: 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
gripthatanchornames (truefor the left, top edge), incolor. - 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 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.alphascales both, for a surface still arriving. - floating_
shadow_ bounds - Every pixel
floating_shadowcan paint for a surface atrect, the surface’s own included. - paint_
border - Stroke the theme’s border (
border) wholly insidebody. 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 useseparatorwith ans3inset andcrate::chrome::selection_tier_onagainst the panel ground. The shadow isfloating_shadow, painted first by the caller. - panel_
unsnapped panelexactly 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
cardatrectwithradius, until the caller’sscene.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 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.
- selectable_
card card, or for the selected one its fill with theselected_edgein place of the rest edge.- selected_
edge - The selected object’s edge, in place of the rest edge
cardpaints: 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, 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. 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
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.