mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Convenience const fn for Margin, Rounding and Shadow (#4080)
I often write constants at the top of my widget files, as a "config". I
kept writing stuff like that :
```rust
const DEFAULT_INNER_MARGIN: Margin = Margin { left: 17., right: 17., top: 7., bottom: 7. };
```
So I prefixed constructors for `Margin`, `Rounding` and `Shadow` const.
No code was changed.
I also added a `Shadow::new()` for similar reasons.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user