Merge pull request #10041 from dotCooCoo/fix/save-options-radio-rows

Save options: All/Range and Transparent/Opaque radios have no empty caption over them
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 21:37:46 -08:00
commit f9769056a1
2 files changed
+59 -3

No files matched your search

+5 -3
View File
@@ -302,10 +302,11 @@ fn option_rows(f: &Format, o: &FormatOption, menus: &Arc<Menus>, legacy: bool) -
});
return vec![row(ParamKind::choice(entries.collect(), None))];
}
// Only the colour preview can keep transparency.
// Only the colour preview can keep transparency. The options stand with no caption over them; the option's label
// names the group for assistive technology.
if f.id == "eps" && o.name == "transparentPreview" {
let kind = ParamKind::radio(vec![("true".into(), tl!("Transparent").into()), ("false".into(), tl!("Opaque").into())], None);
return vec![Param::new(o.name, "", kind).enabled_when("previewFormat", "tiffColor")];
return vec![Param::new(o.name, label.clone(), kind).stacked_options().enabled_when("previewFormat", "tiffColor")];
}
// Type is written as glyph outlines, which need no fonts: the row is on, and never enabled.
if f.id == "eps" && o.name == "embedFonts" {
@@ -320,7 +321,8 @@ fn option_rows(f: &Format, o: &FormatOption, menus: &Arc<Menus>, legacy: bool) -
let mut rows = vec![check];
if matches!(o.name, "separateArtboards" | "useArtboards") {
let all = ParamKind::radio(vec![("true".into(), tl!("All").into()), ("false".into(), tl!("Range:").into())], None);
rows.push(Param::new("all", "", all).enabled_when(o.name, true));
// Right under the check box, with no caption over the options.
rows.push(Param::new("all", "", all).stacked_options().enabled_when(o.name, true));
rows.push(Param::new("range", "", ParamKind::text("")).hint("1-3, 5").enabled_when("all", "false"));
}
rows
@@ -513,6 +513,60 @@ fn eps_save_transparency_follows_the_color_preview() {
assert_eq!(dialog(&mut app).bool("embedFonts"), Some(true));
}
/// The open dialog's labelled controls with their bounds, as a screen reader is told them, after a few frames of a
/// 1440x900 window.
fn labelled_controls(app: &mut VectorcraftApp) -> Vec<(String, egui::Rect)> {
let ctx = app.ui_ctx.clone().unwrap();
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1440.0, 900.0));
let mut nodes = Vec::new();
for _ in 0..4 {
let input = egui::RawInput { screen_rect: Some(screen), ..Default::default() };
nodes = crate::testing::app_frame(app, &ctx, input).platform_output.accesskit_update.map_or_else(Vec::new, |u| u.nodes);
}
nodes
.iter()
.filter_map(|(_, node)| {
let b = node.bounds()?;
Some((node.label()?.to_string(), egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32))))
})
.collect()
}
/// The bounds of the control labelled `label` in `controls`, with or without a final colon.
fn control(controls: &[(String, egui::Rect)], label: &str) -> egui::Rect {
let bare = |l: &str| l.trim_end_matches(':').to_string();
controls
.iter()
.find(|(l, _)| bare(l) == bare(label))
.map(|(_, r)| *r)
.unwrap_or_else(|| panic!("no control labelled {label:?} in {:?}", controls.iter().map(|(l, _)| l).collect::<Vec<_>>()))
}
/// The All and Range radios stand right under the artboard check box, and EPS's Transparent and Opaque radios right
/// under the Preview menu, with no empty caption over them: an empty caption leaves a band about a row tall.
#[test]
fn save_options_radios_have_no_empty_caption_over_them() {
for (picked, check) in [("art.eps", "Use Artboards"), ("art.ai", "Save each artboard to a separate file")] {
let (mut app, _, _) = desktop(picked);
save_as(&mut app, "file.saveAs");
let controls = labelled_controls(&mut app);
let (check, all, range) = (control(&controls, check), control(&controls, "All"), control(&controls, "Range:"));
assert!(all.top() - check.bottom() <= check.height() / 2.0, "{picked}: All at {all:?}, the check box at {check:?}");
assert!(range.top() - all.bottom() <= all.height() / 2.0, "{picked}: Range at {range:?}, All at {all:?}");
if picked == "art.eps" {
let transparent = control(&controls, "Transparent");
// The Preview menu: the nearest control so named above the radios (the window has other Preview controls).
let preview = controls
.iter()
.filter(|(l, r)| l.trim_end_matches(':') == "Preview" && r.bottom() <= transparent.top())
.map(|(_, r)| *r)
.max_by(|a, b| a.bottom().total_cmp(&b.bottom()))
.expect("the Preview menu above Transparent");
assert!(transparent.top() - preview.bottom() <= check.height() / 2.0, "Transparent at {transparent:?}, Preview at {preview:?}");
}
}
}
#[test]
fn a_native_save_options_draft_cannot_redirect_its_path_to_another_drawing() {
let (mut app, written, _) = desktop("original.vectorcraft");