Skip to main content

interactive_rules

Function interactive_rules 

Source
pub fn interactive_rules(selector: &str, depth: Depth, opts: &Emit) -> String
Expand description

Every state a selector that answers a click implies: hover, pressed, focus and disabled, in that order.

Order is the whole cascade mechanism here. All four selectors are specificity (0,2,0), so disabled wins over hover and pressed by coming last and by nothing else.

Pressed emits Depth::pressed in full, fill and edge together. Emitting only the edge is what left goingson hand-writing background: var(--surface-sunken) on three separate rules, and a fill that does not travel with its edge is precisely the disagreement Depth exists to make unrepresentable. So the pressed fill comes from the description (--surface-well) rather than from whatever each app reached for.

Hover has no member in the description and is renderer policy: a terminal and an immediate-mode painter have no hover to express. It resolves against --hover-surface, which makeover already derives and which nothing consumed until now. What it is gated on is capability, via [hover_condition]. Before that gate existed the apps each wrote their own: goingson’s section 60 exists solely to take back the hover state this function had just handed it, by out-specifying a rule it does not own.

depth is the selector’s rest depth, used to place the focus ring and to restore the surface under a disabled control. The pressed rule keeps inverting from Depth::Raised regardless, which is what every caller got before this parameter existed: a tab’s unchosen depth is Depth::Sunken, and Sunken.pressed() is Sunken, so deriving the press from the rest depth would leave a tab with no press at all.