pub struct BlockLayouts(/* private fields */);Expand description
Where each block’s text landed, recorded as it painted.
A caret has to be placeable by pointer, and only paint knows where a glyph ended up. An editor hands one of these in, the renderer fills it, and the next click resolves against it. Read-only callers pass nothing and pay nothing.
Implementations§
Source§impl BlockLayouts
impl BlockLayouts
Sourcepub fn hit(&self, point: Point<Pixels>) -> Option<(Cursor, Affinity)>
pub fn hit(&self, point: Point<Pixels>) -> Option<(Cursor, Affinity)>
The position under point.
Falls back to the nearest text vertically, so clicking the margin beside a line — or below the last one — still lands somewhere useful rather than doing nothing.
Sourcepub fn position(
&self,
at: Cursor,
affinity: Affinity,
) -> Option<(Point<Pixels>, Pixels)>
pub fn position( &self, at: Cursor, affinity: Affinity, ) -> Option<(Point<Pixels>, Pixels)>
Where a position painted last frame, on the row affinity names at a
soft wrap, and how tall its line is.
Vertical motion is geometry rather than arithmetic on line numbers, so
a wrapped row and a hard newline are the same case and neither needs
counting — the rule ui::TextField arrived at.
Sourcepub fn row_start(&self, at: Cursor, affinity: Affinity) -> Option<Cursor>
pub fn row_start(&self, at: Cursor, affinity: Affinity) -> Option<Cursor>
The start of the painted row holding at.
Sourcepub fn row_end(
&self,
at: Cursor,
affinity: Affinity,
) -> Option<(Cursor, Affinity)>
pub fn row_end( &self, at: Cursor, affinity: Affinity, ) -> Option<(Cursor, Affinity)>
The end of the painted row holding at, and the affinity that keeps a
caret there on that row.
Sourcepub fn wraps_at(&self, at: Cursor) -> bool
pub fn wraps_at(&self, at: Cursor) -> bool
Whether at is a soft wrap last frame: the end of one painted row and
the start of the next.
Sourcepub fn rects(&self, selection: Selection) -> Vec<Bounds<Pixels>>
pub fn rects(&self, selection: Selection) -> Vec<Bounds<Pixels>>
The painted rows of a range, in document order — what a bar centred over a selection is placed against, and what a highlight of a caller’s own is drawn from.
One rect per visual row rather than one box: a selection that wraps or crosses blocks has no single box, and a caller given one would paint over the gaps.
Sourcepub fn step_row(
&self,
at: Cursor,
affinity: Affinity,
x: Pixels,
down: bool,
) -> Option<(Cursor, Affinity)>
pub fn step_row( &self, at: Cursor, affinity: Affinity, x: Pixels, down: bool, ) -> Option<(Cursor, Affinity)>
The position one painted row above or below at nearest x. Walks
the recorded runs in paint order — which is document order.
Not a hit test: the gap between blocks belongs to no run, so a probe there answers with whichever run is nearest — and at a boundary that is the block being left, whose bottom edge is zero pixels away while the next block’s top is a whole gap.
Sourcepub fn over_text(&self, point: Point<Pixels>) -> bool
pub fn over_text(&self, point: Point<Pixels>) -> bool
Whether point is inside painted text.
Self::hit answers with the nearest run wherever it is asked, which
is what a click wants and what a pointer must not have: an I-beam
belongs where a caret would land, not everywhere an editor’s box
reaches.
Sourcepub fn block_at(&self, point: Point<Pixels>) -> Option<usize>
pub fn block_at(&self, point: Point<Pixels>) -> Option<usize>
The block under point, for a gutter handle and a drop target.
Sourcepub fn first_row(&self, ix: usize) -> Option<(Pixels, Pixels)>
pub fn first_row(&self, ix: usize) -> Option<(Pixels, Pixels)>
Where a block’s first painted row sits, and how tall that row is — what a mark in the gutter has to line up with.
Self::block_bounds is not that: it spans every row the block holds,
and a heading’s single row is taller than a paragraph’s, so anything
placed from the top of the box rides above the text it points at.
None for a block that paints no text at all, a rule being the one
that does.
Sourcepub fn block_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn block_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where a block painted last frame, in window coordinates.
Sourcepub fn language_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn language_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where a fenced block’s language label painted — the box a host hangs its picker on. Recorded rather than derived: the word’s width is the text system’s answer, and padding arithmetic would be wrong the first time any of it changed.
Sourcepub fn painted_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn painted_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where a resizable painted block painted last frame — a painted fence,
or an embed card — and None for any other block.
Sourcepub fn picture_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn picture_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where an image block’s picture painted, which
BlockLayouts::block_bounds does not give: that box spans the column
and takes in the caption, so a handle placed from it sits off the edge
of any picture narrower than the page.
Sourcepub fn checkbox_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
pub fn checkbox_bounds(&self, ix: usize) -> Option<Bounds<Pixels>>
Where a task block’s checkbox painted, which is the box itself and not the marker column it sits in — a press outside it is a press on the gutter, and belongs to whatever handles one.
Sourcepub fn cell_bounds(&self, ix: usize, part: Part) -> Option<Bounds<Pixels>>
pub fn cell_bounds(&self, ix: usize, part: Part) -> Option<Bounds<Pixels>>
Where a table cell painted, padding included.
Sourcepub fn cell_at(&self, point: Point<Pixels>) -> Option<(usize, Part)>
pub fn cell_at(&self, point: Point<Pixels>) -> Option<(usize, Part)>
The table cell under point: its block and part.
Sourcepub fn reveal(&self, range: Selection)
pub fn reveal(&self, range: Selection)
Scrolls the document until the start of range shows, centring it
when it does not.
Answered over the next few frames by a document rendered with these
layouts and an Editing::scroll; without one the request is dropped
at the next frame. A later call replaces an earlier one.
Sourcepub fn reveal_with(&self, range: Selection, mode: RevealMode)
pub fn reveal_with(&self, range: Selection, mode: RevealMode)
Self::reveal, placing the start of range by mode.
Sourcepub fn top(&self, at: Cursor) -> Option<Pixels>
pub fn top(&self, at: Cursor) -> Option<Pixels>
Where at sits down the window, as last frame placed it: the top of
its row where that row painted, else the top of the item holding it — a
block, or a line of the source — measured or guessed. None before the
column has been laid out.
Off screen the answer is a guess until the item is built, and moves when it is measured.
Trait Implementations§
Source§impl Clone for BlockLayouts
impl Clone for BlockLayouts
Auto Trait Implementations§
impl !RefUnwindSafe for BlockLayouts
impl !Send for BlockLayouts
impl !Sync for BlockLayouts
impl !UnwindSafe for BlockLayouts
impl Freeze for BlockLayouts
impl Unpin for BlockLayouts
impl UnsafeUnpin for BlockLayouts
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().