Enum Breakpoint
pub enum Breakpoint {
Compact,
Medium,
Wide,
}Expand description
The one size class a surface derives from the rect it is laid out in.
A window’s shape is a fact about its current allocation, never a decision an app (or the host that launched it) stores: every layout pass asks this of the rect it was just handed, so a window narrowed or widened shows the layout that rect asks for on the very next frame.
Compact— one column at a time: phone width, a tablet held upright, a window dragged narrow. The sidebar, list and content are screens the person moves between.Medium— a docked sidebar and one primary column beside it: a small laptop, a large tablet on its side.Wide— a sidebar, a primary column and a second column (an overview beside a detail, a document beside an inspector).
The thresholds come from Metrics, so they grow with ui_scale and the
text scale exactly as the panels they separate do. A surface that holds a
class across frames uses BreakpointTracker, which keeps a threshold
from flapping when a window is dragged across it.
Variants§
Compact
One column at a time.
Medium
A docked sidebar and a primary column.
Wide
A sidebar, a primary column and a column beside it.
Implementations§
§impl Breakpoint
impl Breakpoint
pub fn thresholds(m: &Metrics) -> (f64, f64)
pub fn thresholds(m: &Metrics) -> (f64, f64)
The widths this class asks for, from the tokens: (compact, wide) —
below the first a surface shows one column at a time, at or above the
second it shows a column beside the primary one. Between them it
docks its sidebar and keeps one column.
The compact threshold is the sidebar beside the content it has to
keep (Metrics::compact_breakpoint); a second column joins at the
overview’s width past it, which is where a list beside a detail fits
beside a docked sidebar.
pub fn of(width: f64, m: &Metrics) -> Breakpoint
pub fn of(width: f64, m: &Metrics) -> Breakpoint
The class width asks for, without hysteresis: the answer a fresh
rect gets. A surface that lays out repeatedly asks
BreakpointTracker::derive instead.
width is in the space m is measured in. A surface whose text has
grown divides its rect’s width by Metrics::text_growth first, so a
window at 200 % text reaches each class where a 1× window half its
width does — the rule every text-sized breakpoint in the toolkit
already follows.
pub fn is_compact(self) -> bool
pub fn is_compact(self) -> bool
Whether the surface shows one column at a time.
Trait Implementations§
§impl Clone for Breakpoint
impl Clone for Breakpoint
§fn clone(&self) -> Breakpoint
fn clone(&self) -> Breakpoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Breakpoint
impl Debug for Breakpoint
§impl Default for Breakpoint
impl Default for Breakpoint
§fn default() -> Breakpoint
fn default() -> Breakpoint
§impl Hash for Breakpoint
impl Hash for Breakpoint
§impl Ord for Breakpoint
impl Ord for Breakpoint
§fn cmp(&self, other: &Breakpoint) -> Ordering
fn cmp(&self, other: &Breakpoint) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialEq for Breakpoint
impl PartialEq for Breakpoint
§impl PartialOrd for Breakpoint
impl PartialOrd for Breakpoint
impl Copy for Breakpoint
impl Eq for Breakpoint
impl StructuralPartialEq for Breakpoint
Auto Trait Implementations§
impl Freeze for Breakpoint
impl RefUnwindSafe for Breakpoint
impl Send for Breakpoint
impl Sync for Breakpoint
impl Unpin for Breakpoint
impl UnsafeUnpin for Breakpoint
impl UnwindSafe for Breakpoint
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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