Merge branch 'red/t10d' into fw/mac1

This commit is contained in:
aiongg
2026-11-17 00:21:02 +00:00
6 changed files with 47 additions and 24 deletions
+19 -7
View File
@@ -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);
+2 -2
View File
@@ -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();
+19 -9
View File
@@ -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::<fn(&mut Ui)>).0
self.show_footer_with(ui, None::<fn(&mut Ui, &mut BodyCx<'_>)>).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<R>(self, ui: &mut Ui, leading: impl FnMut(&mut Ui) -> R) -> (FooterOutput, Option<R>) {
/// 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<R>(self, ui: &mut Ui, leading: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> (FooterOutput, Option<R>) {
self.show_footer_with(ui, Some(leading))
}
fn show_footer_with<R>(mut self, ui: &mut Ui, mut leading: Option<impl FnMut(&mut Ui) -> R>) -> (FooterOutput, Option<R>) {
fn show_footer_with<R>(mut self, ui: &mut Ui, mut leading: Option<impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R>) -> (FooterOutput, Option<R>) {
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));
}
@@ -190,7 +190,10 @@ impl<'a> NewGuideDialog<'a> {
parsed = position_row(ui, &words, &number_units, &units, values, first);
color_row(ui, &words, &mut values.color, NEW_GUIDE_COLOR_KEY, form.requests());
});
ok_enabled = parsed;
// A measuring run lays the field out without its typing run, so it never says whether the text parses.
if !crate::runtime::measure::active(ui.ctx()) {
ok_enabled = parsed;
}
parsed
});
let result = shown.accepted.map(|values| {
@@ -151,8 +151,7 @@ fn position_text_that_does_not_parse_keeps_ok_from_making_a_guide() {
let position = fixture.by_label("Position").expect("the Position field");
fixture.click(&position).settle();
fixture.key(egui::Key::A, egui::Modifiers::COMMAND);
fixture.type_text("far");
fixture.key(egui::Key::Tab, egui::Modifiers::NONE).settle();
fixture.type_text("far").settle();
assert!(!enabled.get(), "OK is disabled while the text does not parse");
let ok = fixture.by_label("OK").expect("the footer has OK");
fixture.click(&ok).settle();
@@ -162,8 +161,7 @@ fn position_text_that_does_not_parse_keeps_ok_from_making_a_guide() {
let position = fixture.by_label("Position").expect("the Position field");
fixture.click(&position).settle();
fixture.key(egui::Key::A, egui::Modifiers::COMMAND);
fixture.type_text("40");
fixture.key(egui::Key::Tab, egui::Modifiers::NONE).settle();
fixture.type_text("40").settle();
assert!(enabled.get(), "a number enables OK again");
let ok = fixture.by_label("OK").expect("the footer has OK");
fixture.click(&ok).settle();
@@ -204,7 +204,7 @@ impl<K: Clone + Send + Sync + 'static> 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);
}