diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index e42d1996ca1..6b77e8a14ec 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -622,7 +622,7 @@ impl Margin { }; #[inline] - pub fn same(margin: f32) -> Self { + pub const fn same(margin: f32) -> Self { Self { left: margin, right: margin, @@ -633,7 +633,7 @@ impl Margin { /// Margins with the same size on opposing sides #[inline] - pub fn symmetric(x: f32, y: f32) -> Self { + pub const fn symmetric(x: f32, y: f32) -> Self { Self { left: x, right: x, @@ -649,12 +649,12 @@ impl Margin { } #[inline] - pub fn left_top(&self) -> Vec2 { + pub const fn left_top(&self) -> Vec2 { vec2(self.left, self.top) } #[inline] - pub fn right_bottom(&self) -> Vec2 { + pub const fn right_bottom(&self) -> Vec2 { vec2(self.right, self.bottom) } diff --git a/crates/epaint/src/shadow.rs b/crates/epaint/src/shadow.rs index ad13037aeb4..fb6a9a4ab24 100644 --- a/crates/epaint/src/shadow.rs +++ b/crates/epaint/src/shadow.rs @@ -19,8 +19,12 @@ impl Shadow { color: Color32::TRANSPARENT, }; + pub const fn new(extrusion: f32, color: Color32) -> Self { + Self { extrusion, color } + } + /// Tooltips, menus, …, for dark mode. - pub fn small_dark() -> Self { + pub const fn small_dark() -> Self { Self { extrusion: 16.0, color: Color32::from_black_alpha(96), @@ -28,7 +32,7 @@ impl Shadow { } /// Tooltips, menus, …, for light mode. - pub fn small_light() -> Self { + pub const fn small_light() -> Self { Self { extrusion: 16.0, color: Color32::from_black_alpha(20), @@ -36,7 +40,7 @@ impl Shadow { } /// Used for egui windows in dark mode. - pub fn big_dark() -> Self { + pub const fn big_dark() -> Self { Self { extrusion: 32.0, color: Color32::from_black_alpha(96), @@ -44,7 +48,7 @@ impl Shadow { } /// Used for egui windows in light mode. - pub fn big_light() -> Self { + pub const fn big_light() -> Self { Self { extrusion: 32.0, color: Color32::from_black_alpha(16), diff --git a/crates/epaint/src/shape.rs b/crates/epaint/src/shape.rs index ffc7b174be4..033d4dfc5ed 100644 --- a/crates/epaint/src/shape.rs +++ b/crates/epaint/src/shape.rs @@ -701,7 +701,7 @@ impl Rounding { }; #[inline] - pub fn same(radius: f32) -> Self { + pub const fn same(radius: f32) -> Self { Self { nw: radius, ne: radius,