pub struct TextArea {
pub value: String,
pub placeholder: String,
pub focused: bool,
pub width: Option<f32>,
pub height: f32,
pub font_size: Option<f32>,
pub radius: f32,
/* private fields */
}Expand description
A multi-line, wrapped, virtualized-paint text field (D116 Step 4).
Built entirely on the same D116 core TextInput uses — Transaction/
Selection/Command/EditController are unchanged; TextLayoutSnapshot
already models “a list of visual lines” so TextArea just populates one
LineLayout per WRAPPED line instead of TextInput’s single entry.
Click/drag/double/triple-click dispatch in engine.rs is untouched —
it only ever talks to editable.layout, never knows which widget it’s
looking at.
New in this widget: word-wrapping (wrap_char_ranges below), Enter
inserts a real newline (engine.rs, gated on multiline), Up/Down
cross wrapped lines with goal-column memory (TextEditState::goal_x),
and vertical scrolling via the same zero-wiring rosace_scroll::ScrollController
ListView/ScrollView use (D101) — wheel events mutate the
controller’s atoms directly, never the render tree, so there’s no
!Sync/!Send wall to work around here the way click dispatch has.
Paint is virtualized: every visual line’s geometry is computed each frame (needed for correct click-anywhere/goal-column behavior), but only lines intersecting the current viewport actually emit paint commands — a large document’s PAINT cost stays bounded even though its LAYOUT cost does not yet (a named follow-up, not this step’s exit bar).
Fields§
§value: String§placeholder: String§focused: bool§width: Option<f32>§height: f32§font_size: Option<f32>None = read from the active theme’s typography.body_medium
(D127 “environment” track — see Checkbox::resolved_font_size’s doc
for the reasoning).
radius: f32Implementations§
Source§impl TextArea
impl TextArea
pub fn new() -> Self
pub fn value(self, v: impl Into<String>) -> Self
pub fn placeholder(self, p: impl Into<String>) -> Self
pub fn focused(self) -> Self
pub fn width(self, w: f32) -> Self
pub fn height(self, h: f32) -> Self
Sourcepub fn background(self, c: Color) -> Self
pub fn background(self, c: Color) -> Self
See TextInput::background — same seam, same contract.
Sourcepub fn focus_color(self, c: Color) -> Self
pub fn focus_color(self, c: Color) -> Self
See TextInput::focus_color — same seam, same contract.
pub fn on_change(self, f: impl Fn(String) + Send + Sync + 'static) -> Self
pub fn controller(self, c: EditController) -> Self
Sourcepub fn spans(
self,
f: impl Fn(&str, Option<(usize, usize)>) -> Vec<Span> + Send + Sync + 'static,
) -> Self
pub fn spans( self, f: impl Fn(&str, Option<(usize, usize)>) -> Vec<Span> + Send + Sync + 'static, ) -> Self
See TextInput::spans — same seam, same contract (D116 Step 5).
Sourcepub fn cursor_style(self, s: CursorStyle) -> Self
pub fn cursor_style(self, s: CursorStyle) -> Self
See TextInput::cursor_style — same seam, same contract.
Sourcepub fn field(self, f: FormField) -> Self
pub fn field(self, f: FormField) -> Self
See TextInput::field — same seam, same contract (D116 Step 8).
Sourcepub fn filters(self, filters: Vec<InputFilter>) -> Self
pub fn filters(self, filters: Vec<InputFilter>) -> Self
See TextInput::filters — same seam, same contract.
Sourcepub fn no_scrollbar(self) -> Self
pub fn no_scrollbar(self) -> Self
Hide the vertical scroll-position thumb (see ScrollView::no_scrollbar
— same convention). Content still scrolls; only the indicator is gone.
pub fn scrollbar_color(self, c: Color) -> Self
Trait Implementations§
Source§impl Widget for TextArea
impl Widget for TextArea
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read more