Skip to main content

Metrics

Struct Metrics 

pub struct Metrics {
Show 34 fields pub bar_height: f32, pub bar_control_height: f32, pub panel_row_height: f32, pub menu_row_height: f32, pub menu_min_width: f32, pub scrollbar_gutter: f32, pub selector_height: f32, pub min_pointer_target: f32, pub panel_width_utility: f32, pub panel_width_list: f32, pub panel_width_sheet: f32, pub icon_sm: f32, pub icon_md: f32, pub icon_lg: f32, pub icon_label_gap: f32, pub chrome_rule_px: f32, pub sidebar_width: f32, pub drawer_width: f32, pub overview_width: f32, pub compact_breakpoint: f32, pub nav_row_height: f32, pub header_height: f32, pub rail_width: f32, pub inspector_width: f32, pub sidebar_min_width: f32, pub sidebar_max_width: f32, pub content_min_width: f32, pub detail_min_width: f32, pub readable_width: f32, pub reading_measure: f32, pub chooser_width: f32, pub wheel_line: f32, pub scroll_thumb: f32, pub swipe_commit: f32,
}
Expand description

Reference density (HIG §9.6), unscaled. Read live values from theme.tokens.metrics.

Fields§

§bar_height: f32

A top bar, toolbar or status strip. Also the default height of the shared Button and Dropdown controls.

§bar_control_height: f32

A control living inside a 40 px bar (segmented switch, bar button).

§panel_row_height: f32

One row of a Panel — a settings toggle row, a roster entry.

§menu_row_height: f32

One row of a menu (context menu, dropdown list).

§menu_min_width: f32

The narrowest a menu stands, however short its labels: a menu of one short item still reads as a menu, not as a button.

§scrollbar_gutter: f32

Room a scroll view keeps on its trailing edge for its scroll bar while its content overflows, so the bar never covers content: the thumb (Metrics::scroll_thumb) plus s1 on each side.

§selector_height: f32

A compact selector (chip, tab pill, dropdown trigger in a Panel).

§min_pointer_target: f32

No pointer target is smaller than this, whatever glyph it shows.

§panel_width_utility: f32

A utility Panel such as quick settings.

§panel_width_list: f32

A roster or list Panel.

§panel_width_sheet: f32

A sheet carrying a form.

§icon_sm: f32

Compact glyph: tab leading icon, inline status mark.

§icon_md: f32

The standard 20 px glyph that sits in a 32 px hit rect.

§icon_lg: f32

Large glyph: empty-state mark, list leading icon.

§icon_label_gap: f32

Between an icon and the label it belongs to (Button, Tabs).

§chrome_rule_px: f32

Thickness of the rule under a toolbar and along a status bar. 1 is the hairline. 0 draws no rule. A heavier value is a stronger chrome edge. ui_scale multiplies it; a theme’s spacing preference does not.

§sidebar_width: f32

A genuine navigation sidebar (HIG §1a) when docked.

§drawer_width: f32

An overlay drawer; equal to Metrics::panel_width_utility so a docked utility panel and a slid-in drawer are one width.

§overview_width: f32

The overview column of an overview + detail pair (HIG §1b).

§compact_breakpoint: f32

At or above this window width a sidebar docks beside its content; below it the shell switches to separate screens or an overlay. sidebar_width plus a content column that still reads (Metrics::content_min_width).

§nav_row_height: f32

One row of a navigation list (NavList, paint_nav_row) at the default text scale; it grows with the body line like any shell control that carries one line of text.

§header_height: f32

The one header row a NavShell draws across the top of the window: a min_pointer_target control in an s3 inset (32 + 2 × 12).

§rail_width: f32

A compact icon-over-label navigation rail (NavList::rail).

§inspector_width: f32

The inspector column at the trailing edge of a window.

§sidebar_min_width: f32

Narrowest a person can drag a docked sidebar; dragging it below this hides it.

§sidebar_max_width: f32

Widest a person can drag a docked sidebar.

§content_min_width: f32

The room the content beside a sidebar needs: a readable column, the width of a sheet (Metrics::panel_width_sheet). Narrower than this the content would be squeezed, so the sidebar collapses into a drawer instead (compact_breakpoint − sidebar_width).

§detail_min_width: f32

Narrowest the detail column beside an overview may become before the two become push screens.

§readable_width: f32

The widest a form, a settings page or a page of facts grows (FormPage, Page, PropertyList, Container::readable). Wider windows leave the extra room beside it.

§reading_measure: f32

The line length of long-form reading text (documents, books, notes): about 66 characters of the Reading role at the stock text size.

§chooser_width: f32

The width a compact chooser (dropdown, segmented switch, single-line entry) keeps beside its label in a form row.

§wheel_line: f32

How far one notch of a line-stepping wheel scrolls.

§scroll_thumb: f32

Thickness of a scroll bar’s thumb at rest; the bar’s gutter is the thumb plus s1 on each side.

§swipe_commit: f32

How far a row must be swiped sideways before letting go commits its swipe action rather than springing back.

Implementations§

§

impl Metrics

pub const BASE: Metrics

HIG §9.6 values, unscaled.

pub fn text_growth(text_scale: f32) -> f32

The factor a text-sized width or breakpoint grows by at a given accessibility text scale: text_scale.max(1.0).

A destination list, an overview column and the window width at which two panes still fit side by side are all sized by the text they hold, so they grow with the text — but never shrink below their authored 1× geometry, where the rows, hit targets and paddings were designed. This is the one rule the responsive shells (NavShell, SidebarDrawer) apply to their inputs (crate::Theme::responsive_scale), so an app never restates it. A non-finite scale counts as 1×.

pub fn icon_growth(text_scale: f32) -> f32

The factor the glyph metrics (icon_sm, icon_md, icon_lg) grow by at a given accessibility text scale: the square root of Self::text_growth. A glyph sits beside the text it labels, so it grows with it, as symbols follow Dynamic Type; it grows less than the letters, since a glyph already reads at a smaller size than a word and still has to fit the control the text has grown. 2x text gives glyphs about 1.41x. Never below 1.

pub fn with_icons_scaled(self, factor: f32) -> Metrics

These metrics with the glyph sizes multiplied by factor; see Self::icon_growth.

pub fn scaled(&self, factor: f32) -> Metrics

Every metric multiplied by factor. Used by ui_scale; never by a custom theme’s spacing preference.

Trait Implementations§

§

impl Clone for Metrics

§

fn clone(&self) -> Metrics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Metrics

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Metrics

§

fn default() -> Metrics

Returns the “default value” for a type. Read more
§

impl PartialEq for Metrics

§

fn eq(&self, other: &Metrics) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Copy for Metrics

§

impl StructuralPartialEq for Metrics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,