Change window position types from tuple to vec (#5276)
Resolves #5004. As suggested in the original issue, change tuple types to their corresponding vector type. ## migration guide Changed the following fields - `WindowCommand::SetWindowMode.resolution` from `(u32, u32)` to `UVec2` - `WindowCommand::SetResolution.logical_resolution` from `(f32, f32)` to `Vec2` Co-authored-by: Daniel Liu <mr.picklepinosaur@gmail.com>
This commit is contained in:
parent
2344ada89f
commit
3203a8585c
@ -1,4 +1,4 @@
|
|||||||
use bevy_math::{DVec2, IVec2, Vec2};
|
use bevy_math::{DVec2, IVec2, UVec2, Vec2};
|
||||||
use bevy_utils::{tracing::warn, Uuid};
|
use bevy_utils::{tracing::warn, Uuid};
|
||||||
use raw_window_handle::RawWindowHandle;
|
use raw_window_handle::RawWindowHandle;
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ pub enum WindowCommand {
|
|||||||
/// Set the window's [`WindowMode`].
|
/// Set the window's [`WindowMode`].
|
||||||
SetWindowMode {
|
SetWindowMode {
|
||||||
mode: WindowMode,
|
mode: WindowMode,
|
||||||
resolution: (u32, u32),
|
resolution: UVec2,
|
||||||
},
|
},
|
||||||
/// Set the window's title.
|
/// Set the window's title.
|
||||||
SetTitle {
|
SetTitle {
|
||||||
@ -214,7 +214,7 @@ pub enum WindowCommand {
|
|||||||
},
|
},
|
||||||
/// Set the window's resolution.
|
/// Set the window's resolution.
|
||||||
SetResolution {
|
SetResolution {
|
||||||
logical_resolution: (f32, f32),
|
logical_resolution: Vec2,
|
||||||
scale_factor: f64,
|
scale_factor: f64,
|
||||||
},
|
},
|
||||||
/// Set the window's [`PresentMode`].
|
/// Set the window's [`PresentMode`].
|
||||||
@ -447,7 +447,7 @@ impl Window {
|
|||||||
self.requested_width = width;
|
self.requested_width = width;
|
||||||
self.requested_height = height;
|
self.requested_height = height;
|
||||||
self.command_queue.push(WindowCommand::SetResolution {
|
self.command_queue.push(WindowCommand::SetResolution {
|
||||||
logical_resolution: (self.requested_width, self.requested_height),
|
logical_resolution: Vec2::new(self.requested_width, self.requested_height),
|
||||||
scale_factor: self.scale_factor(),
|
scale_factor: self.scale_factor(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -464,7 +464,7 @@ impl Window {
|
|||||||
scale_factor: self.scale_factor(),
|
scale_factor: self.scale_factor(),
|
||||||
});
|
});
|
||||||
self.command_queue.push(WindowCommand::SetResolution {
|
self.command_queue.push(WindowCommand::SetResolution {
|
||||||
logical_resolution: (self.requested_width, self.requested_height),
|
logical_resolution: Vec2::new(self.requested_width, self.requested_height),
|
||||||
scale_factor: self.scale_factor(),
|
scale_factor: self.scale_factor(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -668,7 +668,7 @@ impl Window {
|
|||||||
self.mode = mode;
|
self.mode = mode;
|
||||||
self.command_queue.push(WindowCommand::SetWindowMode {
|
self.command_queue.push(WindowCommand::SetWindowMode {
|
||||||
mode,
|
mode,
|
||||||
resolution: (self.physical_width, self.physical_height),
|
resolution: UVec2::new(self.physical_width, self.physical_height),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// Close the operating system window corresponding to this [`Window`].
|
/// Close the operating system window corresponding to this [`Window`].
|
||||||
|
@ -18,7 +18,7 @@ use bevy_input::{
|
|||||||
mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel},
|
mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel},
|
||||||
touch::TouchInput,
|
touch::TouchInput,
|
||||||
};
|
};
|
||||||
use bevy_math::{ivec2, DVec2, Vec2};
|
use bevy_math::{ivec2, DVec2, UVec2, Vec2};
|
||||||
use bevy_utils::{
|
use bevy_utils::{
|
||||||
tracing::{error, info, trace, warn},
|
tracing::{error, info, trace, warn},
|
||||||
Instant,
|
Instant,
|
||||||
@ -74,7 +74,11 @@ fn change_window(
|
|||||||
match command {
|
match command {
|
||||||
bevy_window::WindowCommand::SetWindowMode {
|
bevy_window::WindowCommand::SetWindowMode {
|
||||||
mode,
|
mode,
|
||||||
resolution: (width, height),
|
resolution:
|
||||||
|
UVec2 {
|
||||||
|
x: width,
|
||||||
|
y: height,
|
||||||
|
},
|
||||||
} => {
|
} => {
|
||||||
let window = winit_windows.get_window(id).unwrap();
|
let window = winit_windows.get_window(id).unwrap();
|
||||||
match mode {
|
match mode {
|
||||||
@ -105,7 +109,11 @@ fn change_window(
|
|||||||
window_dpi_changed_events.send(WindowScaleFactorChanged { id, scale_factor });
|
window_dpi_changed_events.send(WindowScaleFactorChanged { id, scale_factor });
|
||||||
}
|
}
|
||||||
bevy_window::WindowCommand::SetResolution {
|
bevy_window::WindowCommand::SetResolution {
|
||||||
logical_resolution: (width, height),
|
logical_resolution:
|
||||||
|
Vec2 {
|
||||||
|
x: width,
|
||||||
|
y: height,
|
||||||
|
},
|
||||||
scale_factor,
|
scale_factor,
|
||||||
} => {
|
} => {
|
||||||
let window = winit_windows.get_window(id).unwrap();
|
let window = winit_windows.get_window(id).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user