Description
What problem does this solve or what need does it fill?
Windows can't be closed from within bevy, #3575 mentions windows as entities and i really like that idea of that, so here is a proposal on how it could be done
What solution would you like?
WindowId
is now Entity
Extend Commands
with a window
method returns WindowCommands
similar to how the entity
method returns EntityCommands
, WindowCommandQueued
will implement Command
and on write
send itself as an event that window backends like bevy_winit
will process.
Window
should be separated into different components, WindowCursor
, WindowCursorPosition
, WindowHandle
, WindowPosition
, WindowResizeConstraints
, WindowResolution
, WindowTitle
, as well as these markers WindowCurrentlyFocused
(WindowFocused
is taken by a window event), WindowDecorated
, WindowResizable
.
A world query struct containing all these components and markers should be publicly exposed..
Windows should be spawned like an entity in Commands
with a WindowDescriptor
component, window backends should query Added<WindowDescriptor>
and create the windows for them, while also applying a Window
marker confirming they have been created, query Added<Window>
or use a WindowCreated
event to get newly created windows.
Despawning windows should be done just as entities (as they are now entities), window backends should close/destroy windows their internal component has been dropped, e.g. WinitWindow
(wrapper around winit's Window
that destroys itself on drop)
A resource called PrimaryWindow
contains the entity id of initial window created by WindowPlugin
, this replaces Windows::primary
WindowPlugin
should change exit_on_close
into a enum called ExitCondition
with the values OnPrimaryClosed
(when primary window is closed), OnAllClosed
(when all windows are closed), DontExit
(keep app headless)
Activity