Rect

Struct Rect 

Source
pub struct Rect<U> {
    pub v: f32x4,
    /* private fields */
}
Expand description

Represents a 2D Rectangle, similar to the Euclid rectangle, but SSE optimized and uses a LTRB absolute representation, instead of a position and a size.

Fields§

§v: f32x4

Implementations§

Source§

impl<U> Rect<U>

Source

pub const fn new(left: f32, top: f32, right: f32, bottom: f32) -> Self

Examples found in repository?
examples/paragraph-rs.rs (line 101)
98    fn init(&self) -> Self::Store {
99        (
100            Blocker {
101                area: AbsRect::new(f32::NAN, f32::NAN, f32::NAN, f32::NAN),
102            },
103            im::HashMap::new(),
104        )
105    }
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    }
176}
177
178fn main() {
179    let (mut app, event_loop, _, _) = App::<Blocker, BasicApp>::new::<()>(
180        Blocker {
181            area: AbsRect::new(-1.0, -1.0, -1.0, -1.0),
182        },
183        vec![],
184        BasicApp {},
185        |_| (),
186    )
187    .unwrap();
188
189    event_loop.run_app(&mut app).unwrap();
190}
More examples
Hide additional examples
examples/textbox-rs.rs (line 97)
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    }
examples/graph-rs.rs (lines 96-101)
59    fn call(
60        &mut self,
61        mut store: Self::Store,
62        args: GraphState,
63        mut scope: ScopeID<'_>,
64    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
65        if store.0 != args {
66            let mut children: im::Vector<Option<Box<ChildOf<dyn fixed::Prop>>>> = im::Vector::new();
67            let domain: Arc<CrossReferenceDomain> = Default::default();
68
69            let mut node_ids: Vec<Arc<SourceID>> = Vec::new();
70
71            for (i, id) in scope.iter(0..args.nodes.len()) {
72                let node = args.nodes[i];
73                const BASE: sRGB = sRGB::new(0.2, 0.7, 0.4, 1.0);
74
75                let point = DomainPoint::new(id, domain.clone());
76                node_ids.push(point.id.clone());
77
78                let circle = Shape::<DRect, { ShapeKind::Circle as u8 }>::new(
79                    gen_id!(point.id),
80                    FILL_DRECT,
81                    0.0,
82                    0.0,
83                    [0.0, 20.0],
84                    if args.selected == Some(i) {
85                        sRGB::new(0.7, 1.0, 0.8, 1.0)
86                    } else {
87                        BASE
88                    },
89                    BASE,
90                    DAbsPoint::zero(),
91                );
92
93                let bag = Region::<MinimalArea>::new(
94                    gen_id!(point.id),
95                    MinimalArea {
96                        area: AbsRect::new(
97                            node.x - NODE_RADIUS,
98                            node.y - NODE_RADIUS,
99                            node.x + NODE_RADIUS,
100                            node.y + NODE_RADIUS,
101                        )
102                        .into(),
103                    },
104                    feather_ui::children![fixed::Prop, point, circle],
105                );
106
107                children.push_back(Some(Box::new(bag)));
108            }
109
110            for ((a, b), id) in scope.iter(&args.edges) {
111                let line = DomainLine::<()> {
112                    id,
113                    fill: sRGB::white(),
114                    domain: domain.clone(),
115                    start: node_ids[*a].clone(),
116                    end: node_ids[*b].clone(),
117                    props: ().into(),
118                };
119
120                children.push_back(Some(Box::new(line)));
121            }
122
123            let subregion = Region::new(
124                gen_id!(scope),
125                MinimalArea {
126                    area: AbsRect::new(
127                        args.offset.x,
128                        args.offset.y,
129                        args.offset.x + 10000.0,
130                        args.offset.y + 10000.0,
131                    )
132                    .into(),
133                },
134                children,
135            );
136
137            let mousearea: MouseArea<MinimalArea> = MouseArea::new(
138                gen_id!(scope),
139                MinimalArea { area: FILL_DRECT },
140                Some(4.0),
141                [
142                    Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
143                    Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
144                    Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
145                    None,
146                    None,
147                    None,
148                ],
149            );
150
151            let region = Region::new(
152                gen_id!(scope),
153                MinimalArea { area: FILL_DRECT },
154                feather_ui::children![fixed::Prop, subregion, mousearea],
155            );
156
157            let window = Window::new(
158                gen_id!(scope),
159                feather_ui::winit::window::Window::default_attributes()
160                    .with_title(env!("CARGO_CRATE_NAME"))
161                    .with_resizable(true),
162                Box::new(region),
163            );
164
165            store.1 = im::HashMap::new();
166            store.1.insert(window.id.clone(), Some(window));
167            store.0 = args.clone();
168        }
169        let windows = store.1.clone();
170        (store, windows)
171    }
examples/grid-rs.rs (line 121)
109    fn call(
110        &mut self,
111        mut store: Self::Store,
112        args: CounterState,
113        mut scope: ScopeID<'_>,
114    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
115        if store.0 != args {
116            let button = {
117                let text = {
118                    Text::<FixedData> {
119                        id: scope.create(),
120                        props: FixedData {
121                            area: AbsRect::new(10.0, 15.0, 10.0, 15.0)
122                                + RelRect::new(0.0, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
123                            anchor: feather_ui::RelPoint::zero().into(),
124                            ..Default::default()
125                        }
126                        .into(),
127                        text: format!("Boxes: {}", args.count),
128                        font_size: 40.0,
129                        line_height: 56.0,
130                        ..Default::default()
131                    }
132                };
133
134                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
135                    scope.create(),
136                    feather_ui::FILL_DRECT,
137                    0.0,
138                    0.0,
139                    wide::f32x4::splat(10.0),
140                    sRGB::new(0.2, 0.7, 0.4, 1.0),
141                    sRGB::transparent(),
142                    DAbsPoint::zero(),
143                );
144
145                Button::<FixedData>::new(
146                    scope.create(),
147                    FixedData {
148                        area: AbsRect::new(0.0, 20.0, 0.0, 0.0)
149                            + RelRect::new(0.5, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
150                        anchor: feather_ui::RelPoint::new(0.5, 0.0).into(),
151                        zindex: 0,
152                    },
153                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
154                    feather_ui::children![fixed::Prop, rect, text],
155                )
156            };
157
158            const NUM_COLUMNS: usize = 5;
159            let rectgrid = {
160                let mut children: im::Vector<Option<Box<ChildOf<dyn grid::Prop>>>> =
161                    im::Vector::new();
162                {
163                    for (i, id) in scope.iter(0..args.count) {
164                        children.push_back(Some(Box::new(Shape::<
165                            GridChild,
166                            { ShapeKind::RoundRect as u8 },
167                        >::new(
168                            id,
169                            GridChild {
170                                area: FILL_DRECT,
171                                x: i % NUM_COLUMNS,
172                                y: i / NUM_COLUMNS,
173                            },
174                            0.0,
175                            0.0,
176                            wide::f32x4::splat(4.0),
177                            sRGB::new(
178                                (0.1 * i as f32) % 1.0,
179                                (0.65 * i as f32) % 1.0,
180                                (0.2 * i as f32) % 1.0,
181                                1.0,
182                            ),
183                            sRGB::transparent(),
184                            DAbsPoint::zero(),
185                        ))));
186                    }
187                }
188
189                GridBox::<GridData>::new(
190                    scope.create(),
191                    GridData {
192                        area: AbsRect::new(0.0, 200.0, 0.0, 0.0)
193                            + RelRect::new(0.0, 0.0, UNSIZED_AXIS, 1.0),
194
195                        rlimits: feather_ui::RelLimits::new(0.0..1.0, 0.0..),
196                        direction: feather_ui::RowDirection::LeftToRight,
197                        rows: [40.0, 20.0, 40.0, 20.0, 40.0, 20.0, 10.0]
198                            .map(DValue::from)
199                            .to_vec(),
200                        columns: [80.0, 40.0, 80.0, 40.0, 80.0].map(DValue::from).to_vec(),
201                        spacing: AbsPoint::new(4.0, 4.0).into(),
202                        padding: AbsRect::new(8.0, 8.0, 8.0, 8.0).into(),
203                    },
204                    children,
205                )
206            };
207
208            let region = Region::new(
209                scope.create(),
210                FixedData {
211                    area: FILL_DRECT,
212                    zindex: 0,
213                    ..Default::default()
214                },
215                feather_ui::children![fixed::Prop, button, rectgrid],
216            );
217            let window = Window::new(
218                scope.create(),
219                winit::window::Window::default_attributes()
220                    .with_title(env!("CARGO_CRATE_NAME"))
221                    .with_resizable(true),
222                Box::new(region),
223            );
224
225            store.1 = im::HashMap::new();
226            store.1.insert(window.id.clone(), Some(window));
227            store.0 = args.clone();
228        }
229        let windows = store.1.clone();
230        (store, windows)
231    }
examples/basic-rs.rs (line 64)
53    fn call(
54        &mut self,
55        mut store: Self::Store,
56        app: CounterState,
57        mut id: ScopeID<'_>,
58    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
59        if store.0 != app {
60            let button = {
61                let text = Text::<FixedData> {
62                    id: gen_id!(id),
63                    props: Rc::new(FixedData {
64                        area: AbsRect::new(8.0, 0.0, 8.0, 0.0)
65                            + RelRect::new(0.0, 0.5, UNSIZED_AXIS, UNSIZED_AXIS),
66                        anchor: feather_ui::RelPoint::new(0.0, 0.5).into(),
67                        ..Default::default()
68                    }),
69                    color: sRGB::new(1.0, 1.0, 0.0, 1.0),
70                    text: format!("Clicks: {}", app.count),
71                    font_size: 40.0,
72                    line_height: 56.0,
73                    align: Some(cosmic_text::Align::Center),
74                    ..Default::default()
75                };
76
77                let rect = shape::round_rect::<DRect>(
78                    gen_id!(id),
79                    feather_ui::FILL_DRECT,
80                    0.0,
81                    0.0,
82                    wide::f32x4::splat(10.0),
83                    sRGB::new(0.2, 0.7, 0.4, 1.0),
84                    sRGB::transparent(),
85                    DAbsPoint::zero(),
86                );
87
88                Button::<FixedData>::new(
89                    gen_id!(id),
90                    FixedData {
91                        area: AbsRect::new(45.0, 45.0, 0.0, 0.0)
92                            + RelRect::new(0.0, 0.0, UNSIZED_AXIS, 1.0),
93
94                        ..Default::default()
95                    },
96                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
97                    feather_ui::children![fixed::Prop, rect, text],
98                )
99            };
100
101            let block = {
102                let text = Text::<FixedData> {
103                    id: gen_id!(id),
104                    props: Rc::new(FixedData {
105                        area: RelRect::new(0.5, 0.0, UNSIZED_AXIS, UNSIZED_AXIS).into(),
106                        limits: feather_ui::AbsLimits::new(.., 10.0..200.0).into(),
107                        rlimits: feather_ui::RelLimits::new(..1.0, ..),
108                        anchor: feather_ui::RelPoint::new(0.5, 0.0).into(),
109                        padding: AbsRect::new(8.0, 8.0, 8.0, 8.0).into(),
110                        ..Default::default()
111                    }),
112                    text: (0..app.count).map(|_| "█").collect::<String>(),
113                    font_size: 40.0,
114                    line_height: 56.0,
115                    wrap: feather_ui::cosmic_text::Wrap::WordOrGlyph,
116                    align: Some(cosmic_text::Align::Center),
117                    ..Default::default()
118                };
119
120                let rect = shape::round_rect::<DRect>(
121                    gen_id!(id),
122                    feather_ui::FILL_DRECT,
123                    0.0,
124                    0.0,
125                    wide::f32x4::splat(10.0),
126                    sRGB::new(0.7, 0.2, 0.4, 1.0),
127                    sRGB::transparent(),
128                    DAbsPoint::zero(),
129                );
130
131                Region::<FixedData>::new_layer(
132                    gen_id!(id),
133                    FixedData {
134                        area: AbsRect::new(45.0, 245.0, 0.0, 0.0)
135                            + RelRect::new(0.0, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
136                        limits: feather_ui::AbsLimits::new(100.0..300.0, ..).into(),
137                        ..Default::default()
138                    },
139                    sRGB32::from_alpha(128),
140                    0.0,
141                    feather_ui::children![fixed::Prop, rect, text],
142                )
143            };
144
145            let pixel = shape::round_rect::<DRect>(
146                gen_id!(id),
147                PxRect::new(1.0, 1.0, 2.0, 2.0).into(),
148                0.0,
149                0.0,
150                wide::f32x4::zeroed(),
151                sRGB::new(1.0, 1.0, 1.0, 1.0),
152                sRGB::transparent(),
153                DAbsPoint::zero(),
154            );
155
156            let region = Region::new(
157                gen_id!(id),
158                FixedData {
159                    area: AbsRect::new(90.0, 90.0, 0.0, 200.0)
160                        + RelRect::new(0.0, 0.0, UNSIZED_AXIS, 0.0),
161                    zindex: 0,
162                    ..Default::default()
163                },
164                feather_ui::children![fixed::Prop, button, block, pixel],
165            );
166            let window = Window::new(
167                gen_id!(id),
168                winit::window::Window::default_attributes()
169                    .with_title(env!("CARGO_CRATE_NAME"))
170                    .with_resizable(true),
171                Box::new(region),
172            );
173
174            store.1 = im::HashMap::new();
175            store.1.insert(window.id.clone(), Some(window));
176            store.0 = app.clone();
177        }
178        let windows = store.1.clone();
179        (store, windows)
180    }
examples/image-rs.rs (line 53)
45    fn call(
46        &mut self,
47        _: Self::Store,
48        _: (),
49        mut scope: ScopeID<'_>,
50    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
51        let pixel = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
52            scope.create(),
53            PxRect::new(1.0, 1.0, 2.0, 2.0).into(),
54            0.0,
55            0.0,
56            wide::f32x4::splat(0.0),
57            sRGB::new(1.0, 1.0, 1.0, 1.0),
58            sRGB::transparent(),
59            feather_ui::DAbsPoint::zero(),
60        );
61
62        let mut children: im::Vector<Option<Box<feather_ui::component::ChildOf<dyn fixed::Prop>>>> =
63            im::Vector::new();
64        children.push_back(Some(Box::new(pixel)));
65
66        let mut genimage = |pos: AbsPoint,
67                            w: Option<f32>,
68                            h: Option<f32>,
69                            res: &dyn feather_ui::resource::Location,
70                            size: Option<AbsPoint>| {
71            Image::<DRect>::new(
72                scope.create(),
73                AbsRect::new(
74                    pos.x,
75                    pos.y,
76                    w.map(|x| x + pos.x).unwrap_or_default(),
77                    h.map(|y| y + pos.y).unwrap_or_default(),
78                ) + RelRect::new(
79                    0.0,
80                    0.0,
81                    if w.is_none() { UNSIZED_AXIS } else { 0.0 },
82                    if h.is_none() { UNSIZED_AXIS } else { 0.0 },
83                ),
84                res,
85                size.unwrap_or_default().into(),
86                false,
87            )
88        };
89
90        #[cfg(feature = "png")]
91        {
92            let testimage = PathBuf::from("./premul_test.png");
93
94            children.push_back(Some(Box::new(genimage(
95                AbsPoint::new(0.0, 0.0),
96                Some(100.0),
97                Some(100.0),
98                &testimage,
99                None,
100            ))));
101
102            children.push_back(Some(Box::new(genimage(
103                AbsPoint::new(100.0, 0.0),
104                None,
105                Some(100.0),
106                &testimage,
107                None,
108            ))));
109
110            children.push_back(Some(Box::new(genimage(
111                AbsPoint::new(0.0, 100.0),
112                None,
113                None,
114                &testimage,
115                Some(AbsPoint::new(100.0, 100.0)),
116            ))));
117
118            children.push_back(Some(Box::new(genimage(
119                AbsPoint::new(100.0, 100.0),
120                None,
121                None,
122                &testimage,
123                None,
124            ))));
125        }
126
127        #[cfg(feature = "svg")]
128        {
129            let testsvg = PathBuf::from("./FRI_logo.svg");
130
131            children.push_back(Some(Box::new(genimage(
132                AbsPoint::new(200.0, 0.0),
133                Some(100.0),
134                Some(100.0),
135                &testsvg,
136                None,
137            ))));
138
139            children.push_back(Some(Box::new(genimage(
140                AbsPoint::new(300.0, 0.0),
141                None,
142                Some(100.0),
143                &testsvg,
144                None,
145            ))));
146
147            children.push_back(Some(Box::new(genimage(
148                AbsPoint::new(200.0, 100.0),
149                None,
150                None,
151                &testsvg,
152                Some(AbsPoint::new(100.0, 100.0)),
153            ))));
154
155            children.push_back(Some(Box::new(genimage(
156                AbsPoint::new(300.0, 100.0),
157                None,
158                None,
159                &testsvg,
160                None,
161            ))));
162        }
163
164        #[cfg(feature = "png")]
165        {
166            let testimage = PathBuf::from("./test_color.png");
167
168            children.push_back(Some(Box::new(genimage(
169                AbsPoint::new(0.0, 200.0),
170                Some(100.0),
171                Some(100.0),
172                &testimage,
173                None,
174            ))));
175
176            children.push_back(Some(Box::new(genimage(
177                AbsPoint::new(100.0, 200.0),
178                Some(100.0),
179                None,
180                &testimage,
181                None,
182            ))));
183
184            children.push_back(Some(Box::new(genimage(
185                AbsPoint::new(0.0, 300.0),
186                None,
187                None,
188                &testimage,
189                Some(AbsPoint::new(100.0, 100.0)),
190            ))));
191
192            children.push_back(Some(Box::new(genimage(
193                AbsPoint::new(100.0, 300.0),
194                None,
195                None,
196                &testimage,
197                None,
198            ))));
199        }
200
201        #[cfg(feature = "jxl")]
202        {
203            let testimage = PathBuf::from("./dice.jxl");
204
205            children.push_back(Some(Box::new(genimage(
206                AbsPoint::new(200.0, 200.0),
207                Some(100.0),
208                Some(100.0),
209                &testimage,
210                None,
211            ))));
212
213            children.push_back(Some(Box::new(genimage(
214                AbsPoint::new(300.0, 200.0),
215                Some(100.0),
216                None,
217                &testimage,
218                None,
219            ))));
220
221            children.push_back(Some(Box::new(genimage(
222                AbsPoint::new(200.0, 300.0),
223                None,
224                None,
225                &testimage,
226                Some(AbsPoint::new(100.0, 100.0)),
227            ))));
228
229            children.push_back(Some(Box::new(genimage(
230                AbsPoint::new(300.0, 300.0),
231                None,
232                None,
233                &testimage,
234                None,
235            ))));
236        }
237
238        let region = Region::new(
239            gen_id!(scope),
240            FixedData {
241                area: AbsRect::new(10.0, 10.0, -10.0, -10.0) + RelRect::new(0.0, 0.0, 1.0, 1.0),
242
243                zindex: 0,
244                ..Default::default()
245            },
246            children,
247        );
248
249        #[cfg(feature = "svg")]
250        let icon = Some(
251            feather_ui::resource::load_icon(&std::path::PathBuf::from("./FRI_logo.svg")).unwrap(),
252        );
253        #[cfg(not(feature = "svg"))]
254        let icon = None;
255
256        let window = Window::new(
257            gen_id!(scope),
258            winit::window::Window::default_attributes()
259                .with_title(env!("CARGO_CRATE_NAME"))
260                .with_resizable(true)
261                .with_window_icon(icon),
262            Box::new(region),
263        );
264
265        let mut store = im::HashMap::new();
266        store.insert(window.id.clone(), Some(window));
267        let windows = store.clone();
268        (store, windows)
269    }
Source

pub const fn splat(x: f32) -> Self

Examples found in repository?
examples/textbox-rs.rs (line 81)
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    }
Source

