pub struct Paragraph<T: Prop + 'static> {
pub id: Arc<SourceID>,
/* private fields */
}
Fields§
§id: Arc<SourceID>
Implementations§
Source§impl<T: Prop + 'static> Paragraph<T>
impl<T: Prop + 'static> Paragraph<T>
Sourcepub fn new(id: Arc<SourceID>, props: T) -> Self
pub fn new(id: Arc<SourceID>, props: T) -> Self
Examples found in repository?
examples/paragraph-rs.rs (lines 126-132)
106 fn call(
107 &mut self,
108 mut store: Self::Store,
109 args: &Blocker,
110 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
111 if store.0 != *args {
112 let flex = {
113 let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
114 gen_id!(),
115 MinimalFlexChild {
116 area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
117 }
118 .into(),
119 0.0,
120 0.0,
121 Vec4::broadcast(10.0),
122 sRGB::new(0.2, 0.7, 0.4, 1.0),
123 sRGB::transparent(),
124 );
125
126 let mut p = Paragraph::new(
127 gen_id!(),
128 MinimalFlex {
129 area: FILL_DRECT,
130 obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
131 },
132 );
133
134 let text = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
135 p.set_text(
136 text,
137 40.0,
138 56.0,
139 cosmic_text::FamilyOwned::SansSerif,
140 sRGB::white(),
141 Default::default(),
142 Default::default(),
143 true,
144 );
145 p.prepend(Box::new(rect.clone()));
146 p.append(Box::new(rect.clone()));
147 p.append(Box::new(rect.clone()));
148
149 p
150 };
151
152 let region = Region::new(
153 gen_id!(),
154 MinimalArea {
155 area: feather_ui::URect {
156 abs: AbsRect::new(90.0, 90.0, -90.0, -90.0),
157 rel: RelRect::new(0.0, 0.0, 1.0, 1.0),
158 }
159 .into(),
160 }
161 .into(),
162 feather_ui::children![fixed::Prop, flex],
163 );
164
165 let window = Window::new(
166 gen_id!(),
167 winit::window::Window::default_attributes()
168 .with_title(env!("CARGO_CRATE_NAME"))
169 .with_resizable(true),
170 Box::new(region),
171 );
172
173 store.1 = im::HashMap::new();
174 store.1.insert(window.id.clone(), Some(window));
175 store.0 = args.clone();
176 }
177 let windows = store.1.clone();
178 (store, windows)
179 }
Sourcepub fn append(&mut self, child: Box<ChildOf<dyn Prop>>)
pub fn append(&mut self, child: Box<ChildOf<dyn Prop>>)
Examples found in repository?
examples/paragraph-rs.rs (line 146)
106 fn call(
107 &mut self,
108 mut store: Self::Store,
109 args: &Blocker,
110 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
111 if store.0 != *args {
112 let flex = {
113 let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
114 gen_id!(),
115 MinimalFlexChild {
116 area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
117 }
118 .into(),
119 0.0,
120 0.0,
121 Vec4::broadcast(10.0),
122 sRGB::new(0.2, 0.7, 0.4, 1.0),
123 sRGB::transparent(),
124 );
125
126 let mut p = Paragraph::new(
127 gen_id!(),
128 MinimalFlex {
129 area: FILL_DRECT,
130 obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
131 },
132 );
133
134 let text = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
135 p.set_text(
136 text,
137 40.0,
138 56.0,
139 cosmic_text::FamilyOwned::SansSerif,
140 sRGB::white(),
141 Default::default(),
142 Default::default(),
143 true,
144 );
145 p.prepend(Box::new(rect.clone()));
146 p.append(Box::new(rect.clone()));
147 p.append(Box::new(rect.clone()));
148
149 p
150 };
151
152 let region = Region::new(
153 gen_id!(),
154 MinimalArea {
155 area: feather_ui::URect {
156 abs: AbsRect::new(90.0, 90.0, -90.0, -90.0),
157 rel: RelRect::new(0.0, 0.0, 1.0, 1.0),
158 }
159 .into(),
160 }
161 .into(),
162 feather_ui::children![fixed::Prop, flex],
163 );
164
165 let window = Window::new(
166 gen_id!(),
167 winit::window::Window::default_attributes()
168 .with_title(env!("CARGO_CRATE_NAME"))
169 .with_resizable(true),
170 Box::new(region),
171 );
172
173 store.1 = im::HashMap::new();
174 store.1.insert(window.id.clone(), Some(window));
175 store.0 = args.clone();
176 }
177 let windows = store.1.clone();
178 (store, windows)
179 }
Sourcepub fn prepend(&mut self, child: Box<ChildOf<dyn Prop>>)
pub fn prepend(&mut self, child: Box<ChildOf<dyn Prop>>)
Examples found in repository?
examples/paragraph-rs.rs (line 145)
106 fn call(
107 &mut self,
108 mut store: Self::Store,
109 args: &Blocker,
110 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
111 if store.0 != *args {
112 let flex = {
113 let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
114 gen_id!(),
115 MinimalFlexChild {
116 area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
117 }
118 .into(),
119 0.0,
120 0.0,
121 Vec4::broadcast(10.0),
122 sRGB::new(0.2, 0.7, 0.4, 1.0),
123 sRGB::transparent(),
124 );
125
126 let mut p = Paragraph::new(
127 gen_id!(),
128 MinimalFlex {
129 area: FILL_DRECT,
130 obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
131 },
132 );
133
134 let text = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
135 p.set_text(
136 text,
137 40.0,
138 56.0,
139 cosmic_text::FamilyOwned::SansSerif,
140 sRGB::white(),
141 Default::default(),
142 Default::default(),
143 true,
144 );
145 p.prepend(Box::new(rect.clone()));
146 p.append(Box::new(rect.clone()));
147 p.append(Box::new(rect.clone()));
148
149 p
150 };
151
152 let region = Region::new(
153 gen_id!(),
154 MinimalArea {
155 area: feather_ui::URect {
156 abs: AbsRect::new(90.0, 90.0, -90.0, -90.0),
157 rel: RelRect::new(0.0, 0.0, 1.0, 1.0),
158 }
159 .into(),
160 }
161 .into(),
162 feather_ui::children![fixed::Prop, flex],
163 );
164
165 let window = Window::new(
166 gen_id!(),
167 winit::window::Window::default_attributes()
168 .with_title(env!("CARGO_CRATE_NAME"))
169 .with_resizable(true),
170 Box::new(region),
171 );
172
173 store.1 = im::HashMap::new();
174 store.1.insert(window.id.clone(), Some(window));
175 store.0 = args.clone();
176 }
177 let windows = store.1.clone();
178 (store, windows)
179 }
Sourcepub fn set_text(
&mut self,
text: &str,
font_size: f32,
line_height: f32,
font: FamilyOwned,
color: sRGB,
weight: Weight,
style: Style,
fullwidth: bool,
)
pub fn set_text( &mut self, text: &str, font_size: f32, line_height: f32, font: FamilyOwned, color: sRGB, weight: Weight, style: Style, fullwidth: bool, )
Examples found in repository?
examples/paragraph-rs.rs (lines 135-144)
106 fn call(
107 &mut self,
108 mut store: Self::Store,
109 args: &Blocker,
110 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
111 if store.0 != *args {
112 let flex = {
113 let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
114 gen_id!(),
115 MinimalFlexChild {
116 area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
117 }
118 .into(),
119 0.0,
120 0.0,
121 Vec4::broadcast(10.0),
122 sRGB::new(0.2, 0.7, 0.4, 1.0),
123 sRGB::transparent(),
124 );
125
126 let mut p = Paragraph::new(
127 gen_id!(),
128 MinimalFlex {
129 area: FILL_DRECT,
130 obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
131 },
132 );
133
134 let text = "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?";
135 p.set_text(
136 text,
137 40.0,
138 56.0,
139 cosmic_text::FamilyOwned::SansSerif,
140 sRGB::white(),
141 Default::default(),
142 Default::default(),
143 true,
144 );
145 p.prepend(Box::new(rect.clone()));
146 p.append(Box::new(rect.clone()));
147 p.append(Box::new(rect.clone()));
148
149 p
150 };
151
152 let region = Region::new(
153 gen_id!(),
154 MinimalArea {
155 area: feather_ui::URect {
156 abs: AbsRect::new(90.0, 90.0, -90.0, -90.0),
157 rel: RelRect::new(0.0, 0.0, 1.0, 1.0),
158 }
159 .into(),
160 }
161 .into(),
162 feather_ui::children![fixed::Prop, flex],
163 );
164
165 let window = Window::new(
166 gen_id!(),
167 winit::window::Window::default_attributes()
168 .with_title(env!("CARGO_CRATE_NAME"))
169 .with_resizable(true),
170 Box::new(region),
171 );
172
173 store.1 = im::HashMap::new();
174 store.1.insert(window.id.clone(), Some(window));
175 store.0 = args.clone();
176 }
177 let windows = store.1.clone();
178 (store, windows)
179 }
Trait Implementations§
Source§impl<T: Prop + 'static> StateMachineChild for Paragraph<T>
impl<T: Prop + 'static> StateMachineChild for Paragraph<T>
Auto Trait Implementations§
impl<T> Freeze for Paragraph<T>
impl<T> !RefUnwindSafe for Paragraph<T>
impl<T> !Send for Paragraph<T>
impl<T> !Sync for Paragraph<T>
impl<T> Unpin for Paragraph<T>
impl<T> !UnwindSafe for Paragraph<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