pub struct BorderRadius {
pub top_left: Val,
pub top_right: Val,
pub bottom_left: Val,
pub bottom_right: Val,
}
Expand description
Used to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners or specify different radii for each corner. If a given radius exceeds half the length of the smallest dimension between the node’s height or width, the radius will calculated as half the smallest dimension.
Elliptical nodes are not supported yet. Percentage values are based on the node’s smallest dimension, either width or height.
§Example
fn setup_ui(mut commands: Commands) {
commands.spawn((
Node {
width: Val::Px(100.),
height: Val::Px(100.),
border: UiRect::all(Val::Px(2.)),
..Default::default()
},
BackgroundColor(BLUE.into()),
BorderRadius::new(
// top left
Val::Px(10.),
// top right
Val::Px(20.),
// bottom right
Val::Px(30.),
// bottom left
Val::Px(40.),
),
));
}
https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
Fields§
§top_left: Val
§top_right: Val
§bottom_left: Val
§bottom_right: Val
Implementations§
Source§impl BorderRadius
impl BorderRadius
pub const DEFAULT: BorderRadius = Self::ZERO
Sourcepub const ZERO: BorderRadius
pub const ZERO: BorderRadius
Zero curvature. All the corners will be right-angled.
Sourcepub const MAX: BorderRadius
pub const MAX: BorderRadius
Maximum curvature. The UI Node will take a capsule shape or circular if width and height are equal.
Sourcepub const fn all(radius: Val) -> BorderRadius
pub const fn all(radius: Val) -> BorderRadius
Set all four corners to the same curvature.
Examples found in repository?
281fn spawn_drag_button<'a>(
282 commands: &'a mut ChildSpawnerCommands,
283 label: &str,
284) -> EntityCommands<'a> {
285 let mut kid = commands.spawn(Node {
286 border: BUTTON_BORDER,
287 justify_content: JustifyContent::Center,
288 align_items: AlignItems::Center,
289 padding: BUTTON_PADDING,
290 ..default()
291 });
292 kid.insert((
293 Button,
294 BackgroundColor(Color::BLACK),
295 BorderRadius::all(BUTTON_BORDER_RADIUS_SIZE),
296 BUTTON_BORDER_COLOR,
297 ))
298 .with_children(|parent| {
299 widgets::spawn_ui_text(parent, label, Color::WHITE);
300 });
301 kid
302}
More examples
19fn setup(
20 mut commands: Commands,
21 mut ui_materials: ResMut<Assets<CustomUiMaterial>>,
22 asset_server: Res<AssetServer>,
23) {
24 // Camera so we can see UI
25 commands.spawn(Camera2d);
26
27 commands
28 .spawn(Node {
29 width: Val::Percent(100.0),
30 height: Val::Percent(100.0),
31 align_items: AlignItems::Center,
32 justify_content: JustifyContent::Center,
33 ..default()
34 })
35 .with_children(|parent| {
36 let banner_scale_factor = 0.5;
37 parent.spawn((
38 Node {
39 position_type: PositionType::Absolute,
40 width: Val::Px(905.0 * banner_scale_factor),
41 height: Val::Px(363.0 * banner_scale_factor),
42 border: UiRect::all(Val::Px(20.)),
43 ..default()
44 },
45 MaterialNode(ui_materials.add(CustomUiMaterial {
46 color: LinearRgba::WHITE.to_f32_array().into(),
47 slider: Vec4::splat(0.5),
48 color_texture: asset_server.load("branding/banner.png"),
49 border_color: LinearRgba::WHITE.to_f32_array().into(),
50 })),
51 BorderRadius::all(Val::Px(20.)),
52 // UI material nodes can have outlines and shadows like any other UI node
53 Outline {
54 width: Val::Px(2.),
55 offset: Val::Px(100.),
56 color: DARK_BLUE.into(),
57 },
58 ));
59 });
60}
227fn add_mask_group_control(
228 parent: &mut ChildSpawnerCommands,
229 label: &str,
230 width: Val,
231 mask_group_id: u32,
232) {
233 let button_text_style = (
234 TextFont {
235 font_size: 14.0,
236 ..default()
237 },
238 TextColor::WHITE,
239 );
240 let selected_button_text_style = (button_text_style.0.clone(), TextColor::BLACK);
241 let label_text_style = (
242 button_text_style.0.clone(),
243 TextColor(Color::Srgba(LIGHT_GRAY)),
244 );
245
246 parent
247 .spawn((
248 Node {
249 border: UiRect::all(Val::Px(1.0)),
250 width,
251 flex_direction: FlexDirection::Column,
252 justify_content: JustifyContent::Center,
253 align_items: AlignItems::Center,
254 padding: UiRect::ZERO,
255 margin: UiRect::ZERO,
256 ..default()
257 },
258 BorderColor(Color::WHITE),
259 BorderRadius::all(Val::Px(3.0)),
260 BackgroundColor(Color::BLACK),
261 ))
262 .with_children(|builder| {
263 builder
264 .spawn((
265 Node {
266 border: UiRect::ZERO,
267 width: Val::Percent(100.0),
268 justify_content: JustifyContent::Center,
269 align_items: AlignItems::Center,
270 padding: UiRect::ZERO,
271 margin: UiRect::ZERO,
272 ..default()
273 },
274 BackgroundColor(Color::BLACK),
275 ))
276 .with_child((
277 Text::new(label),
278 label_text_style.clone(),
279 Node {
280 margin: UiRect::vertical(Val::Px(3.0)),
281 ..default()
282 },
283 ));
284
285 builder
286 .spawn((
287 Node {
288 width: Val::Percent(100.0),
289 flex_direction: FlexDirection::Row,
290 justify_content: JustifyContent::Center,
291 align_items: AlignItems::Center,
292 border: UiRect::top(Val::Px(1.0)),
293 ..default()
294 },
295 BorderColor(Color::WHITE),
296 ))
297 .with_children(|builder| {
298 for (index, label) in [
299 AnimationLabel::Run,
300 AnimationLabel::Walk,
301 AnimationLabel::Idle,
302 AnimationLabel::Off,
303 ]
304 .iter()
305 .enumerate()
306 {
307 builder
308 .spawn((
309 Button,
310 BackgroundColor(if index > 0 {
311 Color::BLACK
312 } else {
313 Color::WHITE
314 }),
315 Node {
316 flex_grow: 1.0,
317 border: if index > 0 {
318 UiRect::left(Val::Px(1.0))
319 } else {
320 UiRect::ZERO
321 },
322 ..default()
323 },
324 BorderColor(Color::WHITE),
325 AnimationControl {
326 group_id: mask_group_id,
327 label: *label,
328 },
329 ))
330 .with_child((
331 Text(format!("{:?}", label)),
332 if index > 0 {
333 button_text_style.clone()
334 } else {
335 selected_button_text_style.clone()
336 },
337 TextLayout::new_with_justify(JustifyText::Center),
338 Node {
339 flex_grow: 1.0,
340 margin: UiRect::vertical(Val::Px(3.0)),
341 ..default()
342 },
343 ));
344 }
345 });
346 });
347}
103fn setup_ui(
104 mut commands: Commands,
105 mut directional_nav_map: ResMut<DirectionalNavigationMap>,
106 mut input_focus: ResMut<InputFocus>,
107) {
108 const N_ROWS: u16 = 5;
109 const N_COLS: u16 = 3;
110
111 // Rendering UI elements requires a camera
112 commands.spawn(Camera2d);
113
114 // Create a full-screen background node
115 let root_node = commands
116 .spawn(Node {
117 width: Val::Percent(100.0),
118 height: Val::Percent(100.0),
119 ..default()
120 })
121 .id();
122
123 // Add instruction to the left of the grid
124 let instructions = commands
125 .spawn((
126 Text::new("Use arrow keys or D-pad to navigate. \
127 Click the buttons, or press Enter / the South gamepad button to interact with the focused button."),
128 Node {
129 width: Val::Px(300.0),
130 justify_content: JustifyContent::Center,
131 align_items: AlignItems::Center,
132 margin: UiRect::all(Val::Px(12.0)),
133 ..default()
134 },
135 ))
136 .id();
137
138 // Set up the root entity to hold the grid
139 let grid_root_entity = commands
140 .spawn(Node {
141 display: Display::Grid,
142 // Allow the grid to take up the full height and the rest of the width of the window
143 width: Val::Percent(100.),
144 height: Val::Percent(100.),
145 // Set the number of rows and columns in the grid
146 // allowing the grid to automatically size the cells
147 grid_template_columns: RepeatedGridTrack::auto(N_COLS),
148 grid_template_rows: RepeatedGridTrack::auto(N_ROWS),
149 ..default()
150 })
151 .id();
152
153 // Add the instructions and grid to the root node
154 commands
155 .entity(root_node)
156 .add_children(&[instructions, grid_root_entity]);
157
158 let mut button_entities: HashMap<(u16, u16), Entity> = HashMap::default();
159 for row in 0..N_ROWS {
160 for col in 0..N_COLS {
161 let button_name = format!("Button {}-{}", row, col);
162
163 let button_entity = commands
164 .spawn((
165 Button,
166 Node {
167 width: Val::Px(200.0),
168 height: Val::Px(120.0),
169 // Add a border so we can show which element is focused
170 border: UiRect::all(Val::Px(4.0)),
171 // Center the button's text label
172 justify_content: JustifyContent::Center,
173 align_items: AlignItems::Center,
174 // Center the button within the grid cell
175 align_self: AlignSelf::Center,
176 justify_self: JustifySelf::Center,
177 ..default()
178 },
179 ResetTimer::default(),
180 BorderRadius::all(Val::Px(16.0)),
181 BackgroundColor::from(NORMAL_BUTTON),
182 Name::new(button_name.clone()),
183 ))
184 // Add a text element to the button
185 .with_child((
186 Text::new(button_name),
187 // And center the text if it flows onto multiple lines
188 TextLayout {
189 justify: JustifyText::Center,
190 ..default()
191 },
192 ))
193 .id();
194
195 // Add the button to the grid
196 commands.entity(grid_root_entity).add_child(button_entity);
197
198 // Keep track of the button entities so we can set up our navigation graph
199 button_entities.insert((row, col), button_entity);
200 }
201 }
202
203 // Connect all of the buttons in the same row to each other,
204 // looping around when the edge is reached.
205 for row in 0..N_ROWS {
206 let entities_in_row: Vec<Entity> = (0..N_COLS)
207 .map(|col| button_entities.get(&(row, col)).unwrap())
208 .copied()
209 .collect();
210 directional_nav_map.add_looping_edges(&entities_in_row, CompassOctant::East);
211 }
212
213 // Connect all of the buttons in the same column to each other,
214 // but don't loop around when the edge is reached.
215 // While looping is a very reasonable choice, we're not doing it here to demonstrate the different options.
216 for col in 0..N_COLS {
217 let entities_in_column: Vec<Entity> = (0..N_ROWS)
218 .map(|row| button_entities.get(&(row, col)).unwrap())
219 .copied()
220 .collect();
221
222 directional_nav_map.add_edges(&entities_in_column, CompassOctant::South);
223 }
224
225 // When changing scenes, remember to set an initial focus!
226 let top_left_entity = *button_entities.get(&(0, 0)).unwrap();
227 input_focus.set(top_left_entity);
228}
30fn setup(mut commands: Commands) {
31 // `from_env` panics on the web
32 #[cfg(not(target_arch = "wasm32"))]
33 let args: Args = argh::from_env();
34 #[cfg(target_arch = "wasm32")]
35 let args = Args::from_args(&[], &[]).unwrap();
36
37 // ui camera
38 commands.spawn((Camera2d, BoxShadowSamples(args.samples)));
39
40 commands
41 .spawn((
42 Node {
43 width: Val::Percent(100.0),
44 height: Val::Percent(100.0),
45 padding: UiRect::all(Val::Px(30.)),
46 column_gap: Val::Px(30.),
47 flex_wrap: FlexWrap::Wrap,
48 ..default()
49 },
50 BackgroundColor(DEEP_SKY_BLUE.into()),
51 ))
52 .with_children(|commands| {
53 let example_nodes = [
54 (
55 Vec2::splat(50.),
56 Vec2::ZERO,
57 10.,
58 0.,
59 BorderRadius::bottom_right(Val::Px(10.)),
60 ),
61 (Vec2::new(50., 25.), Vec2::ZERO, 10., 0., BorderRadius::ZERO),
62 (Vec2::splat(50.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
63 (Vec2::new(100., 25.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
64 (
65 Vec2::splat(50.),
66 Vec2::ZERO,
67 10.,
68 0.,
69 BorderRadius::bottom_right(Val::Px(10.)),
70 ),
71 (Vec2::new(50., 25.), Vec2::ZERO, 0., 10., BorderRadius::ZERO),
72 (
73 Vec2::splat(50.),
74 Vec2::ZERO,
75 0.,
76 10.,
77 BorderRadius::bottom_right(Val::Px(10.)),
78 ),
79 (Vec2::new(100., 25.), Vec2::ZERO, 0., 10., BorderRadius::MAX),
80 (
81 Vec2::splat(50.),
82 Vec2::splat(25.),
83 0.,
84 0.,
85 BorderRadius::ZERO,
86 ),
87 (
88 Vec2::new(50., 25.),
89 Vec2::splat(25.),
90 0.,
91 0.,
92 BorderRadius::ZERO,
93 ),
94 (
95 Vec2::splat(50.),
96 Vec2::splat(10.),
97 0.,
98 0.,
99 BorderRadius::bottom_right(Val::Px(10.)),
100 ),
101 (
102 Vec2::splat(50.),
103 Vec2::splat(25.),
104 0.,
105 10.,
106 BorderRadius::ZERO,
107 ),
108 (
109 Vec2::new(50., 25.),
110 Vec2::splat(25.),
111 0.,
112 10.,
113 BorderRadius::ZERO,
114 ),
115 (
116 Vec2::splat(50.),
117 Vec2::splat(10.),
118 0.,
119 10.,
120 BorderRadius::bottom_right(Val::Px(10.)),
121 ),
122 (
123 Vec2::splat(50.),
124 Vec2::splat(10.),
125 0.,
126 3.,
127 BorderRadius::ZERO,
128 ),
129 (
130 Vec2::new(50., 25.),
131 Vec2::splat(10.),
132 0.,
133 3.,
134 BorderRadius::ZERO,
135 ),
136 (
137 Vec2::splat(50.),
138 Vec2::splat(10.),
139 0.,
140 3.,
141 BorderRadius::bottom_right(Val::Px(10.)),
142 ),
143 (
144 Vec2::splat(50.),
145 Vec2::splat(10.),
146 0.,
147 3.,
148 BorderRadius::all(Val::Px(20.)),
149 ),
150 (
151 Vec2::new(50., 25.),
152 Vec2::splat(10.),
153 0.,
154 3.,
155 BorderRadius::all(Val::Px(20.)),
156 ),
157 (
158 Vec2::new(25., 50.),
159 Vec2::splat(10.),
160 0.,
161 3.,
162 BorderRadius::MAX,
163 ),
164 (
165 Vec2::splat(50.),
166 Vec2::splat(10.),
167 0.,
168 10.,
169 BorderRadius::all(Val::Px(20.)),
170 ),
171 (
172 Vec2::new(50., 25.),
173 Vec2::splat(10.),
174 0.,
175 10.,
176 BorderRadius::all(Val::Px(20.)),
177 ),
178 (
179 Vec2::new(25., 50.),
180 Vec2::splat(10.),
181 0.,
182 10.,
183 BorderRadius::MAX,
184 ),
185 ];
186
187 for (size, offset, spread, blur, border_radius) in example_nodes {
188 commands.spawn(box_shadow_node_bundle(
189 size,
190 offset,
191 spread,
192 blur,
193 border_radius,
194 ));
195 }
196
197 // Demonstrate multiple shadows on one node
198 commands.spawn((
199 Node {
200 width: Val::Px(40.),
201 height: Val::Px(40.),
202 border: UiRect::all(Val::Px(4.)),
203 ..default()
204 },
205 BorderColor(LIGHT_SKY_BLUE.into()),
206 BorderRadius::all(Val::Px(20.)),
207 BackgroundColor(DEEP_SKY_BLUE.into()),
208 BoxShadow(vec![
209 ShadowStyle {
210 color: RED.with_alpha(0.7).into(),
211 x_offset: Val::Px(-20.),
212 y_offset: Val::Px(-5.),
213 spread_radius: Val::Percent(10.),
214 blur_radius: Val::Px(3.),
215 },
216 ShadowStyle {
217 color: BLUE.with_alpha(0.7).into(),
218 x_offset: Val::Px(-5.),
219 y_offset: Val::Px(-20.),
220 spread_radius: Val::Percent(10.),
221 blur_radius: Val::Px(3.),
222 },
223 ShadowStyle {
224 color: YELLOW.with_alpha(0.7).into(),
225 x_offset: Val::Px(20.),
226 y_offset: Val::Px(5.),
227 spread_radius: Val::Percent(10.),
228 blur_radius: Val::Px(3.),
229 },
230 ShadowStyle {
231 color: GREEN.with_alpha(0.7).into(),
232 x_offset: Val::Px(5.),
233 y_offset: Val::Px(20.),
234 spread_radius: Val::Percent(10.),
235 blur_radius: Val::Px(3.),
236 },
237 ]),
238 ));
239 });
240}
27fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
28 // Camera
29 commands.spawn((Camera2d, IsDefaultUiCamera, BoxShadowSamples(6)));
30
31 // root node
32 commands
33 .spawn(Node {
34 width: Val::Percent(100.0),
35 height: Val::Percent(100.0),
36 justify_content: JustifyContent::SpaceBetween,
37 ..default()
38 })
39 .insert(Pickable::IGNORE)
40 .with_children(|parent| {
41 // left vertical fill (border)
42 parent
43 .spawn((
44 Node {
45 width: Val::Px(200.),
46 border: UiRect::all(Val::Px(2.)),
47 ..default()
48 },
49 BackgroundColor(Color::srgb(0.65, 0.65, 0.65)),
50 ))
51 .with_children(|parent| {
52 // left vertical fill (content)
53 parent
54 .spawn((
55 Node {
56 width: Val::Percent(100.),
57 flex_direction: FlexDirection::Column,
58 padding: UiRect::all(Val::Px(5.)),
59 row_gap: Val::Px(5.),
60 ..default()
61 },
62 BackgroundColor(Color::srgb(0.15, 0.15, 0.15)),
63 Visibility::Visible,
64 ))
65 .with_children(|parent| {
66 // text
67 parent.spawn((
68 Text::new("Text Example"),
69 TextFont {
70 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
71 font_size: 25.0,
72 ..default()
73 },
74 // Because this is a distinct label widget and
75 // not button/list item text, this is necessary
76 // for accessibility to treat the text accordingly.
77 Label,
78 ));
79
80 #[cfg(feature = "bevy_ui_debug")]
81 {
82 // Debug overlay text
83 parent.spawn((
84 Text::new("Press Space to toggle debug outlines."),
85 TextFont {
86 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
87 ..default()
88 },
89 Label,
90 ));
91
92 parent.spawn((
93 Text::new("V: toggle UI root's visibility"),
94 TextFont {
95 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
96 font_size: 12.,
97 ..default()
98 },
99 Label,
100 ));
101
102 parent.spawn((
103 Text::new("S: toggle outlines for hidden nodes"),
104 TextFont {
105 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
106 font_size: 12.,
107 ..default()
108 },
109 Label,
110 ));
111 parent.spawn((
112 Text::new("C: toggle outlines for clipped nodes"),
113 TextFont {
114 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
115 font_size: 12.,
116 ..default()
117 },
118 Label,
119 ));
120 }
121 #[cfg(not(feature = "bevy_ui_debug"))]
122 parent.spawn((
123 Text::new("Try enabling feature \"bevy_ui_debug\"."),
124 TextFont {
125 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
126 ..default()
127 },
128 Label,
129 ));
130 });
131 });
132 // right vertical fill
133 parent
134 .spawn(Node {
135 flex_direction: FlexDirection::Column,
136 justify_content: JustifyContent::Center,
137 align_items: AlignItems::Center,
138 width: Val::Px(200.),
139 ..default()
140 })
141 .with_children(|parent| {
142 // Title
143 parent.spawn((
144 Text::new("Scrolling list"),
145 TextFont {
146 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
147 font_size: 21.,
148 ..default()
149 },
150 Label,
151 ));
152 // Scrolling list
153 parent
154 .spawn((
155 Node {
156 flex_direction: FlexDirection::Column,
157 align_self: AlignSelf::Stretch,
158 height: Val::Percent(50.),
159 overflow: Overflow::scroll_y(),
160 ..default()
161 },
162 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
163 ))
164 .with_children(|parent| {
165 // List items
166 for i in 0..25 {
167 parent
168 .spawn((
169 Text(format!("Item {i}")),
170 TextFont {
171 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
172 ..default()
173 },
174 Label,
175 AccessibilityNode(Accessible::new(Role::ListItem)),
176 ))
177 .insert(Pickable {
178 should_block_lower: false,
179 ..default()
180 });
181 }
182 });
183 });
184
185 parent
186 .spawn(Node {
187 left: Val::Px(210.),
188 bottom: Val::Px(10.),
189 position_type: PositionType::Absolute,
190 ..default()
191 })
192 .with_children(|parent| {
193 parent
194 .spawn((
195 Node {
196 width: Val::Px(200.0),
197 height: Val::Px(200.0),
198 border: UiRect::all(Val::Px(20.)),
199 flex_direction: FlexDirection::Column,
200 justify_content: JustifyContent::Center,
201 ..default()
202 },
203 BorderColor(LIME.into()),
204 BackgroundColor(Color::srgb(0.8, 0.8, 1.)),
205 ))
206 .with_children(|parent| {
207 parent.spawn((
208 ImageNode::new(asset_server.load("branding/bevy_logo_light.png")),
209 // Uses the transform to rotate the logo image by 45 degrees
210 Transform::from_rotation(Quat::from_rotation_z(0.25 * PI)),
211 BorderRadius::all(Val::Px(10.)),
212 Outline {
213 width: Val::Px(2.),
214 offset: Val::Px(4.),
215 color: DARK_GRAY.into(),
216 },
217 ));
218 });
219 });
220
221 let shadow_style = ShadowStyle {
222 color: Color::BLACK.with_alpha(0.5),
223 blur_radius: Val::Px(2.),
224 x_offset: Val::Px(10.),
225 y_offset: Val::Px(10.),
226 ..default()
227 };
228
229 // render order test: reddest in the back, whitest in the front (flex center)
230 parent
231 .spawn(Node {
232 width: Val::Percent(100.0),
233 height: Val::Percent(100.0),
234 position_type: PositionType::Absolute,
235 align_items: AlignItems::Center,
236 justify_content: JustifyContent::Center,
237 ..default()
238 })
239 .insert(Pickable::IGNORE)
240 .with_children(|parent| {
241 parent
242 .spawn((
243 Node {
244 width: Val::Px(100.0),
245 height: Val::Px(100.0),
246 ..default()
247 },
248 BackgroundColor(Color::srgb(1.0, 0.0, 0.)),
249 BoxShadow::from(shadow_style),
250 ))
251 .with_children(|parent| {
252 parent.spawn((
253 Node {
254 // Take the size of the parent node.
255 width: Val::Percent(100.0),
256 height: Val::Percent(100.0),
257 position_type: PositionType::Absolute,
258 left: Val::Px(20.),
259 bottom: Val::Px(20.),
260 ..default()
261 },
262 BackgroundColor(Color::srgb(1.0, 0.3, 0.3)),
263 BoxShadow::from(shadow_style),
264 ));
265 parent.spawn((
266 Node {
267 width: Val::Percent(100.0),
268 height: Val::Percent(100.0),
269 position_type: PositionType::Absolute,
270 left: Val::Px(40.),
271 bottom: Val::Px(40.),
272 ..default()
273 },
274 BackgroundColor(Color::srgb(1.0, 0.5, 0.5)),
275 BoxShadow::from(shadow_style),
276 ));
277 parent.spawn((
278 Node {
279 width: Val::Percent(100.0),
280 height: Val::Percent(100.0),
281 position_type: PositionType::Absolute,
282 left: Val::Px(60.),
283 bottom: Val::Px(60.),
284 ..default()
285 },
286 BackgroundColor(Color::srgb(0.0, 0.7, 0.7)),
287 BoxShadow::from(shadow_style),
288 ));
289 // alpha test
290 parent.spawn((
291 Node {
292 width: Val::Percent(100.0),
293 height: Val::Percent(100.0),
294 position_type: PositionType::Absolute,
295 left: Val::Px(80.),
296 bottom: Val::Px(80.),
297 ..default()
298 },
299 BackgroundColor(Color::srgba(1.0, 0.9, 0.9, 0.4)),
300 BoxShadow::from(ShadowStyle {
301 color: Color::BLACK.with_alpha(0.3),
302 ..shadow_style
303 }),
304 ));
305 });
306 });
307 // bevy logo (flex center)
308 parent
309 .spawn(Node {
310 width: Val::Percent(100.0),
311 position_type: PositionType::Absolute,
312 justify_content: JustifyContent::Center,
313 align_items: AlignItems::FlexStart,
314 ..default()
315 })
316 .with_children(|parent| {
317 // bevy logo (image)
318 parent
319 .spawn((
320 ImageNode::new(asset_server.load("branding/bevy_logo_dark_big.png"))
321 .with_mode(NodeImageMode::Stretch),
322 Node {
323 width: Val::Px(500.0),
324 height: Val::Px(125.0),
325 margin: UiRect::top(Val::VMin(5.)),
326 ..default()
327 },
328 ))
329 .with_children(|parent| {
330 // alt text
331 // This UI node takes up no space in the layout and the `Text` component is used by the accessibility module
332 // and is not rendered.
333 parent.spawn((
334 Node {
335 display: Display::None,
336 ..default()
337 },
338 Text::new("Bevy logo"),
339 ));
340 });
341 });
342
343 // four bevy icons demonstrating image flipping
344 parent
345 .spawn(Node {
346 width: Val::Percent(100.0),
347 height: Val::Percent(100.0),
348 position_type: PositionType::Absolute,
349 justify_content: JustifyContent::Center,
350 align_items: AlignItems::FlexEnd,
351 column_gap: Val::Px(10.),
352 padding: UiRect::all(Val::Px(10.)),
353 ..default()
354 })
355 .insert(Pickable::IGNORE)
356 .with_children(|parent| {
357 for (flip_x, flip_y) in
358 [(false, false), (false, true), (true, true), (true, false)]
359 {
360 parent.spawn((
361 ImageNode {
362 image: asset_server.load("branding/icon.png"),
363 flip_x,
364 flip_y,
365 ..default()
366 },
367 Node {
368 // The height will be chosen automatically to preserve the image's aspect ratio
369 width: Val::Px(75.),
370 ..default()
371 },
372 ));
373 }
374 });
375 });
376}
pub const fn new( top_left: Val, top_right: Val, bottom_right: Val, bottom_left: Val, ) -> BorderRadius
Sourcepub const fn px(
top_left: f32,
top_right: f32,
bottom_right: f32,
bottom_left: f32,
) -> BorderRadius
pub const fn px( top_left: f32, top_right: f32, bottom_right: f32, bottom_left: f32, ) -> BorderRadius
Sets the radii to logical pixel values.
Examples found in repository?
169 pub fn setup(mut commands: Commands) {
170 commands.spawn((Camera2d, StateScoped(super::Scene::Borders)));
171 let root = commands
172 .spawn((
173 Node {
174 flex_wrap: FlexWrap::Wrap,
175 ..default()
176 },
177 StateScoped(super::Scene::Borders),
178 ))
179 .id();
180
181 // all the different combinations of border edges
182 let borders = [
183 UiRect::default(),
184 UiRect::all(Val::Px(20.)),
185 UiRect::left(Val::Px(20.)),
186 UiRect::vertical(Val::Px(20.)),
187 UiRect {
188 left: Val::Px(40.),
189 top: Val::Px(20.),
190 ..Default::default()
191 },
192 UiRect {
193 right: Val::Px(20.),
194 bottom: Val::Px(30.),
195 ..Default::default()
196 },
197 UiRect {
198 right: Val::Px(20.),
199 top: Val::Px(40.),
200 bottom: Val::Px(20.),
201 ..Default::default()
202 },
203 UiRect {
204 left: Val::Px(20.),
205 top: Val::Px(20.),
206 bottom: Val::Px(20.),
207 ..Default::default()
208 },
209 UiRect {
210 left: Val::Px(20.),
211 right: Val::Px(20.),
212 bottom: Val::Px(40.),
213 ..Default::default()
214 },
215 ];
216
217 let non_zero = |x, y| x != Val::Px(0.) && y != Val::Px(0.);
218 let border_size = |x, y| if non_zero(x, y) { f32::MAX } else { 0. };
219
220 for border in borders {
221 for rounded in [true, false] {
222 let border_node = commands
223 .spawn((
224 Node {
225 width: Val::Px(100.),
226 height: Val::Px(100.),
227 border,
228 margin: UiRect::all(Val::Px(30.)),
229 align_items: AlignItems::Center,
230 justify_content: JustifyContent::Center,
231 ..default()
232 },
233 BackgroundColor(MAROON.into()),
234 BorderColor(RED.into()),
235 Outline {
236 width: Val::Px(10.),
237 offset: Val::Px(10.),
238 color: Color::WHITE,
239 },
240 ))
241 .id();
242
243 if rounded {
244 let border_radius = BorderRadius::px(
245 border_size(border.left, border.top),
246 border_size(border.right, border.top),
247 border_size(border.right, border.bottom),
248 border_size(border.left, border.bottom),
249 );
250 commands.entity(border_node).insert(border_radius);
251 }
252
253 commands.entity(root).add_child(border_node);
254 }
255 }
256 }
More examples
12fn setup(mut commands: Commands) {
13 commands.spawn(Camera2d);
14 let root = commands
15 .spawn((
16 Node {
17 margin: UiRect::all(Val::Px(25.0)),
18 align_self: AlignSelf::Stretch,
19 justify_self: JustifySelf::Stretch,
20 flex_wrap: FlexWrap::Wrap,
21 justify_content: JustifyContent::FlexStart,
22 align_items: AlignItems::FlexStart,
23 align_content: AlignContent::FlexStart,
24 ..default()
25 },
26 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
27 ))
28 .id();
29
30 let root_rounded = commands
31 .spawn((
32 Node {
33 margin: UiRect::all(Val::Px(25.0)),
34 align_self: AlignSelf::Stretch,
35 justify_self: JustifySelf::Stretch,
36 flex_wrap: FlexWrap::Wrap,
37 justify_content: JustifyContent::FlexStart,
38 align_items: AlignItems::FlexStart,
39 align_content: AlignContent::FlexStart,
40 ..default()
41 },
42 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
43 ))
44 .id();
45
46 // labels for the different border edges
47 let border_labels = [
48 "None",
49 "All",
50 "Left",
51 "Right",
52 "Top",
53 "Bottom",
54 "Horizontal",
55 "Vertical",
56 "Top Left",
57 "Bottom Left",
58 "Top Right",
59 "Bottom Right",
60 "Top Bottom Right",
61 "Top Bottom Left",
62 "Top Left Right",
63 "Bottom Left Right",
64 ];
65
66 // all the different combinations of border edges
67 // these correspond to the labels above
68 let borders = [
69 UiRect::default(),
70 UiRect::all(Val::Px(10.)),
71 UiRect::left(Val::Px(10.)),
72 UiRect::right(Val::Px(10.)),
73 UiRect::top(Val::Px(10.)),
74 UiRect::bottom(Val::Px(10.)),
75 UiRect::horizontal(Val::Px(10.)),
76 UiRect::vertical(Val::Px(10.)),
77 UiRect {
78 left: Val::Px(20.),
79 top: Val::Px(10.),
80 ..Default::default()
81 },
82 UiRect {
83 left: Val::Px(10.),
84 bottom: Val::Px(20.),
85 ..Default::default()
86 },
87 UiRect {
88 right: Val::Px(20.),
89 top: Val::Px(10.),
90 ..Default::default()
91 },
92 UiRect {
93 right: Val::Px(10.),
94 bottom: Val::Px(10.),
95 ..Default::default()
96 },
97 UiRect {
98 right: Val::Px(10.),
99 top: Val::Px(20.),
100 bottom: Val::Px(10.),
101 ..Default::default()
102 },
103 UiRect {
104 left: Val::Px(10.),
105 top: Val::Px(10.),
106 bottom: Val::Px(10.),
107 ..Default::default()
108 },
109 UiRect {
110 left: Val::Px(20.),
111 right: Val::Px(10.),
112 top: Val::Px(10.),
113 ..Default::default()
114 },
115 UiRect {
116 left: Val::Px(10.),
117 right: Val::Px(10.),
118 bottom: Val::Px(20.),
119 ..Default::default()
120 },
121 ];
122
123 for (label, border) in border_labels.into_iter().zip(borders) {
124 let inner_spot = commands
125 .spawn((
126 Node {
127 width: Val::Px(10.),
128 height: Val::Px(10.),
129 ..default()
130 },
131 BackgroundColor(YELLOW.into()),
132 ))
133 .id();
134 let border_node = commands
135 .spawn((
136 Node {
137 width: Val::Px(50.),
138 height: Val::Px(50.),
139 border,
140 margin: UiRect::all(Val::Px(20.)),
141 align_items: AlignItems::Center,
142 justify_content: JustifyContent::Center,
143 ..default()
144 },
145 BackgroundColor(MAROON.into()),
146 BorderColor(RED.into()),
147 Outline {
148 width: Val::Px(6.),
149 offset: Val::Px(6.),
150 color: Color::WHITE,
151 },
152 ))
153 .add_child(inner_spot)
154 .id();
155 let label_node = commands
156 .spawn((
157 Text::new(label),
158 TextFont {
159 font_size: 9.0,
160 ..Default::default()
161 },
162 ))
163 .id();
164 let container = commands
165 .spawn(Node {
166 flex_direction: FlexDirection::Column,
167 align_items: AlignItems::Center,
168 ..default()
169 })
170 .add_children(&[border_node, label_node])
171 .id();
172 commands.entity(root).add_child(container);
173 }
174
175 for (label, border) in border_labels.into_iter().zip(borders) {
176 let inner_spot = commands
177 .spawn((
178 Node {
179 width: Val::Px(10.),
180 height: Val::Px(10.),
181 ..default()
182 },
183 BorderRadius::MAX,
184 BackgroundColor(YELLOW.into()),
185 ))
186 .id();
187 let non_zero = |x, y| x != Val::Px(0.) && y != Val::Px(0.);
188 let border_size = |x, y| if non_zero(x, y) { f32::MAX } else { 0. };
189 let border_radius = BorderRadius::px(
190 border_size(border.left, border.top),
191 border_size(border.right, border.top),
192 border_size(border.right, border.bottom),
193 border_size(border.left, border.bottom),
194 );
195 let border_node = commands
196 .spawn((
197 Node {
198 width: Val::Px(50.),
199 height: Val::Px(50.),
200 border,
201 margin: UiRect::all(Val::Px(20.)),
202 align_items: AlignItems::Center,
203 justify_content: JustifyContent::Center,
204 ..default()
205 },
206 BackgroundColor(MAROON.into()),
207 BorderColor(RED.into()),
208 border_radius,
209 Outline {
210 width: Val::Px(6.),
211 offset: Val::Px(6.),
212 color: Color::WHITE,
213 },
214 ))
215 .add_child(inner_spot)
216 .id();
217 let label_node = commands
218 .spawn((
219 Text::new(label),
220 TextFont {
221 font_size: 9.0,
222 ..Default::default()
223 },
224 ))
225 .id();
226 let container = commands
227 .spawn(Node {
228 flex_direction: FlexDirection::Column,
229 align_items: AlignItems::Center,
230 ..default()
231 })
232 .add_children(&[border_node, label_node])
233 .id();
234 commands.entity(root_rounded).add_child(container);
235 }
236
237 let border_label = commands
238 .spawn((
239 Node {
240 margin: UiRect {
241 left: Val::Px(25.0),
242 right: Val::Px(25.0),
243 top: Val::Px(25.0),
244 bottom: Val::Px(0.0),
245 },
246 ..default()
247 },
248 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
249 ))
250 .with_children(|builder| {
251 builder.spawn((
252 Text::new("Borders"),
253 TextFont {
254 font_size: 20.0,
255 ..Default::default()
256 },
257 ));
258 })
259 .id();
260
261 let border_rounded_label = commands
262 .spawn((
263 Node {
264 margin: UiRect {
265 left: Val::Px(25.0),
266 right: Val::Px(25.0),
267 top: Val::Px(25.0),
268 bottom: Val::Px(0.0),
269 },
270 ..default()
271 },
272 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
273 ))
274 .with_children(|builder| {
275 builder.spawn((
276 Text::new("Borders Rounded"),
277 TextFont {
278 font_size: 20.0,
279 ..Default::default()
280 },
281 ));
282 })
283 .id();
284
285 commands
286 .spawn((
287 Node {
288 margin: UiRect::all(Val::Px(25.0)),
289 flex_direction: FlexDirection::Column,
290 align_self: AlignSelf::Stretch,
291 justify_self: JustifySelf::Stretch,
292 flex_wrap: FlexWrap::Wrap,
293 justify_content: JustifyContent::FlexStart,
294 align_items: AlignItems::FlexStart,
295 align_content: AlignContent::FlexStart,
296 ..default()
297 },
298 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
299 ))
300 .add_child(border_label)
301 .add_child(root)
302 .add_child(border_rounded_label)
303 .add_child(root_rounded);
304}
Sourcepub const fn percent(
top_left: f32,
top_right: f32,
bottom_right: f32,
bottom_left: f32,
) -> BorderRadius
pub const fn percent( top_left: f32, top_right: f32, bottom_right: f32, bottom_left: f32, ) -> BorderRadius
Sets the radii to percentage values.
Sourcepub const fn top_left(radius: Val) -> BorderRadius
pub const fn top_left(radius: Val) -> BorderRadius
Sets the radius for the top left corner. Remaining corners will be right-angled.
Sourcepub const fn top_right(radius: Val) -> BorderRadius
pub const fn top_right(radius: Val) -> BorderRadius
Sets the radius for the top right corner. Remaining corners will be right-angled.
Sourcepub const fn bottom_right(radius: Val) -> BorderRadius
pub const fn bottom_right(radius: Val) -> BorderRadius
Sets the radius for the bottom right corner. Remaining corners will be right-angled.
Examples found in repository?
262 pub fn setup(mut commands: Commands) {
263 commands.spawn((Camera2d, StateScoped(super::Scene::BoxShadow)));
264
265 commands
266 .spawn((
267 Node {
268 width: Val::Percent(100.0),
269 height: Val::Percent(100.0),
270 padding: UiRect::all(Val::Px(30.)),
271 column_gap: Val::Px(200.),
272 flex_wrap: FlexWrap::Wrap,
273 ..default()
274 },
275 BackgroundColor(GREEN.into()),
276 StateScoped(super::Scene::BoxShadow),
277 ))
278 .with_children(|commands| {
279 let example_nodes = [
280 (
281 Vec2::splat(100.),
282 Vec2::ZERO,
283 10.,
284 0.,
285 BorderRadius::bottom_right(Val::Px(10.)),
286 ),
287 (Vec2::new(200., 50.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
288 (
289 Vec2::new(100., 50.),
290 Vec2::ZERO,
291 10.,
292 10.,
293 BorderRadius::ZERO,
294 ),
295 (
296 Vec2::splat(100.),
297 Vec2::splat(20.),
298 10.,
299 10.,
300 BorderRadius::bottom_right(Val::Px(10.)),
301 ),
302 (
303 Vec2::splat(100.),
304 Vec2::splat(50.),
305 0.,
306 10.,
307 BorderRadius::ZERO,
308 ),
309 (
310 Vec2::new(50., 100.),
311 Vec2::splat(10.),
312 0.,
313 10.,
314 BorderRadius::MAX,
315 ),
316 ];
317
318 for (size, offset, spread, blur, border_radius) in example_nodes {
319 commands.spawn((
320 Node {
321 width: Val::Px(size.x),
322 height: Val::Px(size.y),
323 border: UiRect::all(Val::Px(2.)),
324 ..default()
325 },
326 BorderColor(WHITE.into()),
327 border_radius,
328 BackgroundColor(BLUE.into()),
329 BoxShadow::new(
330 Color::BLACK.with_alpha(0.9),
331 Val::Percent(offset.x),
332 Val::Percent(offset.y),
333 Val::Percent(spread),
334 Val::Px(blur),
335 ),
336 ));
337 }
338 });
339 }
More examples
30fn setup(mut commands: Commands) {
31 // `from_env` panics on the web
32 #[cfg(not(target_arch = "wasm32"))]
33 let args: Args = argh::from_env();
34 #[cfg(target_arch = "wasm32")]
35 let args = Args::from_args(&[], &[]).unwrap();
36
37 // ui camera
38 commands.spawn((Camera2d, BoxShadowSamples(args.samples)));
39
40 commands
41 .spawn((
42 Node {
43 width: Val::Percent(100.0),
44 height: Val::Percent(100.0),
45 padding: UiRect::all(Val::Px(30.)),
46 column_gap: Val::Px(30.),
47 flex_wrap: FlexWrap::Wrap,
48 ..default()
49 },
50 BackgroundColor(DEEP_SKY_BLUE.into()),
51 ))
52 .with_children(|commands| {
53 let example_nodes = [
54 (
55 Vec2::splat(50.),
56 Vec2::ZERO,
57 10.,
58 0.,
59 BorderRadius::bottom_right(Val::Px(10.)),
60 ),
61 (Vec2::new(50., 25.), Vec2::ZERO, 10., 0., BorderRadius::ZERO),
62 (Vec2::splat(50.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
63 (Vec2::new(100., 25.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
64 (
65 Vec2::splat(50.),
66 Vec2::ZERO,
67 10.,
68 0.,
69 BorderRadius::bottom_right(Val::Px(10.)),
70 ),
71 (Vec2::new(50., 25.), Vec2::ZERO, 0., 10., BorderRadius::ZERO),
72 (
73 Vec2::splat(50.),
74 Vec2::ZERO,
75 0.,
76 10.,
77 BorderRadius::bottom_right(Val::Px(10.)),
78 ),
79 (Vec2::new(100., 25.), Vec2::ZERO, 0., 10., BorderRadius::MAX),
80 (
81 Vec2::splat(50.),
82 Vec2::splat(25.),
83 0.,
84 0.,
85 BorderRadius::ZERO,
86 ),
87 (
88 Vec2::new(50., 25.),
89 Vec2::splat(25.),
90 0.,
91 0.,
92 BorderRadius::ZERO,
93 ),
94 (
95 Vec2::splat(50.),
96 Vec2::splat(10.),
97 0.,
98 0.,
99 BorderRadius::bottom_right(Val::Px(10.)),
100 ),
101 (
102 Vec2::splat(50.),
103 Vec2::splat(25.),
104 0.,
105 10.,
106 BorderRadius::ZERO,
107 ),
108 (
109 Vec2::new(50., 25.),
110 Vec2::splat(25.),
111 0.,
112 10.,
113 BorderRadius::ZERO,
114 ),
115 (
116 Vec2::splat(50.),
117 Vec2::splat(10.),
118 0.,
119 10.,
120 BorderRadius::bottom_right(Val::Px(10.)),
121 ),
122 (
123 Vec2::splat(50.),
124 Vec2::splat(10.),
125 0.,
126 3.,
127 BorderRadius::ZERO,
128 ),
129 (
130 Vec2::new(50., 25.),
131 Vec2::splat(10.),
132 0.,
133 3.,
134 BorderRadius::ZERO,
135 ),
136 (
137 Vec2::splat(50.),
138 Vec2::splat(10.),
139 0.,
140 3.,
141 BorderRadius::bottom_right(Val::Px(10.)),
142 ),
143 (
144 Vec2::splat(50.),
145 Vec2::splat(10.),
146 0.,
147 3.,
148 BorderRadius::all(Val::Px(20.)),
149 ),
150 (
151 Vec2::new(50., 25.),
152 Vec2::splat(10.),
153 0.,
154 3.,
155 BorderRadius::all(Val::Px(20.)),
156 ),
157 (
158 Vec2::new(25., 50.),
159 Vec2::splat(10.),
160 0.,
161 3.,
162 BorderRadius::MAX,
163 ),
164 (
165 Vec2::splat(50.),
166 Vec2::splat(10.),
167 0.,
168 10.,
169 BorderRadius::all(Val::Px(20.)),
170 ),
171 (
172 Vec2::new(50., 25.),
173 Vec2::splat(10.),
174 0.,
175 10.,
176 BorderRadius::all(Val::Px(20.)),
177 ),
178 (
179 Vec2::new(25., 50.),
180 Vec2::splat(10.),
181 0.,
182 10.,
183 BorderRadius::MAX,
184 ),
185 ];
186
187 for (size, offset, spread, blur, border_radius) in example_nodes {
188 commands.spawn(box_shadow_node_bundle(
189 size,
190 offset,
191 spread,
192 blur,
193 border_radius,
194 ));
195 }
196
197 // Demonstrate multiple shadows on one node
198 commands.spawn((
199 Node {
200 width: Val::Px(40.),
201 height: Val::Px(40.),
202 border: UiRect::all(Val::Px(4.)),
203 ..default()
204 },
205 BorderColor(LIGHT_SKY_BLUE.into()),
206 BorderRadius::all(Val::Px(20.)),
207 BackgroundColor(DEEP_SKY_BLUE.into()),
208 BoxShadow(vec![
209 ShadowStyle {
210 color: RED.with_alpha(0.7).into(),
211 x_offset: Val::Px(-20.),
212 y_offset: Val::Px(-5.),
213 spread_radius: Val::Percent(10.),
214 blur_radius: Val::Px(3.),
215 },
216 ShadowStyle {
217 color: BLUE.with_alpha(0.7).into(),
218 x_offset: Val::Px(-5.),
219 y_offset: Val::Px(-20.),
220 spread_radius: Val::Percent(10.),
221 blur_radius: Val::Px(3.),
222 },
223 ShadowStyle {
224 color: YELLOW.with_alpha(0.7).into(),
225 x_offset: Val::Px(20.),
226 y_offset: Val::Px(5.),
227 spread_radius: Val::Percent(10.),
228 blur_radius: Val::Px(3.),
229 },
230 ShadowStyle {
231 color: GREEN.with_alpha(0.7).into(),
232 x_offset: Val::Px(5.),
233 y_offset: Val::Px(20.),
234 spread_radius: Val::Percent(10.),
235 blur_radius: Val::Px(3.),
236 },
237 ]),
238 ));
239 });
240}
Sourcepub const fn bottom_left(radius: Val) -> BorderRadius
pub const fn bottom_left(radius: Val) -> BorderRadius
Sets the radius for the bottom left corner. Remaining corners will be right-angled.
Sourcepub const fn left(radius: Val) -> BorderRadius
pub const fn left(radius: Val) -> BorderRadius
Sets the radii for the top left and bottom left corners. Remaining corners will be right-angled.
Sourcepub const fn right(radius: Val) -> BorderRadius
pub const fn right(radius: Val) -> BorderRadius
Sets the radii for the top right and bottom right corners. Remaining corners will be right-angled.
Sourcepub const fn top(radius: Val) -> BorderRadius
pub const fn top(radius: Val) -> BorderRadius
Sets the radii for the top left and top right corners. Remaining corners will be right-angled.
Sourcepub const fn bottom(radius: Val) -> BorderRadius
pub const fn bottom(radius: Val) -> BorderRadius
Sets the radii for the bottom left and bottom right corners. Remaining corners will be right-angled.
Sourcepub const fn with_top_left(self, radius: Val) -> BorderRadius
pub const fn with_top_left(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its top_left
field set to the given value.
Sourcepub const fn with_top_right(self, radius: Val) -> BorderRadius
pub const fn with_top_right(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its top_right
field set to the given value.
Sourcepub const fn with_bottom_right(self, radius: Val) -> BorderRadius
pub const fn with_bottom_right(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its bottom_right
field set to the given value.
Sourcepub const fn with_bottom_left(self, radius: Val) -> BorderRadius
pub const fn with_bottom_left(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its bottom_left
field set to the given value.
Sourcepub const fn with_left(self, radius: Val) -> BorderRadius
pub const fn with_left(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its top_left
and bottom_left
fields set to the given value.
Examples found in repository?
57pub fn spawn_option_button<T>(
58 parent: &mut ChildSpawnerCommands,
59 option_value: T,
60 option_name: &str,
61 is_selected: bool,
62 is_first: bool,
63 is_last: bool,
64) where
65 T: Clone + Send + Sync + 'static,
66{
67 let (bg_color, fg_color) = if is_selected {
68 (Color::WHITE, Color::BLACK)
69 } else {
70 (Color::BLACK, Color::WHITE)
71 };
72
73 // Add the button node.
74 parent
75 .spawn((
76 Button,
77 Node {
78 border: BUTTON_BORDER.with_left(if is_first { Val::Px(1.0) } else { Val::Px(0.0) }),
79 justify_content: JustifyContent::Center,
80 align_items: AlignItems::Center,
81 padding: BUTTON_PADDING,
82 ..default()
83 },
84 BUTTON_BORDER_COLOR,
85 BorderRadius::ZERO
86 .with_left(if is_first {
87 BUTTON_BORDER_RADIUS_SIZE
88 } else {
89 Val::Px(0.0)
90 })
91 .with_right(if is_last {
92 BUTTON_BORDER_RADIUS_SIZE
93 } else {
94 Val::Px(0.0)
95 }),
96 BackgroundColor(bg_color),
97 ))
98 .insert(RadioButton)
99 .insert(WidgetClickSender(option_value.clone()))
100 .with_children(|parent| {
101 spawn_ui_text(parent, option_name, fg_color)
102 .insert(RadioButtonText)
103 .insert(WidgetClickSender(option_value));
104 });
105}
Sourcepub const fn with_right(self, radius: Val) -> BorderRadius
pub const fn with_right(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its top_right
and bottom_right
fields set to the given value.
Examples found in repository?
57pub fn spawn_option_button<T>(
58 parent: &mut ChildSpawnerCommands,
59 option_value: T,
60 option_name: &str,
61 is_selected: bool,
62 is_first: bool,
63 is_last: bool,
64) where
65 T: Clone + Send + Sync + 'static,
66{
67 let (bg_color, fg_color) = if is_selected {
68 (Color::WHITE, Color::BLACK)
69 } else {
70 (Color::BLACK, Color::WHITE)
71 };
72
73 // Add the button node.
74 parent
75 .spawn((
76 Button,
77 Node {
78 border: BUTTON_BORDER.with_left(if is_first { Val::Px(1.0) } else { Val::Px(0.0) }),
79 justify_content: JustifyContent::Center,
80 align_items: AlignItems::Center,
81 padding: BUTTON_PADDING,
82 ..default()
83 },
84 BUTTON_BORDER_COLOR,
85 BorderRadius::ZERO
86 .with_left(if is_first {
87 BUTTON_BORDER_RADIUS_SIZE
88 } else {
89 Val::Px(0.0)
90 })
91 .with_right(if is_last {
92 BUTTON_BORDER_RADIUS_SIZE
93 } else {
94 Val::Px(0.0)
95 }),
96 BackgroundColor(bg_color),
97 ))
98 .insert(RadioButton)
99 .insert(WidgetClickSender(option_value.clone()))
100 .with_children(|parent| {
101 spawn_ui_text(parent, option_name, fg_color)
102 .insert(RadioButtonText)
103 .insert(WidgetClickSender(option_value));
104 });
105}
Sourcepub const fn with_top(self, radius: Val) -> BorderRadius
pub const fn with_top(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its top_left
and top_right
fields set to the given value.
Sourcepub const fn with_bottom(self, radius: Val) -> BorderRadius
pub const fn with_bottom(self, radius: Val) -> BorderRadius
Returns the BorderRadius
with its bottom_left
and bottom_right
fields set to the given value.
Trait Implementations§
Source§impl Clone for BorderRadius
impl Clone for BorderRadius
Source§fn clone(&self) -> BorderRadius
fn clone(&self) -> BorderRadius
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Component for BorderRadius
impl Component for BorderRadius
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>
],
while immutable components will instead have [Component<Mutability = Immutable>
]. Read moreSource§fn register_required_components(
requiree: ComponentId,
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
inheritance_depth: u16,
recursion_check_stack: &mut Vec<ComponentId>,
)
fn register_required_components( requiree: ComponentId, components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, inheritance_depth: u16, recursion_check_stack: &mut Vec<ComponentId>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn register_component_hooks(hooks: &mut ComponentHooks)
fn register_component_hooks(hooks: &mut ComponentHooks)
Component::on_add
, etc.)ComponentHooks
.Source§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper
. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component
, this is populated by annotating fields containing entities with #[entities]
Read moreSource§impl Debug for BorderRadius
impl Debug for BorderRadius
Source§impl Default for BorderRadius
impl Default for BorderRadius
Source§fn default() -> BorderRadius
fn default() -> BorderRadius
Source§impl<'de> Deserialize<'de> for BorderRadius
impl<'de> Deserialize<'de> for BorderRadius
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BorderRadius, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BorderRadius, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl FromArg for &'static BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for &'static mut BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static mut BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromReflect for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromReflect for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn from_reflect(
reflect: &(dyn PartialReflect + 'static),
) -> Option<BorderRadius>
fn from_reflect( reflect: &(dyn PartialReflect + 'static), ) -> Option<BorderRadius>
Self
from a reflected value.Source§fn take_from_reflect(
reflect: Box<dyn PartialReflect>,
) -> Result<Self, Box<dyn PartialReflect>>
fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>
Self
using,
constructing the value using from_reflect
if that fails. Read moreSource§impl GetOwnership for &BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for &mut BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &mut BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetTypeRegistration for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetTypeRegistration for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
TypeRegistration
for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Source§impl IntoReturn for &BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
&BorderRadius: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
&BorderRadius: 'into_return,
Source§impl IntoReturn for &mut BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &mut BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
&mut BorderRadius: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
&mut BorderRadius: 'into_return,
Source§impl IntoReturn for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
BorderRadius: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
BorderRadius: 'into_return,
Source§impl PartialEq for BorderRadius
impl PartialEq for BorderRadius
Source§impl PartialReflect for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl PartialReflect for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
Source§fn try_apply(
&mut self,
value: &(dyn PartialReflect + 'static),
) -> Result<(), ApplyError>
fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>
Source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Source§fn reflect_owned(self: Box<BorderRadius>) -> ReflectOwned
fn reflect_owned(self: Box<BorderRadius>) -> ReflectOwned
Source§fn try_into_reflect(
self: Box<BorderRadius>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<BorderRadius>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
Source§fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
Source§fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
Source§fn into_partial_reflect(self: Box<BorderRadius>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<BorderRadius>) -> Box<dyn PartialReflect>
Source§fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
Source§fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
Source§fn reflect_partial_eq(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<bool>
fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Source§fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Self
using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
fn apply(&mut self, value: &(dyn PartialReflect + 'static))
Source§fn clone_value(&self) -> Box<dyn PartialReflect>
fn clone_value(&self) -> Box<dyn PartialReflect>
reflect_clone
. To convert reflected values to dynamic ones, use to_dynamic
.Self
into its dynamic representation. Read moreSource§fn to_dynamic(&self) -> Box<dyn PartialReflect>
fn to_dynamic(&self) -> Box<dyn PartialReflect>
Source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Source§impl Reflect for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Reflect for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_any(self: Box<BorderRadius>) -> Box<dyn Any>
fn into_any(self: Box<BorderRadius>) -> Box<dyn Any>
Box<dyn Any>
. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any
. Read moreSource§fn into_reflect(self: Box<BorderRadius>) -> Box<dyn Reflect>
fn into_reflect(self: Box<BorderRadius>) -> Box<dyn Reflect>
Source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Source§impl Serialize for BorderRadius
impl Serialize for BorderRadius
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl Struct for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Struct for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
name
as a &dyn PartialReflect
.Source§fn field_mut(
&mut self,
name: &str,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>
name
as a
&mut dyn PartialReflect
.Source§fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
index
as a
&dyn PartialReflect
.Source§fn field_at_mut(
&mut self,
index: usize,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>
index
as a &mut dyn PartialReflect
.Source§fn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
index
.Source§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn to_dynamic_struct(&self) -> DynamicStruct
Source§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
to_dynamic_struct
insteadDynamicStruct
.Source§fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
None
if TypeInfo
is not available.Source§impl TypePath for BorderRadius
impl TypePath for BorderRadius
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Source§impl Typed for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Typed for BorderRadiuswhere
BorderRadius: Any + Send + Sync,
Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Copy for BorderRadius
impl StructuralPartialEq for BorderRadius
Auto Trait Implementations§
impl Freeze for BorderRadius
impl RefUnwindSafe for BorderRadius
impl Send for BorderRadius
impl Sync for BorderRadius
impl Unpin for BorderRadius
impl UnwindSafe for BorderRadius
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )
Source§fn register_required_components(
components: &mut ComponentsRegistrator<'_>,
required_components: &mut RequiredComponents,
)
fn register_required_components( components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, )
Bundle
.Source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
Source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path
.Source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
Source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident
.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name
.Source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
Source§impl<T> DynamicTyped for Twhere
T: Typed,
impl<T> DynamicTyped for Twhere
T: Typed,
Source§fn reflect_type_info(&self) -> &'static TypeInfo
fn reflect_type_info(&self) -> &'static TypeInfo
Typed::type_info
.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.
Source§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
Source§impl<T> GetPath for T
impl<T> GetPath for T
Source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
path
. Read moreSource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
path
. Read moreSource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moreSource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
path
. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.