Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d4dca09
Initial port of bevy_ui_navigation to bevy
nicopap Jul 19, 2022
0f64324
Remove event_helpers module
nicopap Jul 19, 2022
719b29b
Remove off_screen_focusables example
nicopap Jul 21, 2022
653aff0
A few refactors + compile bevy_ui
nicopap Jul 22, 2022
c9e51bf
Remove absolute URLs to bevy doc
nicopap Jul 22, 2022
c95ded7
Update UI examples to use new focus system
nicopap Jul 23, 2022
fbea754
Fix IOS example
nicopap Jul 23, 2022
963017e
Add back old focus system
nicopap Jul 26, 2022
c5a8769
Edit out the bevy-ui-navigation README
nicopap Jul 26, 2022
12b3440
Add wrapper to simplify working with NavEvents
nicopap Jul 26, 2022
8d6fa61
Export FocusPolicy and Hover
nicopap Jul 26, 2022
d0684fc
Update examples to use new APIs
nicopap Jul 26, 2022
72c434a
Fix documentation links
nicopap Jul 29, 2022
0c854f2
Improve the initialize focusable algorithm
nicopap Jul 29, 2022
ac70da1
Fix markdownlint
nicopap Jul 29, 2022
6419893
Fix trait bound on activated_in_query
nicopap Jul 31, 2022
3d0cf7b
Fix wrapping navigation not working
nicopap Jul 31, 2022
4a6b722
Add a procedurally generated menu example
nicopap Aug 1, 2022
6c5531e
Rename InputMapping
nicopap Aug 1, 2022
02a195c
Add simple button navigation example
nicopap Aug 5, 2022
5363a80
Fix clippy lints on infinite_upgrades
nicopap Aug 5, 2022
97a6c94
Add basic tests to bevy_ui_navigation
nicopap Aug 5, 2022
c67252b
Refactor
nicopap Aug 8, 2022
8c8b39f
Fix examples to compile with new bevy changes
nicopap Aug 9, 2022
44dbe99
Add NavRequest::Lock
nicopap Aug 9, 2022
0399d33
Add the Blocked focus state
nicopap Aug 9, 2022
225461f
Remove focus follow mouse in default mouse input
nicopap Aug 9, 2022
e438efe
Fix doc links
nicopap Aug 9, 2022
890c5af
Remove commented test stubs
nicopap Aug 9, 2022
7d2fbe8
Fix doc links
nicopap Aug 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ render = [
"bevy_internal/bevy_sprite",
"bevy_internal/bevy_text",
"bevy_internal/bevy_ui",
"bevy_internal/bevy_ui_navigation",
]

# Optional bevy crates
Expand Down Expand Up @@ -1462,6 +1463,48 @@ description = "Illustrates how to scale the UI"
category = "UI (User Interface)"
wasm = true

# UI navigation
[[example]]
name = "button_navigation"
path = "examples/ui_navigation/button_navigation.rs"

[package.metadata.example.button_navigation]
name = "UI button navigation"
description = "Illustrates simple cursor focus movement between buttons"
category = "UI navigation"
wasm = true

[[example]]
name = "locking"
path = "examples/ui_navigation/locking.rs"

[package.metadata.example.locking]
name = "UI locking"
description = "Illustrates UI locking"
category = "UI navigation"
wasm = true

[[example]]
name = "menu_navigation"
path = "examples/ui_navigation/menu_navigation.rs"

[package.metadata.example.menu_navigation]
name = "menu navigation"
description = "Illustrates movement between menus"
category = "UI navigation"
wasm = true

[[example]]
name = "infinite_upgrades"
path = "examples/ui_navigation/infinite_upgrades.rs"

[package.metadata.example.infinite_upgrades]
name = "Infinite upgrades"
description = "Shows usage of a custom navigation system in 2D space and procedural menus"
category = "UI navigation"
wasm = true


# Window
[[example]]
name = "clear_color"
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ bevy_scene = { path = "../bevy_scene", optional = true, version = "0.9.0-dev" }
bevy_sprite = { path = "../bevy_sprite", optional = true, version = "0.9.0-dev" }
bevy_text = { path = "../bevy_text", optional = true, version = "0.9.0-dev" }
bevy_ui = { path = "../bevy_ui", optional = true, version = "0.9.0-dev" }
bevy_ui_navigation = { path = "../bevy_ui_navigation", optional = true, version = "0.9.0-dev" }
bevy_winit = { path = "../bevy_winit", optional = true, version = "0.9.0-dev" }
bevy_gilrs = { path = "../bevy_gilrs", optional = true, version = "0.9.0-dev" }

Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ pub mod ui {
pub use bevy_ui::*;
}

#[cfg(feature = "bevy_ui_navigation")]
pub mod ui_navigation {
//! Generic cursor navigation.
pub use bevy_ui_navigation::*;
}

