Expand description
Global user-experience scale factor.
Distinct from [crate::device_scale], which tracks the physical
device-pixel ratio so glyphs stay crisp on HiDPI displays. The UX
scale exists because the same logical pixel feels very different
to a user on a desktop monitor at desk distance vs. a phone held
at arm’s length.
The cleanest mental model:
device_scale: pixels per logical unit on the physical display surface. Always set by the platform shell to whateverwindow.devicePixelRatio/winit::Window::scale_factorreports. Driven by the hardware.ux_scale: how much bigger the user wants every logical unit to be on top of that. Driven by ergonomic / accessibility needs — small on a 27“ monitor read at arm’s length, bigger on a 6“ phone read at arm’s length, bigger still for users with reduced vision.
The framework multiplies the two when it computes the effective
viewport / paint transform inside crate::App. Widgets always
see “logical” units (already divided by the effective scale), so
no per-widget changes are needed — only platform shells need to
call set_ux_scale.
§Suggested values
1.0— desktop / laptop / cursor-driven UI. The default.1.6–1.8— mobile touch (phone / tablet) where the user reads at arm’s length and needs ~44 px touch targets. Auto-set whencrate::input_profile::set_input_profileis called with any mobile variant.- User-controlled accessibility setting on top of that —
1.0to2.0+for users who explicitly want bigger UI.
Functions§
- effective_
scale - Combined “physical pixels per logical unit” the framework uses
for layout / paint scaling.
device_scale * ux_scale. - set_
ux_ scale - Set the UX scale factor. Panics on non-positive values in debug.
- ux_
scale - Current UX scale factor. Multiplied with [
crate::device_scale] incrate::App::layout/crate::App::paintto give the effective “physical pixels per logical unit” the framework actually uses.