Skip to main content

Density

Enum Density 

Source
pub enum Density {
    Compact,
    Relaxed,
}
Expand description

How much room an interactive widget’s hit target should claim.

Not itself consulted by anything in this crate: there are no built-in interactive widgets yet to apply it to; every widget here is a free function or a thin, stateless composition of one (see the crate’s module docs). It exists so an app choosing between a phone-sized and a desktop-sized layout has one place to ask “how big should this button/row/slider be”, rather than inventing its own ad hoc breakpoint constants per widget (as e.g. responsive_game_ui’s own MIN_TARGET_W/MIN_TARGET_H do today). A future interactive widget in this crate (a checkbox, say) would read min_target_size the same way it would read Sense.

Variants§

§

Compact

Smaller interactive targets, for narrow or short terminals, or touch input where every cell of screen space is scarce.

§

Relaxed

Larger interactive targets, comfortable to hit with a mouse on a normal desktop-sized terminal.

Implementations§

Source§

impl Density

Source

pub const fn min_target_size(self) -> Size

The minimum size, in cells, an interactive target should claim at this density.

Counter-intuitively, Compact targets are taller than Relaxed ones, not shorter: “compact” here means a narrow, likely touch-driven layout (a phone-width terminal, say), where a fingertip needs a noticeably taller row than a mouse pointer does, at the cost of showing fewer rows at once. Relaxed assumes a normal desktop terminal with a mouse, where dense, single-line rows are both legible and easy to click precisely.

Trait Implementations§

Source§

impl Clone for Density

Source§

fn clone(&self) -> Density

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
Source§

impl Copy for Density

Source§

impl Debug for Density

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Density

Source§

impl Hash for Density

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Density

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Density

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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.
Source§

impl<C> WithAlpha for C
where C: Copy,

Source§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see AlphaFirst).
Source§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see AlphaLast).