pub struct RhythmGrid { /* private fields */ }gpui only.Expand description
The vertical rhythm grid in gpui units.
Implementations§
Source§impl RhythmGrid
impl RhythmGrid
Sourcepub fn new(size: Pixels) -> Self
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.
Sourcepub const fn rhythm(&self) -> Rhythm
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.
Sourcepub fn spacing(&self, n: i32) -> Pixels
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.
Sourcepub fn height(&self, n: i32) -> Pixels
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.
Sourcepub fn snap_up(&self, height: Pixels) -> Pixels
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.
Sourcepub fn snap_down(&self, height: Pixels) -> Pixels
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.
Sourcepub fn line_metrics(
&self,
ascent: Pixels,
descent: Pixels,
line_rhythms: u32,
) -> RhythmLineMetrics
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.
Sourcepub fn line_metrics_at_least(
&self,
ascent: Pixels,
descent: Pixels,
line_rhythms: u32,
) -> RhythmLineMetrics
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.
Sourcepub fn line_metrics_covering(
&self,
metrics: &[RhythmLineMetrics],
) -> RhythmLineMetrics
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.
Sourcepub fn font(
&self,
text_system: &TextSystem,
font: Font,
font_size: Pixels,
line_rhythms: u32,
) -> RhythmFont
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.
Sourcepub fn overlay(&self, color: impl Into<Hsla>) -> RhythmOverlay
pub fn overlay(&self, color: impl Into<Hsla>) -> RhythmOverlay
A debug overlay on this grid in a custom color — rhythm_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
impl Clone for RhythmGrid
Source§fn clone(&self) -> RhythmGrid
fn clone(&self) -> RhythmGrid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RhythmGrid
Source§impl Debug for RhythmGrid
impl Debug for RhythmGrid
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.
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
fn from(grid: RhythmGrid) -> Self
Source§impl PartialEq for RhythmGrid
impl PartialEq for RhythmGrid
impl StructuralPartialEq for RhythmGrid
Auto Trait Implementations§
impl Freeze for RhythmGrid
impl RefUnwindSafe for RhythmGrid
impl Send for RhythmGrid
impl Sync for RhythmGrid
impl Unpin for RhythmGrid
impl UnsafeUnpin for RhythmGrid
impl UnwindSafe for RhythmGrid
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>. 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<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