Skip to main content

RhythmGrid

Struct RhythmGrid 

Source
pub struct RhythmGrid { /* private fields */ }
Available on crate feature gpui only.
Expand description

The vertical rhythm grid in gpui units.

Implementations§

Source§

impl RhythmGrid

Source

pub fn new(size: Pixels) -> Self

Create a grid with a finite, positive rhythm-unit size.

§Panics

Panics when size is zero, negative, or non-finite.

Source

pub fn size(&self) -> Pixels

Height of one rhythm unit.

Source

pub const fn rhythm(&self) -> Rhythm

This grid as the dependency-free Rhythm — the entry to the math layer, mirroring RhythmFont::metrics for fonts. Use it to hand this grid to the f32 layer: FontRhythm geometry takes it per call, and RhythmLineMetrics takes it once at construction.

Source

pub fn spacing(&self, n: i32) -> Pixels

Axis-neutral length of n rhythm units. Use this for horizontal indents, gaps, or padding measured with the same scale as the vertical rhythm.

Source

pub fn height(&self, n: i32) -> Pixels

Total height of n rhythm units (rhythm-sass rhythm($n)). An exact alias for spacing, kept as the vertical name.

Source

pub fn snap_up(&self, height: Pixels) -> Pixels

Round height up to whole rhythm rows — the pad strategy for content whose height is not rhythm-controlled; see Rhythm::snap_up. With a known width this is all a media block needs: div().w(w).h(grid.snap_up(w / ratio)); for fluid widths use rhythm_frame.

§Panics

Panics when height is negative or non-finite.

Source

pub fn snap_down(&self, height: Pixels) -> Pixels

Round height down to whole rhythm rows — the crop strategy; see Rhythm::snap_down.

§Panics

Panics when height is negative or non-finite.

Source

pub fn line_metrics( &self, ascent: Pixels, descent: Pixels, line_rhythms: u32, ) -> RhythmLineMetrics

Metrics for one shaped line on this grid — the Pixels-typed entry to RhythmLineMetrics. Feed a WrappedLine’s ascent() / descent() (the shaped maxima over the line’s explicit font runs) and the line height in whole rhythm units; see RhythmLineMetrics for the placement contract.

Source

pub fn line_metrics_at_least( &self, ascent: Pixels, descent: Pixels, line_rhythms: u32, ) -> RhythmLineMetrics

line_metrics with line_rhythms as a floor: grow the line box when the reported ascent/descent envelope needs more rows.

Source

pub fn line_metrics_covering( &self, metrics: &[RhythmLineMetrics], ) -> RhythmLineMetrics

The smallest line box on this grid containing every line in metrics.

§Panics

Panics when metrics is empty or an entry was built on another grid.

Source

pub fn font( &self, text_system: &TextSystem, font: Font, font_size: Pixels, line_rhythms: u32, ) -> RhythmFont

Resolve a font bound to this grid — RhythmFont::resolve with the grid slot filled in; see it for the fallback-resolution caveats.

Source

pub fn overlay(&self, color: impl Into<Hsla>) -> RhythmOverlay

A debug overlay on this grid in a custom colorrhythm_overlay as a grid factory. Pass the result to RhythmStyled::rhythm_debug_overlay in place of the bare grid to customize the stripes without giving up the chainable toggle.

Trait Implementations§

Source§

impl Clone for RhythmGrid

Source§

fn clone(&self) -> RhythmGrid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RhythmGrid

Source§

impl Debug for RhythmGrid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<RhythmGrid> for RhythmOverlay

A bare grid converts to its default debug appearance — the classic translucent red (0xff78783f), zero phase — which is what lets RhythmStyled::rhythm_debug_overlay accept the grid directly.

Source§

fn from(grid: RhythmGrid) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RhythmGrid

Source§

fn eq(&self, other: &RhythmGrid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RhythmGrid

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more