pub struct Hovered(pub bool);Expand description
A component that allows users to use regular Bevy change detection to determine when the pointer enters or leaves an entity. Users should insert this component on an entity to indicate interest in knowing about hover state changes.
The component’s boolean value will be true whenever the pointer is currently directly hovering
over the entity, or any of the entity’s descendants (as defined by the ChildOf
relationship). This is consistent with the behavior of the CSS :hover pseudo-class, which
applies to the element and all of its descendants.
The contained boolean value is guaranteed to only be mutated when the pointer enters or leaves
the entity, allowing Bevy change detection to be used efficiently. This is in contrast to the
HoverMap resource, which is updated every frame.
Typically, a simple hoverable entity or widget will have this component added to it. More complex widgets can have this component added to each hoverable part.
The computational cost of keeping the Hovered components up to date is relatively cheap, and
linear in the number of entities that have the Hovered component inserted.
Tuple Fields§
§0: boolImplementations§
Source§impl Hovered
impl Hovered
Sourcepub fn get(&self) -> bool
pub fn get(&self) -> bool
Get whether the entity is currently hovered.
Examples found in repository?
270fn update_button_style(
271 mut buttons: Query<
272 (
273 Has<Pressed>,
274 &Hovered,
275 Has<InteractionDisabled>,
276 &mut BackgroundColor,
277 &mut BorderColor,
278 &Children,
279 ),
280 (
281 Or<(
282 Changed<Pressed>,
283 Changed<Hovered>,
284 Added<InteractionDisabled>,
285 )>,
286 With<DemoButton>,
287 ),
288 >,
289 mut text_query: Query<&mut Text>,
290) {
291 for (pressed, hovered, disabled, mut color, mut border_color, children) in &mut buttons {
292 let mut text = text_query.get_mut(children[0]).unwrap();
293 set_button_style(
294 disabled,
295 hovered.get(),
296 pressed,
297 &mut color,
298 &mut border_color,
299 &mut text,
300 );
301 }
302}
303
304/// Supplementary system to detect removed marker components
305fn update_button_style2(
306 mut buttons: Query<
307 (
308 Has<Pressed>,
309 &Hovered,
310 Has<InteractionDisabled>,
311 &mut BackgroundColor,
312 &mut BorderColor,
313 &Children,
314 ),
315 With<DemoButton>,
316 >,
317 mut removed_depressed: RemovedComponents<Pressed>,
318 mut removed_disabled: RemovedComponents<InteractionDisabled>,
319 mut text_query: Query<&mut Text>,
320) {
321 removed_depressed
322 .read()
323 .chain(removed_disabled.read())
324 .for_each(|entity| {
325 if let Ok((pressed, hovered, disabled, mut color, mut border_color, children)) =
326 buttons.get_mut(entity)
327 {
328 let mut text = text_query.get_mut(children[0]).unwrap();
329 set_button_style(
330 disabled,
331 hovered.get(),
332 pressed,
333 &mut color,
334 &mut border_color,
335 &mut text,
336 );
337 }
338 });
339}
340
341fn set_button_style(
342 disabled: bool,
343 hovered: bool,
344 pressed: bool,
345 color: &mut BackgroundColor,
346 border_color: &mut BorderColor,
347 text: &mut Text,
348) {
349 match (disabled, hovered, pressed) {
350 // Disabled button
351 (true, _, _) => {
352 **text = "Disabled".to_string();
353 *color = NORMAL_BUTTON.into();
354 border_color.set_all(GRAY);
355 }
356
357 // Pressed and hovered button
358 (false, true, true) => {
359 **text = "Press".to_string();
360 *color = PRESSED_BUTTON.into();
361 border_color.set_all(RED);
362 }
363
364 // Hovered, unpressed button
365 (false, true, false) => {
366 **text = "Hover".to_string();
367 *color = HOVERED_BUTTON.into();
368 border_color.set_all(WHITE);
369 }
370
371 // Unhovered button (either pressed or not).
372 (false, false, _) => {
373 **text = "Button".to_string();
374 *color = NORMAL_BUTTON.into();
375 border_color.set_all(BLACK);
376 }
377 }
378}
379
380/// Create a demo slider
381fn slider(min: f32, max: f32, value: f32) -> impl Bundle {
382 (
383 Node {
384 display: Display::Flex,
385 flex_direction: FlexDirection::Column,
386 justify_content: JustifyContent::Center,
387 align_items: AlignItems::Stretch,
388 justify_items: JustifyItems::Center,
389 column_gap: px(4),
390 height: px(12),
391 width: percent(30),
392 ..default()
393 },
394 Name::new("Slider"),
395 Hovered::default(),
396 DemoSlider,
397 Slider {
398 track_click: TrackClick::Snap,
399 ..Default::default()
400 },
401 SliderValue(value),
402 SliderRange::new(min, max),
403 TabIndex(0),
404 Children::spawn((
405 // Slider background rail
406 Spawn((
407 Node {
408 height: px(6),
409 border_radius: BorderRadius::all(px(3)),
410 ..default()
411 },
412 BackgroundColor(SLIDER_TRACK), // Border color for the slider
413 )),
414 // Invisible track to allow absolute placement of thumb entity. This is narrower than
415 // the actual slider, which allows us to position the thumb entity using simple
416 // percentages, without having to measure the actual width of the slider thumb.
417 Spawn((
418 Node {
419 display: Display::Flex,
420 position_type: PositionType::Absolute,
421 left: px(0),
422 // Track is short by 12px to accommodate the thumb.
423 right: px(12),
424 top: px(0),
425 bottom: px(0),
426 ..default()
427 },
428 children![(
429 // Thumb
430 DemoSliderThumb,
431 SliderThumb,
432 Node {
433 display: Display::Flex,
434 width: px(12),
435 height: px(12),
436 position_type: PositionType::Absolute,
437 left: percent(0), // This will be updated by the slider's value
438 border_radius: BorderRadius::MAX,
439 ..default()
440 },
441 BackgroundColor(SLIDER_THUMB),
442 )],
443 )),
444 )),
445 )
446}
447
448/// Update the visuals of the slider based on the slider state.
449fn update_slider_style(
450 sliders: Query<
451 (
452 Entity,
453 &SliderValue,
454 &SliderRange,
455 &Hovered,
456 &SliderDragState,
457 Has<InteractionDisabled>,
458 ),
459 (
460 Or<(
461 Changed<SliderValue>,
462 Changed<SliderRange>,
463 Changed<Hovered>,
464 Changed<SliderDragState>,
465 Added<InteractionDisabled>,
466 )>,
467 With<DemoSlider>,
468 ),
469 >,
470 children: Query<&Children>,
471 mut thumbs: Query<(&mut Node, &mut BackgroundColor, Has<DemoSliderThumb>), Without<DemoSlider>>,
472) {
473 for (slider_ent, value, range, hovered, drag_state, disabled) in sliders.iter() {
474 for child in children.iter_descendants(slider_ent) {
475 if let Ok((mut thumb_node, mut thumb_bg, is_thumb)) = thumbs.get_mut(child)
476 && is_thumb
477 {
478 thumb_node.left = percent(range.thumb_position(value.0) * 100.0);
479 thumb_bg.0 = thumb_color(disabled, hovered.0 | drag_state.dragging);
480 }
481 }
482 }
483}
484
485fn update_slider_style2(
486 sliders: Query<
487 (Entity, &Hovered, &SliderDragState, Has<InteractionDisabled>),
488 With<DemoSlider>,
489 >,
490 children: Query<&Children>,
491 mut thumbs: Query<(&mut BackgroundColor, Has<DemoSliderThumb>), Without<DemoSlider>>,
492 mut removed_disabled: RemovedComponents<InteractionDisabled>,
493) {
494 removed_disabled.read().for_each(|entity| {
495 if let Ok((slider_ent, hovered, drag_state, disabled)) = sliders.get(entity) {
496 for child in children.iter_descendants(slider_ent) {
497 if let Ok((mut thumb_bg, is_thumb)) = thumbs.get_mut(child)
498 && is_thumb
499 {
500 thumb_bg.0 = thumb_color(disabled, hovered.0 | drag_state.dragging);
501 }
502 }
503 }
504 });
505}
506
507fn thumb_color(disabled: bool, hovered: bool) -> Color {
508 match (disabled, hovered) {
509 (true, _) => ELEMENT_FILL_DISABLED,
510
511 (false, true) => SLIDER_THUMB.lighter(0.3),
512
513 _ => SLIDER_THUMB,
514 }
515}
516
517/// Create a demo checkbox
518fn checkbox(asset_server: &AssetServer, caption: &str) -> impl Bundle {
519 (
520 Node {
521 display: Display::Flex,
522 flex_direction: FlexDirection::Row,
523 justify_content: JustifyContent::FlexStart,
524 align_items: AlignItems::Center,
525 align_content: AlignContent::Center,
526 column_gap: px(4),
527 ..default()
528 },
529 Name::new("Checkbox"),
530 Hovered::default(),
531 DemoCheckbox,
532 Checkbox,
533 TabIndex(0),
534 Children::spawn((
535 Spawn((
536 // Checkbox outer
537 Node {
538 display: Display::Flex,
539 width: px(16),
540 height: px(16),
541 border: UiRect::all(px(2)),
542 border_radius: BorderRadius::all(px(3)),
543 ..default()
544 },
545 BorderColor::all(ELEMENT_OUTLINE), // Border color for the checkbox
546 children![
547 // Checkbox inner
548 (
549 Node {
550 display: Display::Flex,
551 width: px(8),
552 height: px(8),
553 position_type: PositionType::Absolute,
554 left: px(2),
555 top: px(2),
556 ..default()
557 },
558 BackgroundColor(ELEMENT_FILL),
559 ),
560 ],
561 )),
562 Spawn((
563 Text::new(caption),
564 TextFont {
565 font: asset_server.load("fonts/FiraSans-Bold.ttf").into(),
566 font_size: FontSize::Px(20.0),
567 ..default()
568 },
569 )),
570 )),
571 )
572}
573
574// Update the element's styles.
575fn update_checkbox_or_radio_style(
576 mut q_checkbox: Query<
577 (Has<Checked>, &Hovered, Has<InteractionDisabled>, &Children),
578 (
579 Or<(With<DemoCheckbox>, With<DemoRadio>)>,
580 Or<(
581 Added<DemoCheckbox>,
582 Changed<Hovered>,
583 Added<Checked>,
584 Added<InteractionDisabled>,
585 )>,
586 ),
587 >,
588 mut q_border_color: Query<
589 (&mut BorderColor, &mut Children),
590 (Without<DemoCheckbox>, Without<DemoRadio>),
591 >,
592 mut q_bg_color: Query<&mut BackgroundColor, (Without<DemoCheckbox>, Without<Children>)>,
593) {
594 for (checked, Hovered(is_hovering), is_disabled, children) in q_checkbox.iter_mut() {
595 let Some(border_id) = children.first() else {
596 continue;
597 };
598
599 let Ok((mut border_color, border_children)) = q_border_color.get_mut(*border_id) else {
600 continue;
601 };
602
603 let Some(mark_id) = border_children.first() else {
604 warn!("Checkbox does not have a mark entity.");
605 continue;
606 };
607
608 let Ok(mut mark_bg) = q_bg_color.get_mut(*mark_id) else {
609 warn!("Checkbox mark entity lacking a background color.");
610 continue;
611 };
612
613 set_checkbox_or_radio_style(
614 is_disabled,
615 *is_hovering,
616 checked,
617 &mut border_color,
618 &mut mark_bg,
619 );
620 }
621}
622
623fn update_checkbox_or_radio_style2(
624 mut q_checkbox: Query<
625 (Has<Checked>, &Hovered, Has<InteractionDisabled>, &Children),
626 Or<(With<DemoCheckbox>, With<DemoRadio>)>,
627 >,
628 mut q_border_color: Query<
629 (&mut BorderColor, &mut Children),
630 (Without<DemoCheckbox>, Without<DemoRadio>),
631 >,
632 mut q_bg_color: Query<
633 &mut BackgroundColor,
634 (Without<DemoCheckbox>, Without<DemoRadio>, Without<Children>),
635 >,
636 mut removed_checked: RemovedComponents<Checked>,
637 mut removed_disabled: RemovedComponents<InteractionDisabled>,
638) {
639 removed_checked
640 .read()
641 .chain(removed_disabled.read())
642 .for_each(|entity| {
643 if let Ok((checked, Hovered(is_hovering), is_disabled, children)) =
644 q_checkbox.get_mut(entity)
645 {
646 let Some(border_id) = children.first() else {
647 return;
648 };
649
650 let Ok((mut border_color, border_children)) = q_border_color.get_mut(*border_id)
651 else {
652 return;
653 };
654
655 let Some(mark_id) = border_children.first() else {
656 warn!("Checkbox does not have a mark entity.");
657 return;
658 };
659
660 let Ok(mut mark_bg) = q_bg_color.get_mut(*mark_id) else {
661 warn!("Checkbox mark entity lacking a background color.");
662 return;
663 };
664
665 set_checkbox_or_radio_style(
666 is_disabled,
667 *is_hovering,
668 checked,
669 &mut border_color,
670 &mut mark_bg,
671 );
672 }
673 });
674}
675
676fn set_checkbox_or_radio_style(
677 disabled: bool,
678 hovering: bool,
679 checked: bool,
680 border_color: &mut BorderColor,
681 mark_bg: &mut BackgroundColor,
682) {
683 let color: Color = if disabled {
684 // If the element is disabled, use a lighter color
685 ELEMENT_OUTLINE.with_alpha(0.2)
686 } else if hovering {
687 // If hovering, use a lighter color
688 ELEMENT_OUTLINE.lighter(0.2)
689 } else {
690 // Default color for the element
691 ELEMENT_OUTLINE
692 };
693
694 // Update the background color of the element
695 border_color.set_all(color);
696
697 let mark_color: Color = match (disabled, checked) {
698 (true, true) => ELEMENT_FILL_DISABLED,
699 (false, true) => ELEMENT_FILL,
700 (_, false) => Srgba::NONE.into(),
701 };
702
703 if mark_bg.0 != mark_color {
704 // Update the color of the element
705 mark_bg.0 = mark_color;
706 }
707}
708
709/// Create a demo radio group
710fn radio_group(asset_server: &AssetServer) -> impl Bundle {
711 (
712 Node {
713 display: Display::Flex,
714 flex_direction: FlexDirection::Column,
715 align_items: AlignItems::Start,
716 column_gap: px(4),
717 ..default()
718 },
719 Name::new("RadioGroup"),
720 RadioGroup,
721 TabIndex::default(),
722 children![
723 (radio(asset_server, TrackClick::Drag, "Slider Drag"),),
724 (radio(asset_server, TrackClick::Step, "Slider Step"),),
725 (radio(asset_server, TrackClick::Snap, "Slider Snap"),)
726 ],
727 )
728}
729
730/// Create a demo radio button
731fn radio(asset_server: &AssetServer, value: TrackClick, caption: &str) -> impl Bundle {
732 (
733 Node {
734 display: Display::Flex,
735 flex_direction: FlexDirection::Row,
736 justify_content: JustifyContent::FlexStart,
737 align_items: AlignItems::Center,
738 align_content: AlignContent::Center,
739 column_gap: px(4),
740 ..default()
741 },
742 Name::new("RadioButton"),
743 Hovered::default(),
744 DemoRadio(value),
745 RadioButton,
746 Children::spawn((
747 Spawn((
748 // Radio outer
749 Node {
750 display: Display::Flex,
751 width: px(16),
752 height: px(16),
753 border: UiRect::all(px(2)),
754 border_radius: BorderRadius::MAX,
755 ..default()
756 },
757 BorderColor::all(ELEMENT_OUTLINE), // Border color for the radio button
758 children![
759 // Radio inner
760 (
761 Node {
762 display: Display::Flex,
763 width: px(8),
764 height: px(8),
765 position_type: PositionType::Absolute,
766 left: px(2),
767 top: px(2),
768 border_radius: BorderRadius::MAX,
769 ..default()
770 },
771 BackgroundColor(ELEMENT_FILL),
772 ),
773 ],
774 )),
775 Spawn((
776 Text::new(caption),
777 TextFont {
778 font: asset_server.load("fonts/FiraSans-Bold.ttf").into(),
779 font_size: FontSize::Px(20.0),
780 ..default()
781 },
782 )),
783 )),
784 )
785}
786
787fn on_menu_event(
788 menu_event: On<MenuEvent>,
789 q_anchor: Single<(Entity, &Children), With<DemoMenuAnchor>>,
790 q_popup: Query<Entity, With<MenuPopup>>,
791 assets: Res<AssetServer>,
792 mut focus: ResMut<InputFocus>,
793 mut commands: Commands,
794) {
795 let (anchor, children) = q_anchor.into_inner();
796 let popup = children.iter().find_map(|c| q_popup.get(c).ok());
797 info!("Menu action: {:?}", menu_event.action);
798 match menu_event.action {
799 MenuAction::Open(_) => {
800 if popup.is_none() {
801 spawn_menu(anchor, assets, commands);
802 }
803 }
804 MenuAction::Toggle => match popup {
805 Some(popup) => commands.entity(popup).despawn(),
806 None => spawn_menu(anchor, assets, commands),
807 },
808 MenuAction::CloseAll => {
809 if let Some(popup) = popup {
810 commands.entity(popup).despawn();
811 }
812 }
813 MenuAction::FocusRoot => {
814 focus.set(anchor, FocusCause::Navigated);
815 }
816 }
817}
818
819fn spawn_menu(anchor: Entity, assets: Res<AssetServer>, mut commands: Commands) {
820 let menu = commands
821 .spawn((
822 Node {
823 display: Display::Flex,
824 flex_direction: FlexDirection::Column,
825 min_height: px(10.),
826 min_width: percent(100),
827 border: UiRect::all(px(1)),
828 position_type: PositionType::Absolute,
829 ..default()
830 },
831 MenuPopup::default(),
832 BorderColor::all(GREEN),
833 BackgroundColor(GRAY.into()),
834 BoxShadow::new(
835 Srgba::BLACK.with_alpha(0.9).into(),
836 px(0),
837 px(0),
838 px(1),
839 px(4),
840 ),
841 GlobalZIndex(100),
842 Popover {
843 positions: vec![
844 PopoverPlacement {
845 side: PopoverSide::Bottom,
846 align: PopoverAlign::Start,
847 gap: 2.0,
848 },
849 PopoverPlacement {
850 side: PopoverSide::Top,
851 align: PopoverAlign::Start,
852 gap: 2.0,
853 },
854 ],
855 window_margin: 10.0,
856 },
857 OverrideClip,
858 children![
859 menu_item(&assets),
860 menu_item(&assets),
861 menu_item(&assets),
862 menu_item(&assets)
863 ],
864 ))
865 .id();
866 commands.entity(anchor).add_child(menu);
867}
868
869fn menu_item(asset_server: &AssetServer) -> impl Bundle {
870 (
871 Node {
872 padding: UiRect::axes(px(8), px(2)),
873 justify_content: JustifyContent::Center,
874 align_items: AlignItems::Start,
875 ..default()
876 },
877 DemoMenuItem,
878 MenuItem,
879 Hovered::default(),
880 TabIndex(0),
881 BackgroundColor(NORMAL_BUTTON),
882 children![(
883 Text::new("Menu Item"),
884 TextFont {
885 font: asset_server.load("fonts/FiraSans-Bold.ttf").into(),
886 font_size: FontSize::Px(33.0),
887 ..default()
888 },
889 TextColor(Color::srgb(0.9, 0.9, 0.9)),
890 TextShadow::default(),
891 )],
892 )
893}
894
895fn update_menu_item_style(
896 mut buttons: Query<
897 (
898 Has<Pressed>,
899 &Hovered,
900 Has<InteractionDisabled>,
901 &mut BackgroundColor,
902 ),
903 (
904 Or<(
905 Changed<Pressed>,
906 Changed<Hovered>,
907 Added<InteractionDisabled>,
908 )>,
909 With<DemoMenuItem>,
910 ),
911 >,
912) {
913 for (pressed, hovered, disabled, mut color) in &mut buttons {
914 set_menu_item_style(disabled, hovered.get(), pressed, &mut color);
915 }
916}
917
918/// Supplementary system to detect removed marker components
919fn update_menu_item_style2(
920 mut buttons: Query<
921 (
922 Has<Pressed>,
923 &Hovered,
924 Has<InteractionDisabled>,
925 &mut BackgroundColor,
926 ),
927 With<DemoMenuItem>,
928 >,
929 mut removed_depressed: RemovedComponents<Pressed>,
930 mut removed_disabled: RemovedComponents<InteractionDisabled>,
931) {
932 removed_depressed
933 .read()
934 .chain(removed_disabled.read())
935 .for_each(|entity| {
936 if let Ok((pressed, hovered, disabled, mut color)) = buttons.get_mut(entity) {
937 set_menu_item_style(disabled, hovered.get(), pressed, &mut color);
938 }
939 });
940}More examples
153fn button_on_interaction<E: EntityEvent, C: Component>(
154 event: On<E, C>,
155 mut buttons: Query<
156 (
157 &Hovered,
158 Has<InteractionDisabled>,
159 Has<Pressed>,
160 &mut BackgroundColor,
161 &mut BorderColor,
162 &Children,
163 ),
164 With<DemoButton>,
165 >,
166 mut text_query: Query<&mut Text>,
167) {
168 if let Ok((hovered, disabled, pressed, mut color, mut border_color, children)) =
169 buttons.get_mut(event.event_target())
170 {
171 if children.is_empty() {
172 return;
173 }
174 let Ok(mut text) = text_query.get_mut(children[0]) else {
175 return;
176 };
177 let hovered = hovered.get();
178 // These "removal event checks" exist because the `Remove` event is triggered _before_ the component is actually
179 // removed, meaning it still shows up in the query. We're investigating the best way to improve this scenario.
180 let pressed = pressed && !(E::is::<Remove>() && C::is::<Pressed>());
181 let disabled = disabled && !(E::is::<Remove>() && C::is::<InteractionDisabled>());
182 match (disabled, hovered, pressed) {
183 // Disabled button
184 (true, _, _) => {
185 **text = "Disabled".to_string();
186 *color = NORMAL_BUTTON.into();
187 border_color.set_all(GRAY);
188 }
189
190 // Pressed and hovered button
191 (false, true, true) => {
192 **text = "Press".to_string();
193 *color = PRESSED_BUTTON.into();
194 border_color.set_all(RED);
195 }
196
197 // Hovered, unpressed button
198 (false, true, false) => {
199 **text = "Hover".to_string();
200 *color = HOVERED_BUTTON.into();
201 border_color.set_all(WHITE);
202 }
203
204 // Unhovered button (either pressed or not).
205 (false, false, _) => {
206 **text = "Button".to_string();
207 *color = NORMAL_BUTTON.into();
208 border_color.set_all(BLACK);
209 }
210 }
211 }
212}
213
214/// Create a demo slider
215fn slider(min: f32, max: f32, value: f32) -> impl Bundle {
216 (
217 Node {
218 display: Display::Flex,
219 flex_direction: FlexDirection::Column,
220 justify_content: JustifyContent::Center,
221 align_items: AlignItems::Stretch,
222 justify_items: JustifyItems::Center,
223 column_gap: px(4),
224 height: px(12),
225 width: percent(30),
226 ..default()
227 },
228 Name::new("Slider"),
229 Hovered::default(),
230 DemoSlider,
231 Slider::default(),
232 SliderValue(value),
233 SliderRange::new(min, max),
234 TabIndex(0),
235 Children::spawn((
236 // Slider background rail
237 Spawn((
238 Node {
239 height: px(6),
240 border_radius: BorderRadius::all(px(3)),
241 ..default()
242 },
243 BackgroundColor(SLIDER_TRACK), // Border color for the checkbox
244 )),
245 // Invisible track to allow absolute placement of thumb entity. This is narrower than
246 // the actual slider, which allows us to position the thumb entity using simple
247 // percentages, without having to measure the actual width of the slider thumb.
248 Spawn((
249 Node {
250 display: Display::Flex,
251 position_type: PositionType::Absolute,
252 left: px(0),
253 // Track is short by 12px to accommodate the thumb.
254 right: px(12),
255 top: px(0),
256 bottom: px(0),
257 ..default()
258 },
259 children![(
260 // Thumb
261 DemoSliderThumb,
262 SliderThumb,
263 Node {
264 display: Display::Flex,
265 width: px(12),
266 height: px(12),
267 position_type: PositionType::Absolute,
268 left: percent(0), // This will be updated by the slider's value
269 border_radius: BorderRadius::MAX,
270 ..default()
271 },
272 BackgroundColor(SLIDER_THUMB),
273 )],
274 )),
275 )),
276 )
277}
278
279fn slider_on_interaction<E: EntityEvent, C: Component>(
280 event: On<E, C>,
281 sliders: Query<(Entity, &Hovered, Has<InteractionDisabled>), With<DemoSlider>>,
282 children: Query<&Children>,
283 mut thumbs: Query<(&mut BackgroundColor, Has<DemoSliderThumb>), Without<DemoSlider>>,
284) {
285 if let Ok((slider_ent, hovered, disabled)) = sliders.get(event.event_target()) {
286 // These "removal event checks" exist because the `Remove` event is triggered _before_ the component is actually
287 // removed, meaning it still shows up in the query. We're investigating the best way to improve this scenario.
288 let disabled = disabled && !(E::is::<Remove>() && C::is::<InteractionDisabled>());
289 for child in children.iter_descendants(slider_ent) {
290 if let Ok((mut thumb_bg, is_thumb)) = thumbs.get_mut(child)
291 && is_thumb
292 {
293 thumb_bg.0 = thumb_color(disabled, hovered.0);
294 }
295 }
296 }
297}
298
299fn slider_on_change_value<C: Component>(
300 insert: On<Insert, C>,
301 sliders: Query<(Entity, &SliderValue, &SliderRange), With<DemoSlider>>,
302 children: Query<&Children>,
303 mut thumbs: Query<(&mut Node, Has<DemoSliderThumb>), Without<DemoSlider>>,
304) {
305 if let Ok((slider_ent, value, range)) = sliders.get(insert.entity) {
306 for child in children.iter_descendants(slider_ent) {
307 if let Ok((mut thumb_node, is_thumb)) = thumbs.get_mut(child)
308 && is_thumb
309 {
310 thumb_node.left = percent(range.thumb_position(value.0) * 100.0);
311 }
312 }
313 }
314}
315
316fn thumb_color(disabled: bool, hovered: bool) -> Color {
317 match (disabled, hovered) {
318 (true, _) => GRAY.into(),
319
320 (false, true) => SLIDER_THUMB.lighter(0.3),
321
322 _ => SLIDER_THUMB,
323 }
324}
325
326/// Create a demo checkbox
327fn checkbox(asset_server: &AssetServer, caption: &str) -> impl Bundle {
328 (
329 Node {
330 display: Display::Flex,
331 flex_direction: FlexDirection::Row,
332 justify_content: JustifyContent::FlexStart,
333 align_items: AlignItems::Center,
334 align_content: AlignContent::Center,
335 column_gap: px(4),
336 ..default()
337 },
338 Name::new("Checkbox"),
339 Hovered::default(),
340 DemoCheckbox,
341 Checkbox,
342 TabIndex(0),
343 Children::spawn((
344 Spawn((
345 // Checkbox outer
346 Node {
347 display: Display::Flex,
348 width: px(16),
349 height: px(16),
350 border: UiRect::all(px(2)),
351 border_radius: BorderRadius::all(px(3)),
352 ..default()
353 },
354 BorderColor::all(CHECKBOX_OUTLINE), // Border color for the checkbox
355 children![
356 // Checkbox inner
357 (
358 Node {
359 display: Display::Flex,
360 width: px(8),
361 height: px(8),
362 position_type: PositionType::Absolute,
363 left: px(2),
364 top: px(2),
365 ..default()
366 },
367 BackgroundColor(Srgba::NONE.into()),
368 ),
369 ],
370 )),
371 Spawn((
372 Text::new(caption),
373 TextFont {
374 font: asset_server.load("fonts/FiraSans-Bold.ttf").into(),
375 font_size: FontSize::Px(20.0),
376 ..default()
377 },
378 )),
379 )),
380 )
381}
382
383fn checkbox_on_interaction<E: EntityEvent, C: Component>(
384 event: On<E, C>,
385 checkboxes: Query<
386 (&Hovered, Has<InteractionDisabled>, Has<Checked>, &Children),
387 With<DemoCheckbox>,
388 >,
389 mut borders: Query<(&mut BorderColor, &mut Children), Without<DemoCheckbox>>,
390 mut marks: Query<&mut BackgroundColor, (Without<DemoCheckbox>, Without<Children>)>,
391) {
392 if let Ok((hovered, disabled, checked, children)) = checkboxes.get(event.event_target()) {
393 let hovered = hovered.get();
394 // These "removal event checks" exist because the `Remove` event is triggered _before_ the component is actually
395 // removed, meaning it still shows up in the query. We're investigating the best way to improve this scenario.
396 let checked = checked && !(E::is::<Remove>() && C::is::<Checked>());
397 let disabled = disabled && !(E::is::<Remove>() && C::is::<InteractionDisabled>());
398
399 let Some(border_id) = children.first() else {
400 return;
401 };
402
403 let Ok((mut border_color, border_children)) = borders.get_mut(*border_id) else {
404 return;
405 };
406
407 let Some(mark_id) = border_children.first() else {
408 warn!("Checkbox does not have a mark entity.");
409 return;
410 };
411
412 let Ok(mut mark_bg) = marks.get_mut(*mark_id) else {
413 warn!("Checkbox mark entity lacking a background color.");
414 return;
415 };
416
417 let color: Color = if disabled {
418 // If the checkbox is disabled, use a lighter color
419 CHECKBOX_OUTLINE.with_alpha(0.2)
420 } else if hovered {
421 // If hovering, use a lighter color
422 CHECKBOX_OUTLINE.lighter(0.2)
423 } else {
424 // Default color for the checkbox
425 CHECKBOX_OUTLINE
426 };
427
428 // Update the background color of the check mark
429 border_color.set_all(color);
430
431 let mark_color: Color = match (disabled, checked) {
432 (true, true) => CHECKBOX_CHECK.with_alpha(0.5),
433 (false, true) => CHECKBOX_CHECK,
434 (_, false) => Srgba::NONE.into(),
435 };
436
437 if mark_bg.0 != mark_color {
438 // Update the color of the check mark
439 mark_bg.0 = mark_color;
440 }
441 }
442}Trait Implementations§
Source§impl Component for Hovered
impl Component for Hovered
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Immutable
type Mutability = Immutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Hovered>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Hovered>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§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_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> 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 moreimpl Copy for Hovered
impl Eq for Hovered
Source§impl FromReflect for Hovered
impl FromReflect for Hovered
Source§fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Hovered>
fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Hovered>
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 Hovered
impl GetOwnership for Hovered
Source§impl GetTypeRegistration for Hovered
impl GetTypeRegistration for Hovered
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 Hovered
impl IntoReturn for Hovered
Source§impl PartialReflect for Hovered
impl PartialReflect for Hovered
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<Hovered>) -> ReflectOwned
fn reflect_owned(self: Box<Hovered>) -> ReflectOwned
Source§fn try_into_reflect(
self: Box<Hovered>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<Hovered>, ) -> 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<Hovered>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<Hovered>) -> 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 reflect_partial_cmp(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<Ordering>
fn reflect_partial_cmp( &self, value: &(dyn PartialReflect + 'static), ) -> Option<Ordering>
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 to_dynamic(&self) -> Box<dyn PartialReflect>
fn to_dynamic(&self) -> Box<dyn PartialReflect>
Source§fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
PartialReflect, combines reflect_clone and
take in a useful fashion, automatically constructing an appropriate
ReflectCloneError if the downcast fails.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 Hovered
impl Reflect for Hovered
Source§fn into_any(self: Box<Hovered>) -> Box<dyn Any>
fn into_any(self: Box<Hovered>) -> 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<Hovered>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Hovered>) -> 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)
impl StructuralPartialEq for Hovered
Source§impl TupleStruct for Hovered
impl TupleStruct for Hovered
Source§fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
index as a
&dyn Reflect.Source§fn field_mut(
&mut self,
index: usize,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>
index
as a &mut dyn Reflect.Source§fn iter_fields(&self) -> TupleStructFieldIter<'_> ⓘ
fn iter_fields(&self) -> TupleStructFieldIter<'_> ⓘ
Source§fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct
fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct
DynamicTupleStruct from this tuple struct.Source§fn get_represented_tuple_struct_info(&self) -> Option<&'static TupleStructInfo>
fn get_represented_tuple_struct_info(&self) -> Option<&'static TupleStructInfo>
None if TypeInfo is not available.Source§impl TypePath for Hovered
impl TypePath for Hovered
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>
Auto Trait Implementations§
impl Freeze for Hovered
impl RefUnwindSafe for Hovered
impl Send for Hovered
impl Sync for Hovered
impl Unpin for Hovered
impl UnsafeUnpin for Hovered
impl UnwindSafe for Hovered
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
impl<T> Brush for T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
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<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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> ErasedBundleTemplate for T
impl<T> ErasedBundleTemplate for T
Source§unsafe fn apply(
&self,
context: &mut TemplateContext<'_, '_>,
) -> Result<(), BevyError>
unsafe fn apply( &self, context: &mut TemplateContext<'_, '_>, ) -> Result<(), BevyError>
entity. Read moreSource§fn clone_template(&self) -> Box<dyn ErasedBundleTemplate>
fn clone_template(&self) -> Box<dyn ErasedBundleTemplate>
Clone.Source§impl<T> ErasedComponentTemplate for T
impl<T> ErasedComponentTemplate for T
Source§unsafe fn apply(
&self,
context: &mut TemplateContext<'_, '_>,
bundle_writer: &mut BundleWriter<'_>,
) -> Result<(), BevyError>
unsafe fn apply( &self, context: &mut TemplateContext<'_, '_>, bundle_writer: &mut BundleWriter<'_>, ) -> Result<(), BevyError>
entity. Read moreSource§fn clone_template(&self) -> Box<dyn ErasedComponentTemplate>
fn clone_template(&self) -> Box<dyn ErasedComponentTemplate>
Clone.impl<T> ErasedDestructor for Twhere
T: 'static,
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> FromTemplate for T
impl<T> FromTemplate for T
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<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<S> GetTupleStructField for Swhere
S: TupleStruct,
impl<S> GetTupleStructField for Swhere
S: TupleStruct,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T> HitDataExtra for T
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§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<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§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<G> PatchFromTemplate for Gwhere
G: FromTemplate,
impl<G> PatchFromTemplate for Gwhere
G: FromTemplate,
Source§fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
func, and turns it into a TemplatePatch.Source§impl<T> PatchTemplate for Twhere
T: Template,
impl<T> PatchTemplate for Twhere
T: Template,
Source§fn patch_template<F>(func: F) -> TemplatePatch<F, T>
fn patch_template<F>(func: F) -> TemplatePatch<F, 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.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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().impl<T> Reflectable for T
impl<T> Settings for T
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
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.Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.