Struct zng::layout::LayoutMetrics
source · pub struct LayoutMetrics { /* private fields */ }
Expand description
Layout metrics in a LAYOUT
context.
Implementations§
source§impl LayoutMetrics
impl LayoutMetrics
sourcepub fn new(
scale_factor: Factor,
viewport: Size2D<Px, Px>,
font_size: Px,
) -> LayoutMetrics
pub fn new( scale_factor: Factor, viewport: Size2D<Px, Px>, font_size: Px, ) -> LayoutMetrics
New root LayoutMetrics
.
The font_size
sets both font sizes, the initial PPI is 96.0
, you can use the builder style method and
with_screen_ppi
to set a different value.
sourcepub fn constraints(&self) -> PxConstraints2d
pub fn constraints(&self) -> PxConstraints2d
Current size constraints.
sourcepub fn z_constraints(&self) -> PxConstraints
pub fn z_constraints(&self) -> PxConstraints
Current perspective constraints.
sourcepub fn inline_constraints(&self) -> Option<InlineConstraints>
pub fn inline_constraints(&self) -> Option<InlineConstraints>
Current inline constraints.
Only present if the parent widget supports inline.
sourcepub fn direction(&self) -> LayoutDirection
pub fn direction(&self) -> LayoutDirection
Gets the inline or text flow direction.
sourcepub fn root_font_size(&self) -> Px
pub fn root_font_size(&self) -> Px
Computed font size at the root widget.
sourcepub fn scale_factor(&self) -> Factor
pub fn scale_factor(&self) -> Factor
Pixel scale factor.
sourcepub fn viewport(&self) -> Size2D<Px, Px>
pub fn viewport(&self) -> Size2D<Px, Px>
Computed size of the nearest viewport ancestor.
This is usually the window content area size, but can be the scroll viewport size or any other value depending on the implementation of the context widgets.
sourcepub fn viewport_min(&self) -> Px
pub fn viewport_min(&self) -> Px
Smallest dimension of the viewport
.
sourcepub fn viewport_max(&self) -> Px
pub fn viewport_max(&self) -> Px
Largest dimension of the viewport
.
sourcepub fn screen_ppi(&self) -> Ppi
pub fn screen_ppi(&self) -> Ppi
The current screen “pixels-per-inch” resolution.
This value is dependent in the actual physical size of the screen.
Default is 96.0
.
sourcepub fn leftover(&self) -> Size2D<Option<Px>, ()>
pub fn leftover(&self) -> Size2D<Option<Px>, ()>
Computed leftover length for the widget, given the Length::Leftover
value it communicated to the parent.
sourcepub fn with_constraints(self, constraints: PxConstraints2d) -> LayoutMetrics
pub fn with_constraints(self, constraints: PxConstraints2d) -> LayoutMetrics
Sets the constraints
to constraints
.
sourcepub fn with_z_constraints(self, constraints: PxConstraints) -> LayoutMetrics
pub fn with_z_constraints(self, constraints: PxConstraints) -> LayoutMetrics
Sets the z_constraints
to constraints
.
sourcepub fn with_inline_constraints(
self,
inline_constraints: Option<InlineConstraints>,
) -> LayoutMetrics
pub fn with_inline_constraints( self, inline_constraints: Option<InlineConstraints>, ) -> LayoutMetrics
Set the inline_constraints
.
sourcepub fn with_font_size(self, font_size: Px) -> LayoutMetrics
pub fn with_font_size(self, font_size: Px) -> LayoutMetrics
Sets the font_size
.
sourcepub fn with_viewport(self, viewport: Size2D<Px, Px>) -> LayoutMetrics
pub fn with_viewport(self, viewport: Size2D<Px, Px>) -> LayoutMetrics
Sets the viewport
.
sourcepub fn with_scale_factor(self, scale_factor: Factor) -> LayoutMetrics
pub fn with_scale_factor(self, scale_factor: Factor) -> LayoutMetrics
Sets the scale_factor
.
sourcepub fn with_screen_ppi(self, screen_ppi: Ppi) -> LayoutMetrics
pub fn with_screen_ppi(self, screen_ppi: Ppi) -> LayoutMetrics
Sets the screen_ppi
.
sourcepub fn with_direction(self, direction: LayoutDirection) -> LayoutMetrics
pub fn with_direction(self, direction: LayoutDirection) -> LayoutMetrics
Sets the direction
.
sourcepub fn with_leftover(
self,
width: Option<Px>,
height: Option<Px>,
) -> LayoutMetrics
pub fn with_leftover( self, width: Option<Px>, height: Option<Px>, ) -> LayoutMetrics
Sets the leftover
.
sourcepub fn snapshot(&self) -> LayoutMetricsSnapshot
pub fn snapshot(&self) -> LayoutMetricsSnapshot
Clones all current metrics into a snapshot.
Trait Implementations§
source§impl Clone for LayoutMetrics
impl Clone for LayoutMetrics
source§fn clone(&self) -> LayoutMetrics
fn clone(&self) -> LayoutMetrics
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for LayoutMetrics
impl RefUnwindSafe for LayoutMetrics
impl Send for LayoutMetrics
impl Sync for LayoutMetrics
impl Unpin for LayoutMetrics
impl UnwindSafe for LayoutMetrics
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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> 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 more