Skip to content

Export the needed parts of Winit or add better utilities for centering a window. #4993

@CalinZBaenen

Description

@CalinZBaenen

What problem does this solve or what need does it fill?

The problem this proposition intents to solve is making the task of centering a window easier.
It intents to remove the need to have dependencies for both bevy and winit.

What solution would you like?

There's multiple ways to o about this.
First, the way I would not like to see, by re-exporting the required parts of winit to center a window: winit::dpi::(::PhysicalPosition) and winit::event_loop(::EventLoop).

Second, the solution I'd like to see implemented, WindowDescriptor.position when set to None should say that the window should be centered, then Bevy can take care of everything behind the scenes.
This also allows all windows to be centered by default.

What alternative(s) have you considered?

The alternative I'm using is to have dependencies for both winit and bevy in my Cargo.toml file:

[[bin]]
name = "bevytest"
path = "./src/main.rs"

[package]
edition = "2021"
version = "0.1.0"
name = "bevy_test"

[profile.dev]
opt-level = 1

[profile.dev.package."*"]
opt-level = 3

[dependencies]
winit = { version = "0.26.0", default-features = false }
bevy = { version="0.7" }

However, this seems inconvenient.

Additional Context

I believe centering the window could be delegated to WindowDescriptor.position = None or a center() method on a Window.
Check out the current solution for centering a window in a Discord-thread on the Bevy Discord guild.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WindowingPlatform-agnostic interface layer to run your app inC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-TrivialNice and easy! A great choice to get started with Bevy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions