Skip to content

Commit

Permalink
Compiles again, maybe not entirely correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceeri committed Nov 20, 2022
1 parent 248c1c5 commit f4fe9c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/flex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ pub fn flex_node_system(
(With<Node>, Changed<CalculatedSize>),
>,
children_query: Query<(Entity, &Children), (With<Node>, Changed<Children>)>,
removed_children: RemovedComponent<Children>,
removed_children: RemovedComponents<Children>,
mut node_transform_query: Query<(Entity, &mut Node, &mut Transform, Option<&Parent>)>,
removed_nodes: RemovedComponent<Node>,
removed_nodes: RemovedComponents<Node>,
) {
// update window root nodes
for (window_id, window_resolution) in windows.iter() {
Expand Down
19 changes: 12 additions & 7 deletions crates/bevy_ui/src/focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::{camera::RenderTarget, prelude::Camera, view::ComputedVisibility};
use bevy_transform::components::GlobalTransform;
use bevy_utils::FloatOrd;
use bevy_window::{CursorPosition, Window, WindowFocus};
use bevy_window::{CursorPosition, Window, WindowFocus, WindowResolution};
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;

Expand Down Expand Up @@ -81,7 +81,7 @@ pub struct NodeQuery {
pub fn ui_focus_system(
mut state: Local<State>,
camera: Query<(&Camera, Option<&UiCameraConfig>)>,
cursor_positions: Query<(&CursorPosition, &WindowFocus), With<Window>>,
cursor_positions: Query<(&CursorPosition, &WindowResolution, &WindowFocus), With<Window>>,
mouse_button_input: Res<Input<MouseButton>>,
touches_input: Res<Touches>,
ui_stack: Res<UiStack>,
Expand Down Expand Up @@ -122,12 +122,17 @@ pub fn ui_focus_system(
None
}
})
//.filter(|window| window.is_focused())
.find_map(|window| {
window.cursor_position().map(|mut cursor_pos| {
cursor_pos.y = window.height() - cursor_pos.y;
cursor_pos
})
cursor_positions
.get(window)
.ok()
.map(|(position, resolution, _)| {
position.physical_position().map(|mut cursor_pos| {
cursor_pos.y = resolution.height() - cursor_pos.y;
cursor_pos.as_vec2()
})
})
.flatten()
})
.or_else(|| touches_input.first_pressed_position());

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub fn extract_uinodes(
images: Extract<Res<Assets<Image>>>,
ui_stack: Extract<Res<UiStack>>,
primary_window: Option<Res<PrimaryWindow>>,
windows: Query<(Entity, &WindowResolution), With<Window>>,
windows: Query<&WindowResolution, With<Window>>,
uinode_query: Extract<
Query<(
&Node,
Expand All @@ -219,7 +219,7 @@ pub fn extract_uinodes(
)>,
>,
) {
let primary_window = if let Some(primary_window) = &*primary_window {
let primary_window = if let Some(primary_window) = primary_window.as_ref() {
primary_window
} else {
bevy_log::error!("No primary window found");
Expand Down

0 comments on commit f4fe9c2

Please sign in to comment.