bevy/crates
Aceeri ddfafab971 Windows as Entities (#5589)
# Objective

Fix https://github.com/bevyengine/bevy/issues/4530

- Make it easier to open/close/modify windows by setting them up as `Entity`s with a `Window` component.
- Make multiple windows very simple to set up. (just add a `Window` component to an entity and it should open)

## Solution

- Move all properties of window descriptor to ~components~ a component.
- Replace `WindowId` with `Entity`.
- ~Use change detection for components to update backend rather than events/commands. (The `CursorMoved`/`WindowResized`/... events are kept for user convenience.~
  Check each field individually to see what we need to update, events are still kept for user convenience.

---

## Changelog

- `WindowDescriptor` renamed to `Window`.
    - Width/height consolidated into a `WindowResolution` component.
    - Requesting maximization/minimization is done on the [`Window::state`] field.
- `WindowId` is now `Entity`.

## Migration Guide

- Replace `WindowDescriptor` with `Window`.
    - Change `width` and `height` fields in a `WindowResolution`, either by doing
      ```rust
      WindowResolution::new(width, height) // Explicitly
      // or using From<_> for tuples for convenience
      (1920., 1080.).into()
      ```
- Replace any `WindowCommand` code to just modify the `Window`'s fields directly  and creating/closing windows is now by spawning/despawning an entity with a `Window` component like so:
  ```rust
  let window = commands.spawn(Window { ... }).id(); // open window
  commands.entity(window).despawn(); // close window
  ```

## Unresolved
- ~How do we tell when a window is minimized by a user?~
  ~Currently using the `Resize(0, 0)` as an indicator of minimization.~
  No longer attempting to tell given how finnicky this was across platforms, now the user can only request that a window be maximized/minimized.
  
 ## Future work
 - Move `exit_on_close` functionality out from windowing and into app(?)
 - https://github.com/bevyengine/bevy/issues/5621
 - https://github.com/bevyengine/bevy/issues/7099
 - https://github.com/bevyengine/bevy/issues/7098


Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2023-01-19 00:38:28 +00:00
..
bevy_animation Smooth Transition between Animations (#6922) 2023-01-09 19:24:51 +00:00
bevy_app Docs: App::run() might never return; effect of WinitSettings::return_from_run. (#7228) 2023-01-18 23:02:38 +00:00
bevy_asset fix load_internal_binary_asset with debug_asset_server (#7246) 2023-01-18 02:07:26 +00:00
bevy_audio AudioOutput is actually a normal resource now, not a non-send resource (#7262) 2023-01-18 17:20:26 +00:00
bevy_core Break CorePlugin into TaskPoolPlugin, TypeRegistrationPlugin, FrameCountPlugin. (#7083) 2023-01-05 11:42:35 +00:00
bevy_core_pipeline fix bloom viewport (#6802) 2023-01-17 17:39:28 +00:00
bevy_derive Fix ndk-macro link (#7027) 2022-12-25 05:06:03 +00:00
bevy_diagnostic Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
bevy_dylib Release 0.9.0 (#6568) 2022-11-12 20:01:29 +00:00
bevy_dynamic_plugin Adapt path type of dynamically_load_plugin (#6734) 2022-12-05 23:39:43 +00:00
bevy_ecs Fix tiny clippy issue for upcoming Rust version (#7266) 2023-01-18 17:20:27 +00:00
bevy_ecs_compile_fail_tests Fix clippy lints and failed test with Rust 1.66 (#6945) 2022-12-15 18:05:15 +00:00
bevy_encase_derive add helper for macro to get either bevy::x or bevy_x depending on how it was imported (#7164) 2023-01-11 21:12:02 +00:00
bevy_gilrs Gamepad events refactor (#6965) 2023-01-09 19:24:52 +00:00
bevy_gltf enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00
bevy_hierarchy Add ReplaceChildren and ClearChildren EntityCommands (#6035) 2023-01-16 21:24:15 +00:00
bevy_input Fix incorrect behavior of just_pressed and just_released in Input<GamepadButton> (#7238) 2023-01-16 21:09:24 +00:00
bevy_internal Expose symphonia features from rodio in bevy_audio and bevy (#6388) 2023-01-09 19:05:30 +00:00
bevy_log Fix suppression of all console logs when trace_tracy is enabled (#6955) 2022-12-20 23:45:43 +00:00
bevy_macro_utils Add bevy_ecs::schedule_v3 module (#6587) 2023-01-17 01:39:17 +00:00
bevy_math Improve code/comments for Ray::intersect_plane and its tests (#6823) 2022-12-05 22:49:06 +00:00
bevy_mikktspace Release 0.9.0 (#6568) 2022-11-12 20:01:29 +00:00
bevy_pbr Make PipelineCache internally mutable. (#7205) 2023-01-16 15:41:14 +00:00
bevy_ptr Improve safety for BlobVec::replace_unchecked (#7181) 2023-01-16 15:41:12 +00:00
bevy_reflect bevy_reflect: Add simple enum support to reflection paths (#6560) 2023-01-11 16:46:27 +00:00
bevy_reflect_compile_fail_tests bevy_reflect: Add compile fail tests for bevy_reflect (#7041) 2023-01-02 21:07:33 +00:00
bevy_render Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
bevy_scene Fix beta clippy lints (#7154) 2023-01-11 09:51:22 +00:00
bevy_sprite Remove VerticalAlign from TextAlignment (#6807) 2023-01-18 02:19:17 +00:00
bevy_tasks Thread executor for running tasks on specific threads. (#7087) 2023-01-10 22:32:42 +00:00
bevy_text Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
bevy_time Add bevy_ecs::schedule_v3 module (#6587) 2023-01-17 01:39:17 +00:00
bevy_transform Improve change detection behavior for transform propagation (#6870) 2023-01-17 22:26:51 +00:00
bevy_ui Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
bevy_utils Add bevy_ecs::schedule_v3 module (#6587) 2023-01-17 01:39:17 +00:00
bevy_window Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00
bevy_winit Windows as Entities (#5589) 2023-01-19 00:38:28 +00:00