Struct AbsRect

Source
pub struct AbsRect(/* private fields */);
Expand description

Absolutely positioned rectangle

Implementations§

Source§

impl AbsRect

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    ) -> (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    }
180}
181
182fn main() {
183    let (mut app, event_loop): (App<Blocker, BasicApp>, winit::event_loop::EventLoop<()>) =
184        App::new(
185            Blocker {
186                area: AbsRect::new(-1.0, -1.0, -1.0, -1.0),
187            },
188            vec![],
189            BasicApp {},
190            |_| (),
191        )
192        .unwrap();
193
194    event_loop.run_app(&mut app).unwrap();
195}
More examples
Hide additional examples
examples/textbox-rs.rs (line 94)
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    }
examples/graph-rs.rs (lines 101-106)
66    fn call(
67        &mut self,
68        mut store: Self::Store,
69        args: &GraphState,
70    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
71        if store.0 != *args {
72            let mut children: im::Vector<Option<Box<ChildOf<dyn fixed::Prop>>>> = im::Vector::new();
73            let domain: Arc<CrossReferenceDomain> = Default::default();
74
75            let mut node_ids: Vec<Arc<SourceID>> = Vec::new();
76
77            for i in 0..args.nodes.len() {
78                let node = args.nodes[i];
79                const BASE: sRGB = sRGB::new(0.2, 0.7, 0.4, 1.0);
80
81                let point = DomainPoint::new(gen_id!(), domain.clone());
82                node_ids.push(point.id.clone());
83
84                let circle = Shape::<DRect, { ShapeKind::Circle as u8 }>::new(
85                    gen_id!(),
86                    FILL_DRECT.into(),
87                    0.0,
88                    0.0,
89                    Vec2::new(0.0, 20.0),
90                    if args.selected == Some(i) {
91                        sRGB::new(0.7, 1.0, 0.8, 1.0)
92                    } else {
93                        BASE
94                    },
95                    BASE,
96                );
97
98                let bag = Region::<MinimalArea>::new(
99                    gen_id!(gen_id!(), i),
100                    MinimalArea {
101                        area: AbsRect::new(
102                            node.x - NODE_RADIUS,
103                            node.y - NODE_RADIUS,
104                            node.x + NODE_RADIUS,
105                            node.y + NODE_RADIUS,
106                        )
107                        .into(),
108                    }
109                    .into(),
110                    feather_ui::children![fixed::Prop, point, circle],
111                );
112
113                children.push_back(Some(Box::new(bag)));
114            }
115
116            let edge_id = gen_id!();
117
118            for (a, b) in &args.edges {
119                let line = DomainLine::<()> {
120                    id: edge_id
121                        .child(DataID::Int(*a as i64))
122                        .child(DataID::Int(*b as i64)),
123                    fill: sRGB::white(),
124                    domain: domain.clone(),
125                    start: node_ids[*a].clone(),
126                    end: node_ids[*b].clone(),
127                    props: ().into(),
128                };
129
130                children.push_back(Some(Box::new(line)));
131            }
132
133            let subregion = Region::new(
134                gen_id!(),
135                MinimalArea {
136                    area: AbsRect::new(
137                        args.offset.x,
138                        args.offset.y,
139                        args.offset.x + 10000.0,
140                        args.offset.y + 10000.0,
141                    )
142                    .into(),
143                }
144                .into(),
145                children,
146            );
147
148            let mousearea: MouseArea<MinimalArea> = MouseArea::new(
149                gen_id!(),
150                MinimalArea { area: FILL_DRECT },
151                Some(4.0),
152                [
153                    Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
154                    Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
155                    Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
156                    None,
157                    None,
158                    None,
159                ],
160            );
161
162            let region = Region::new(
163                gen_id!(),
164                MinimalArea { area: FILL_DRECT }.into(),
165                feather_ui::children![fixed::Prop, subregion, mousearea],
166            );
167
168            let window = Window::new(
169                gen_id!(),
170                feather_ui::winit::window::Window::default_attributes()
171                    .with_title(env!("CARGO_CRATE_NAME"))
172                    .with_resizable(true),
173                Box::new(region),
174            );
175
176            store.1 = im::HashMap::new();
177            store.1.insert(window.id.clone(), Some(window));
178            store.0 = args.clone();
179        }
180        let windows = store.1.clone();
181        (store, windows)
182    }
examples/grid-rs.rs (line 121)
110    fn call(
111        &mut self,
112        mut store: Self::Store,
113        args: &CounterState,
114    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
115        if store.0 != *args {
116            let button = {
117                let text = Text::<FixedData> {
118                    id: gen_id!(),
119                    props: FixedData {
120                        area: feather_ui::URect {
121                            abs: AbsRect::new(10.0, 15.0, 10.0, 15.0),
122                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
123                        }
124                        .into(),
125                        anchor: feather_ui::RelPoint(Vec2 { x: 0.0, y: 0.0 }).into(),
126                        ..Default::default()
127                    }
128                    .into(),
129                    text: format!("Boxes: {}", args.count),
130                    font_size: 40.0,
131                    line_height: 56.0,
132                    ..Default::default()
133                };
134
135                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
136                    gen_id!(),
137                    feather_ui::FILL_DRECT.into(),
138                    0.0,
139                    0.0,
140                    Vec4::broadcast(10.0),
141                    sRGB::new(0.2, 0.7, 0.4, 1.0),
142                    sRGB::transparent(),
143                );
144
145                Button::<FixedData>::new(
146                    gen_id!(),
147                    FixedData {
148                        area: feather_ui::URect {
149                            abs: AbsRect::new(0.0, 20.0, 0.0, 0.0),
150                            rel: RelRect::new(0.5, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
151                        }
152                        .into(),
153                        anchor: feather_ui::RelPoint(Vec2 { x: 0.5, y: 0.0 }).into(),
154                        zindex: 0,
155                    },
156                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
157                    feather_ui::children![fixed::Prop, rect, text],
158                )
159            };
160
161            const NUM_COLUMNS: usize = 5;
162            let rectgrid = {
163                let mut children: im::Vector<Option<Box<ChildOf<dyn grid::Prop>>>> =
164                    im::Vector::new();
165                let grid_id = gen_id!();
166                for i in 0..args.count {
167                    children.push_back(Some(Box::new(Shape::<
168                        GridChild,
169                        { ShapeKind::RoundRect as u8 },
170                    >::new(
171                        grid_id.child(DataID::Int(i as i64)),
172                        GridChild {
173                            area: FILL_DRECT,
174                            x: i % NUM_COLUMNS,
175                            y: i / NUM_COLUMNS,
176                        }
177                        .into(),
178                        0.0,
179                        0.0,
180                        Vec4::broadcast(4.0),
181                        sRGB::new(
182                            (0.1 * i as f32) % 1.0,
183                            (0.65 * i as f32) % 1.0,
184                            (0.2 * i as f32) % 1.0,
185                            1.0,
186                        ),
187                        sRGB::transparent(),
188                    ))));
189
190                    /*children.push_back(Some(Box::new(Text::<GridChild> {
191                        id: gen_id!(),
192                        props: GridChild {
193                            area: FILL_DRECT,
194                            x: i % NUM_COLUMNS,
195                            y: i / NUM_COLUMNS,
196                        }
197                        .into(),
198                        text: format!("Cell: {}", i),
199                        font_size: 20.0,
200                        line_height: 22.0,
201                        ..Default::default()
202                    })));*/
203                }
204
205                GridBox::<GridData>::new(
206                    gen_id!(),
207                    GridData {
208                        area: feather_ui::URect {
209                            abs: AbsRect::new(0.0, 200.0, 0.0, 0.0),
210                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, 1.0),
211                        }
212                        .into(),
213                        rlimits: feather_ui::RelLimits::new(
214                            ZERO_POINT,
215                            Vec2::new(1.0, f32::INFINITY),
216                        ),
217                        direction: feather_ui::RowDirection::BottomToTop,
218                        rows: [40.0, 20.0, 40.0, 20.0, 40.0, 20.0, 10.0]
219                            .map(DValue::from)
220                            .to_vec(),
221                        columns: [80.0, 40.0, 80.0, 40.0, 80.0].map(DValue::from).to_vec(),
222                        spacing: DPoint::from(Vec2::new(4.0, 4.0)),
223                        padding: AbsRect::new(8.0, 8.0, 8.0, 8.0).into(),
224                    }
225                    .into(),
226                    children,
227                )
228            };
229
230            let region = Region::new(
231                gen_id!(),
232                FixedData {
233                    area: FILL_DRECT,
234                    zindex: 0,
235                    ..Default::default()
236                }
237                .into(),
238                feather_ui::children![fixed::Prop, button, rectgrid],
239            );
240            let window = Window::new(
241                gen_id!(),
242                winit::window::Window::default_attributes()
243                    .with_title(env!("CARGO_CRATE_NAME"))
244                    .with_resizable(true),
245                Box::new(region),
246            );
247
248            store.1 = im::HashMap::new();
249            store.1.insert(window.id.clone(), Some(window));
250            store.0 = args.clone();
251        }
252        let windows = store.1.clone();
253        (store, windows)
254    }
examples/basic-rs.rs (line 61)
50    fn call(
51        &mut self,
52        mut store: Self::Store,
53        args: &CounterState,
54    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
55        if store.0 != *args {
56            let button = {
57                let text = Text::<FixedData> {
58                    id: gen_id!(),
59                    props: Rc::new(FixedData {
60                        area: URect {
61                            abs: AbsRect::new(8.0, 0.0, 8.0, 0.0),
62                            rel: RelRect::new(0.0, 0.5, UNSIZED_AXIS, UNSIZED_AXIS),
63                        }
64                        .into(),
65                        anchor: feather_ui::RelPoint(Vec2 { x: 0.0, y: 0.5 }).into(),
66                        ..Default::default()
67                    }),
68                    text: format!("Clicks: {}", args.count),
69                    font_size: 40.0,
70                    line_height: 56.0,
71                    ..Default::default()
72                };
73
74                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
75                    gen_id!(),
76                    feather_ui::FILL_DRECT.into(),
77                    0.0,
78                    0.0,
79                    Vec4::broadcast(10.0),
80                    sRGB::new(0.2, 0.7, 0.4, 1.0),
81                    sRGB::transparent(),
82                );
83
84                Button::<FixedData>::new(
85                    gen_id!(),
86                    FixedData {
87                        area: URect {
88                            abs: AbsRect::new(45.0, 45.0, 0.0, 0.0),
89                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, 1.0),
90                        }
91                        .into(),
92                        ..Default::default()
93                    },
94                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
95                    feather_ui::children![fixed::Prop, rect, text],
96                )
97            };
98
99            let fakebutton = {
100                let text = Text::<FixedData> {
101                    id: gen_id!(),
102                    props: Rc::new(FixedData {
103                        area: RelRect::new(0.5, 0.0, UNSIZED_AXIS, UNSIZED_AXIS).into(),
104                        limits: feather_ui::AbsLimits::new(
105                            Vec2::new(f32::NEG_INFINITY, 10.0),
106                            Vec2::new(f32::INFINITY, 200.0),
107                        )
108                        .into(),
109                        rlimits: feather_ui::RelLimits::new(
110                            Vec2::new(f32::NEG_INFINITY, f32::NEG_INFINITY),
111                            Vec2::new(1.0, f32::INFINITY),
112                        ),
113                        anchor: feather_ui::RelPoint(Vec2 { x: 0.5, y: 0.0 }).into(),
114                        padding: AbsRect::new(8.0, 8.0, 8.0, 8.0).into(),
115                        ..Default::default()
116                    }),
117                    text: (0..args.count).map(|_| "█").collect::<String>(),
118                    font_size: 40.0,
119                    line_height: 56.0,
120                    wrap: feather_ui::cosmic_text::Wrap::WordOrGlyph,
121                    ..Default::default()
122                };
123
124                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
125                    gen_id!(),
126                    feather_ui::FILL_DRECT.into(),
127                    0.0,
128                    0.0,
129                    Vec4::broadcast(10.0),
130                    sRGB::new(0.7, 0.2, 0.4, 1.0),
131                    sRGB::transparent(),
132                );
133
134                Button::<FixedData>::new(
135                    gen_id!(),
136                    FixedData {
137                        area: URect {
138                            abs: AbsRect::new(45.0, 245.0, 0.0, 0.0),
139                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
140                        }
141                        .into(),
142                        limits: feather_ui::AbsLimits::new(
143                            Vec2::new(100.0, f32::NEG_INFINITY),
144                            Vec2::new(300.0, f32::INFINITY),
145                        )
146                        .into(),
147                        ..Default::default()
148                    },
149                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
150                    feather_ui::children![fixed::Prop, rect, text],
151                )
152            };
153
154            let pixel = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
155                gen_id!(),
156                Rc::new(DRect {
157                    px: AbsRect::new(1.0, 1.0, 2.0, 2.0),
158                    dp: ZERO_RECT,
159                    rel: ZERO_RELRECT,
160                }),
161                0.0,
162                0.0,
163                Vec4::broadcast(0.0),
164                sRGB::new(1.0, 1.0, 1.0, 1.0),
165                sRGB::transparent(),
166            );
167
168            let region = Region::new(
169                gen_id!(),
170                FixedData {
171                    area: URect {
172                        abs: AbsRect::new(90.0, 90.0, 0.0, 200.0),
173                        rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, 0.0),
174                    }
175                    .into(),
176                    zindex: 0,
177                    ..Default::default()
178                }
179                .into(),
180                feather_ui::children![fixed::Prop, button, fakebutton, pixel],
181            );
182            let window = Window::new(
183                gen_id!(),
184                winit::window::Window::default_attributes()
185                    .with_title(env!("CARGO_CRATE_NAME"))
186                    .with_resizable(true),
187                Box::new(region),
188            );
189
190            store.1 = im::HashMap::new();
191            store.1.insert(window.id.clone(), Some(window));
192            store.0 = args.clone();
193        }
194        let windows = store.1.clone();
195        (store, windows)
196    }
examples/list-rs.rs (line 136)
125    fn call(
126        &mut self,
127        mut store: Self::Store,
128        args: &CounterState,
129    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
130        if store.0 != *args {
131            let button = {
132                let text = Text::<FixedData> {
133                    id: gen_id!(),
134                    props: FixedData {
135                        area: feather_ui::URect {
136                            abs: AbsRect::new(10.0, 15.0, 10.0, 15.0),
137                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
138                        }
139                        .into(),
140                        anchor: feather_ui::RelPoint(Vec2 { x: 0.0, y: 0.0 }).into(),
141                        ..Default::default()
142                    }
143                    .into(),
144                    text: format!("Boxes: {}", args.count),
145                    font_size: 40.0,
146                    line_height: 56.0,
147                    ..Default::default()
148                };
149
150                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
151                    gen_id!(),
152                    feather_ui::FILL_DRECT.into(),
153                    0.0,
154                    0.0,
155                    Vec4::broadcast(10.0),
156                    sRGB::new(0.2, 0.7, 0.4, 1.0),
157                    sRGB::transparent(),
158                );
159
160                Button::<FixedData>::new(
161                    gen_id!(),
162                    FixedData {
163                        area: feather_ui::URect {
164                            abs: AbsRect::new(0.0, 20.0, 0.0, 0.0),
165                            rel: RelRect::new(0.5, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
166                        }
167                        .into(),
168                        anchor: feather_ui::RelPoint(Vec2 { x: 0.5, y: 0.0 }).into(),
169                        zindex: 0,
170                    },
171                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
172                    feather_ui::children![fixed::Prop, rect, text],
173                )
174            };
175
176            let rectlist = {
177                let mut children: im::Vector<Option<Box<ChildOf<dyn list::Prop>>>> =
178                    im::Vector::new();
179
180                let rect_id = gen_id!();
181
182                for i in 0..args.count {
183                    children.push_back(Some(Box::new(Shape::<
184                        ListChild,
185                        { ShapeKind::RoundRect as u8 },
186                    >::new(
187                        rect_id.child(DataID::Int(i as i64)),
188                        ListChild {
189                            area: AbsRect::new(0.0, 0.0, 40.0, 40.0).into(),
190                            margin: AbsRect::new(8.0, 8.0, 4.0, 4.0).into(),
191                        }
192                        .into(),
193                        0.0,
194                        0.0,
195                        Vec4::broadcast(8.0),
196                        sRGB::new(
197                            (0.1 * i as f32) % 1.0,
198                            (0.65 * i as f32) % 1.0,
199                            (0.2 * i as f32) % 1.0,
200                            1.0,
201                        ),
202                        sRGB::transparent(),
203                    ))));
204                }
205
206                ListBox::<ListData>::new(
207                    gen_id!(),
208                    ListData {
209                        area: feather_ui::URect {
210                            abs: AbsRect::new(0.0, 200.0, 0.0, 0.0),
211                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, 1.0),
212                        }
213                        .into(),
214                        rlimits: feather_ui::RelLimits::new(
215                            ZERO_POINT,
216                            Vec2::new(1.0, f32::INFINITY),
217                        ),
218                        direction: feather_ui::RowDirection::BottomToTop,
219                    }
220                    .into(),
221                    children,
222                )
223            };
224
225            let flexlist = {
226                let mut children: im::Vector<Option<Box<ChildOf<dyn flex::Prop>>>> =
227                    im::Vector::new();
228
229                let box_id = gen_id!();
230                for i in 0..args.count {
231                    children.push_back(Some(Box::new(Shape::<
232                        FlexChild,
233                        { ShapeKind::RoundRect as u8 },
234                    >::new(
235                        box_id.child(DataID::Int(i as i64)),
236                        FlexChild {
237                            area: feather_ui::URect {
238                                abs: AbsRect::new(0.0, 0.0, 0.0, 40.0),
239                                rel: RelRect::new(0.0, 0.0, 1.0, 0.0),
240                            }
241                            .into(),
242                            margin: AbsRect::new(8.0, 8.0, 4.0, 4.0).into(),
243                            basis: 40.0.into(),
244                            grow: 0.0,
245                            shrink: 0.0,
246                        }
247                        .into(),
248                        0.0,
249                        0.0,
250                        Vec4::broadcast(8.0),
251                        sRGB::new(
252                            (0.1 * i as f32) % 1.0,
253                            (0.65 * i as f32) % 1.0,
254                            (0.2 * i as f32) % 1.0,
255                            1.0,
256                        ),
257                        sRGB::transparent(),
258                    ))));
259                }
260
261                FlexBox::<MinimalFlex>::new(
262                    gen_id!(),
263                    MinimalFlex {
264                        area: (AbsRect::new(40.0, 40.0, 0.0, 200.0)
265                            + RelRect::new(0.0, 0.0, 1.0, 0.0))
266                        .into(),
267                    }
268                    .into(),
269                    children,
270                )
271            };
272
273            let region = Region::new(
274                gen_id!(),
275                FixedData {
276                    area: FILL_DRECT,
277                    zindex: 0,
278                    ..Default::default()
279                }
280                .into(),
281                feather_ui::children![fixed::Prop, button, flexlist, rectlist],
282            );
283            let window = Window::new(
284                gen_id!(),
285                feather_ui::winit::window::Window::default_attributes()
286                    .with_title(env!("CARGO_CRATE_NAME"))
287                    .with_resizable(true),
288                Box::new(region),
289            );
290
291            store.1 = im::HashMap::new();
292            store.1.insert(window.id.clone(), Some(window));
293            store.0 = args.clone();
294        }
295        let windows = store.1.clone();
296        (store, windows)
297    }
Source

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

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