pub const fn corners( topleft: Point2D<f32, U>, bottomright: Point2D<f32, U>, ) -> Self

Source

pub fn contains(&self, p: Point2D<f32, U>) -> bool

Source

pub fn collides(&self, rhs: &Self) -> bool

Source

pub fn intersect(&self, rhs: Self) -> Self

Source

pub fn extend(&self, rhs: Self) -> Self

Source

pub fn topleft(&self) -> Point2D<f32, U>

Source

pub fn set_topleft(&mut self, v: Point2D<f32, U>)

Source

pub fn bottomright(&self) -> Point2D<f32, U>

Source

pub fn set_bottomright(&mut self, v: Point2D<f32, U>)

Source

pub fn dim(&self) -> Size2D<f32, U>

Source

pub const fn zero() -> Self

Source

pub const fn unit() -> Self

Source

pub fn to_untyped(self) -> PxRect

Discard the units

Source

pub fn cast_unit<V>(self) -> Rect<V>

Cast the unit

Trait Implementations§

Source§

impl<U> Add<Perimeter<U>> for Rect<U>

Source§

type Output = Rect<U>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Perimeter<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<U> Add<Point2D<f32, U>> for Rect<U>

Source§

type Output = Rect<U>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Point2D<f32, U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T, U: Into<DRect>> Add<U> for Rect<T>
where Self: Into<DRect>,

