pub struct TextEditorArgs {
pub width: Option<DimensionValue>,
pub height: Option<DimensionValue>,
pub min_width: Option<Dp>,
pub min_height: Option<Dp>,
pub background_color: Option<Color>,
pub border_width: f32,
pub border_color: Option<Color>,
pub shape: Shape,
pub padding: Dp,
pub focus_border_color: Option<Color>,
pub focus_background_color: Option<Color>,
pub selection_color: Option<Color>,
}
Expand description
Arguments for the text_editor
component.
§Example
use tessera_ui_basic_components::text_editor::{TextEditorArgs, TextEditorArgsBuilder, TextEditorState};
use tessera_ui::{Dp, DimensionValue, Px};
use std::sync::Arc;
use parking_lot::RwLock;
// Create a text editor with a fixed width and height.
let editor_args_fixed = TextEditorArgsBuilder::default()
.width(Some(DimensionValue::Fixed(Px(200)))) // pixels
.height(Some(DimensionValue::Fixed(Px(100)))) // pixels
.build()
.unwrap();
// Create a text editor that fills available width up to 500px, with a min width of 50px
let editor_args_fill_wrap = TextEditorArgsBuilder::default()
.width(Some(DimensionValue::Fill { min: Some(Px(50)), max: Some(Px(500)) })) // pixels
.height(Some(DimensionValue::Wrap { min: None, max: None }))
.build()
.unwrap();
// Create the editor state
let editor_state = Arc::new(RwLock::new(TextEditorState::new(Dp(10.0), None)));
// text_editor(editor_args_fixed, editor_state.clone());
// text_editor(editor_args_fill_wrap, editor_state.clone());
Arguments for configuring the text_editor
component.
TextEditorArgs
provides flexible options for layout, appearance, and interaction of the text editor.
All fields are optional and have sensible defaults. Use the builder pattern or convenience methods for construction.
§Fields
width
,height
: Optional constraints for the editor’s size (logical pixels or fill/wrap).min_width
,min_height
: Minimum size in density-independent pixels (Dp).background_color
,focus_background_color
: Editor background color (normal/focused).border_width
,border_color
,focus_border_color
: Border styling (width and color, normal/focused).shape
: Shape of the editor container (e.g., rounded rectangle).padding
: Inner padding (Dp).selection_color
: Highlight color for selected text.
§Example
use tessera_ui_basic_components::text_editor::{TextEditorArgs, TextEditorArgsBuilder};
use tessera_ui::{Dp, DimensionValue, Px};
let args = TextEditorArgsBuilder::default()
.width(Some(DimensionValue::Fixed(Px(300))))
.height(Some(DimensionValue::Fill { min: Some(Px(50)), max: Some(Px(500)) }))
.background_color(Some(tessera_ui::Color::WHITE))
.padding(Dp(8.0))
.build()
.unwrap();
Fields§
§width: Option<DimensionValue>
Optional width constraint for the text editor. Values are in logical pixels or fill/wrap.
height: Option<DimensionValue>
Optional height constraint for the text editor. Values are in logical pixels or fill/wrap.
min_width: Option<Dp>
Minimum width in density-independent pixels. Defaults to 120dp if not specified.
min_height: Option<Dp>
Minimum height in density-independent pixels. Defaults to line height + padding if not specified.
background_color: Option<Color>
Background color of the text editor (RGBA). Defaults to light gray.
border_width: f32
Border width in pixels. Defaults to 1.0.
border_color: Option<Color>
Border color (RGBA). Defaults to gray.
shape: Shape
The shape of the text editor container.
padding: Dp
Padding inside the text editor. Defaults to 5.0 Dp.
focus_border_color: Option<Color>
Border color when focused (RGBA). Defaults to blue.
focus_background_color: Option<Color>
Background color when focused (RGBA). Defaults to white.
selection_color: Option<Color>
Color for text selection highlight (RGBA). Defaults to light blue with transparency.
Implementations§
Source§impl TextEditorArgs
Convenience constructors for common use cases
impl TextEditorArgs
Convenience constructors for common use cases
Sourcepub fn simple() -> Self
pub fn simple() -> Self
Creates a simple text editor with default styling.
- Minimum width: 120dp
- Background: white
- Border: 1px gray, rounded rectangle
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::simple();
Source§impl TextEditorArgs
Builder methods for fluent API
impl TextEditorArgs
Builder methods for fluent API
Sourcepub fn with_width(self, width: DimensionValue) -> Self
pub fn with_width(self, width: DimensionValue) -> Self
Sets the width constraint for the editor.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::{DimensionValue, Px};
let args = TextEditorArgs::simple().with_width(DimensionValue::Fixed(Px(200)));
Sourcepub fn with_height(self, height: DimensionValue) -> Self
pub fn with_height(self, height: DimensionValue) -> Self
Sets the height constraint for the editor.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::{DimensionValue, Px};
let args = TextEditorArgs::simple().with_height(DimensionValue::Fixed(Px(100)));
Sourcepub fn with_min_width(self, min_width: Dp) -> Self
pub fn with_min_width(self, min_width: Dp) -> Self
Sets the minimum width in Dp.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_min_width(Dp(80.0));
Sourcepub fn with_min_height(self, min_height: Dp) -> Self
pub fn with_min_height(self, min_height: Dp) -> Self
Sets the minimum height in Dp.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_min_height(Dp(40.0));
Sourcepub fn with_background_color(self, color: Color) -> Self
pub fn with_background_color(self, color: Color) -> Self
Sets the background color.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_background_color(Color::WHITE);
Sourcepub fn with_border_width(self, width: f32) -> Self
pub fn with_border_width(self, width: f32) -> Self
Sets the border width in pixels.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
let args = TextEditorArgs::simple().with_border_width(2.0);
Sourcepub fn with_border_color(self, color: Color) -> Self
pub fn with_border_color(self, color: Color) -> Self
Sets the border color.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_border_color(Color::BLACK);
Sourcepub fn with_shape(self, shape: Shape) -> Self
pub fn with_shape(self, shape: Shape) -> Self
Sets the shape of the editor container.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui_basic_components::shape_def::Shape;
let args = TextEditorArgs::simple().with_shape(Shape::RoundedRectangle { corner_radius: 8.0, g2_k_value: 3.0 });
Sourcepub fn with_padding(self, padding: Dp) -> Self
pub fn with_padding(self, padding: Dp) -> Self
Sets the inner padding in Dp.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Dp;
let args = TextEditorArgs::simple().with_padding(Dp(12.0));
Sourcepub fn with_focus_border_color(self, color: Color) -> Self
pub fn with_focus_border_color(self, color: Color) -> Self
Sets the border color when focused.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_focus_border_color(Color::new(0.0, 0.5, 1.0, 1.0));
Sourcepub fn with_focus_background_color(self, color: Color) -> Self
pub fn with_focus_background_color(self, color: Color) -> Self
Sets the background color when focused.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_focus_background_color(Color::WHITE);
Sourcepub fn with_selection_color(self, color: Color) -> Self
pub fn with_selection_color(self, color: Color) -> Self
Sets the selection highlight color.
§Example
use tessera_ui_basic_components::text_editor::TextEditorArgs;
use tessera_ui::Color;
let args = TextEditorArgs::simple().with_selection_color(Color::new(0.5, 0.7, 1.0, 0.4));
Trait Implementations§
Source§impl Clone for TextEditorArgs
impl Clone for TextEditorArgs
Source§fn clone(&self) -> TextEditorArgs
fn clone(&self) -> TextEditorArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TextEditorArgs
impl Debug for TextEditorArgs
Source§impl Default for TextEditorArgs
impl Default for TextEditorArgs
Source§fn default() -> TextEditorArgs
fn default() -> TextEditorArgs
Auto Trait Implementations§
impl Freeze for TextEditorArgs
impl RefUnwindSafe for TextEditorArgs
impl Send for TextEditorArgs
impl Sync for TextEditorArgs
impl Unpin for TextEditorArgs
impl UnwindSafe for TextEditorArgs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> Pointable for T
impl<T> Pointable for T
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()
.