pub struct DensityProjection(pub fn(&Theme, TargetDensity) -> Theme);Expand description
How a theme re-derives itself for another TargetDensity, registered as
a ThemeExtensions entry.
Absent — the default, and what every raw-token theme gets — means
Theme::with_density swaps Theme::input and changes nothing else.
That is right for a theme whose style_slots are all None, because each
widget then builds its own Recipe*Style from ctx.theme().input at its
next build.
A preset that installs Tier-3 slots of its own (Fluent, macOS,
Material 3) needs more: its slots are Some(..), so they would ride across
a density switch still carrying the dimensions they were built with, and a
Fluent button would stay 32 dp tall under Touch. Such a preset registers
this — a function taking the current theme, so it can recover the palette
it was built from (theme.extension::<FluentPalette>()) and rebuild only
the slots it owns, leaving colours, id, other extensions and any slot the
app installed itself alone.
It lives in the extension registry rather than as a Theme field for the
reason the registry exists: it is optional, typed, non-serializable state
that only some themes carry.
Tuple Fields§
§0: fn(&Theme, TargetDensity) -> Theme