Source§

type Output = DRect

The resulting type after applying the + operator.
Source§

fn add(self, rhs: U) -> Self::Output

Performs the + operation. Read more
Source§

impl<U> Add<Vector2D<f32, U>> for Rect<U>

Source§

type Output = Rect<U>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector2D<f32, U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<U> AddAssign<Point2D<f32, U>> for Rect<U>

Source§

fn add_assign(&mut self, rhs: Point2D<f32, U>)

Performs the += operation. Read more
Source§

impl<U> AddAssign<Vector2D<f32, U>> for Rect<U>

Source§

fn add_assign(&mut self, rhs: Vector2D<f32, U>)

Performs the += operation. Read more
Source§

impl<U: Clone> Clone for Rect<U>

Source§

fn clone(&self) -> Rect<U>

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<U: Debug> Debug for Rect<U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<U: Default> Default for Rect<U>

Source§

fn default() -> Rect<U>

Returns the “default value” for a type. Read more
Source§

impl<U> Display for Rect<U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<U> From<[f32; 4]> for Rect<U>

Source§

fn from(value: [f32; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<Rect<Logical>> for DAbsRect

Source§

fn from(value: AbsRect) -> Self

Converts to this type from the input type.
Source§

impl From<Rect<Logical>> for DRect

Source§

fn from(value: AbsRect) -> Self

Converts to this type from the input type.
Source§

impl From<Rect<Pixel>> for DAbsRect

Source§

fn from(value: PxRect) -> Self

Converts to this type from the input type.
Source§

impl From<Rect<Pixel>> for DRect

Source§

fn from(value: PxRect) -> Self

Converts to this type from the input type.
Source§

impl From<Rect<Relative>> for DRect

Source§

fn from(value: RelRect) -> Self

Converts to this type from the input type.
Source§

impl<U> From<Size2D<f32, U>> for Rect<U>

Source§

fn from(value: Size2D<f32, U>) -> Self

Converts to this type from the input type.
Source§

impl<U: LuaKind> FromLua for Rect<U>

Source§

fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self>

Performs the conversion.
Source§

impl Mul<Rect<Pixel>> for URect

Source§

type Output = Rect<Pixel>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: PxRect) -> Self::Output

Performs the * operation. Read more
Source§

impl<U> Neg for Rect<U>

Source§

type Output = Rect<U>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<U: PartialEq> PartialEq for Rect<U>

Source§

fn eq(&self, other: &Rect<U>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<U> Sub<Point2D<f32, U>> for Rect<U>

Source§

type Output = Rect<U>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Point2D<f32, U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<U> SubAssign<Point2D<f32, U>> for Rect<U>

Source§

fn sub_assign(&mut self, rhs: Point2D<f32, U>)

Performs the -= operation. Read more
Source§

impl<U: Copy> Copy for Rect<U>

Source§

impl<U: Copy + 'static> NoUninit for Rect<U>

Source§

impl<U> StructuralPartialEq for Rect<U>

Auto Trait Implementations§

§

impl<U> Freeze for Rect<U>

§

impl<U> RefUnwindSafe for Rect<U>
where U: RefUnwindSafe,

§

impl<U> Send for Rect<U>
where U: Send,

§

impl<U> Sync for Rect<U>
where U: Sync,

§

impl<U> Unpin for Rect<U>
where U: Unpin,

§

impl<U> UnwindSafe for Rect<U>
where U: UnwindSafe,

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<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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> FromLuaMulti for T
where T: FromLua,

Source§

fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>

Performs the conversion. Read more
Source§

fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>

Source§

unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>

Source§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>

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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,