From 4710c92a489083a6bba96ddd8cc547843fd19c9e Mon Sep 17 00:00:00 2001 From: Nicola Papale Date: Tue, 11 Jul 2023 07:32:27 +0200 Subject: [PATCH] Add migration for CalculatedSize Fixes #701 --- .../migration-guides/0.10-0.11/_index.md | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/content/learn/migration-guides/0.10-0.11/_index.md b/content/learn/migration-guides/0.10-0.11/_index.md index 24c75a8a61..37e2bbfd32 100644 --- a/content/learn/migration-guides/0.10-0.11/_index.md +++ b/content/learn/migration-guides/0.10-0.11/_index.md @@ -1428,13 +1428,47 @@ pub const ABSOLUTE_STYLE: Style = Style { // Implement all the fields or don't use const ``` +### `CalculatedSize` split + +`CalculatedSize` doesn't exist anymore. + +The data from the `CalculatedSize` `size` field still exist. But it has been +split between the two following components: + +* the new component `bevy::ui::widget::UiImageSize::size`'s method +* the new component `bevy::text::TextLayoutInfo::size`'s field + +```rust +// before: 0.10.1 +fn evaluate_size(query: Query<&CalculatedSize>) { + for calculated in &query { + let size = calculated.size; + // do things with size + } +} +// after: 0.11.0 +use bevy::{ + ui::widget::UiImageSize, + text::TextLayoutInfo, +}; +fn evaluate_size(query: Query>) { + for calculated in &query { + let size = match calculated { + (Some(image), None) => image.size(), + (None, Some(text)) => text.size, + _ => unreachable!(), + }; + // do things with size + } +} +``` + ### [`MeasureFunc` improvements](https://github.com/bevyengine/bevy/pull/8402)
UI
-- `CalculatedSize` has been renamed to `ContentSize`. - The `upsert_leaf` function has been removed from `UiSurface` and replaced with `update_measure` which updates the `MeasureFunc` without node insertion. - The `dyn_clone` method has been removed from the `Measure` trait. - The new function of `CalculatedSize` has been replaced with the method `set`.