-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Windows as entities #4530
Copy link
Copy link
Closed
Labels
A-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Metadata
Metadata
Assignees
Labels
A-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Type
Fields
Give feedbackNo fields configured for issues without a type.
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?
WindowIdis nowEntityExtend
Commandswith awindowmethod returnsWindowCommandssimilar to how theentitymethod returnsEntityCommands,WindowCommandQueuedwill implementCommandand onwritesend itself as an event that window backends likebevy_winitwill process.Windowshould be separated into different components,WindowCursor,WindowCursorPosition,WindowHandle,WindowPosition,WindowResizeConstraints,WindowResolution,WindowTitle, as well as these markersWindowCurrentlyFocused(WindowFocusedis 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
Commandswith aWindowDescriptorcomponent, window backends should queryAdded<WindowDescriptor>and create the windows for them, while also applying aWindowmarker confirming they have been created, queryAdded<Window>or use aWindowCreatedevent 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'sWindowthat destroys itself on drop)A resource called
PrimaryWindowcontains the entity id of initial window created byWindowPlugin, this replaces Windows::primaryWindowPluginshould changeexit_on_closeinto a enum calledExitConditionwith the valuesOnPrimaryClosed(when primary window is closed),OnAllClosed(when all windows are closed),DontExit(keep app headless)