bevy/crates/bevy_ui
ickshonpe ba532e4a37
MeasureFunc improvements (#8402)
# Objective

fixes #8516

* Give `CalculatedSize` a more specific and intuitive name.

* `MeasureFunc`s should only be updated when their `CalculatedSize` is
modified by the systems managing their content.

For example, suppose that you have a UI displaying an image using an
`ImageNode`. When the window is resized, the node's `MeasureFunc` will
be updated even though the dimensions of the texture contained by the
node are unchanged.

* Fix the `CalculatedSize` API so that it no longer requires the extra
boxing and the `dyn_clone` method.


## Solution

* Rename `CalculatedSize` to `ContentSize`

* Only update `MeasureFunc`s on `CalculatedSize` changes.

* Remove the `dyn_clone` method from `Measure` and move the `Measure`
from the `ContentSize` component rather than cloning it.

* Change the measure_func field of `ContentSize` to type
`Option<taffy::node::MeasureFunc>`. Add a `set` method that wraps the
given measure appropriately.

---

## Changelog

* Renamed `CalculatedSize` to `ContentSize`.
* Replaced `upsert_leaf` with a function `update_measure` that only
updates the node's `MeasureFunc`.
* `MeasureFunc`s are only updated when the `ContentSize` changes and not
when the layout changes.
* Scale factor is no longer applied to the size values passed to the
`MeasureFunc`.
* Remove the `ContentSize` scaling in `text_system`.
* The `dyn_clone` method has been removed from the `Measure` trait.
* `Measure`s are moved from the `ContentSize` component instead of
cloning them.
* Added `set` method to `ContentSize` that replaces the `new` function.

## Migration Guide

* `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`.
2023-05-01 15:40:53 +00:00
..
src MeasureFunc improvements (#8402) 2023-05-01 15:40:53 +00:00
Cargo.toml Add CSS Grid support to bevy_ui (#8026) 2023-04-17 16:21:38 +00:00