mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
add position to WindowDescriptor (#3070)
# Objective Set initial position of the window, so I can start it at the left side of the view automatically, used with `cargo watch` ## Solution add window position to WindowDescriptor
This commit is contained in:
parent
225d6a138f
commit
aac09353fd
2 changed files with 21 additions and 0 deletions
|
@ -525,6 +525,7 @@ impl Window {
|
||||||
pub struct WindowDescriptor {
|
pub struct WindowDescriptor {
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
pub height: f32,
|
pub height: f32,
|
||||||
|
pub position: Option<Vec2>,
|
||||||
pub resize_constraints: WindowResizeConstraints,
|
pub resize_constraints: WindowResizeConstraints,
|
||||||
pub scale_factor_override: Option<f64>,
|
pub scale_factor_override: Option<f64>,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
|
@ -544,6 +545,7 @@ impl Default for WindowDescriptor {
|
||||||
title: "bevy".to_string(),
|
title: "bevy".to_string(),
|
||||||
width: 1280.,
|
width: 1280.,
|
||||||
height: 720.,
|
height: 720.,
|
||||||
|
position: None,
|
||||||
resize_constraints: WindowResizeConstraints::default(),
|
resize_constraints: WindowResizeConstraints::default(),
|
||||||
scale_factor_override: None,
|
scale_factor_override: None,
|
||||||
vsync: true,
|
vsync: true,
|
||||||
|
|
|
@ -44,9 +44,28 @@ impl WinitWindows {
|
||||||
let WindowDescriptor {
|
let WindowDescriptor {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
position,
|
||||||
scale_factor_override,
|
scale_factor_override,
|
||||||
..
|
..
|
||||||
} = window_descriptor;
|
} = window_descriptor;
|
||||||
|
|
||||||
|
if let Some(position) = position {
|
||||||
|
if let Some(sf) = scale_factor_override {
|
||||||
|
winit_window_builder = winit_window_builder.with_position(
|
||||||
|
winit::dpi::LogicalPosition::new(
|
||||||
|
position[0] as f64,
|
||||||
|
position[1] as f64,
|
||||||
|
)
|
||||||
|
.to_physical::<f64>(*sf),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
winit_window_builder =
|
||||||
|
winit_window_builder.with_position(winit::dpi::LogicalPosition::new(
|
||||||
|
position[0] as f64,
|
||||||
|
position[1] as f64,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(sf) = scale_factor_override {
|
if let Some(sf) = scale_factor_override {
|
||||||
winit_window_builder.with_inner_size(
|
winit_window_builder.with_inner_size(
|
||||||
winit::dpi::LogicalSize::new(*width, *height).to_physical::<f64>(*sf),
|
winit::dpi::LogicalSize::new(*width, *height).to_physical::<f64>(*sf),
|
||||||
|
|
Loading…
Add table
Reference in a new issue