Paragraph

Struct Paragraph 

Source
pub struct Paragraph<T> {
    pub id: Arc<SourceID>,
    /* private fields */
}

Fields§

§id: Arc<SourceID>

Implementations§

Source§

impl<T: Prop + 'static> Paragraph<T>

Source

pub fn new(id: Arc<SourceID>, props: T) -> Self

Examples found in repository?
examples/paragraph-rs.rs (lines 127-133)
106    fn call(
107        &mut self,
108        mut store: Self::Store,
109        args: Blocker,
110        mut scope: ScopeID<'_>,
111    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
112        if store.0 != args {
113            let flex = {
114                let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
115                    gen_id!(scope),
116                    MinimalFlexChild {
117                        area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
118                    },
119                    0.0,
120                    0.0,
121                    wide::f32x4::splat(10.0),
122                    sRGB::new(0.2, 0.7, 0.4, 1.0),
123                    sRGB::transparent(),
124                    feather_ui::DAbsPoint::zero(),
125                );
126
127                let mut p = Paragraph::new(
128                    gen_id!(scope),
129                    MinimalFlex {
130                        area: FILL_DRECT,
131                        obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
132                    },
133                );
134
135                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?";
136                p.set_text(
137                    text,
138                    40.0,
139                    56.0,
140                    cosmic_text::FamilyOwned::SansSerif,
141                    sRGB::white(),
142                    Default::default(),
143                    Default::default(),
144                    true,
145                );
146                p.prepend(Box::new(rect.clone()));
147                p.append(Box::new(rect.clone()));
148                p.append(Box::new(rect.clone()));
149
150                p
151            };
152
153            let region = Region::new(
154                gen_id!(scope),
155                MinimalArea {
156                    area: AbsRect::new(90.0, 90.0, -90.0, -90.0) + RelRect::new(0.0, 0.0, 1.0, 1.0),
157                },
158                feather_ui::children![fixed::Prop, flex],
159            );
160
161            let window = Window::new(
162                gen_id!(scope),
163                winit::window::Window::default_attributes()
164                    .with_title(env!("CARGO_CRATE_NAME"))
165                    .with_resizable(true),
166                Box::new(region),
167            );
168
169            store.1 = im::HashMap::new();
170            store.1.insert(window.id.clone(), Some(window));
171            store.0 = args.clone();
172        }
173        let windows = store.1.clone();
174        (store, windows)
175    }
Source

pub fn append(&mut self, child: Box<ChildOf<dyn Prop>>)

Examples found in repository?
examples/paragraph-rs.rs (line 147)
106    fn call(
107        &mut self,
108        mut store: Self::Store,
109        args: Blocker,
110        mut scope: ScopeID<'_>,
111    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
112        if store.0 != args {
113            let flex = {
114                let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
115                    gen_id!(scope),
116                    MinimalFlexChild {
117                        area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
118                    },
119                    0.0,
120                    0.0,
121                    wide::f32x4::splat(10.0),
122                    sRGB::new(0.2, 0.7, 0.4, 1.0),
123                    sRGB::transparent(),
124                    feather_ui::DAbsPoint::zero(),
125                );
126
127                let mut p = Paragraph::new(
128                    gen_id!(scope),
129                    MinimalFlex {
130                        area: FILL_DRECT,
131                        obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
132                    },
133                );
134
135                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?";
136                p.set_text(
137                    text,
138                    40.0,
139                    56.0,
140                    cosmic_text::FamilyOwned::SansSerif,
141                    sRGB::white(),
142                    Default::default(),
143                    Default::default(),
144                    true,
145                );
146                p.prepend(Box::new(rect.clone()));
147                p.append(Box::new(rect.clone()));
148                p.append(Box::new(rect.clone()));
149
150                p
151            };
152
153            let region = Region::new(
154                gen_id!(scope),
155                MinimalArea {
156                    area: AbsRect::new(90.0, 90.0, -90.0, -90.0) + RelRect::new(0.0, 0.0, 1.0, 1.0),
157                },
158                feather_ui::children![fixed::Prop, flex],
159            );
160
161            let window = Window::new(
162                gen_id!(scope),
163                winit::window::Window::default_attributes()
164                    .with_title(env!("CARGO_CRATE_NAME"))
165                    .with_resizable(true),
166                Box::new(region),
167            );
168
169            store.1 = im::HashMap::new();
170            store.1.insert(window.id.clone(), Some(window));
171            store.0 = args.clone();
172        }
173        let windows = store.1.clone();
174        (store, windows)
175    }
Source

