From 15ca92cebf5cd687fc3adba2fc868f7a51f42a64 Mon Sep 17 00:00:00 2001 From: lucasmerlin Date: Thu, 17 Apr 2025 19:13:44 +0200 Subject: [PATCH] Add align2 option --- crates/egui/src/widget_layout.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widget_layout.rs b/crates/egui/src/widget_layout.rs index 28f243896..336f22fc4 100644 --- a/crates/egui/src/widget_layout.rs +++ b/crates/egui/src/widget_layout.rs @@ -35,6 +35,7 @@ pub struct WidgetLayout<'a> { fallback_text_color: Option, min_size: Vec2, wrap_mode: Option, + align2: Option, } impl<'a> WidgetLayout<'a> { @@ -48,6 +49,7 @@ impl<'a> WidgetLayout<'a> { fallback_text_color: None, min_size: Vec2::ZERO, wrap_mode: None, + align2: None, } } @@ -92,6 +94,11 @@ impl<'a> WidgetLayout<'a> { self } + pub fn align2(mut self, align2: Align2) -> Self { + self.align2 = Some(align2); + self + } + pub fn show(self, ui: &mut Ui) -> AtomicLayoutResponse { let Self { id, @@ -102,6 +109,7 @@ impl<'a> WidgetLayout<'a> { fallback_text_color, min_size, wrap_mode, + align2, } = self; let id = id.unwrap_or_else(|| ui.next_auto_id()); @@ -126,7 +134,9 @@ impl<'a> WidgetLayout<'a> { let mut shrink_item = None; - let align2 = Align2([ui.layout().horizontal_align(), ui.layout().vertical_align()]); + let align2 = align2.unwrap_or_else(|| { + Align2([ui.layout().horizontal_align(), ui.layout().vertical_align()]) + }); if atomics.0.len() > 1 { let gap_space = gap * (atomics.0.len() as f32 - 1.0);