#[cfg(feature = "bevy_winit")]
pub mod winit {
//! Window creation, configuration, and handling
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_internal/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub use crate::text::prelude::*;
#[cfg(feature = "bevy_ui")]
pub use crate::ui::prelude::*;

#[doc(hidden)]
#[cfg(feature = "bevy_ui_navigation")]
pub use crate::ui_navigation::prelude::*;

#[doc(hidden)]
#[cfg(feature = "bevy_dynamic_plugin")]
pub use crate::dynamic_plugin::*;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bevy_sprite = { path = "../bevy_sprite", version = "0.9.0-dev" }
bevy_text = { path = "../bevy_text", version = "0.9.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.9.0-dev" }
bevy_window = { path = "../bevy_window", version = "0.9.0-dev" }
bevy_ui_navigation = { path = "../bevy_ui_navigation", version = "0.9.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.9.0-dev" }

# other
Expand Down
66 changes: 20 additions & 46 deletions crates/bevy_ui/src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
widget::{Button, ImageMode},
CalculatedSize, FocusPolicy, Interaction, Node, Style, UiColor, UiImage,
CalculatedSize, Hover, Node, Style, UiColor, UiImage,
};
use bevy_ecs::{
bundle::Bundle,
Expand All @@ -15,6 +15,7 @@ use bevy_render::{
};
use bevy_text::{Text, TextAlignment, TextSection, TextStyle};
use bevy_transform::prelude::{GlobalTransform, Transform};
use bevy_ui_navigation::prelude::{Focusable, MenuBuilder, MenuSetting};

/// The basic UI node
#[derive(Bundle, Clone, Debug, Default)]
Expand All @@ -27,8 +28,6 @@ pub struct NodeBundle {
pub color: UiColor,
/// Describes the image of the node
pub image: UiImage,
/// Whether this node should block interaction with lower nodes
pub focus_policy: FocusPolicy,
/// The transform of the node
pub transform: Transform,
/// The global transform of the node
Expand All @@ -39,6 +38,18 @@ pub struct NodeBundle {
pub computed_visibility: ComputedVisibility,
}

/// A menu. All [`Focusable`] transitive children of this entity will
/// be part of this menu.
#[derive(Bundle)]
pub struct MenuBundle {
#[bundle]
pub node_bundle: NodeBundle,
/// From which [`Focusable`] is this menu accessible (if any).
pub menu: MenuBuilder,
/// How this menu should behave.
pub setting: MenuSetting,
}

/// A UI node that is an image
#[derive(Bundle, Clone, Debug, Default)]
pub struct ImageBundle {
Expand All @@ -54,8 +65,6 @@ pub struct ImageBundle {
pub color: UiColor,
/// The image of the node
pub image: UiImage,
/// Whether this node should block interaction with lower nodes
pub focus_policy: FocusPolicy,
/// The transform of the node
pub transform: Transform,
/// The global transform of the node
Expand All @@ -67,7 +76,7 @@ pub struct ImageBundle {
}

/// A UI node that is text
#[derive(Bundle, Clone, Debug)]
#[derive(Bundle, Clone, Debug, Default)]
pub struct TextBundle {
/// Describes the size of the node
pub node: Node,
Expand All @@ -77,8 +86,6 @@ pub struct TextBundle {
pub text: Text,
/// The calculated size based on the given image
pub calculated_size: CalculatedSize,
/// Whether this node should block interaction with lower nodes
pub focus_policy: FocusPolicy,
/// The transform of the node
pub transform: Transform,
/// The global transform of the node
Expand Down Expand Up @@ -123,35 +130,17 @@ impl TextBundle {
}
}

impl Default for TextBundle {
fn default() -> Self {
TextBundle {
focus_policy: FocusPolicy::Pass,
text: Default::default(),
node: Default::default(),
calculated_size: Default::default(),
style: Default::default(),
transform: Default::default(),
global_transform: Default::default(),
visibility: Default::default(),
computed_visibility: Default::default(),
}
}
}

/// A UI node that is a button
#[derive(Bundle, Clone, Debug)]
#[derive(Bundle, Clone, Debug, Default)]
pub struct ButtonBundle {
/// Describes the size of the node
pub node: Node,
/// Marker component that signals this node is a button
pub button: Button,
/// Describes the style including flexbox settings
pub style: Style,
/// Describes whether and how the button has been interacted with by the input
pub interaction: Interaction,
/// Whether this node should block interaction with lower nodes
pub focus_policy: FocusPolicy,
/// How this button fits with other ones
pub focusable: Focusable,
/// The color of the node
pub color: UiColor,
/// The image of the node
Expand All @@ -164,25 +153,10 @@ pub struct ButtonBundle {
pub visibility: Visibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
pub computed_visibility: ComputedVisibility,
/// Handle hovering state of the button
pub hover: Hover,
}

impl Default for ButtonBundle {
fn default() -> Self {
ButtonBundle {
button: Button,
interaction: Default::default(),
focus_policy: Default::default(),
node: Default::default(),
style: Default::default(),
color: Default::default(),
image: Default::default(),
transform: Default::default(),
global_transform: Default::default(),
visibility: Default::default(),
computed_visibility: Default::default(),
}
}
}
/// Configuration for cameras related to UI.
///
/// When a [`Camera`] doesn't have the [`UiCameraConfig`] component,
Expand Down
Loading