pub struct MediaBlock {
pub source: MediaSource,
pub intrinsic: Option<(u32, u32)>,
pub fit: MediaFit,
pub alt: String,
pub height_lh: Option<f32>,
}Expand description
An inline media block: what to draw, how big, and what to say instead.
Fields§
§source: MediaSource§intrinsic: Option<(u32, u32)>Natural size in pixels, once a header read has established it.
None until then — and a block is perfectly usable meanwhile, which
is the point: it reserves rows either way.
fit: MediaFit§alt: StringWhat the TUI shows and what a screen reader reads. Never empty in
practice — MediaBlock::new falls back to the file name — because
a blank box tells the user nothing about what they are missing.
height_lh: Option<f32>IM.5: the block’s drawn height in line-heights, once geometry is
known — None until then.
This is the number that makes the block genuinely variable-height rather than snapped to whole rows, and it is deliberately allowed to differ from the reserved row count. A 3.4-line-height image reserves 4 rows and draws 3.4 of them.
The HOST populates it, in the media pump’s sizing pass, from the
file’s header and the drawing peer’s published cell metrics
(inline-media.md §7.1). This comment used to say the renderer did,
“through RowWeights” — which was the intent and never the code: no
renderer ever wrote it, so it stayed None on every block and the
GPUI peer skipped each one as unresolved.
None still means “not measured”, and a peer that draws pixels must
treat it that way: on a peer that published no metrics, and for a file
whose header could not be read, it stays None and the alt text is
the rendering.
Implementations§
Source§impl MediaBlock
impl MediaBlock
Sourcepub fn new(path: impl Into<PathBuf>, alt: Option<String>) -> Self
pub fn new(path: impl Into<PathBuf>, alt: Option<String>) -> Self
A block for path, with alt defaulting to the file’s name when the
producer has nothing better.
Sourcepub fn line_heights(&self, rows: u16) -> f32
pub fn line_heights(&self, rows: u16) -> f32
Height in line-heights — the drawn height once geometry is known, else the reserved row count.
The fallback is what keeps a block harmless before its size is resolved and on any peer that does not draw media: it then costs the scroll walks exactly what its rows already cost, so introducing a block cannot move an existing scroll position.
Trait Implementations§
Source§impl Clone for MediaBlock
impl Clone for MediaBlock
Source§fn clone(&self) -> MediaBlock
fn clone(&self) -> MediaBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more