[Merged by Bors] - Added multi windows check for bevy_ui Interaction.#5225
[Merged by Bors] - Added multi windows check for bevy_ui Interaction.#5225fadhliazhari wants to merge 7 commits intobevyengine:mainfrom fadhliazhari:multiple-window-ui-interaction
Interaction.#5225Conversation
`Interaction` focus system will get first available window's cursor position instead of just primary window.
There was a problem hiding this comment.
There is a situation that this handles poorly:
You have two windows:
- Window 1 with UI elements
- Window 2 without the UI elements
When the mouse hovers over Window 2 I believe, this patch will activate the button under the corresponding position in Window 1.
I suggest this alternative: get the Window for windows.get(id) where id is the target: RenderTarget::Window(WindowId) field of the Camera component of the entity with the CameraUi marker component. Probably requires adding a query to ui_focus_system or store the ID in an additional resource.
This is more difficult, because you can have multiple ui cameras. I think currently, it would be fine to take the windows id of the first ui camera and keep the issue open. A design that accounts for all ui cameras might be way harder to handle properly.
Now the focus system will consider the currently focused window instead of all window
nicopap
left a comment
There was a problem hiding this comment.
I think we should limit the query to stuff with a CameraUi component. Otherwise, we might pick up other types of camera.
crates/bevy_ui/src/focus.rs
Outdated
| if let Some(&CameraUi { | ||
| is_enabled: false, .. | ||
| }) = camera_ui | ||
| { | ||
| return None; | ||
| } |
There was a problem hiding this comment.
With the change suggested on the query parameter, you can replace this with if !camera_ui.is_enabled.
There was a problem hiding this comment.
The user are able to add in any camera without this component.
|
Give me a minute and I'll give you a third review. |
nicopap
left a comment
There was a problem hiding this comment.
LGTM I'd like this merged
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
|
bors r+ |
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes #5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
Interaction.Interaction.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
This enables having different UI per camera. With bevyengine#5225, this enables having different interactive UIs per window. Although, to properly complete this, the focus system will need to account for RenderLayer of UI nodes.
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes bevyengine#5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes bevyengine#5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
# Objective - Currently bevy_ui only checks for primary window cursor position to determine `Interaction` behavior. - Added checks for focused window where cursor position is available. - Fixes bevyengine#5224. ## Solution - Added checks for focused windows in `Interaction` focus system. ## Follow Up - All windows with camera will be rendering the UI elements right now. - We will need some way to tell which camera to render which UI. --- Co-authored-by: fadhliazhari <44402264+fadhliazhari@users.noreply.github.com>
Objective
Interactionbehavior.Solution
Interactionfocus system.Follow Up