Skip to content

Commit

Permalink
Align the behavior of the ui feature with egui (#477)
Browse files Browse the repository at this point in the history
* Make `ui` and `egui` features behave the same way

* README.md

* RELEASES.md

* Document

* RELEASES.md

* Document

* CI

* typo
  • Loading branch information
Shute052 authored Feb 20, 2024
1 parent 9628f6b commit 88d330e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ opt-level = 3
members = ["./", "tools/ci", "macros"]

[features]
default = ['asset', 'ui', 'block_ui_interactions']
default = ['asset', 'ui']

# Allow using the `InputMap` as `bevy::asset::Asset`.
asset = ['bevy/bevy_asset']

# Add support for 'bevy::ui' integration:
# - Allow 'bevy::ui' to take priority over actions when processing inputs.
# - Automatic process clicks on 'bevy::ui' buttons that attached `ActionStateDriver` to drive corresponding actions.
# - Allow using `MockUIInteraction` for 'bevy::ui' input mocking.
ui = ['bevy/bevy_ui']

# Allow 'bevy::ui' to take priority over actions when processing inputs.
block_ui_interactions = []
# Disable the priority of 'bevy::ui' when processing inputs.
no_ui_priority = []

# Add support for 'egui' integration:
# - Allow 'egui' to take priority over actions when processing inputs.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ This snippet is the `minimal.rs` example from the [`examples`](./examples) folde

## Crate Feature Flags

This crate has four feature flags: `asset`, `ui`, `block_ui_interactions`, and `egui`.
This crate has four feature flags: `asset`, `ui`, `no_ui_priority`, and `egui`.
Please refer to the `[features]` section in the [`Cargo.toml`](./Cargo.toml) for detailed information about their configurations.
8 changes: 8 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes

## Unreleased

### Breaking Changes

- removed the `block_ui_interactions` feature:
- by default, this library will prioritize `bevy::ui`.
- if you want to disable this priority, add the newly added `no_ui_priority` feature to your configuration.

## Version 0.13.0

### Breaking Changes
Expand Down
6 changes: 2 additions & 4 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ pub fn update_action_state<A: Actionlike>(
mut mouse_wheel: EventReader<MouseWheel>,
mut mouse_motion: EventReader<MouseMotion>,
clash_strategy: Res<ClashStrategy>,
#[cfg(all(feature = "ui", feature = "block_ui_interactions"))] interactions: Query<
&Interaction,
>,
#[cfg(all(feature = "ui", not(feature = "no_ui_priority")))] interactions: Query<&Interaction>,
#[cfg(feature = "egui")] mut maybe_egui: Query<(Entity, &'static mut EguiContext)>,
action_state: Option<ResMut<ActionState<A>>>,
input_map: Option<Res<InputMap<A>>>,
Expand All @@ -91,7 +89,7 @@ pub fn update_action_state<A: Actionlike>(
let mouse_motion: Vec<MouseMotion> = mouse_motion.read().cloned().collect();

// If use clicks on a button, do not apply them to the game state
#[cfg(all(feature = "ui", feature = "block_ui_interactions"))]
#[cfg(all(feature = "ui", not(feature = "no_ui_priority")))]
let (mouse_buttons, mouse_wheel) = if interactions
.iter()
.any(|&interaction| interaction != Interaction::None)
Expand Down
2 changes: 1 addition & 1 deletion tools/ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn main() {
}

// The features the lib offers
let lib_features = ["asset", "ui", "block_ui_interactions", "egui"];
let lib_features = ["asset", "ui", "no_ui_priority", "egui"];

// Generate all possible combinations of lib features
// and convert them into '--features=<FEATURE_A,FEATURE_B,...>'
Expand Down

0 comments on commit 88d330e

Please sign in to comment.