Skip to main content

frame_radius

Function frame_radius 

Source
pub fn frame_radius(cx: &App) -> Pixels
Expand description

The corner radius a decoration must carry to reach a component’s edge.

Every framed component in this library rounds its frame by the theme’s large radius, so a layer that paints to the edge rounds itself by this and lands on the frame exactly. It follows the active theme, including a custom JSON one, which is why it is a call rather than a constant.

It exists because the alternative does not: GPUI’s ContentMask is a Bounds, so nothing here can clip a layer to a rounded shape on the caller’s behalf. Per-element radii on a div background or an img are resolved in the shader and do work - and note that ObjectFit::Cover hands a sprite bounds larger than the element, which puts those radii on corners that are off screen. A covered photograph has to be cropped to the frame, not fitted into it.