diff --git a/RELEASES.md b/RELEASES.md index 34ef114636dd..9d87988b792a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -45,6 +45,7 @@ We don't update the MSRV in a patch release, unless we really, really need to. * [ ] check that CI is green ## Preparation +* [ ] make sure there are no important unmerged PRs * [ ] run `scripts/generate_example_screenshots.sh` if needed * [ ] write a short release note that fits in a bluesky post * [ ] record gif for `CHANGELOG.md` release note (and later bluesky post) diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index 343897dcc82d..1fdbbca922d8 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -4,7 +4,7 @@ use crate::{ epaint, layers::ShapeIdx, InnerResponse, Response, Sense, Style, Ui, UiBuilder, UiKind, UiStackInfo, }; -use epaint::{Color32, CornerRadius, Margin, Marginf, Rect, Shadow, Shape, Stroke}; +use epaint::{Color32, CornerRadius, Margin, MarginF32, Rect, Shadow, Shape, Stroke}; /// A frame around some content, including margin, colors, etc. /// @@ -337,10 +337,10 @@ impl Frame { /// /// [`Self::inner_margin`] + [`Self.stroke`]`.width` + [`Self::outer_margin`]. #[inline] - pub fn total_margin(&self) -> Marginf { - Marginf::from(self.inner_margin) - + Marginf::from(self.stroke.width) - + Marginf::from(self.outer_margin) + pub fn total_margin(&self) -> MarginF32 { + MarginF32::from(self.inner_margin) + + MarginF32::from(self.stroke.width) + + MarginF32::from(self.outer_margin) } /// Calculate the `fill_rect` from the `content_rect`. @@ -354,14 +354,14 @@ impl Frame { /// /// This is the visible and interactive rectangle. pub fn widget_rect(&self, content_rect: Rect) -> Rect { - content_rect + self.inner_margin + Marginf::from(self.stroke.width) + content_rect + self.inner_margin + MarginF32::from(self.stroke.width) } /// Calculate the `outer_rect` from the `content_rect`. /// /// This is what is allocated in the outer [`Ui`], and is what is returned by [`Response::rect`]. pub fn outer_rect(&self, content_rect: Rect) -> Rect { - content_rect + self.inner_margin + Marginf::from(self.stroke.width) + self.outer_margin + content_rect + self.inner_margin + MarginF32::from(self.stroke.width) + self.outer_margin } } @@ -463,7 +463,7 @@ impl Prepared { let content_rect = self.content_ui.min_rect(); content_rect + self.frame.inner_margin - + Marginf::from(self.frame.stroke.width) + + MarginF32::from(self.frame.stroke.width) + self.frame.outer_margin } diff --git a/crates/epaint/src/lib.rs b/crates/epaint/src/lib.rs index ac0a90c60061..f84a8caff952 100644 --- a/crates/epaint/src/lib.rs +++ b/crates/epaint/src/lib.rs @@ -29,7 +29,7 @@ mod corner_radius; mod corner_radius_f32; pub mod image; mod margin; -mod marginf; +mod margin_f32; mod mesh; pub mod mutex; mod shadow; @@ -52,7 +52,7 @@ pub use self::{ corner_radius_f32::CornerRadiusF32, image::{ColorImage, FontImage, ImageData, ImageDelta}, margin::Margin, - marginf::Marginf, + margin_f32::*, mesh::{Mesh, Mesh16, Vertex}, shadow::Shadow, shapes::{ diff --git a/crates/epaint/src/margin.rs b/crates/epaint/src/margin.rs index e8fc530aae70..2e87b7b308e0 100644 --- a/crates/epaint/src/margin.rs +++ b/crates/epaint/src/margin.rs @@ -9,7 +9,7 @@ use emath::{vec2, Rect, Vec2}; /// Use with care. /// /// All values are stored as [`i8`] to keep the size of [`Margin`] small. -/// If you want floats, use [`crate::Marginf`] instead. +/// If you want floats, use [`crate::MarginF32`] instead. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Margin { diff --git a/crates/epaint/src/marginf.rs b/crates/epaint/src/margin_f32.rs similarity index 79% rename from crates/epaint/src/marginf.rs rename to crates/epaint/src/margin_f32.rs index eb3a1fbc90d5..fd88611d04e3 100644 --- a/crates/epaint/src/marginf.rs +++ b/crates/epaint/src/margin_f32.rs @@ -10,14 +10,17 @@ use crate::Margin; /// For storage, use [`crate::Margin`] instead. #[derive(Clone, Copy, Debug, Default, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -pub struct Marginf { +pub struct MarginF32 { pub left: f32, pub right: f32, pub top: f32, pub bottom: f32, } -impl From for Marginf { +#[deprecated = "Renamed to MarginF32"] +pub type Marginf = MarginF32; + +impl From for MarginF32 { #[inline] fn from(margin: Margin) -> Self { Self { @@ -29,9 +32,9 @@ impl From for Marginf { } } -impl From for Margin { +impl From for Margin { #[inline] - fn from(marginf: Marginf) -> Self { + fn from(marginf: MarginF32) -> Self { Self { left: marginf.left as _, right: marginf.right as _, @@ -41,7 +44,7 @@ impl From for Margin { } } -impl Marginf { +impl MarginF32 { pub const ZERO: Self = Self { left: 0.0, right: 0.0, @@ -108,22 +111,22 @@ impl Marginf { } } -impl From for Marginf { +impl From for MarginF32 { #[inline] fn from(v: f32) -> Self { Self::same(v) } } -impl From for Marginf { +impl From for MarginF32 { #[inline] fn from(v: Vec2) -> Self { Self::symmetric(v.x, v.y) } } -/// `Marginf + Marginf` -impl std::ops::Add for Marginf { +/// `MarginF32 + MarginF32` +impl std::ops::Add for MarginF32 { type Output = Self; #[inline] @@ -137,8 +140,8 @@ impl std::ops::Add for Marginf { } } -/// `Marginf + f32` -impl std::ops::Add for Marginf { +/// `MarginF32 + f32` +impl std::ops::Add for MarginF32 { type Output = Self; #[inline] @@ -153,7 +156,7 @@ impl std::ops::Add for Marginf { } /// `Margind += f32` -impl std::ops::AddAssign for Marginf { +impl std::ops::AddAssign for MarginF32 { #[inline] fn add_assign(&mut self, v: f32) { self.left += v; @@ -163,8 +166,8 @@ impl std::ops::AddAssign for Marginf { } } -/// `Marginf * f32` -impl std::ops::Mul for Marginf { +/// `MarginF32 * f32` +impl std::ops::Mul for MarginF32 { type Output = Self; #[inline] @@ -178,8 +181,8 @@ impl std::ops::Mul for Marginf { } } -/// `Marginf *= f32` -impl std::ops::MulAssign for Marginf { +/// `MarginF32 *= f32` +impl std::ops::MulAssign for MarginF32 { #[inline] fn mul_assign(&mut self, v: f32) { self.left *= v; @@ -189,8 +192,8 @@ impl std::ops::MulAssign for Marginf { } } -/// `Marginf / f32` -impl std::ops::Div for Marginf { +/// `MarginF32 / f32` +impl std::ops::Div for MarginF32 { type Output = Self; #[inline] @@ -204,8 +207,8 @@ impl std::ops::Div for Marginf { } } -/// `Marginf /= f32` -impl std::ops::DivAssign for Marginf { +/// `MarginF32 /= f32` +impl std::ops::DivAssign for MarginF32 { #[inline] fn div_assign(&mut self, v: f32) { self.left /= v; @@ -215,8 +218,8 @@ impl std::ops::DivAssign for Marginf { } } -/// `Marginf - Marginf` -impl std::ops::Sub for Marginf { +/// `MarginF32 - MarginF32` +impl std::ops::Sub for MarginF32 { type Output = Self; #[inline] @@ -230,8 +233,8 @@ impl std::ops::Sub for Marginf { } } -/// `Marginf - f32` -impl std::ops::Sub for Marginf { +/// `MarginF32 - f32` +impl std::ops::Sub for MarginF32 { type Output = Self; #[inline] @@ -245,8 +248,8 @@ impl std::ops::Sub for Marginf { } } -/// `Marginf -= f32` -impl std::ops::SubAssign for Marginf { +/// `MarginF32 -= f32` +impl std::ops::SubAssign for MarginF32 { #[inline] fn sub_assign(&mut self, v: f32) { self.left -= v; @@ -256,12 +259,12 @@ impl std::ops::SubAssign for Marginf { } } -/// `Rect + Marginf` -impl std::ops::Add for Rect { +/// `Rect + MarginF32` +impl std::ops::Add for Rect { type Output = Self; #[inline] - fn add(self, margin: Marginf) -> Self { + fn add(self, margin: MarginF32) -> Self { Self::from_min_max( self.min - margin.left_top(), self.max + margin.right_bottom(), @@ -269,20 +272,20 @@ impl std::ops::Add for Rect { } } -/// `Rect += Marginf` -impl std::ops::AddAssign for Rect { +/// `Rect += MarginF32` +impl std::ops::AddAssign for Rect { #[inline] - fn add_assign(&mut self, margin: Marginf) { + fn add_assign(&mut self, margin: MarginF32) { *self = *self + margin; } } -/// `Rect - Marginf` -impl std::ops::Sub for Rect { +/// `Rect - MarginF32` +impl std::ops::Sub for Rect { type Output = Self; #[inline] - fn sub(self, margin: Marginf) -> Self { + fn sub(self, margin: MarginF32) -> Self { Self::from_min_max( self.min + margin.left_top(), self.max - margin.right_bottom(), @@ -290,10 +293,10 @@ impl std::ops::Sub for Rect { } } -/// `Rect -= Marginf` -impl std::ops::SubAssign for Rect { +/// `Rect -= MarginF32` +impl std::ops::SubAssign for Rect { #[inline] - fn sub_assign(&mut self, margin: Marginf) { + fn sub_assign(&mut self, margin: MarginF32) { *self = *self - margin; } } diff --git a/crates/epaint/src/shadow.rs b/crates/epaint/src/shadow.rs index e05cbdbe4659..ee010ee99dda 100644 --- a/crates/epaint/src/shadow.rs +++ b/crates/epaint/src/shadow.rs @@ -1,4 +1,4 @@ -use crate::{Color32, CornerRadius, Marginf, Rect, RectShape, Vec2}; +use crate::{Color32, CornerRadius, MarginF32, Rect, RectShape, Vec2}; /// The color and fuzziness of a fuzzy shape. /// @@ -64,7 +64,7 @@ impl Shadow { } /// How much larger than the parent rect are we in each direction? - pub fn margin(&self) -> Marginf { + pub fn margin(&self) -> MarginF32 { let Self { offset, blur, @@ -74,7 +74,7 @@ impl Shadow { let spread = spread as f32; let blur = blur as f32; let [offset_x, offset_y] = offset; - Marginf { + MarginF32 { left: spread + 0.5 * blur - offset_x as f32, right: spread + 0.5 * blur + offset_x as f32, top: spread + 0.5 * blur - offset_y as f32,