diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index 734fcd65c62aad..9462ef4e770d59 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -4,6 +4,7 @@ use bevy_reflect::ReflectDeserialize; use bevy_reflect::ReflectSerialize; use serde::Deserialize; use serde::Serialize; +use std::ops::Neg; use std::ops::{Div, DivAssign, Mul, MulAssign}; use thiserror::Error; @@ -154,6 +155,22 @@ impl DivAssign for Val { } } +impl Neg for Val { + type Output = Val; + + fn neg(self) -> Self::Output { + match self { + Val::Px(value) => Val::Px(-value), + Val::Percent(value) => Val::Percent(-value), + Val::Vw(value) => Val::Vw(-value), + Val::Vh(value) => Val::Vh(-value), + Val::VMin(value) => Val::VMin(-value), + Val::VMax(value) => Val::VMax(-value), + _ => self, + } + } +} + #[derive(Debug, Eq, PartialEq, Clone, Copy, Error)] pub enum ValArithmeticError { #[error("the variants of the Vals don't match")]