pub struct TextBox<T> {
pub font_size: f32,
pub line_height: f32,
pub font: FamilyOwned,
pub color: sRGB,
pub weight: Weight,
pub style: Style,
pub wrap: Wrap,
pub align: Option<Align>,
pub slots: [Option<Slot>; 1],
/* private fields */
}
Fields§
§font_size: f32
§line_height: f32
§font: FamilyOwned
§color: sRGB
§weight: Weight
§style: Style
§wrap: Wrap
§align: Option<Align>
§slots: [Option<Slot>; 1]
Implementations§
Source§impl<T: Prop + 'static> TextBox<T>
impl<T: Prop + 'static> TextBox<T>
Sourcepub fn new(
id: Arc<SourceID>,
props: T,
font_size: f32,
line_height: f32,
font: FamilyOwned,
color: sRGB,
weight: Weight,
style: Style,
wrap: Wrap,
align: Option<Align>,
) -> Self
pub fn new( id: Arc<SourceID>, props: T, font_size: f32, line_height: f32, font: FamilyOwned, color: sRGB, weight: Weight, style: Style, wrap: Wrap, align: Option<Align>, ) -> Self
Examples found in repository?
examples/textbox-rs.rs (lines 77-92)
70 fn call(
71 &mut self,
72 mut store: Self::Store,
73 args: TextState,
74 mut scope: ScopeID<'_>,
75 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
76 if store.0 != args {
77 let textbox = TextBox::new(
78 gen_id!(scope),
79 MinimalText {
80 area: FILL_DRECT,
81 padding: AbsRect::splat(12.0).into(),
82 textedit: args.text.clone(), // Be careful to take the value from args, not store.0, which is stale.
83 },
84 40.0,
85 56.0,
86 cosmic_text::FamilyOwned::SansSerif,
87 sRGB::white(),
88 Default::default(),
89 Default::default(),
90 cosmic_text::Wrap::Word,
91 Some(cosmic_text::Align::Right),
92 );
93
94 let region = Region::new(
95 gen_id!(scope),
96 MinimalArea {
97 area: AbsRect::new(90.0, 0.0, -90.0, -180.0) + RelRect::new(0.0, 0.0, 1.0, 1.0),
98 },
99 feather_ui::children![fixed::Prop, textbox],
100 );
101 let window = Window::new(
102 gen_id!(scope),
103 winit::window::Window::default_attributes()
104 .with_title(env!("CARGO_CRATE_NAME"))
105 .with_inner_size(winit::dpi::PhysicalSize::new(600, 400))
106 .with_resizable(true),
107 Box::new(region),
108 );
109
110 store.1 = im::HashMap::new();
111 store.1.insert(window.id.clone(), Some(window));
112 store.0 = args.clone();
113 }
114 let windows = store.1.clone();
115 (store, windows)
116 }
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TextBox<T>
impl<T> !RefUnwindSafe for TextBox<T>
impl<T> !Send for TextBox<T>
impl<T> !Sync for TextBox<T>
impl<T> Unpin for TextBox<T>
impl<T> !UnwindSafe for TextBox<T>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<U, C> ComponentWrap<U> for C
impl<U, C> ComponentWrap<U> for C
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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>
Converts
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>
Converts
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