From c962f10027ef245ddd65ad09c83e5790677dc05f Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 23:39:06 +0000 Subject: [PATCH] Dialog footer: the content stands at the start of the buttons' line, not on a line above --- crates/ui-panels/src/dialog/frame.rs | 26 ++++++++++++----- crates/ui-panels/src/dialog/modal.rs | 4 +-- crates/ui-panels/src/sections/footer.rs | 28 +++++++++++++------ .../src/patterns/presets/footer.rs | 2 +- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/crates/ui-panels/src/dialog/frame.rs b/crates/ui-panels/src/dialog/frame.rs index 88acd6df7..5491eed6e 100644 --- a/crates/ui-panels/src/dialog/frame.rs +++ b/crates/ui-panels/src/dialog/frame.rs @@ -183,12 +183,24 @@ pub(crate) fn footer_in( bar.show(ui, |ui, bar| content(ui, &mut FooterCx { bar, dialog: cx, close })); } }; - if !column { + if buttons.is_empty() { show_content(ui, cx, content, &mut close); - } - if !buttons.is_empty() { + } else { let bar = FooterBar::buttons(buttons.iter().cloned()).enter_activates(enter); - *picked = if column { bar.column() } else { bar }.show_footer(ui).picked; + *picked = if column { + bar.column().show_footer(ui).picked + } else if content.is_some() { + // The content stands at the start of the buttons' line. + bar.show_footer_leading(ui, |ui, bar| { + if let Some(content) = content.as_mut() { + content(ui, &mut FooterCx { bar, dialog: cx, close: &mut close }); + } + }) + .0 + .picked + } else { + bar.show_footer(ui).picked + }; if let Some(at) = *picked { if let Some(act) = on_pick.as_mut() { act(&buttons[at], cx); @@ -202,9 +214,9 @@ pub(crate) fn footer_in( } } } - } - if column { - show_content(ui, cx, content, &mut close); + if column { + show_content(ui, cx, content, &mut close); + } } if let Some(why) = close { cx.request_close_as(why); diff --git a/crates/ui-panels/src/dialog/modal.rs b/crates/ui-panels/src/dialog/modal.rs index 1c96e263a..c68a5e987 100644 --- a/crates/ui-panels/src/dialog/modal.rs +++ b/crates/ui-panels/src/dialog/modal.rs @@ -245,8 +245,8 @@ impl<'a> Dialog<'a> { self.route_enter() } - /// The footer's content: the closure fills a footer bar above the buttons (under them with - /// [`side_buttons`](Dialog::side_buttons)), or alone. + /// The footer's content: the closure fills the start of the buttons' line (under the buttons with + /// [`side_buttons`](Dialog::side_buttons)), or a line of its own when there are no buttons. #[must_use] pub fn footer(mut self, content: impl FnMut(&mut Ui, &mut FooterCx<'_, '_, '_>) + 'a) -> Self { let region = self.footer_region(); diff --git a/crates/ui-panels/src/sections/footer.rs b/crates/ui-panels/src/sections/footer.rs index 49b03b0f0..105888a1e 100644 --- a/crates/ui-panels/src/sections/footer.rs +++ b/crates/ui-panels/src/sections/footer.rs @@ -3,7 +3,7 @@ use super::words::SectionWords; use crate::buttons::{Button, IconButton, PopupMark}; use crate::contract::{ - Access, BodyLayout, Common, Component, Container, ContainerProps, Cx, DropMark, DropOperation, DropTarget, LeastWidth, NoValue, Outcome, Pad, + Access, BodyCx, BodyLayout, Common, Component, Container, ContainerProps, Cx, DropMark, DropOperation, DropTarget, LeastWidth, NoValue, Outcome, Pad, PaintUi, Pointer as _, PopupKind, Props as _, Role, RowAlign, Show as _, ShowContainer as _, Sizing, TooltipSpec, WordSetCx as _, }; use crate::layout_components::Row; @@ -582,21 +582,21 @@ impl FooterBar { /// Shows the bar with the actions or buttons it was made with and reports what happened to them. pub fn show_footer(self, ui: &mut Ui) -> FooterOutput { - self.show_footer_with(ui, None::).0 + self.show_footer_with(ui, None::)>).0 } - /// Shows a bar of actions with the host's `leading` controls at its start edge, before the actions placed there by - /// [`at_start`](FooterBar::at_start), under the same rule: a preset panel's size slider. Returns what `leading` - /// returned on its last run. - pub fn show_footer_leading(self, ui: &mut Ui, leading: impl FnMut(&mut Ui) -> R) -> (FooterOutput, Option) { + /// Shows a bar of actions or buttons with the host's `leading` controls at its start edge, before the actions + /// placed there by [`at_start`](FooterBar::at_start), under the same rule: a preset panel's size slider, a filter + /// dialog's Preview box. `leading` gets the bar's body context. Returns what `leading` returned on its last run. + pub fn show_footer_leading(self, ui: &mut Ui, leading: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> (FooterOutput, Option) { self.show_footer_with(ui, Some(leading)) } - fn show_footer_with(mut self, ui: &mut Ui, mut leading: Option R>) -> (FooterOutput, Option) { + fn show_footer_with(mut self, ui: &mut Ui, mut leading: Option) -> R>) -> (FooterOutput, Option) { let content = std::mem::take(&mut self.content); let (enter, column, start) = (self.enter, self.column, self.start); let mut led = None; - let shown = self.show(ui, |ui, _| match &content { + let shown = self.show(ui, |ui, bar| match &content { Content::Body => Shown::default(), Content::Actions(actions) => { let mut shown = Shown::default(); @@ -605,7 +605,7 @@ impl FooterBar { if let Some(leading) = leading.as_mut() { // The leading controls are units of the bar's row, so they narrow to leave the actions their // width; the end group fills the rest. - led = Some(leading(ui)); + led = Some(leading(ui, bar)); show_actions(ui, actions, 0..start, &mut shown); Row::new().fill_width().align(RowAlign::End).show(ui, |ui, _| show_actions(ui, actions, from_end(), &mut shown)); } else if start == 0 { @@ -627,6 +627,7 @@ impl FooterBar { // Initial focus lands on the first enabled Accept button on every OS. let default_at = buttons.iter().position(|button| button.role == DialogRole::Accept && button.enabled); let least = if column { LeastWidth::DialogSideButton } else { LeastWidth::DialogButton }; + let mut place = |ui: &mut Ui, shown: &mut Shown| { for at in display_order(&roles, crate::runtime::windows::os_of(ui.ctx()) == Os::Windows, column) { let button = &buttons[at]; let variant = match button.role { @@ -663,6 +664,15 @@ impl FooterBar { } } } + }; + if let Some(leading) = leading.as_mut() { + // The leading controls stand at the start edge of the buttons' line; the buttons fill the rest and + // sit at the end edge. + led = Some(leading(ui, bar)); + Row::new().fill_width().align(RowAlign::End).show(ui, |ui, _| place(ui, &mut shown)); + } else { + place(ui, &mut shown); + } if enter && shown.picked.is_none() && !ui.is_sizing_pass() { shown.picked = default_at.filter(|_| enter_reaches_footer(&ctx) && keys::take_submit(&ctx)); } diff --git a/crates/ui-patterns/src/patterns/presets/footer.rs b/crates/ui-patterns/src/patterns/presets/footer.rs index 0e28e8fff..219eabf4f 100644 --- a/crates/ui-patterns/src/patterns/presets/footer.rs +++ b/crates/ui-patterns/src/patterns/presets/footer.rs @@ -204,7 +204,7 @@ impl PresetFooter<'_, K> { slots.push(Slot::Custom(index)); } - let (footer, zoom_edit) = FooterBar::actions(shown).show_footer_leading(ui, |ui| { + let (footer, zoom_edit) = FooterBar::actions(shown).show_footer_leading(ui, |ui, _| { if let Some(add) = &leading { add(ui); }