pub fn prepend(&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        mut scope: ScopeID<'_>,
111    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
112        if store.0 != args {
113            let flex = {
114                let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
115                    gen_id!(scope),
116                    MinimalFlexChild {
117                        area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
118                    },
119                    0.0,
120                    0.0,
121                    wide::f32x4::splat(10.0),
122                    sRGB::new(0.2, 0.7, 0.4, 1.0),
123                    sRGB::transparent(),
124                    feather_ui::DAbsPoint::zero(),
125                );
126
127                let mut p = Paragraph::new(
128                    gen_id!(scope),
129                    MinimalFlex {
130                        area: FILL_DRECT,
131                        obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
132                    },
133                );
134
135                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?";
136                p.set_text(
137                    text,
138                    40.0,
139                    56.0,
140                    cosmic_text::FamilyOwned::SansSerif,
141                    sRGB::white(),
142                    Default::default(),
143                    Default::default(),
144                    true,
145                );
146                p.prepend(Box::new(rect.clone()));
147                p.append(Box::new(rect.clone()));
148                p.append(Box::new(rect.clone()));
149
150                p
151            };
152
153            let region = Region::new(
154                gen_id!(scope),
155                MinimalArea {
156                    area: AbsRect::new(90.0, 90.0, -90.0, -90.0) + RelRect::new(0.0, 0.0, 1.0, 1.0),
157                },
158                feather_ui::children![fixed::Prop, flex],
159            );
160
161            let window = Window::new(
162                gen_id!(scope),
163                winit::window::Window::default_attributes()
164                    .with_title(env!("CARGO_CRATE_NAME"))
165                    .with_resizable(true),
166                Box::new(region),
167            );
168
169            store.1 = im::HashMap::new();
170            store.1.insert(window.id.clone(), Some(window));
171            store.0 = args.clone();
172        }
173        let windows = store.1.clone();
174        (store, windows)
175    }
Source

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 136-145)
106    fn call(
107        &mut self,
108        mut store: Self::Store,
109        args: Blocker,
110        mut scope: ScopeID<'_>,
111    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
112        if store.0 != args {
113            let flex = {
114                let rect = Shape::<MinimalFlexChild, { ShapeKind::RoundRect as u8 }>::new(
115                    gen_id!(scope),
116                    MinimalFlexChild {
117                        area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
118                    },
119                    0.0,
120                    0.0,
121                    wide::f32x4::splat(10.0),
122                    sRGB::new(0.2, 0.7, 0.4, 1.0),
123                    sRGB::transparent(),
124                    feather_ui::DAbsPoint::zero(),
125                );
126
127                let mut p = Paragraph::new(
128                    gen_id!(scope),
129                    MinimalFlex {
130                        area: FILL_DRECT,
131                        obstacles: vec![AbsRect::new(200.0, 30.0, 300.0, 150.0).into()],
132                    },
133                );
134
135                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?";
136                p.set_text(
137                    text,
138                    40.0,
139                    56.0,
140                    cosmic_text::FamilyOwned::SansSerif,
141                    sRGB::white(),
142                    Default::default(),
143                    Default::default(),
144                    true,
145                );
146                p.prepend(Box::new(rect.clone()));
147                p.append(Box::new(rect.clone()));
148                p.append(Box::new(rect.clone()));
149
150                p
151            };
152
153            let region = Region::new(
154                gen_id!(scope),
155                MinimalArea {
156                    area: AbsRect::new(90.0, 90.0, -90.0, -90.0) + RelRect::new(0.0, 0.0, 1.0, 1.0),
157                },
158                feather_ui::children![fixed::Prop, flex],
159            );
160
161            let window = Window::new(
162                gen_id!(scope),
163                winit::window::Window::default_attributes()
164                    .with_title(env!("CARGO_CRATE_NAME"))
165                    .with_resizable(true),
166                Box::new(region),
167            );
168
169            store.1 = im::HashMap::new();
170            store.1.insert(window.id.clone(), Some(window));
171            store.0 = args.clone();
172        }
173        let windows = store.1.clone();
174        (store, windows)
175    }

Trait Implementations§

Source§

impl<T> Clone for Paragraph<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Prop + 'static> Component for Paragraph<T>

Source§

type Props = T

Source§

fn layout( &self, manager: &mut StateManager, driver: &Driver, window: &Arc<SourceID>, ) -> Box<dyn Layout<T>>

Source§

impl<T> StateMachineChild for Paragraph<T>

Source§

fn id(&self) -> Arc<SourceID>

Source§

fn apply_children( &self, f: &mut dyn FnMut(&dyn StateMachineChild) -> Result<()>, ) -> Result<()>

Source§

fn init( &self, driver: &Weak<Driver>, ) -> Result<Box<dyn StateMachineWrapper>, Error>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<U, C> ComponentWrap<U> for C
where C: Component, &'a U: for<'a> From<&'a <C as Component>::Props>, <C as Component>::Props: Sized, U: ?Sized,

Source§

fn layout( &self, state: &mut StateManager, driver: &Driver, window: &Arc<SourceID>, ) -> Box<dyn Layout<U>>

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T