Skip to main content

TextFieldLayout

Struct TextFieldLayout 

Source
pub struct TextFieldLayout {
    pub lines: Vec<TextFieldLine>,
    pub line_h: f32,
    pub top_pad: f32,
    pub text_width: f32,
    pub content_height: f32,
    pub viewport_height: f32,
    pub max_scroll: f32,
    pub scroll_y: f32,
}
Expand description

TextField 的可视布局:视觉行 + 行高/滚动几何

Fields§

§lines: Vec<TextFieldLine>§line_h: f32§top_pad: f32§text_width: f32§content_height: f32§viewport_height: f32

文本可视区高度(不含上下 padding)

§max_scroll: f32§scroll_y: f32

已 clamp 的滚动偏移

Implementations§

Source§

impl TextFieldLayout

Source

pub fn cursor_line(&self, cursor: usize) -> usize

光标所在视觉行(软换行边界取下一行,便于继续输入)

Source

pub fn line_text<'a>(&self, value: &'a str, index: usize) -> &'a str

Source

pub fn x_at_in_line( &self, value: &str, line_index: usize, byte: usize, font_size: f32, ) -> f32

指定行内 byte 位置相对文本区左缘的 x(未加 PAD_X)

与 Self::cursor_x 的区别:soft wrap 边界处 byte 同时属于两行, 这里强制按调用方指定的行计算(选区逐行高亮必须用这个)。

Source

pub fn single_line_char_positions( &self, value: &str, font_size: f32, ) -> Option<(Vec<f32>, Vec<f32>)>

单行 LTR 文本的逐字符位置/宽度(相对文本区左缘)。

多行、soft wrap 后多行或 RTL 文本返回 None:AccessKit 的 character_positions 是单行标量,跨行/RTL 需要拆成多个 TextRun。

Source

pub fn cursor_x(&self, value: &str, cursor: usize, font_size: f32) -> f32

光标相对文本区左缘的 x(未加 PAD_X)

Source

pub fn cursor_y(&self, cursor: usize) -> f32

光标相对 widget 顶部的 y(已含 top_pad 与滚动)

Source

pub fn offset_at(&self, value: &str, x: f32, y: f32, font_size: f32) -> usize

把局部坐标映射为 value 字节偏移

Source

pub fn scroll_to_show(&self, cursor: usize) -> f32

保证 cursor 所在视觉行可见,返回新的 scroll_y

Trait Implementations§

Source§

impl Clone for TextFieldLayout

Source§

fn clone(&self) -> TextFieldLayout

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 Debug for TextFieldLayout

Source§

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

Formats the value using the given formatter. Read more

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<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,