From 72699b7032c77910f2797ebd5f589f55f9db93fa Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Thu, 27 Aug 2026 13:18:57 +0200 Subject: [PATCH] Remove fallback_gap --- crates/egui/src/atomics/atom_layout.rs | 7 ------- crates/egui/src/theme/default_style.rs | 2 -- crates/egui/src/widgets/button.rs | 9 +++++++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/egui/src/atomics/atom_layout.rs b/crates/egui/src/atomics/atom_layout.rs index 3bc5211b1..5c7da5cc7 100644 --- a/crates/egui/src/atomics/atom_layout.rs +++ b/crates/egui/src/atomics/atom_layout.rs @@ -107,13 +107,6 @@ impl<'a> AtomLayout<'a> { self } - /// Set the gap between atoms, unless [`Self::gap`] already set one. - #[inline] - pub fn fallback_gap(mut self, gap: f32) -> Self { - self.gap.get_or_insert(gap); - self - } - /// Set the [`Frame`]. #[inline] pub fn frame(mut self, frame: Frame) -> Self { diff --git a/crates/egui/src/theme/default_style.rs b/crates/egui/src/theme/default_style.rs index 0cb665f3f..c36a963b3 100644 --- a/crates/egui/src/theme/default_style.rs +++ b/crates/egui/src/theme/default_style.rs @@ -89,8 +89,6 @@ impl StyleProvider for DefaultStyle { ..Default::default() }, layout: LayoutStyle { - // Historically only the height was floored, so that a button is at least as tall - // as any other interactive widget on the same row. min_size: Vec2::new(0.0, spacing.interact_size.y), gap: spacing.icon_spacing, }, diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index c646214af..c4358faa5 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -35,6 +35,7 @@ pub struct Button<'a> { frame_when_inactive: bool, min_size: Vec2, corner_radius: Option, + gap: Option, selected: Option, image_tint_follows_text_color: bool, limit_image_size: bool, @@ -54,6 +55,7 @@ impl<'a> Button<'a> { frame_when_inactive: true, min_size: Vec2::ZERO, corner_radius: None, + gap: None, selected: None, image_tint_follows_text_color: false, limit_image_size: false, @@ -273,9 +275,11 @@ impl<'a> Button<'a> { } /// Set the gap between atoms. + /// + /// Overrides the gap the theme picked. #[inline] pub fn gap(mut self, gap: f32) -> Self { - self.layout = self.layout.gap(gap); + self.gap = Some(gap); self } @@ -297,6 +301,7 @@ impl<'a> Button<'a> { frame_when_inactive, mut min_size, corner_radius, + gap: gap_override, selected, image_tint_follows_text_color, limit_image_size, @@ -333,7 +338,7 @@ impl<'a> Button<'a> { text_style, } = ui.widget_style(id, &classes); - layout = layout.fallback_gap(gap); + layout = layout.gap(gap_override.unwrap_or(gap)); // The theme decides how small a button may get — unless it is a `small` one, which sizes // itself purely from its contents.