1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#![doc = include_str!("../Readme.md")]
mod commands;
#[cfg(feature = "bevy-ui")]
pub mod components;
pub mod events;
mod marker;
mod named;
mod resolve;
mod seeds;
pub mod systems;
use std::marker::PhantomData;
use bevy::prelude::*;
pub use non_empty_vec::NonEmpty;
pub use seeds::NavMenu;
pub mod bundles {
pub use crate::seeds::{MarkingMenuSeed, MenuSeed, NamedMarkingMenuSeed, NamedMenuSeed};
}
pub use events::{NavEvent, NavRequest};
pub use resolve::{FocusAction, FocusState, Focusable, Focused, NavLock};
pub struct NavMarkerPropagationPlugin<T>(PhantomData<T>);
impl<T> NavMarkerPropagationPlugin<T> {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
NavMarkerPropagationPlugin(PhantomData)
}
}
impl<T: 'static + Sync + Send + Component + Clone> Plugin for NavMarkerPropagationPlugin<T> {
fn build(&self, app: &mut App) {
app.add_system(marker::mark_new_menus::<T>)
.add_system(marker::mark_new_focusables::<T>);
}
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, SystemLabel)]
pub struct NavRequestSystem;
pub struct NavigationPlugin;
impl Plugin for NavigationPlugin {
fn build(&self, app: &mut App) {
app.add_event::<NavRequest>()
.add_event::<NavEvent>()
.insert_resource(NavLock::new())
.add_system(resolve::listen_nav_requests.label(NavRequestSystem))
.add_system(resolve::set_first_focused)
.add_system(resolve::insert_tree_menus.label("nav_build"))
.add_system(named::resolve_named_menus.before("nav_build"));
}
}