bevy/crates
Dawid Piotrowski 9066d51420 Utility methods for Val (#6134)
# Objective

Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes #6080.

## Solution

- Added `try_add` and `try_sub` methods to Val.
- Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour.
- As a consequence of the prior,  ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct
- Added a `From<(Val, Val)>` impl for the `Size` struct
- Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`.
- Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding.

---

## Migration Guide

Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately.


Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com>
2022-10-24 14:33:46 +00:00
..
bevy_animation Fix end-of-animation index OOB (#6210) 2022-10-17 16:42:34 +00:00
bevy_app Adding Debug implementations for App, Stage, Schedule, Query, QueryState, etc. (#6214) 2022-10-10 20:59:38 +00:00
bevy_asset Add From<String> for AssetPath<'a> (#6337) 2022-10-24 14:14:24 +00:00
bevy_audio Update rodio requirement from 0.15 to 0.16 (#6020) 2022-09-19 13:56:56 +00:00
bevy_core tick local executor (#6121) 2022-10-24 13:46:40 +00:00
bevy_core_pipeline Accept Bundles for insert and remove. Deprecate insert/remove_bundle (#6039) 2022-09-21 21:47:53 +00:00
bevy_derive Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_diagnostic Add Exponential Moving Average into diagnostics (#4992) 2022-10-24 13:46:37 +00:00
bevy_dylib Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_dynamic_plugin Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_ecs implemented #[bundle(ignore)] (#6123) 2022-10-24 14:33:45 +00:00
bevy_ecs_compile_fail_tests Fix tests breaking when new WorldQuery impls are added (#6317) 2022-10-21 11:15:06 +00:00
bevy_encase_derive Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_gilrs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
bevy_gltf Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
bevy_hierarchy Fix RemoveChildren command (#6192) 2022-10-10 23:40:32 +00:00
bevy_input Add getters and setters for InputAxis and ButtonSettings (#6088) 2022-10-17 14:38:55 +00:00
bevy_internal Update wgpu to 0.14.0, naga to 0.10.0, winit to 0.27.4, raw-window-handle to 0.5.0, ndk to 0.7 (#6218) 2022-10-19 17:40:23 +00:00
bevy_log Make Resource trait opt-in, requiring #[derive(Resource)] V2 (#5577) 2022-08-08 21:36:35 +00:00
bevy_macro_utils Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_math Add Camera::viewport_to_world (#6126) 2022-10-05 22:16:26 +00:00
bevy_mikktspace Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_pbr Use wgsl saturate (#6318) 2022-10-22 08:37:51 +00:00
bevy_ptr Bump Version after Release (#5576) 2022-08-05 02:03:05 +00:00
bevy_reflect bevy_reflect: Reflect doc comments (#6234) 2022-10-18 13:49:57 +00:00
bevy_render Add global time scaling (#5752) 2022-10-22 18:52:29 +00:00
bevy_scene Create a scene from a dynamic scene (#6229) 2022-10-17 16:25:12 +00:00
bevy_sprite Add globals struct to mesh2d (#6222) 2022-10-10 19:23:43 +00:00
bevy_tasks tick local executor (#6121) 2022-10-24 13:46:40 +00:00
bevy_text Fixes incorrect glyph positioning for text2d (#6273) 2022-10-18 13:28:34 +00:00
bevy_time better wording for time scaling docs (#6340) 2022-10-24 14:14:25 +00:00
bevy_transform Fix documentation for looking_at/look_at (#4696) 2022-10-12 20:18:20 +00:00
bevy_ui Utility methods for Val (#6134) 2022-10-24 14:33:46 +00:00
bevy_utils Remove Sync bound from Local (#5483) 2022-09-12 04:15:55 +00:00
bevy_window Update wgpu to 0.14.0, naga to 0.10.0, winit to 0.27.4, raw-window-handle to 0.5.0, ndk to 0.7 (#6218) 2022-10-19 17:40:23 +00:00
bevy_winit Update wgpu to 0.14.0, naga to 0.10.0, winit to 0.27.4, raw-window-handle to 0.5.0, ndk to 0.7 (#6218) 2022-10-19 17:40:23 +00:00