pub struct AlignHints {
pub horiz: Option<Align>,
pub vert: Option<Align>,
}
Expand description
Partial alignment information provided by the parent
Hints are optional. Widgets are expected to substitute default values where hints are not provided.
The AlignHints::complete
method is provided to conveniently apply
alignment to a widget within crate::Layout::set_rect
:
let pref_size = Size(30, 20); // usually size comes from SizeCx
let rect = align
.complete(Align::Stretch, Align::Center)
.aligned_rect(pref_size, rect);
// self.core.rect = rect;
Fields§
§horiz: Option<Align>
§vert: Option<Align>
Implementations§
Source§impl AlignHints
impl AlignHints
Sourcepub const NONE: AlignHints
pub const NONE: AlignHints
No hints
Sourcepub const TOP: AlignHints
pub const TOP: AlignHints
Top, no horizontal hint
Sourcepub const BOTTOM: AlignHints
pub const BOTTOM: AlignHints
Bottom, no horizontal hint
Sourcepub const LEFT: AlignHints
pub const LEFT: AlignHints
Left, no vertical hint
Sourcepub const RIGHT: AlignHints
pub const RIGHT: AlignHints
Right, no vertical hint
Sourcepub const TOP_LEFT: AlignHints
pub const TOP_LEFT: AlignHints
Top, left
Sourcepub const TOP_RIGHT: AlignHints
pub const TOP_RIGHT: AlignHints
Top, right
Sourcepub const BOTTOM_LEFT: AlignHints
pub const BOTTOM_LEFT: AlignHints
Bottom, left
Sourcepub const BOTTOM_RIGHT: AlignHints
pub const BOTTOM_RIGHT: AlignHints
Bottom, right
Sourcepub const CENTER: AlignHints
pub const CENTER: AlignHints
Center on both axes
Sourcepub const TOP_CENTER: AlignHints
pub const TOP_CENTER: AlignHints
Top, center
Sourcepub const BOTTOM_CENTER: AlignHints
pub const BOTTOM_CENTER: AlignHints
Bottom, center
Sourcepub const CENTER_LEFT: AlignHints
pub const CENTER_LEFT: AlignHints
Center, left
Sourcepub const CENTER_RIGHT: AlignHints
pub const CENTER_RIGHT: AlignHints
Center, right
Sourcepub const STRETCH: AlignHints
pub const STRETCH: AlignHints
Stretch on both axes
Sourcepub const fn new(horiz: Option<Align>, vert: Option<Align>) -> Self
pub const fn new(horiz: Option<Align>, vert: Option<Align>) -> Self
Construct with optional horiz. and vert. alignment
Sourcepub fn extract(self, dir: impl Directional) -> Option<Align>
pub fn extract(self, dir: impl Directional) -> Option<Align>
Take horizontal/vertical component
Sourcepub fn set_component<D: Directional>(&mut self, dir: D, align: Option<Align>)
pub fn set_component<D: Directional>(&mut self, dir: D, align: Option<Align>)
Set one component of self, based on a direction
Sourcepub fn combine(self, rhs: AlignHints) -> Self
pub fn combine(self, rhs: AlignHints) -> Self
Combine two hints (first takes priority)
Sourcepub fn unwrap_or(self, horiz: Align, vert: Align) -> (Align, Align)
pub fn unwrap_or(self, horiz: Align, vert: Align) -> (Align, Align)
Unwrap type’s alignments or substitute parameters
Sourcepub fn complete(&self, horiz: Align, vert: Align) -> AlignPair
pub fn complete(&self, horiz: Align, vert: Align) -> AlignPair
Complete, using specified alignments as defaults
Sourcepub fn complete_default(&self) -> AlignPair
pub fn complete_default(&self) -> AlignPair
Complete, using Align::Default
as defaults
Sourcepub fn complete_center(&self) -> AlignPair
pub fn complete_center(&self) -> AlignPair
Complete, using Align::Center
as defaults
Trait Implementations§
Source§impl Clone for AlignHints
impl Clone for AlignHints
Source§fn clone(&self) -> AlignHints
fn clone(&self) -> AlignHints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AlignHints
impl Debug for AlignHints
Source§impl Default for AlignHints
impl Default for AlignHints
Source§fn default() -> AlignHints
fn default() -> AlignHints
Source§impl Hash for AlignHints
impl Hash for AlignHints
Source§impl PartialEq for AlignHints
impl PartialEq for AlignHints
impl Copy for AlignHints
impl Eq for AlignHints
impl StructuralPartialEq for AlignHints
Auto Trait Implementations§
impl Freeze for AlignHints
impl RefUnwindSafe for AlignHints
impl Send for AlignHints
impl Sync for AlignHints
impl Unpin for AlignHints
impl UnwindSafe for AlignHints
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
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>
. Box<dyn Any>
can
then be further downcast
into Box<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>
. Rc<Any>
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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.