Skip to content

Commit

Permalink
Renamed feature to "bevy_ui_debug"
Browse files Browse the repository at this point in the history
  • Loading branch information
ickshonpe committed Dec 7, 2024
1 parent 0c5d633 commit cc68bd2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bevy_ui_picking_backend = [
]

# Provides a debug overlay for bevy UI
bevy_ui_debug = []
bevy_ui_debug = ["bevy_internal/bevy_ui_debug"]

# Force dynamic linking, which improves iterative compile times
dynamic_linking = ["dep:bevy_dylib", "bevy_internal/dynamic_linking"]
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ bevy_sprite_picking_backend = [
# Provides a UI picking backend
bevy_ui_picking_backend = ["bevy_picking", "bevy_ui/bevy_ui_picking_backend"]

# Provides a UI debug overlay
bevy_ui_debug = ["bevy_ui?/bevy_ui_debug"]

# Enable support for the ios_simulator by downgrading some rendering capabilities
ios_simulator = ["bevy_pbr?/ios_simulator", "bevy_render?/ios_simulator"]

Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ pub use focus::*;
pub use geometry::*;
pub use layout::*;
pub use measurement::*;
use render::debug_overlay::UiDebugOptions;
pub use render::*;
pub use ui_material::*;
pub use ui_node::*;

use widget::{ImageNode, ImageNodeSize};

/// The UI prelude.
///
/// This includes the most common types in this crate, re-exported for your convenience.
pub mod prelude {
#[doc(hidden)]
#[cfg(feature = "bevy_ui_debug")]
pub use crate::render::UiDebugOptions;
#[allow(deprecated)]
#[doc(hidden)]
pub use crate::widget::TextBundle;
Expand Down Expand Up @@ -231,6 +234,7 @@ impl Plugin for UiPlugin {
return;
}

#[cfg(feature = "bevy_ui_debug")]
app.init_resource::<UiDebugOptions>();

build_ui_render(app);
Expand Down
14 changes: 9 additions & 5 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pub mod box_shadow;
pub mod debug_overlay;
mod pipeline;
mod render_pass;
mod ui_material_pipeline;
pub mod ui_texture_slice_pipeline;

#[cfg(feature = "bevy_ui_debug")]
mod debug_overlay;

use crate::widget::ImageNode;
use crate::{
experimental::UiChildren, BackgroundColor, BorderColor, BoxShadowSamples, CalculatedClip,
Expand Down Expand Up @@ -42,7 +44,8 @@ use bevy_render::{
};
use bevy_sprite::TextureAtlasLayout;
use bevy_sprite::{BorderRect, SpriteAssetEvents};
use debug_overlay::extract_debug_overlay;
#[cfg(feature = "bevy_ui_debug")]
pub use debug_overlay::UiDebugOptions;

use crate::{Display, Node};
use bevy_text::{ComputedTextBlock, PositionedGlyph, TextColor, TextLayoutInfo};
Expand Down Expand Up @@ -100,7 +103,7 @@ pub enum RenderUiSystem {
ExtractTextureSlice,
ExtractBorders,
ExtractText,
ExtractDebugOverlay,
ExtractDebug,
}

pub fn build_ui_render(app: &mut App) {
Expand Down Expand Up @@ -128,7 +131,7 @@ pub fn build_ui_render(app: &mut App) {
RenderUiSystem::ExtractTextureSlice,
RenderUiSystem::ExtractBorders,
RenderUiSystem::ExtractText,
RenderUiSystem::ExtractDebugOverlay,
RenderUiSystem::ExtractDebug,
)
.chain(),
)
Expand All @@ -140,7 +143,8 @@ pub fn build_ui_render(app: &mut App) {
extract_uinode_images.in_set(RenderUiSystem::ExtractImages),
extract_uinode_borders.in_set(RenderUiSystem::ExtractBorders),
extract_text_sections.in_set(RenderUiSystem::ExtractText),
extract_debug_overlay.in_set(RenderUiSystem::ExtractDebugOverlay),
#[cfg(feature = "bevy_ui_debug")]
debug_overlay::extract_debug_overlay.in_set(RenderUiSystem::ExtractDebug),
),
)
.add_systems(
Expand Down
9 changes: 3 additions & 6 deletions examples/testbed/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
.add_systems(Startup, setup)
.add_systems(Update, update_scroll_position);

#[cfg(feature = "bevy_ui_debug_overlay")]
#[cfg(feature = "bevy_ui_debug")]
app.add_systems(Update, toggle_debug_overlay);

app.run();
Expand Down Expand Up @@ -344,12 +344,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
});
}

#[cfg(feature = "bevy_ui_debug_overlay")]
#[cfg(feature = "bevy_ui_debug")]
// The system that will enable/disable the debug outlines around the nodes
fn toggle_debug_overlay(
input: Res<ButtonInput<KeyCode>>,
mut options: ResMut<bevy::ui::debug_overlay::UiDebugOptions>,
) {
fn toggle_debug_overlay(input: Res<ButtonInput<KeyCode>>, mut options: ResMut<UiDebugOptions>) {
info_once!("The debug outlines are enabled, press Space to turn them on/off");
if input.just_pressed(KeyCode::Space) {
// The toggle method will enable the debug_overlay if disabled and disable if enabled
Expand Down

0 comments on commit cc68bd2

Please sign in to comment.