#[repr(transparent)]pub struct Dp(pub f32);Expand description
Density-independent pixels. Authoring APIs (Modifier, layout) take this.
Compose parity (Dp.kt): value class, Hairline/Infinity/Unspecified,
isSpecified, arithmetic, coerce*, lerp.
Tuple Fields§
§0: f32Implementations§
Source§impl Dp
impl Dp
pub const ZERO: Dp
pub const INFINITY: Dp
Sourcepub const UNSPECIFIED: Dp
pub const UNSPECIFIED: Dp
Compose Dp.Unspecified (NaN sentinel).
pub const fn from_px_raw(v: f32) -> Dp
Sourcepub fn is_specified(self) -> bool
pub fn is_specified(self) -> bool
false for Dp::UNSPECIFIED.
Sourcepub fn is_unspecified(self) -> bool
pub fn is_unspecified(self) -> bool
true for Dp::UNSPECIFIED.
Sourcepub fn take_or_else(self, block: impl FnOnce() -> Dp) -> Dp
pub fn take_or_else(self, block: impl FnOnce() -> Dp) -> Dp
Return self if specified, else block(). (Compose takeOrElse.)
pub fn is_finite(self) -> bool
pub fn coerce_in(self, min: Dp, max: Dp) -> Dp
pub fn coerce_at_least(self, min: Dp) -> Dp
pub fn coerce_at_most(self, max: Dp) -> Dp
Sourcepub fn to_px_with_scale(self, scale: f32) -> Px
pub fn to_px_with_scale(self, scale: f32) -> Px
Convert to physical pixels with an explicit scale.
Sourcepub fn round_to_px(self) -> i32
pub fn round_to_px(self) -> i32
Round to whole pixels with the ambient scale (Compose roundToPx).
Trait Implementations§
impl Copy for Dp
Source§impl From<f32> for Dp
Standard conversions so generic code can use .into().
Setters intentionally keep taking Dp/Sp directly (no impl Into<Dp>
params) so call sites stay explicit: 16.dp() or Dp(16.0).
impl From<f32> for Dp
Standard conversions so generic code can use .into().
Setters intentionally keep taking Dp/Sp directly (no impl Into<Dp>
params) so call sites stay explicit: 16.dp() or Dp(16.0).
Source§impl PartialOrd for Dp
impl PartialOrd for Dp
impl StructuralPartialEq for Dp
Auto Trait Implementations§
impl Freeze for Dp
impl RefUnwindSafe for Dp
impl Send for Dp
impl Sync for Dp
impl Unpin for Dp
impl UnsafeUnpin for Dp
impl UnwindSafe for Dp
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
Mutably borrows from an owned value. Read more