pub struct TextBox<T: Prop + 'static> {
pub font_size: f32,
pub line_height: f32,
pub font: FamilyOwned,
pub color: sRGB,
pub weight: Weight,
pub style: Style,
pub wrap: Wrap,
pub slots: [Option<Slot>; 1],
/* private fields */
}
Fields§
§font_size: f32
§line_height: f32
§font: FamilyOwned
§color: sRGB
§weight: Weight
§style: Style
§wrap: Wrap
§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,
) -> 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, ) -> Self
Examples found in repository?
examples/textbox-rs.rs (lines 74-88)
68 fn call(
69 &mut self,
70 mut store: Self::Store,
71 args: &TextState,
72 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
73 if store.0 != *args {
74 let textbox = TextBox::new(
75 gen_id!(),
76 MinimalText {
77 area: FILL_DRECT,
78 padding: AbsRect::broadcast(12.0).into(),
79 textedit: args.text.clone(), // Be careful to take the value from args, not store.0, which is stale.
80 },
81 40.0,
82 56.0,
83 cosmic_text::FamilyOwned::SansSerif,
84 sRGB::white(),
85 Default::default(),
86 Default::default(),
87 cosmic_text::Wrap::Word,
88 );
89
90 let region = Region::new(
91 gen_id!(),
92 MinimalArea {
93 area: feather_ui::URect {
94 abs: AbsRect::new(90.0, 0.0, -90.0, -180.0),
95 rel: RelRect::new(0.0, 0.0, 1.0, 1.0),
96 }
97 .into(),
98 }
99 .into(),
100 feather_ui::children![fixed::Prop, textbox],
101 );
102 let window = Window::new(
103 gen_id!(),
104 winit::window::Window::default_attributes()
105 .with_title(env!("CARGO_CRATE_NAME"))
106 .with_inner_size(winit::dpi::PhysicalSize::new(600, 400))
107 .with_resizable(true),
108 Box::new(region),
109 );
110
111 store.1 = im::HashMap::new();
112 store.1.insert(window.id.clone(), Some(window));
113 store.0 = args.clone();
114 }
115 let windows = store.1.clone();
116 (store, windows)
117 }
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