bevy/crates/bevy_ui/src
Jakob Hellermann 218b0fd3b6 bevy_reflect: put serialize into external ReflectSerialize type (#4782)
builds on top of #4780 

# Objective

`Reflect` and `Serialize` are currently very tied together because `Reflect` has a `fn serialize(&self) -> Option<Serializable<'_>>` method. Because of that, we can either implement `Reflect` for types like `Option<T>` with `T: Serialize` and have `fn serialize` be implemented, or without the bound but having `fn serialize` return `None`.

By separating `ReflectSerialize` into a separate type (like how it already is for `ReflectDeserialize`, `ReflectDefault`), we could separately `.register::<Option<T>>()` and `.register_data::<Option<T>, ReflectSerialize>()` only if the type `T: Serialize`.

This PR does not change the registration but allows it to be changed in a future PR.

## Solution

- add the type
```rust
struct ReflectSerialize { .. }
impl<T: Reflect + Serialize> FromType<T> for ReflectSerialize { .. }
```

- remove `#[reflect(Serialize)]` special casing. 

- when serializing reflect value types, look for `ReflectSerialize` in the `TypeRegistry` instead of calling `value.serialize()`
2022-06-20 17:18:58 +00:00
..
flex Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
render Overflow::Hidden doesn't work correctly with scale_factor_override (#3854) 2022-06-12 19:14:48 +00:00
widget bevy_reflect: put serialize into external ReflectSerialize type (#4782) 2022-06-20 17:18:58 +00:00
entity.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
focus.rs bevy_reflect: put serialize into external ReflectSerialize type (#4782) 2022-06-20 17:18:58 +00:00
geometry.rs Move Rect to bevy_ui and rename it to UiRect (#4276) 2022-04-25 19:20:38 +00:00
lib.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
ui_node.rs Clippy improvements (#4665) 2022-05-31 01:38:07 +00:00
update.rs Split bevy_hierarchy out from bevy_transform (#4168) 2022-03-15 01:54:05 +00:00