Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Derive Reflect + FromReflect for window event types #6235

Closed
wants to merge 18 commits into from

Conversation

TehPers
Copy link
Contributor

@TehPers TehPers commented Oct 11, 2022

Objective

The window event types currently don't support reflection. This PR adds support to them (as requested here).

Solution

Implement Reflect + FromReflect for window event types. Relevant traits are also being reflected with #[reflect(...)] attributes.

Additionally, this PR derives Reflect + FromReflect for WindowDescriptor and the types it depends on so that CreateWindow events can be fully manipulated through reflection.

Finally, this PR adds FromReflect for PathBuf as a value type, which is needed for FileDragAndDrop.

This adds the "glam" feature to the bevy_reflect dependency for package bevy_window. Since bevy_window transitively depends on glam already, all this brings in are the reflection impls.

Open questions

Should app.register_type::<PathBuf>(); be moved to CorePlugin? I added it to WindowPlugin because that's where it's used and CorePlugin doesn't seem to register all the missing std types, but it would also make sense in CorePlugin I believe since it's a commonly used type.


Changelog

Added:

  • Implemented Reflect + FromReflect for window events and related types. These types are automatically registered when adding the WindowPlugin.

@TehPers TehPers changed the title Implement Reflect + FromReflect on window types Derive Reflect + FromReflect for window types Oct 11, 2022
@TehPers TehPers changed the title Derive Reflect + FromReflect for window types Derive Reflect + FromReflect for window event types Oct 11, 2022
@MrGVSV MrGVSV added A-Windowing Platform-agnostic interface layer to run your app in C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types labels Oct 11, 2022
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments, otherwise looks good!

crates/bevy_window/src/window.rs Outdated Show resolved Hide resolved
crates/bevy_window/src/window.rs Outdated Show resolved Hide resolved
crates/bevy_window/src/window.rs Outdated Show resolved Hide resolved
crates/bevy_window/src/window.rs Outdated Show resolved Hide resolved
crates/bevy_window/src/lib.rs Show resolved Hide resolved
crates/bevy_window/src/lib.rs Outdated Show resolved Hide resolved
@TehPers
Copy link
Contributor Author

TehPers commented Oct 11, 2022

CI error is caused by having multiple #[reflect]/#[reflect_value]s on a type. This is resolved by #6237. Once that PR merges, I'll merge the changes into this branch and the errors should be fixed.

Edit: changes are merged now

@MrGVSV
Copy link
Member

MrGVSV commented Oct 24, 2022

@TehPers Could you rebase this PR?

@MrGVSV
Copy link
Member

MrGVSV commented Dec 3, 2022

@TehPers looks like there's been some more conflicts added. Could you rebase? I'm hoping we can actually try to get this in soon so it's not just sitting around increasing in conflicts for you to resolve 😅

@cart
Copy link
Member

cart commented Dec 9, 2022

bors r+

bors bot pushed a commit that referenced this pull request Dec 9, 2022
# Objective

The window event types currently don't support reflection. This PR adds support to them (as requested [here](#6223 (comment))).

## Solution

Implement `Reflect` + `FromReflect` for window event types. Relevant traits are also being reflected with `#[reflect(...)]` attributes.

Additionally, this PR derives `Reflect` + `FromReflect` for `WindowDescriptor` and the types it depends on so that `CreateWindow` events can be fully manipulated through reflection.

Finally, this PR adds `FromReflect` for `PathBuf` as a value type, which is needed for `FileDragAndDrop`.

This adds the "glam" feature to the `bevy_reflect` dependency for package `bevy_window`. Since `bevy_window` transitively depends on `glam` already, all this brings in are the reflection `impl`s.

## Open questions

Should `app.register_type::<PathBuf>();` be moved to `CorePlugin`? I added it to `WindowPlugin` because that's where it's used and `CorePlugin` doesn't seem to register all the missing std types, but it would also make sense in `CorePlugin` I believe since it's a commonly used type.

---

## Changelog

Added:
- Implemented `Reflect` + `FromReflect` for window events and related types. These types are automatically registered when adding the `WindowPlugin`.
@bors bors bot changed the title Derive Reflect + FromReflect for window event types [Merged by Bors] - Derive Reflect + FromReflect for window event types Dec 9, 2022
@bors bors bot closed this Dec 9, 2022
@TehPers TehPers deleted the window-events-derive-reflect branch December 9, 2022 05:21
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
)

# Objective

The window event types currently don't support reflection. This PR adds support to them (as requested [here](bevyengine#6223 (comment))).

## Solution

Implement `Reflect` + `FromReflect` for window event types. Relevant traits are also being reflected with `#[reflect(...)]` attributes.

Additionally, this PR derives `Reflect` + `FromReflect` for `WindowDescriptor` and the types it depends on so that `CreateWindow` events can be fully manipulated through reflection.

Finally, this PR adds `FromReflect` for `PathBuf` as a value type, which is needed for `FileDragAndDrop`.

This adds the "glam" feature to the `bevy_reflect` dependency for package `bevy_window`. Since `bevy_window` transitively depends on `glam` already, all this brings in are the reflection `impl`s.

## Open questions

Should `app.register_type::<PathBuf>();` be moved to `CorePlugin`? I added it to `WindowPlugin` because that's where it's used and `CorePlugin` doesn't seem to register all the missing std types, but it would also make sense in `CorePlugin` I believe since it's a commonly used type.

---

## Changelog

Added:
- Implemented `Reflect` + `FromReflect` for window events and related types. These types are automatically registered when adding the `WindowPlugin`.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
)

# Objective

The window event types currently don't support reflection. This PR adds support to them (as requested [here](bevyengine#6223 (comment))).

## Solution

Implement `Reflect` + `FromReflect` for window event types. Relevant traits are also being reflected with `#[reflect(...)]` attributes.

Additionally, this PR derives `Reflect` + `FromReflect` for `WindowDescriptor` and the types it depends on so that `CreateWindow` events can be fully manipulated through reflection.

Finally, this PR adds `FromReflect` for `PathBuf` as a value type, which is needed for `FileDragAndDrop`.

This adds the "glam" feature to the `bevy_reflect` dependency for package `bevy_window`. Since `bevy_window` transitively depends on `glam` already, all this brings in are the reflection `impl`s.

## Open questions

Should `app.register_type::<PathBuf>();` be moved to `CorePlugin`? I added it to `WindowPlugin` because that's where it's used and `CorePlugin` doesn't seem to register all the missing std types, but it would also make sense in `CorePlugin` I believe since it's a commonly used type.

---

## Changelog

Added:
- Implemented `Reflect` + `FromReflect` for window events and related types. These types are automatically registered when adding the `WindowPlugin`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types A-Windowing Platform-agnostic interface layer to run your app in C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants