pub struct TextLayoutSnapshot {
pub lines: Vec<LineLayout>,
}Expand description
Plain-data paint-time geometry for an editable field (D116 layer 3).
Declared fresh each paint on EditableDecl, like everything else
there — never mutated by dispatch, only read.
Fields§
§lines: Vec<LineLayout>Implementations§
Source§impl TextLayoutSnapshot
impl TextLayoutSnapshot
Sourcepub fn position_at(&self, x: f32, y: f32) -> usize
pub fn position_at(&self, x: f32, y: f32) -> usize
The grapheme boundary nearest (x, y) — the click-to-caret
primitive. Picks the line whose y-band contains (or is nearest)
y, then within that line the boundary straddling x, snapped
to whichever side of the nearest glyph’s midpoint x falls on
(the universal “click past halfway selects the position after
it” convention). Returns 0 if the snapshot has no lines at all
(shouldn’t happen for a real editable widget’s own paint).
Sourcepub fn x_of(&self, char_idx: usize) -> Option<f32>
pub fn x_of(&self, char_idx: usize) -> Option<f32>
World-space x of char_idx, if it’s a known boundary in some
line — caret rendering and scroll-into-view both want this
(computed once here rather than re-measuring text at paint time
AND again at dispatch time from two different code paths).
Sourcepub fn line_range_at(&self, char_idx: usize) -> (usize, usize)
pub fn line_range_at(&self, char_idx: usize) -> (usize, usize)
The [start, end) range of the line containing char_idx —
triple-click-to-select-line. For TextInput (one line spanning
the whole value) this is equivalent to select-all; TextArea
(Step 4) gets real per-visual-line selection for free.
Trait Implementations§
Source§impl Clone for TextLayoutSnapshot
impl Clone for TextLayoutSnapshot
Source§fn clone(&self) -> TextLayoutSnapshot
fn clone(&self) -> TextLayoutSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more