pub struct SplitterRatio(/* private fields */);Expand description
Shared, clonable divider position — the seam between a Splitter
buried in a widget tree and a host that wants to save or restore it.
Two-way by design: the splitter writes the cell on every drag, and
reads it at the start of each layout() so a host write (restoring a
document’s saved layout) lands on the next frame. They never fight —
the value the splitter adopts is the value it would publish.
Poisoning is swallowed: the payload is one f64 that no panic can
leave logically inconsistent, so both accessors take the inner value
rather than propagating a panic into the UI thread.
Implementations§
Source§impl SplitterRatio
impl SplitterRatio
Sourcepub fn new(ratio: f64) -> Self
pub fn new(ratio: f64) -> Self
New channel seeded with ratio (clamped like
Splitter::with_ratio; a non-finite seed falls back to a even
split, see Self::set).
Sourcepub fn get(&self) -> f64
pub fn get(&self) -> f64
Current divider position as a fraction of the total length going
to children[0] (left / top pane).
Sourcepub fn set(&self, ratio: f64) -> bool
pub fn set(&self, ratio: f64) -> bool
Ask the splitter to move. Applied on its next layout pass.
A non-finite ratio is ignored — f64::clamp passes NaN
through, and a NaN divider makes both panes zero-sized with no
way for the user to drag it back (the drag maths derives the new
ratio from the old one). Restoring a corrupt document therefore
leaves the splitter where it is rather than destroying the
layout. Returns true when the value was accepted.
Trait Implementations§
Source§impl Clone for SplitterRatio
impl Clone for SplitterRatio
Source§fn clone(&self) -> SplitterRatio
fn clone(&self) -> SplitterRatio
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SplitterRatio
impl RefUnwindSafe for SplitterRatio
impl Send for SplitterRatio
impl Sync for SplitterRatio
impl Unpin for SplitterRatio
impl UnsafeUnpin for SplitterRatio
impl UnwindSafe for SplitterRatio
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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