pub struct Overflow {
pub x: OverflowAxis,
pub y: OverflowAxis,
}
Expand description
Whether to show or hide overflowing items
Fields§
§x: OverflowAxis
Whether to show or clip overflowing items on the x axis
y: OverflowAxis
Whether to show or clip overflowing items on the y axis
Implementations§
Source§impl Overflow
impl Overflow
pub const DEFAULT: Overflow
Sourcepub const fn visible() -> Overflow
pub const fn visible() -> Overflow
Show overflowing items on both axes
Examples found in repository?
examples/ui/overflow_debug.rs (line 265)
246fn toggle_overflow(
247 mut containers: Query<&mut Node, With<Container>>,
248 instructions: Single<Entity, With<Instructions>>,
249 mut writer: TextUiWriter,
250) {
251 for mut node in &mut containers {
252 node.overflow = match node.overflow {
253 Overflow {
254 x: OverflowAxis::Visible,
255 y: OverflowAxis::Visible,
256 } => Overflow::clip_y(),
257 Overflow {
258 x: OverflowAxis::Visible,
259 y: OverflowAxis::Clip,
260 } => Overflow::clip_x(),
261 Overflow {
262 x: OverflowAxis::Clip,
263 y: OverflowAxis::Visible,
264 } => Overflow::clip(),
265 _ => Overflow::visible(),
266 };
267
268 let entity = *instructions;
269 *writer.text(entity, 1) = format!("{:?}", node.overflow);
270 }
271}
More examples
examples/testbed/ui.rs (line 405)
387 pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
388 commands.spawn((Camera2d, StateScoped(super::Scene::Overflow)));
389 let image = asset_server.load("branding/icon.png");
390
391 commands
392 .spawn((
393 Node {
394 width: Val::Percent(100.),
395 height: Val::Percent(100.),
396 align_items: AlignItems::Center,
397 justify_content: JustifyContent::SpaceAround,
398 ..Default::default()
399 },
400 BackgroundColor(BLUE.into()),
401 StateScoped(super::Scene::Overflow),
402 ))
403 .with_children(|parent| {
404 for overflow in [
405 Overflow::visible(),
406 Overflow::clip_x(),
407 Overflow::clip_y(),
408 Overflow::clip(),
409 ] {
410 parent
411 .spawn((
412 Node {
413 width: Val::Px(100.),
414 height: Val::Px(100.),
415 padding: UiRect {
416 left: Val::Px(25.),
417 top: Val::Px(25.),
418 ..Default::default()
419 },
420 border: UiRect::all(Val::Px(5.)),
421 overflow,
422 ..default()
423 },
424 BorderColor(RED.into()),
425 BackgroundColor(Color::WHITE),
426 ))
427 .with_children(|parent| {
428 parent.spawn((
429 ImageNode::new(image.clone()),
430 Node {
431 min_width: Val::Px(100.),
432 min_height: Val::Px(100.),
433 ..default()
434 },
435 Interaction::default(),
436 Outline {
437 width: Val::Px(2.),
438 offset: Val::Px(2.),
439 color: Color::NONE,
440 },
441 ));
442 });
443 }
444 });
445 }
examples/ui/overflow.rs (line 35)
15fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
16 commands.spawn(Camera2d);
17
18 let text_style = TextFont::default();
19
20 let image = asset_server.load("branding/icon.png");
21
22 commands
23 .spawn((
24 Node {
25 width: Val::Percent(100.),
26 height: Val::Percent(100.),
27 align_items: AlignItems::Center,
28 justify_content: JustifyContent::Center,
29 ..Default::default()
30 },
31 BackgroundColor(ANTIQUE_WHITE.into()),
32 ))
33 .with_children(|parent| {
34 for overflow in [
35 Overflow::visible(),
36 Overflow::clip_x(),
37 Overflow::clip_y(),
38 Overflow::clip(),
39 ] {
40 parent
41 .spawn(Node {
42 flex_direction: FlexDirection::Column,
43 align_items: AlignItems::Center,
44 margin: UiRect::horizontal(Val::Px(25.)),
45 ..Default::default()
46 })
47 .with_children(|parent| {
48 let label = format!("{overflow:#?}");
49 parent
50 .spawn((
51 Node {
52 padding: UiRect::all(Val::Px(10.)),
53 margin: UiRect::bottom(Val::Px(25.)),
54 ..Default::default()
55 },
56 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
57 ))
58 .with_children(|parent| {
59 parent.spawn((Text::new(label), text_style.clone()));
60 });
61 parent
62 .spawn((
63 Node {
64 width: Val::Px(100.),
65 height: Val::Px(100.),
66 padding: UiRect {
67 left: Val::Px(25.),
68 top: Val::Px(25.),
69 ..Default::default()
70 },
71 border: UiRect::all(Val::Px(5.)),
72 overflow,
73 ..default()
74 },
75 BorderColor(Color::BLACK),
76 BackgroundColor(GRAY.into()),
77 ))
78 .with_children(|parent| {
79 parent.spawn((
80 ImageNode::new(image.clone()),
81 Node {
82 min_width: Val::Px(100.),
83 min_height: Val::Px(100.),
84 ..default()
85 },
86 Interaction::default(),
87 Outline {
88 width: Val::Px(2.),
89 offset: Val::Px(2.),
90 color: Color::NONE,
91 },
92 ));
93 });
94 });
95 }
96 });
97}
Sourcepub const fn clip() -> Overflow
pub const fn clip() -> Overflow
Clip overflowing items on both axes
Examples found in repository?
examples/ui/overflow_debug.rs (line 101)
77fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
78 // Camera
79
80 commands.spawn(Camera2d);
81
82 // Instructions
83
84 let text_font = TextFont::default();
85
86 commands
87 .spawn((
88 Text::new(
89 "Next Overflow Setting (O)\nNext Container Size (S)\nToggle Animation (space)\n\n",
90 ),
91 text_font.clone(),
92 Node {
93 position_type: PositionType::Absolute,
94 top: Val::Px(12.0),
95 left: Val::Px(12.0),
96 ..default()
97 },
98 Instructions,
99 ))
100 .with_child((
101 TextSpan::new(format!("{:?}", Overflow::clip())),
102 text_font.clone(),
103 ));
104
105 // Overflow Debug
106
107 commands
108 .spawn(Node {
109 width: Val::Percent(100.),
110 height: Val::Percent(100.),
111 justify_content: JustifyContent::Center,
112 align_items: AlignItems::Center,
113 ..default()
114 })
115 .with_children(|parent| {
116 parent
117 .spawn(Node {
118 display: Display::Grid,
119 grid_template_columns: RepeatedGridTrack::px(3, CONTAINER_SIZE),
120 grid_template_rows: RepeatedGridTrack::px(2, CONTAINER_SIZE),
121 row_gap: Val::Px(80.),
122 column_gap: Val::Px(80.),
123 ..default()
124 })
125 .with_children(|parent| {
126 spawn_image(parent, &asset_server, Move);
127 spawn_image(parent, &asset_server, Scale);
128 spawn_image(parent, &asset_server, Rotate);
129
130 spawn_text(parent, &asset_server, Move);
131 spawn_text(parent, &asset_server, Scale);
132 spawn_text(parent, &asset_server, Rotate);
133 });
134 });
135}
136
137fn spawn_image(
138 parent: &mut ChildSpawnerCommands,
139 asset_server: &Res<AssetServer>,
140 update_transform: impl UpdateTransform + Component,
141) {
142 spawn_container(parent, update_transform, |parent| {
143 parent.spawn((
144 ImageNode::new(asset_server.load("branding/bevy_logo_dark_big.png")),
145 Node {
146 height: Val::Px(100.),
147 position_type: PositionType::Absolute,
148 top: Val::Px(-50.),
149 left: Val::Px(-200.),
150 ..default()
151 },
152 ));
153 });
154}
155
156fn spawn_text(
157 parent: &mut ChildSpawnerCommands,
158 asset_server: &Res<AssetServer>,
159 update_transform: impl UpdateTransform + Component,
160) {
161 spawn_container(parent, update_transform, |parent| {
162 parent.spawn((
163 Text::new("Bevy"),
164 TextFont {
165 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
166 font_size: 100.0,
167 ..default()
168 },
169 ));
170 });
171}
172
173fn spawn_container(
174 parent: &mut ChildSpawnerCommands,
175 update_transform: impl UpdateTransform + Component,
176 spawn_children: impl FnOnce(&mut ChildSpawnerCommands),
177) {
178 let mut transform = Transform::default();
179
180 update_transform.update(0.0, &mut transform);
181
182 parent
183 .spawn((
184 Node {
185 width: Val::Percent(100.),
186 height: Val::Percent(100.),
187 align_items: AlignItems::Center,
188 justify_content: JustifyContent::Center,
189 overflow: Overflow::clip(),
190 ..default()
191 },
192 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
193 Container(0),
194 ))
195 .with_children(|parent| {
196 parent
197 .spawn((
198 Node {
199 align_items: AlignItems::Center,
200 justify_content: JustifyContent::Center,
201 top: Val::Px(transform.translation.x),
202 left: Val::Px(transform.translation.y),
203 ..default()
204 },
205 transform,
206 update_transform,
207 ))
208 .with_children(spawn_children);
209 });
210}
211
212fn update_animation(
213 mut animation: ResMut<AnimationState>,
214 time: Res<Time>,
215 keys: Res<ButtonInput<KeyCode>>,
216) {
217 let delta = time.elapsed_secs();
218
219 if keys.just_pressed(KeyCode::Space) {
220 animation.playing = !animation.playing;
221
222 if !animation.playing {
223 animation.paused_at = delta;
224 } else {
225 animation.paused_total += delta - animation.paused_at;
226 }
227 }
228
229 if animation.playing {
230 animation.t = (delta - animation.paused_total) % LOOP_LENGTH / LOOP_LENGTH;
231 }
232}
233
234fn update_transform<T: UpdateTransform + Component>(
235 animation: Res<AnimationState>,
236 mut containers: Query<(&mut Transform, &mut Node, &ComputedNode, &T)>,
237) {
238 for (mut transform, mut node, computed_node, update_transform) in &mut containers {
239 update_transform.update(animation.t, &mut transform);
240
241 node.left = Val::Px(transform.translation.x * computed_node.inverse_scale_factor());
242 node.top = Val::Px(transform.translation.y * computed_node.inverse_scale_factor());
243 }
244}
245
246fn toggle_overflow(
247 mut containers: Query<&mut Node, With<Container>>,
248 instructions: Single<Entity, With<Instructions>>,
249 mut writer: TextUiWriter,
250) {
251 for mut node in &mut containers {
252 node.overflow = match node.overflow {
253 Overflow {
254 x: OverflowAxis::Visible,
255 y: OverflowAxis::Visible,
256 } => Overflow::clip_y(),
257 Overflow {
258 x: OverflowAxis::Visible,
259 y: OverflowAxis::Clip,
260 } => Overflow::clip_x(),
261 Overflow {
262 x: OverflowAxis::Clip,
263 y: OverflowAxis::Visible,
264 } => Overflow::clip(),
265 _ => Overflow::visible(),
266 };
267
268 let entity = *instructions;
269 *writer.text(entity, 1) = format!("{:?}", node.overflow);
270 }
271}
More examples
examples/testbed/ui.rs (line 408)
387 pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
388 commands.spawn((Camera2d, StateScoped(super::Scene::Overflow)));
389 let image = asset_server.load("branding/icon.png");
390
391 commands
392 .spawn((
393 Node {
394 width: Val::Percent(100.),
395 height: Val::Percent(100.),
396 align_items: AlignItems::Center,
397 justify_content: JustifyContent::SpaceAround,
398 ..Default::default()
399 },
400 BackgroundColor(BLUE.into()),
401 StateScoped(super::Scene::Overflow),
402 ))
403 .with_children(|parent| {
404 for overflow in [
405 Overflow::visible(),
406 Overflow::clip_x(),
407 Overflow::clip_y(),
408 Overflow::clip(),
409 ] {
410 parent
411 .spawn((
412 Node {
413 width: Val::Px(100.),
414 height: Val::Px(100.),
415 padding: UiRect {
416 left: Val::Px(25.),
417 top: Val::Px(25.),
418 ..Default::default()
419 },
420 border: UiRect::all(Val::Px(5.)),
421 overflow,
422 ..default()
423 },
424 BorderColor(RED.into()),
425 BackgroundColor(Color::WHITE),
426 ))
427 .with_children(|parent| {
428 parent.spawn((
429 ImageNode::new(image.clone()),
430 Node {
431 min_width: Val::Px(100.),
432 min_height: Val::Px(100.),
433 ..default()
434 },
435 Interaction::default(),
436 Outline {
437 width: Val::Px(2.),
438 offset: Val::Px(2.),
439 color: Color::NONE,
440 },
441 ));
442 });
443 }
444 });
445 }
examples/ui/overflow.rs (line 38)
15fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
16 commands.spawn(Camera2d);
17
18 let text_style = TextFont::default();
19
20 let image = asset_server.load("branding/icon.png");
21
22 commands
23 .spawn((
24 Node {
25 width: Val::Percent(100.),
26 height: Val::Percent(100.),
27 align_items: AlignItems::Center,
28 justify_content: JustifyContent::Center,
29 ..Default::default()
30 },
31 BackgroundColor(ANTIQUE_WHITE.into()),
32 ))
33 .with_children(|parent| {
34 for overflow in [
35 Overflow::visible(),
36 Overflow::clip_x(),
37 Overflow::clip_y(),
38 Overflow::clip(),
39 ] {
40 parent
41 .spawn(Node {
42 flex_direction: FlexDirection::Column,
43 align_items: AlignItems::Center,
44 margin: UiRect::horizontal(Val::Px(25.)),
45 ..Default::default()
46 })
47 .with_children(|parent| {
48 let label = format!("{overflow:#?}");
49 parent
50 .spawn((
51 Node {
52 padding: UiRect::all(Val::Px(10.)),
53 margin: UiRect::bottom(Val::Px(25.)),
54 ..Default::default()
55 },
56 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
57 ))
58 .with_children(|parent| {
59 parent.spawn((Text::new(label), text_style.clone()));
60 });
61 parent
62 .spawn((
63 Node {
64 width: Val::Px(100.),
65 height: Val::Px(100.),
66 padding: UiRect {
67 left: Val::Px(25.),
68 top: Val::Px(25.),
69 ..Default::default()
70 },
71 border: UiRect::all(Val::Px(5.)),
72 overflow,
73 ..default()
74 },
75 BorderColor(Color::BLACK),
76 BackgroundColor(GRAY.into()),
77 ))
78 .with_children(|parent| {
79 parent.spawn((
80 ImageNode::new(image.clone()),
81 Node {
82 min_width: Val::Px(100.),
83 min_height: Val::Px(100.),
84 ..default()
85 },
86 Interaction::default(),
87 Outline {
88 width: Val::Px(2.),
89 offset: Val::Px(2.),
90 color: Color::NONE,
91 },
92 ));
93 });
94 });
95 }
96 });
97}
examples/ui/overflow_clip_margin.rs (line 65)
14fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
15 commands.spawn(Camera2d);
16
17 let image = asset_server.load("branding/icon.png");
18
19 commands
20 .spawn((
21 Node {
22 width: Val::Percent(100.),
23 height: Val::Percent(100.),
24 align_items: AlignItems::Center,
25 justify_content: JustifyContent::Center,
26 row_gap: Val::Px(40.),
27 flex_direction: FlexDirection::Column,
28 ..default()
29 },
30 BackgroundColor(ANTIQUE_WHITE.into()),
31 ))
32 .with_children(|parent| {
33 for overflow_clip_margin in [
34 OverflowClipMargin::border_box().with_margin(25.),
35 OverflowClipMargin::border_box(),
36 OverflowClipMargin::padding_box(),
37 OverflowClipMargin::content_box(),
38 ] {
39 parent
40 .spawn(Node {
41 flex_direction: FlexDirection::Row,
42 column_gap: Val::Px(20.),
43 ..default()
44 })
45 .with_children(|parent| {
46 parent
47 .spawn((
48 Node {
49 padding: UiRect::all(Val::Px(10.)),
50 margin: UiRect::bottom(Val::Px(25.)),
51 ..default()
52 },
53 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
54 ))
55 .with_child(Text(format!("{overflow_clip_margin:#?}")));
56
57 parent
58 .spawn((
59 Node {
60 margin: UiRect::top(Val::Px(10.)),
61 width: Val::Px(100.),
62 height: Val::Px(100.),
63 padding: UiRect::all(Val::Px(20.)),
64 border: UiRect::all(Val::Px(5.)),
65 overflow: Overflow::clip(),
66 overflow_clip_margin,
67 ..default()
68 },
69 BackgroundColor(GRAY.into()),
70 BorderColor(Color::BLACK),
71 ))
72 .with_children(|parent| {
73 parent
74 .spawn((
75 Node {
76 min_width: Val::Px(50.),
77 min_height: Val::Px(50.),
78 ..default()
79 },
80 BackgroundColor(LIGHT_CYAN.into()),
81 ))
82 .with_child((
83 ImageNode::new(image.clone()),
84 Node {
85 min_width: Val::Px(100.),
86 min_height: Val::Px(100.),
87 ..default()
88 },
89 ));
90 });
91 });
92 }
93 });
94}
Sourcepub const fn clip_x() -> Overflow
pub const fn clip_x() -> Overflow
Clip overflowing items on the x axis
Examples found in repository?
examples/ui/overflow_debug.rs (line 260)
246fn toggle_overflow(
247 mut containers: Query<&mut Node, With<Container>>,
248 instructions: Single<Entity, With<Instructions>>,
249 mut writer: TextUiWriter,
250) {
251 for mut node in &mut containers {
252 node.overflow = match node.overflow {
253 Overflow {
254 x: OverflowAxis::Visible,
255 y: OverflowAxis::Visible,
256 } => Overflow::clip_y(),
257 Overflow {
258 x: OverflowAxis::Visible,
259 y: OverflowAxis::Clip,
260 } => Overflow::clip_x(),
261 Overflow {
262 x: OverflowAxis::Clip,
263 y: OverflowAxis::Visible,
264 } => Overflow::clip(),
265 _ => Overflow::visible(),
266 };
267
268 let entity = *instructions;
269 *writer.text(entity, 1) = format!("{:?}", node.overflow);
270 }
271}
More examples
examples/testbed/ui.rs (line 354)
345 pub fn setup(mut commands: Commands) {
346 commands.spawn((Camera2d, StateScoped(super::Scene::TextWrap)));
347
348 let root = commands
349 .spawn((
350 Node {
351 flex_direction: FlexDirection::Column,
352 width: Val::Px(200.),
353 height: Val::Percent(100.),
354 overflow: Overflow::clip_x(),
355 ..default()
356 },
357 BackgroundColor(Color::BLACK),
358 StateScoped(super::Scene::TextWrap),
359 ))
360 .id();
361
362 for linebreak in [
363 LineBreak::AnyCharacter,
364 LineBreak::WordBoundary,
365 LineBreak::WordOrCharacter,
366 LineBreak::NoWrap,
367 ] {
368 let messages = [
369 "Lorem ipsum dolor sit amet, consectetur adipiscing elit.".to_string(),
370 "pneumonoultramicroscopicsilicovolcanoconiosis".to_string(),
371 ];
372
373 for (j, message) in messages.into_iter().enumerate() {
374 commands.entity(root).with_child((
375 Text(message.clone()),
376 TextLayout::new(JustifyText::Left, linebreak),
377 BackgroundColor(Color::srgb(0.8 - j as f32 * 0.3, 0., 0.)),
378 ));
379 }
380 }
381 }
382}
383
384mod overflow {
385 use bevy::{color::palettes::css::*, prelude::*};
386
387 pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
388 commands.spawn((Camera2d, StateScoped(super::Scene::Overflow)));
389 let image = asset_server.load("branding/icon.png");
390
391 commands
392 .spawn((
393 Node {
394 width: Val::Percent(100.),
395 height: Val::Percent(100.),
396 align_items: AlignItems::Center,
397 justify_content: JustifyContent::SpaceAround,
398 ..Default::default()
399 },
400 BackgroundColor(BLUE.into()),
401 StateScoped(super::Scene::Overflow),
402 ))
403 .with_children(|parent| {
404 for overflow in [
405 Overflow::visible(),
406 Overflow::clip_x(),
407 Overflow::clip_y(),
408 Overflow::clip(),
409 ] {
410 parent
411 .spawn((
412 Node {
413 width: Val::Px(100.),
414 height: Val::Px(100.),
415 padding: UiRect {
416 left: Val::Px(25.),
417 top: Val::Px(25.),
418 ..Default::default()
419 },
420 border: UiRect::all(Val::Px(5.)),
421 overflow,
422 ..default()
423 },
424 BorderColor(RED.into()),
425 BackgroundColor(Color::WHITE),
426 ))
427 .with_children(|parent| {
428 parent.spawn((
429 ImageNode::new(image.clone()),
430 Node {
431 min_width: Val::Px(100.),
432 min_height: Val::Px(100.),
433 ..default()
434 },
435 Interaction::default(),
436 Outline {
437 width: Val::Px(2.),
438 offset: Val::Px(2.),
439 color: Color::NONE,
440 },
441 ));
442 });
443 }
444 });
445 }
examples/ui/text_wrap_debug.rs (line 101)
45fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
46 commands.spawn(Camera2d);
47
48 let text_font = TextFont {
49 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
50 font_size: 12.0,
51 ..default()
52 };
53
54 let root = commands
55 .spawn((
56 Node {
57 width: Val::Percent(100.),
58 height: Val::Percent(100.),
59 flex_direction: FlexDirection::Column,
60 ..default()
61 },
62 BackgroundColor(Color::BLACK),
63 ))
64 .id();
65
66 for linebreak in [
67 LineBreak::AnyCharacter,
68 LineBreak::WordBoundary,
69 LineBreak::WordOrCharacter,
70 LineBreak::NoWrap,
71 ] {
72 let row_id = commands
73 .spawn(Node {
74 flex_direction: FlexDirection::Row,
75 justify_content: JustifyContent::SpaceAround,
76 align_items: AlignItems::Center,
77 width: Val::Percent(100.),
78 height: Val::Percent(50.),
79 ..default()
80 })
81 .id();
82
83 let justifications = vec![
84 JustifyContent::Center,
85 JustifyContent::FlexStart,
86 JustifyContent::FlexEnd,
87 JustifyContent::SpaceAround,
88 JustifyContent::SpaceBetween,
89 JustifyContent::SpaceEvenly,
90 ];
91
92 for (i, justification) in justifications.into_iter().enumerate() {
93 let c = 0.3 + i as f32 * 0.1;
94 let column_id = commands
95 .spawn((
96 Node {
97 justify_content: justification,
98 flex_direction: FlexDirection::Column,
99 width: Val::Percent(16.),
100 height: Val::Percent(95.),
101 overflow: Overflow::clip_x(),
102 ..default()
103 },
104 BackgroundColor(Color::srgb(0.5, c, 1.0 - c)),
105 ))
106 .id();
107
108 let messages = [
109 format!("JustifyContent::{justification:?}"),
110 format!("LineBreakOn::{linebreak:?}"),
111 "Line 1\nLine 2".to_string(),
112 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas auctor, nunc ac faucibus fringilla.".to_string(),
113 "pneumonoultramicroscopicsilicovolcanoconiosis".to_string()
114 ];
115
116 for (j, message) in messages.into_iter().enumerate() {
117 commands.entity(column_id).with_child((
118 Text(message.clone()),
119 text_font.clone(),
120 TextLayout::new(JustifyText::Left, linebreak),
121 BackgroundColor(Color::srgb(0.8 - j as f32 * 0.2, 0., 0.)),
122 ));
123 }
124 commands.entity(row_id).add_child(column_id);
125 }
126 commands.entity(root).add_child(row_id);
127 }
128}
examples/ui/overflow.rs (line 36)
15fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
16 commands.spawn(Camera2d);
17
18 let text_style = TextFont::default();
19
20 let image = asset_server.load("branding/icon.png");
21
22 commands
23 .spawn((
24 Node {
25 width: Val::Percent(100.),
26 height: Val::Percent(100.),
27 align_items: AlignItems::Center,
28 justify_content: JustifyContent::Center,
29 ..Default::default()
30 },
31 BackgroundColor(ANTIQUE_WHITE.into()),
32 ))
33 .with_children(|parent| {
34 for overflow in [
35 Overflow::visible(),
36 Overflow::clip_x(),
37 Overflow::clip_y(),
38 Overflow::clip(),
39 ] {
40 parent
41 .spawn(Node {
42 flex_direction: FlexDirection::Column,
43 align_items: AlignItems::Center,
44 margin: UiRect::horizontal(Val::Px(25.)),
45 ..Default::default()
46 })
47 .with_children(|parent| {
48 let label = format!("{overflow:#?}");
49 parent
50 .spawn((
51 Node {
52 padding: UiRect::all(Val::Px(10.)),
53 margin: UiRect::bottom(Val::Px(25.)),
54 ..Default::default()
55 },
56 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
57 ))
58 .with_children(|parent| {
59 parent.spawn((Text::new(label), text_style.clone()));
60 });
61 parent
62 .spawn((
63 Node {
64 width: Val::Px(100.),
65 height: Val::Px(100.),
66 padding: UiRect {
67 left: Val::Px(25.),
68 top: Val::Px(25.),
69 ..Default::default()
70 },
71 border: UiRect::all(Val::Px(5.)),
72 overflow,
73 ..default()
74 },
75 BorderColor(Color::BLACK),
76 BackgroundColor(GRAY.into()),
77 ))
78 .with_children(|parent| {
79 parent.spawn((
80 ImageNode::new(image.clone()),
81 Node {
82 min_width: Val::Px(100.),
83 min_height: Val::Px(100.),
84 ..default()
85 },
86 Interaction::default(),
87 Outline {
88 width: Val::Px(2.),
89 offset: Val::Px(2.),
90 color: Color::NONE,
91 },
92 ));
93 });
94 });
95 }
96 });
97}
Sourcepub const fn clip_y() -> Overflow
pub const fn clip_y() -> Overflow
Clip overflowing items on the y axis
Examples found in repository?
examples/ui/overflow_debug.rs (line 256)
246fn toggle_overflow(
247 mut containers: Query<&mut Node, With<Container>>,
248 instructions: Single<Entity, With<Instructions>>,
249 mut writer: TextUiWriter,
250) {
251 for mut node in &mut containers {
252 node.overflow = match node.overflow {
253 Overflow {
254 x: OverflowAxis::Visible,
255 y: OverflowAxis::Visible,
256 } => Overflow::clip_y(),
257 Overflow {
258 x: OverflowAxis::Visible,
259 y: OverflowAxis::Clip,
260 } => Overflow::clip_x(),
261 Overflow {
262 x: OverflowAxis::Clip,
263 y: OverflowAxis::Visible,
264 } => Overflow::clip(),
265 _ => Overflow::visible(),
266 };
267
268 let entity = *instructions;
269 *writer.text(entity, 1) = format!("{:?}", node.overflow);
270 }
271}
More examples
examples/testbed/ui.rs (line 407)
387 pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
388 commands.spawn((Camera2d, StateScoped(super::Scene::Overflow)));
389 let image = asset_server.load("branding/icon.png");
390
391 commands
392 .spawn((
393 Node {
394 width: Val::Percent(100.),
395 height: Val::Percent(100.),
396 align_items: AlignItems::Center,
397 justify_content: JustifyContent::SpaceAround,
398 ..Default::default()
399 },
400 BackgroundColor(BLUE.into()),
401 StateScoped(super::Scene::Overflow),
402 ))
403 .with_children(|parent| {
404 for overflow in [
405 Overflow::visible(),
406 Overflow::clip_x(),
407 Overflow::clip_y(),
408 Overflow::clip(),
409 ] {
410 parent
411 .spawn((
412 Node {
413 width: Val::Px(100.),
414 height: Val::Px(100.),
415 padding: UiRect {
416 left: Val::Px(25.),
417 top: Val::Px(25.),
418 ..Default::default()
419 },
420 border: UiRect::all(Val::Px(5.)),
421 overflow,
422 ..default()
423 },
424 BorderColor(RED.into()),
425 BackgroundColor(Color::WHITE),
426 ))
427 .with_children(|parent| {
428 parent.spawn((
429 ImageNode::new(image.clone()),
430 Node {
431 min_width: Val::Px(100.),
432 min_height: Val::Px(100.),
433 ..default()
434 },
435 Interaction::default(),
436 Outline {
437 width: Val::Px(2.),
438 offset: Val::Px(2.),
439 color: Color::NONE,
440 },
441 ));
442 });
443 }
444 });
445 }
examples/ui/overflow.rs (line 37)
15fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
16 commands.spawn(Camera2d);
17
18 let text_style = TextFont::default();
19
20 let image = asset_server.load("branding/icon.png");
21
22 commands
23 .spawn((
24 Node {
25 width: Val::Percent(100.),
26 height: Val::Percent(100.),
27 align_items: AlignItems::Center,
28 justify_content: JustifyContent::Center,
29 ..Default::default()
30 },
31 BackgroundColor(ANTIQUE_WHITE.into()),
32 ))
33 .with_children(|parent| {
34 for overflow in [
35 Overflow::visible(),
36 Overflow::clip_x(),
37 Overflow::clip_y(),
38 Overflow::clip(),
39 ] {
40 parent
41 .spawn(Node {
42 flex_direction: FlexDirection::Column,
43 align_items: AlignItems::Center,
44 margin: UiRect::horizontal(Val::Px(25.)),
45 ..Default::default()
46 })
47 .with_children(|parent| {
48 let label = format!("{overflow:#?}");
49 parent
50 .spawn((
51 Node {
52 padding: UiRect::all(Val::Px(10.)),
53 margin: UiRect::bottom(Val::Px(25.)),
54 ..Default::default()
55 },
56 BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
57 ))
58 .with_children(|parent| {
59 parent.spawn((Text::new(label), text_style.clone()));
60 });
61 parent
62 .spawn((
63 Node {
64 width: Val::Px(100.),
65 height: Val::Px(100.),
66 padding: UiRect {
67 left: Val::Px(25.),
68 top: Val::Px(25.),
69 ..Default::default()
70 },
71 border: UiRect::all(Val::Px(5.)),
72 overflow,
73 ..default()
74 },
75 BorderColor(Color::BLACK),
76 BackgroundColor(GRAY.into()),
77 ))
78 .with_children(|parent| {
79 parent.spawn((
80 ImageNode::new(image.clone()),
81 Node {
82 min_width: Val::Px(100.),
83 min_height: Val::Px(100.),
84 ..default()
85 },
86 Interaction::default(),
87 Outline {
88 width: Val::Px(2.),
89 offset: Val::Px(2.),
90 color: Color::NONE,
91 },
92 ));
93 });
94 });
95 }
96 });
97}
Hide overflowing items on both axes by influencing layout and then clipping
Hide overflowing items on the x axis by influencing layout and then clipping
Hide overflowing items on the y axis by influencing layout and then clipping
Sourcepub const fn is_visible(&self) -> bool
pub const fn is_visible(&self) -> bool
Overflow is visible on both axes
Sourcepub const fn scroll() -> Overflow
pub const fn scroll() -> Overflow
Examples found in repository?
examples/ui/scroll.rs (line 208)
25fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
26 // Camera
27 commands.spawn((Camera2d, IsDefaultUiCamera));
28
29 // root node
30 commands
31 .spawn(Node {
32 width: Val::Percent(100.0),
33 height: Val::Percent(100.0),
34 justify_content: JustifyContent::SpaceBetween,
35 flex_direction: FlexDirection::Column,
36 ..default()
37 })
38 .insert(Pickable::IGNORE)
39 .with_children(|parent| {
40 // horizontal scroll example
41 parent
42 .spawn(Node {
43 width: Val::Percent(100.),
44 flex_direction: FlexDirection::Column,
45 ..default()
46 })
47 .with_children(|parent| {
48 // header
49 parent.spawn((
50 Text::new("Horizontally Scrolling list (Ctrl + MouseWheel)"),
51 TextFont {
52 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
53 font_size: FONT_SIZE,
54 ..default()
55 },
56 Label,
57 ));
58
59 // horizontal scroll container
60 parent
61 .spawn((
62 Node {
63 width: Val::Percent(80.),
64 margin: UiRect::all(Val::Px(10.)),
65 flex_direction: FlexDirection::Row,
66 overflow: Overflow::scroll_x(), // n.b.
67 ..default()
68 },
69 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
70 ))
71 .with_children(|parent| {
72 for i in 0..100 {
73 parent.spawn((Text(format!("Item {i}")),
74 TextFont {
75 font: asset_server
76 .load("fonts/FiraSans-Bold.ttf"),
77 ..default()
78 },
79 Label,
80 AccessibilityNode(Accessible::new(Role::ListItem)),
81 ))
82 .insert(Node {
83 min_width: Val::Px(200.),
84 align_content: AlignContent::Center,
85 ..default()
86 })
87 .insert(Pickable {
88 should_block_lower: false,
89 ..default()
90 })
91 .observe(|
92 trigger: Trigger<Pointer<Pressed>>,
93 mut commands: Commands
94 | {
95 if trigger.event().button == PointerButton::Primary {
96 commands.entity(trigger.target()).despawn();
97 }
98 });
99 }
100 });
101 });
102
103 // container for all other examples
104 parent
105 .spawn(Node {
106 width: Val::Percent(100.),
107 height: Val::Percent(100.),
108 flex_direction: FlexDirection::Row,
109 justify_content: JustifyContent::SpaceBetween,
110 ..default()
111 })
112 .with_children(|parent| {
113 // vertical scroll example
114 parent
115 .spawn(Node {
116 flex_direction: FlexDirection::Column,
117 justify_content: JustifyContent::Center,
118 align_items: AlignItems::Center,
119 width: Val::Px(200.),
120 ..default()
121 })
122 .with_children(|parent| {
123 // Title
124 parent.spawn((
125 Text::new("Vertically Scrolling List"),
126 TextFont {
127 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
128 font_size: FONT_SIZE,
129 ..default()
130 },
131 Label,
132 ));
133 // Scrolling list
134 parent
135 .spawn((
136 Node {
137 flex_direction: FlexDirection::Column,
138 align_self: AlignSelf::Stretch,
139 height: Val::Percent(50.),
140 overflow: Overflow::scroll_y(), // n.b.
141 ..default()
142 },
143 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
144 ))
145 .with_children(|parent| {
146 // List items
147 for i in 0..25 {
148 parent
149 .spawn(Node {
150 min_height: Val::Px(LINE_HEIGHT),
151 max_height: Val::Px(LINE_HEIGHT),
152 ..default()
153 })
154 .insert(Pickable {
155 should_block_lower: false,
156 ..default()
157 })
158 .with_children(|parent| {
159 parent
160 .spawn((
161 Text(format!("Item {i}")),
162 TextFont {
163 font: asset_server
164 .load("fonts/FiraSans-Bold.ttf"),
165 ..default()
166 },
167 Label,
168 AccessibilityNode(Accessible::new(
169 Role::ListItem,
170 )),
171 ))
172 .insert(Pickable {
173 should_block_lower: false,
174 ..default()
175 });
176 });
177 }
178 });
179 });
180
181 // Bidirectional scroll example
182 parent
183 .spawn(Node {
184 flex_direction: FlexDirection::Column,
185 justify_content: JustifyContent::Center,
186 align_items: AlignItems::Center,
187 width: Val::Px(200.),
188 ..default()
189 })
190 .with_children(|parent| {
191 // Title
192 parent.spawn((
193 Text::new("Bidirectionally Scrolling List"),
194 TextFont {
195 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
196 font_size: FONT_SIZE,
197 ..default()
198 },
199 Label,
200 ));
201 // Scrolling list
202 parent
203 .spawn((
204 Node {
205 flex_direction: FlexDirection::Column,
206 align_self: AlignSelf::Stretch,
207 height: Val::Percent(50.),
208 overflow: Overflow::scroll(), // n.b.
209 ..default()
210 },
211 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
212 ))
213 .with_children(|parent| {
214 // Rows in each column
215 for oi in 0..10 {
216 parent
217 .spawn(Node {
218 flex_direction: FlexDirection::Row,
219 ..default()
220 })
221 .insert(Pickable::IGNORE)
222 .with_children(|parent| {
223 // Elements in each row
224 for i in 0..25 {
225 parent
226 .spawn((
227 Text(format!("Item {}", (oi * 25) + i)),
228 TextFont {
229 font: asset_server.load(
230 "fonts/FiraSans-Bold.ttf",
231 ),
232 ..default()
233 },
234 Label,
235 AccessibilityNode(Accessible::new(
236 Role::ListItem,
237 )),
238 ))
239 .insert(Pickable {
240 should_block_lower: false,
241 ..default()
242 });
243 }
244 });
245 }
246 });
247 });
248
249 // Nested scrolls example
250 parent
251 .spawn(Node {
252 flex_direction: FlexDirection::Column,
253 justify_content: JustifyContent::Center,
254 align_items: AlignItems::Center,
255 width: Val::Px(200.),
256 ..default()
257 })
258 .with_children(|parent| {
259 // Title
260 parent.spawn((
261 Text::new("Nested Scrolling Lists"),
262 TextFont {
263 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
264 font_size: FONT_SIZE,
265 ..default()
266 },
267 Label,
268 ));
269 // Outer, horizontal scrolling container
270 parent
271 .spawn((
272 Node {
273 column_gap: Val::Px(20.),
274 flex_direction: FlexDirection::Row,
275 align_self: AlignSelf::Stretch,
276 height: Val::Percent(50.),
277 overflow: Overflow::scroll_x(), // n.b.
278 ..default()
279 },
280 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
281 ))
282 .with_children(|parent| {
283 // Inner, scrolling columns
284 for oi in 0..30 {
285 parent
286 .spawn((
287 Node {
288 flex_direction: FlexDirection::Column,
289 align_self: AlignSelf::Stretch,
290 overflow: Overflow::scroll_y(),
291 ..default()
292 },
293 BackgroundColor(Color::srgb(0.05, 0.05, 0.05)),
294 ))
295 .insert(Pickable {
296 should_block_lower: false,
297 ..default()
298 })
299 .with_children(|parent| {
300 for i in 0..25 {
301 parent
302 .spawn((
303 Text(format!("Item {}", (oi * 25) + i)),
304 TextFont {
305 font: asset_server.load(
306 "fonts/FiraSans-Bold.ttf",
307 ),
308 ..default()
309 },
310 Label,
311 AccessibilityNode(Accessible::new(
312 Role::ListItem,
313 )),
314 ))
315 .insert(Pickable {
316 should_block_lower: false,
317 ..default()
318 });
319 }
320 });
321 }
322 });
323 });
324 });
325 });
326}
Sourcepub const fn scroll_x() -> Overflow
pub const fn scroll_x() -> Overflow
Scroll overflowing items on the x axis
Examples found in repository?
examples/ui/scroll.rs (line 66)
25fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
26 // Camera
27 commands.spawn((Camera2d, IsDefaultUiCamera));
28
29 // root node
30 commands
31 .spawn(Node {
32 width: Val::Percent(100.0),
33 height: Val::Percent(100.0),
34 justify_content: JustifyContent::SpaceBetween,
35 flex_direction: FlexDirection::Column,
36 ..default()
37 })
38 .insert(Pickable::IGNORE)
39 .with_children(|parent| {
40 // horizontal scroll example
41 parent
42 .spawn(Node {
43 width: Val::Percent(100.),
44 flex_direction: FlexDirection::Column,
45 ..default()
46 })
47 .with_children(|parent| {
48 // header
49 parent.spawn((
50 Text::new("Horizontally Scrolling list (Ctrl + MouseWheel)"),
51 TextFont {
52 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
53 font_size: FONT_SIZE,
54 ..default()
55 },
56 Label,
57 ));
58
59 // horizontal scroll container
60 parent
61 .spawn((
62 Node {
63 width: Val::Percent(80.),
64 margin: UiRect::all(Val::Px(10.)),
65 flex_direction: FlexDirection::Row,
66 overflow: Overflow::scroll_x(), // n.b.
67 ..default()
68 },
69 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
70 ))
71 .with_children(|parent| {
72 for i in 0..100 {
73 parent.spawn((Text(format!("Item {i}")),
74 TextFont {
75 font: asset_server
76 .load("fonts/FiraSans-Bold.ttf"),
77 ..default()
78 },
79 Label,
80 AccessibilityNode(Accessible::new(Role::ListItem)),
81 ))
82 .insert(Node {
83 min_width: Val::Px(200.),
84 align_content: AlignContent::Center,
85 ..default()
86 })
87 .insert(Pickable {
88 should_block_lower: false,
89 ..default()
90 })
91 .observe(|
92 trigger: Trigger<Pointer<Pressed>>,
93 mut commands: Commands
94 | {
95 if trigger.event().button == PointerButton::Primary {
96 commands.entity(trigger.target()).despawn();
97 }
98 });
99 }
100 });
101 });
102
103 // container for all other examples
104 parent
105 .spawn(Node {
106 width: Val::Percent(100.),
107 height: Val::Percent(100.),
108 flex_direction: FlexDirection::Row,
109 justify_content: JustifyContent::SpaceBetween,
110 ..default()
111 })
112 .with_children(|parent| {
113 // vertical scroll example
114 parent
115 .spawn(Node {
116 flex_direction: FlexDirection::Column,
117 justify_content: JustifyContent::Center,
118 align_items: AlignItems::Center,
119 width: Val::Px(200.),
120 ..default()
121 })
122 .with_children(|parent| {
123 // Title
124 parent.spawn((
125 Text::new("Vertically Scrolling List"),
126 TextFont {
127 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
128 font_size: FONT_SIZE,
129 ..default()
130 },
131 Label,
132 ));
133 // Scrolling list
134 parent
135 .spawn((
136 Node {
137 flex_direction: FlexDirection::Column,
138 align_self: AlignSelf::Stretch,
139 height: Val::Percent(50.),
140 overflow: Overflow::scroll_y(), // n.b.
141 ..default()
142 },
143 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
144 ))
145 .with_children(|parent| {
146 // List items
147 for i in 0..25 {
148 parent
149 .spawn(Node {
150 min_height: Val::Px(LINE_HEIGHT),
151 max_height: Val::Px(LINE_HEIGHT),
152 ..default()
153 })
154 .insert(Pickable {
155 should_block_lower: false,
156 ..default()
157 })
158 .with_children(|parent| {
159 parent
160 .spawn((
161 Text(format!("Item {i}")),
162 TextFont {
163 font: asset_server
164 .load("fonts/FiraSans-Bold.ttf"),
165 ..default()
166 },
167 Label,
168 AccessibilityNode(Accessible::new(
169 Role::ListItem,
170 )),
171 ))
172 .insert(Pickable {
173 should_block_lower: false,
174 ..default()
175 });
176 });
177 }
178 });
179 });
180
181 // Bidirectional scroll example
182 parent
183 .spawn(Node {
184 flex_direction: FlexDirection::Column,
185 justify_content: JustifyContent::Center,
186 align_items: AlignItems::Center,
187 width: Val::Px(200.),
188 ..default()
189 })
190 .with_children(|parent| {
191 // Title
192 parent.spawn((
193 Text::new("Bidirectionally Scrolling List"),
194 TextFont {
195 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
196 font_size: FONT_SIZE,
197 ..default()
198 },
199 Label,
200 ));
201 // Scrolling list
202 parent
203 .spawn((
204 Node {
205 flex_direction: FlexDirection::Column,
206 align_self: AlignSelf::Stretch,
207 height: Val::Percent(50.),
208 overflow: Overflow::scroll(), // n.b.
209 ..default()
210 },
211 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
212 ))
213 .with_children(|parent| {
214 // Rows in each column
215 for oi in 0..10 {
216 parent
217 .spawn(Node {
218 flex_direction: FlexDirection::Row,
219 ..default()
220 })
221 .insert(Pickable::IGNORE)
222 .with_children(|parent| {
223 // Elements in each row
224 for i in 0..25 {
225 parent
226 .spawn((
227 Text(format!("Item {}", (oi * 25) + i)),
228 TextFont {
229 font: asset_server.load(
230 "fonts/FiraSans-Bold.ttf",
231 ),
232 ..default()
233 },
234 Label,
235 AccessibilityNode(Accessible::new(
236 Role::ListItem,
237 )),
238 ))
239 .insert(Pickable {
240 should_block_lower: false,
241 ..default()
242 });
243 }
244 });
245 }
246 });
247 });
248
249 // Nested scrolls example
250 parent
251 .spawn(Node {
252 flex_direction: FlexDirection::Column,
253 justify_content: JustifyContent::Center,
254 align_items: AlignItems::Center,
255 width: Val::Px(200.),
256 ..default()
257 })
258 .with_children(|parent| {
259 // Title
260 parent.spawn((
261 Text::new("Nested Scrolling Lists"),
262 TextFont {
263 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
264 font_size: FONT_SIZE,
265 ..default()
266 },
267 Label,
268 ));
269 // Outer, horizontal scrolling container
270 parent
271 .spawn((
272 Node {
273 column_gap: Val::Px(20.),
274 flex_direction: FlexDirection::Row,
275 align_self: AlignSelf::Stretch,
276 height: Val::Percent(50.),
277 overflow: Overflow::scroll_x(), // n.b.
278 ..default()
279 },
280 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
281 ))
282 .with_children(|parent| {
283 // Inner, scrolling columns
284 for oi in 0..30 {
285 parent
286 .spawn((
287 Node {
288 flex_direction: FlexDirection::Column,
289 align_self: AlignSelf::Stretch,
290 overflow: Overflow::scroll_y(),
291 ..default()
292 },
293 BackgroundColor(Color::srgb(0.05, 0.05, 0.05)),
294 ))
295 .insert(Pickable {
296 should_block_lower: false,
297 ..default()
298 })
299 .with_children(|parent| {
300 for i in 0..25 {
301 parent
302 .spawn((
303 Text(format!("Item {}", (oi * 25) + i)),
304 TextFont {
305 font: asset_server.load(
306 "fonts/FiraSans-Bold.ttf",
307 ),
308 ..default()
309 },
310 Label,
311 AccessibilityNode(Accessible::new(
312 Role::ListItem,
313 )),
314 ))
315 .insert(Pickable {
316 should_block_lower: false,
317 ..default()
318 });
319 }
320 });
321 }
322 });
323 });
324 });
325 });
326}
Sourcepub const fn scroll_y() -> Overflow
pub const fn scroll_y() -> Overflow
Scroll overflowing items on the y axis
Examples found in repository?
examples/ui/scroll.rs (line 140)
25fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
26 // Camera
27 commands.spawn((Camera2d, IsDefaultUiCamera));
28
29 // root node
30 commands
31 .spawn(Node {
32 width: Val::Percent(100.0),
33 height: Val::Percent(100.0),
34 justify_content: JustifyContent::SpaceBetween,
35 flex_direction: FlexDirection::Column,
36 ..default()
37 })
38 .insert(Pickable::IGNORE)
39 .with_children(|parent| {
40 // horizontal scroll example
41 parent
42 .spawn(Node {
43 width: Val::Percent(100.),
44 flex_direction: FlexDirection::Column,
45 ..default()
46 })
47 .with_children(|parent| {
48 // header
49 parent.spawn((
50 Text::new("Horizontally Scrolling list (Ctrl + MouseWheel)"),
51 TextFont {
52 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
53 font_size: FONT_SIZE,
54 ..default()
55 },
56 Label,
57 ));
58
59 // horizontal scroll container
60 parent
61 .spawn((
62 Node {
63 width: Val::Percent(80.),
64 margin: UiRect::all(Val::Px(10.)),
65 flex_direction: FlexDirection::Row,
66 overflow: Overflow::scroll_x(), // n.b.
67 ..default()
68 },
69 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
70 ))
71 .with_children(|parent| {
72 for i in 0..100 {
73 parent.spawn((Text(format!("Item {i}")),
74 TextFont {
75 font: asset_server
76 .load("fonts/FiraSans-Bold.ttf"),
77 ..default()
78 },
79 Label,
80 AccessibilityNode(Accessible::new(Role::ListItem)),
81 ))
82 .insert(Node {
83 min_width: Val::Px(200.),
84 align_content: AlignContent::Center,
85 ..default()
86 })
87 .insert(Pickable {
88 should_block_lower: false,
89 ..default()
90 })
91 .observe(|
92 trigger: Trigger<Pointer<Pressed>>,
93 mut commands: Commands
94 | {
95 if trigger.event().button == PointerButton::Primary {
96 commands.entity(trigger.target()).despawn();
97 }
98 });
99 }
100 });
101 });
102
103 // container for all other examples
104 parent
105 .spawn(Node {
106 width: Val::Percent(100.),
107 height: Val::Percent(100.),
108 flex_direction: FlexDirection::Row,
109 justify_content: JustifyContent::SpaceBetween,
110 ..default()
111 })
112 .with_children(|parent| {
113 // vertical scroll example
114 parent
115 .spawn(Node {
116 flex_direction: FlexDirection::Column,
117 justify_content: JustifyContent::Center,
118 align_items: AlignItems::Center,
119 width: Val::Px(200.),
120 ..default()
121 })
122 .with_children(|parent| {
123 // Title
124 parent.spawn((
125 Text::new("Vertically Scrolling List"),
126 TextFont {
127 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
128 font_size: FONT_SIZE,
129 ..default()
130 },
131 Label,
132 ));
133 // Scrolling list
134 parent
135 .spawn((
136 Node {
137 flex_direction: FlexDirection::Column,
138 align_self: AlignSelf::Stretch,
139 height: Val::Percent(50.),
140 overflow: Overflow::scroll_y(), // n.b.
141 ..default()
142 },
143 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
144 ))
145 .with_children(|parent| {
146 // List items
147 for i in 0..25 {
148 parent
149 .spawn(Node {
150 min_height: Val::Px(LINE_HEIGHT),
151 max_height: Val::Px(LINE_HEIGHT),
152 ..default()
153 })
154 .insert(Pickable {
155 should_block_lower: false,
156 ..default()
157 })
158 .with_children(|parent| {
159 parent
160 .spawn((
161 Text(format!("Item {i}")),
162 TextFont {
163 font: asset_server
164 .load("fonts/FiraSans-Bold.ttf"),
165 ..default()
166 },
167 Label,
168 AccessibilityNode(Accessible::new(
169 Role::ListItem,
170 )),
171 ))
172 .insert(Pickable {
173 should_block_lower: false,
174 ..default()
175 });
176 });
177 }
178 });
179 });
180
181 // Bidirectional scroll example
182 parent
183 .spawn(Node {
184 flex_direction: FlexDirection::Column,
185 justify_content: JustifyContent::Center,
186 align_items: AlignItems::Center,
187 width: Val::Px(200.),
188 ..default()
189 })
190 .with_children(|parent| {
191 // Title
192 parent.spawn((
193 Text::new("Bidirectionally Scrolling List"),
194 TextFont {
195 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
196 font_size: FONT_SIZE,
197 ..default()
198 },
199 Label,
200 ));
201 // Scrolling list
202 parent
203 .spawn((
204 Node {
205 flex_direction: FlexDirection::Column,
206 align_self: AlignSelf::Stretch,
207 height: Val::Percent(50.),
208 overflow: Overflow::scroll(), // n.b.
209 ..default()
210 },
211 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
212 ))
213 .with_children(|parent| {
214 // Rows in each column
215 for oi in 0..10 {
216 parent
217 .spawn(Node {
218 flex_direction: FlexDirection::Row,
219 ..default()
220 })
221 .insert(Pickable::IGNORE)
222 .with_children(|parent| {
223 // Elements in each row
224 for i in 0..25 {
225 parent
226 .spawn((
227 Text(format!("Item {}", (oi * 25) + i)),
228 TextFont {
229 font: asset_server.load(
230 "fonts/FiraSans-Bold.ttf",
231 ),
232 ..default()
233 },
234 Label,
235 AccessibilityNode(Accessible::new(
236 Role::ListItem,
237 )),
238 ))
239 .insert(Pickable {
240 should_block_lower: false,
241 ..default()
242 });
243 }
244 });
245 }
246 });
247 });
248
249 // Nested scrolls example
250 parent
251 .spawn(Node {
252 flex_direction: FlexDirection::Column,
253 justify_content: JustifyContent::Center,
254 align_items: AlignItems::Center,
255 width: Val::Px(200.),
256 ..default()
257 })
258 .with_children(|parent| {
259 // Title
260 parent.spawn((
261 Text::new("Nested Scrolling Lists"),
262 TextFont {
263 font: asset_server.load("fonts/FiraSans-Bold.ttf"),
264 font_size: FONT_SIZE,
265 ..default()
266 },
267 Label,
268 ));
269 // Outer, horizontal scrolling container
270 parent
271 .spawn((
272 Node {
273 column_gap: Val::Px(20.),
274 flex_direction: FlexDirection::Row,
275 align_self: AlignSelf::Stretch,
276 height: Val::Percent(50.),
277 overflow: Overflow::scroll_x(), // n.b.
278 ..default()
279 },
280 BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
281 ))
282 .with_children(|parent| {
283 // Inner, scrolling columns
284 for oi in 0..30 {
285 parent
286 .spawn((
287 Node {
288 flex_direction: FlexDirection::Column,
289 align_self: AlignSelf::Stretch,
290 overflow: Overflow::scroll_y(),
291 ..default()
292 },
293 BackgroundColor(Color::srgb(0.05, 0.05, 0.05)),
294 ))
295 .insert(Pickable {
296 should_block_lower: false,
297 ..default()
298 })
299 .with_children(|parent| {
300 for i in 0..25 {
301 parent
302 .spawn((
303 Text(format!("Item {}", (oi * 25) + i)),
304 TextFont {
305 font: asset_server.load(
306 "fonts/FiraSans-Bold.ttf",
307 ),
308 ..default()
309 },
310 Label,
311 AccessibilityNode(Accessible::new(
312 Role::ListItem,
313 )),
314 ))
315 .insert(Pickable {
316 should_block_lower: false,
317 ..default()
318 });
319 }
320 });
321 }
322 });
323 });
324 });
325 });
326}
More examples
examples/testbed/full_ui.rs (line 159)
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}
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Overflow
impl<'de> Deserialize<'de> for Overflow
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Overflow, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Overflow, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromArg for &'static Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for &'static mut Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static mut Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromReflect for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromReflect for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Overflow>
fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Overflow>
Constructs a concrete instance of
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>>
Attempts to downcast the given value to
Self
using,
constructing the value using from_reflect
if that fails. Read moreSource§impl GetOwnership for &Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for &mut Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &mut Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetTypeRegistration for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetTypeRegistration for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
Returns the default
TypeRegistration
for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Registers other types needed by this type. Read more
Source§impl IntoReturn for &Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl IntoReturn for &mut Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &mut Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl IntoReturn for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl PartialReflect for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl PartialReflect for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: 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
Returns a zero-sized enumeration of “kinds” of type. Read more
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Returns an immutable enumeration of “kinds” of type. Read more
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Returns a mutable enumeration of “kinds” of type. Read more
Source§fn reflect_owned(self: Box<Overflow>) -> ReflectOwned
fn reflect_owned(self: Box<Overflow>) -> ReflectOwned
Returns an owned enumeration of “kinds” of type. Read more
Source§fn try_into_reflect(
self: Box<Overflow>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<Overflow>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
Attempts to cast this type to a boxed, fully-reflected value.
Source§fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
Attempts to cast this type to a fully-reflected value.
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)>
Attempts to cast this type to a mutable, fully-reflected value.
Source§fn into_partial_reflect(self: Box<Overflow>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<Overflow>) -> Box<dyn PartialReflect>
Casts this type to a boxed, reflected value. Read more
Source§fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
Casts this type to a reflected value. Read more
Source§fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
Casts this type to a mutable, reflected value. Read more
Source§fn reflect_partial_eq(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<bool>
fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>
Returns a “partial equality” comparison result. Read more
Source§fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Attempts to clone
Self
using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
fn apply(&mut self, value: &(dyn PartialReflect + 'static))
Applies a reflected value to this value. Read more
Source§fn clone_value(&self) -> Box<dyn PartialReflect>
fn clone_value(&self) -> Box<dyn PartialReflect>
👎Deprecated since 0.16.0: to clone reflected values, prefer using
reflect_clone
. To convert reflected values to dynamic ones, use to_dynamic
.Clones
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>
Returns a hash of the value (which includes the type). Read more
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Debug formatter for the value. Read more
Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Indicates whether or not this type is a dynamic type. Read more
Source§impl Reflect for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Reflect for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_any(self: Box<Overflow>) -> Box<dyn Any>
fn into_any(self: Box<Overflow>) -> Box<dyn Any>
Returns the value as a
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)
Returns the value as a
&mut dyn Any
. Read moreSource§fn into_reflect(self: Box<Overflow>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Overflow>) -> Box<dyn Reflect>
Casts this type to a boxed, fully-reflected value.
Source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Casts this type to a fully-reflected value.
Source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Casts this type to a mutable, fully-reflected value.
Source§impl Serialize for Overflow
impl Serialize for Overflow
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,
Serialize this value into the given Serde serializer. Read more
Source§impl Struct for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Struct for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
Returns a reference to the value of the field named
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)>
Returns a mutable reference to the value of the field named
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)>
Returns a reference to the value of the field with index
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)>
Returns a mutable reference to the value of the field with index
index
as a &mut dyn PartialReflect
.Source§fn name_at(&self, index: usize) -> Option<&str>
fn name_at(&self, index: usize) -> Option<&str>
Returns the name of the field with index
index
.Source§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
Returns an iterator over the values of the reflectable fields for this struct.
fn to_dynamic_struct(&self) -> DynamicStruct
Source§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
👎Deprecated since 0.16.0: use
to_dynamic_struct
insteadClones the struct into a
DynamicStruct
.Source§fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
Will return
None
if TypeInfo
is not available.Source§impl TypePath for Overflow
impl TypePath for Overflow
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Returns the fully qualified path of the underlying type. Read more
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Returns a short, pretty-print enabled path to the type. Read more
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 Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Typed for Overflowwhere
Overflow: Any + Send + Sync,
OverflowAxis: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Copy for Overflow
impl Eq for Overflow
impl StructuralPartialEq for Overflow
Auto Trait Implementations§
impl Freeze for Overflow
impl RefUnwindSafe for Overflow
impl Send for Overflow
impl Sync for Overflow
impl Unpin for Overflow
impl UnwindSafe for Overflow
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
Return the
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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
See
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>
See
TypePath::type_ident
.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
See
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
See
Typed::type_info
.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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,
Causes
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>>
Returns a reference to the value specified by
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>>
Returns a mutable reference to the value specified by
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,
Returns a statically typed reference to the value specified by
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,
Returns a statically typed mutable reference to the value specified by
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> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read 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,
Pipes by value. This is generally the method you want to use. Read more
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,
Borrows
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,
Mutably borrows
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
Borrows
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
Mutably borrows
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
Borrows
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>
Read this value from the supplied reader. Same as
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
Immutable access to the
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
Mutable access to the
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
Immutable access to the
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
Mutable access to the
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
Immutable access to the
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
Mutable access to the
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
Calls
.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
Calls
.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
Calls
.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
Calls
.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
Calls
.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
Calls
.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
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.