pub const fn corners(topleft: Vec2, bottomright: Vec2) -> Self

Source

pub fn contains(&self, p: Vec2) -> bool

Source

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

Source

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

Source

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

Source

pub fn topleft(&self) -> Vec2

Source

pub fn set_topleft(&mut self, v: Vec2)

Source

pub fn bottomright(&self) -> Vec2

Source

pub fn set_bottomright(&mut self, v: Vec2)

Source

pub fn dim(&self) -> AbsDim

Trait Implementations§

Source§

impl Add<AbsRect> for RelRect

Source§

type Output = URect

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<RelRect> for AbsRect

Source§

type Output = URect

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<Vec2> for AbsRect

Source§

type Output = AbsRect

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign<Vec2> for AbsRect

Source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
Source§

impl Clone for AbsRect

Source§

fn clone(&self) -> AbsRect

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 Debug for AbsRect

Source§

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

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

impl Default for AbsRect

Source§

fn default() -> AbsRect

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

impl Display for AbsRect

Source§

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

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

impl From<[f32; 4]> for AbsRect

Source§

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

Converts to this type from the input type.
Source§

impl From<AbsDim> for AbsRect

Source§

fn from(value: AbsDim) -> Self

Converts to this type from the input type.
Source§

impl From<AbsRect> for DAbsRect

Source§

fn from(value: AbsRect) -> Self

Converts to this type from the input type.
Source§

impl From<AbsRect> for DRect

Source§

fn from(value: AbsRect) -> Self

By default we assume everything is in device independent pixels - if you wanted pixels, you should be using DRect explicitly

Source§

impl From<AbsRect> for URect

Source§

fn from(value: AbsRect) -> Self

Converts to this type from the input type.
Source§

impl Mul<AbsRect> for UPoint

Source§

type Output = Vec2

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<AbsRect> for URect

Source§

type Output = AbsRect

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl PartialEq for AbsRect

Source§

fn eq(&self, other: &AbsRect) -> 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 Sub<Vec2> for AbsRect

Source§

type Output = AbsRect

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vec2) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Vec2> for AbsRect

Source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
Source§

impl Copy for AbsRect

Source§

impl NoUninit for AbsRect

Source§

impl StructuralPartialEq for AbsRect

Auto Trait Implementations§

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> 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> 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,