diff --git a/crates/ui-egui/src/dialogs/effect.rs b/crates/ui-egui/src/dialogs/effect.rs
index bcfecb47e1..ebb78e8c90 100644
--- a/crates/ui-egui/src/dialogs/effect.rs
+++ b/crates/ui-egui/src/dialogs/effect.rs
@@ -561,6 +561,21 @@ mod tests {
assert_eq!((pa["detail"].as_f64(), pb["detail"].as_f64()), (Some(3.0), Some(8.0)), "each keeps its untouched value");
}
+ /// Zig Zag's Ridges per segment and Roughen's Detail are counts: their rows show no percent sign, while Size
+ /// with Relative, a share of the object's size, shows one.
+ #[test]
+ fn zig_zag_ridges_and_roughen_detail_show_no_percent_sign() {
+ use craft::ui::runtime::env::UnitKind;
+ let app = app();
+ for (effect, key) in [("distort.zigZag", "ridges"), ("distort.roughen", "detail")] {
+ let cx = EffectCx::new(&app, effect, false);
+ let rows = super::super::effect_rows::distort(&cx, &DialogFields::new());
+ let unit = |k: &str| rows.iter().find(|p| p.key == k).map(|p| p.unit);
+ assert_eq!(unit(key), Some(None), "{effect} {key}");
+ assert_eq!(unit("size"), Some(Some(UnitKind::Percent)), "{effect} size");
+ }
+ }
+
/// The lists the dialogs draw hold the values the effect's parameter documentation lists, in
/// its order; Rasterize's Color Model names the document's mode first.
#[test]
diff --git a/crates/ui-egui/src/dialogs/effect_rows.rs b/crates/ui-egui/src/dialogs/effect_rows.rs
index 580036d430..ef91055575 100644
--- a/crates/ui-egui/src/dialogs/effect_rows.rs
+++ b/crates/ui-egui/src/dialogs/effect_rows.rs
@@ -36,7 +36,12 @@ fn data_label(text: &str) -> Label {
/// A whole-number slider row over `0..=100` percent.
fn percent_range(key: &str, label: Label, default: f64) -> Param {
- Param::new(key, label, ParamKind::range(0.0, 100.0, default, SliderScale::Linear)).decimals(0).unit(UnitKind::Percent)
+ count_range(key, label, default).unit(UnitKind::Percent)
+}
+
+/// A whole-number slider row over `0..=100` with no unit after the number.
+fn count_range(key: &str, label: Label, default: f64) -> Param {
+ Param::new(key, label, ParamKind::range(0.0, 100.0, default, SliderScale::Linear)).decimals(0)
}
/// The row of `key` for either unit of a Relative/Absolute pair: a share of the object's size, or a distance in the
@@ -82,7 +87,7 @@ pub(super) fn transform(cx: &EffectCx, _fields: &DialogFields) -> Vec {
pub(super) fn distort(cx: &EffectCx, fields: &DialogFields) -> Vec {
let roughen = cx.id == "distort.roughen";
// PLAN: production suffixes Detail with "/in"; `Param::unit` takes a `UnitKind` and none stands for it
- let second = if roughen { percent_range("detail", lbl!("Detail:"), 10.0) } else { percent_range("ridges", lbl!("Ridges per segment:"), 4.0) };
+ let second = if roughen { count_range("detail", lbl!("Detail:"), 10.0) } else { count_range("ridges", lbl!("Ridges per segment:"), 4.0) };
let points: Vec<(String, Label)> = choices(&cx.id, "points")
.unwrap_or_default()
.iter()
diff --git a/crates/ui-egui/src/dialogs/para_style_options.rs b/crates/ui-egui/src/dialogs/para_style_options.rs
index 119228b39f..04e86b346d 100644
--- a/crates/ui-egui/src/dialogs/para_style_options.rs
+++ b/crates/ui-egui/src/dialogs/para_style_options.rs
@@ -15,7 +15,10 @@
use std::sync::Arc;
+use craft::ui::buttons::Button;
+use craft::ui::contract::{Props as _, Show as _, ShowContainer as _, clicked};
use craft::ui::dialog::DialogResult;
+use craft::ui::layout_components::Row;
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedPropertiesDialog, Param, ParamKind, PropertiesTab, PropertyRow};
use craft::ui::runtime::env::Label;
use serde_json::{Map, Value, json};
@@ -599,8 +602,6 @@ fn seed_editors(fields: &mut DialogFields) {
}
}
-// PLAN: the stop list is a Select over the stops and the buttons are egui buttons: the List and button
-// components' signatures are not in the bundle.
/// The Add, Delete Tab and Clear All Tabs buttons, which also keep the editors and the stop they edit in step.
fn tabs_buttons(unit: Unit) -> Param {
Param::custom("tabs", tl!("Tabs"), move |ui, fields, _| {
@@ -608,10 +609,10 @@ fn tabs_buttons(unit: Unit) -> Param {
let (rows, _, _) = tab_rows(fields);
let can_add = new_tab_position(&rows, unit).is_some();
let (mut add, mut delete, mut clear) = (false, false, false);
- let line = ui.horizontal(|ui| {
- add = ui.add_enabled(can_add, egui::Button::new(tl!("Add"))).clicked();
- delete = ui.add_enabled(!rows.is_empty(), egui::Button::new(tl!("Delete Tab"))).clicked();
- clear = ui.add_enabled(!rows.is_empty(), egui::Button::new(tl!("Clear All Tabs"))).clicked();
+ let line = Row::new().show(ui, |ui, _| {
+ add = clicked(&Button::new(tl!("Add")).enabled(can_add).show(ui));
+ delete = clicked(&Button::new(tl!("Delete Tab")).enabled(!rows.is_empty()).show(ui));
+ clear = clicked(&Button::new(tl!("Clear All Tabs")).enabled(!rows.is_empty()).show(ui));
});
if add {
add_tab(fields, unit);
@@ -621,7 +622,7 @@ fn tabs_buttons(unit: Unit) -> Param {
clear_tabs(fields);
}
seed_editors(fields);
- line.response
+ line.output
})
.companions(["__tabSel", "__tabEdited", "__tabShown", "__tabAlign", "__tabPosition", "__tabLeader", "__tabAlignOn"])
}
diff --git a/crates/ui-egui/src/dialogs/path_ops.rs b/crates/ui-egui/src/dialogs/path_ops.rs
index 72fb260ee2..64176e93ac 100644
--- a/crates/ui-egui/src/dialogs/path_ops.rs
+++ b/crates/ui-egui/src/dialogs/path_ops.rs
@@ -5,12 +5,16 @@
// PLAN: the framework import paths below are assumed from the contract rows (craft-ui-patterns re-exports contract and
// runtime; the form-dialog items live under `patterns::form_dialogs`; `Field` and `NumberField` under craft-ui-widgets).
-use craft::ui::contract::{Bind, FieldLabelRole, Show as _, ShowContainer as _, SideLabel};
+use craft::behavior::ColumnWidth;
+use craft::ui::contract::{Bind, FieldLabelRole, Props as _, Show as _, ShowContainer as _, SideLabel};
use craft::ui::dialog::DialogId;
use craft::ui::display::Text;
use craft::ui::form::Field;
+use craft::ui::layout::GridFit;
+use craft::ui::layout_components::Grid;
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind};
use craft::ui::runtime::env::{LengthUnits, UnitKind};
+use craft::ui::runtime::measure;
use craft::ui::runtime::memory::{SaveKey, saved_value, set_saved_value};
use craft::ui::text::{NumberField, NumberOutput};
use craft::ui::value_drag::SliderScale;
@@ -30,6 +34,10 @@ use crate::VectorcraftApp;
/// sends 180° less the threshold: 150° sends `object.path.simplify`'s default of 30°.
pub(crate) const ANGLE_THRESHOLD: f64 = 150.0;
+/// Split Into Grid's two columns, each as wide as its fields: the rows on the left, the columns on the right. The
+/// grid keeps both columns in a narrow dialog.
+const AXES: [ColumnWidth; 2] = [ColumnWidth::Content; 2];
+
/// Simplify's tolerance when the dialog opens from the menu, in points.
const DEFAULT_TOLERANCE: f64 = 1.0;
@@ -175,7 +183,7 @@ pub(crate) fn split_fields(width: f64, height: f64) -> DialogFields {
fn cell(ui: &mut egui::Ui, label: &'static str, name: String, describes: bool, value: f64, lengths: Option) -> Option {
let role = if describes { FieldLabelRole::Describes } else { FieldLabelRole::Names };
let mut edited = None;
- Field::new(label).side(SideLabel::new().role(role)).show(ui, |ui, _| {
+ Field::new(label).side(SideLabel::new().role(role)).id_salt(name.as_str()).show(ui, |ui, _| {
let bind = Bind::given(Some(value));
let out: NumberOutput = match lengths {
Some(l) => NumberField::length(name.clone(), bind, l).show(ui),
@@ -194,41 +202,45 @@ fn split_grid(ui: &mut egui::Ui, f: &mut DialogFields, lengths: LengthUnits) ->
("rows", tl!("Rows:"), tl!("Height:"), "rowGutter", "totalHeight", 2.0),
("columns", tl!("Columns:"), tl!("Width:"), "columnGutter", "totalWidth", 2.0),
];
- egui::Grid::new("split-grid")
- .num_columns(2)
- .show(ui, |ui| {
- for (number, label, _, _, _, default) in axes {
- let n = f.number(number).unwrap_or(default);
- if let Some(v) = cell(ui, label, label.to_string(), false, n, None) {
- f.set(number, v);
- }
+ // The grid can run its body twice in a pass, so the body edits a copy, kept only from the run that takes effect.
+ let before = f.clone();
+ let mut edited = None;
+ let shown = Grid::new(&AXES).fit(GridFit::Fixed).id_salt("split-grid").show(ui, |ui, _| {
+ let mut f = before.clone();
+ for (number, label, _, _, _, default) in axes {
+ let n = f.number(number).unwrap_or(default);
+ if let Some(v) = cell(ui, label, label.to_string(), false, n, None) {
+ f.set(number, v);
}
- ui.end_row();
- for (number, _, label, gutter, total, default) in axes {
- let n = f.number(number).unwrap_or(default).max(1.0);
- let gaps = f.number(gutter).unwrap_or(0.0) * (n - 1.0);
- let size = (f.number(total).unwrap_or(0.0) - gaps) / n;
- if let Some(v) = cell(ui, label, label.to_string(), false, size, Some(lengths)) {
- f.set(total, n * v + gaps);
- }
+ }
+ for (number, _, label, gutter, total, default) in axes {
+ let n = f.number(number).unwrap_or(default).max(1.0);
+ let gaps = f.number(gutter).unwrap_or(0.0) * (n - 1.0);
+ let size = (f.number(total).unwrap_or(0.0) - gaps) / n;
+ if let Some(v) = cell(ui, label, label.to_string(), false, size, Some(lengths)) {
+ f.set(total, n * v + gaps);
}
- ui.end_row();
- for (_, axis, _, gutter, _, _) in axes {
- let label = tl!("Gutter:");
- if let Some(v) = cell(ui, label, format!("{axis} {label}"), true, f.number(gutter).unwrap_or(0.0), Some(lengths)) {
- f.set(gutter, v);
- }
+ }
+ for (_, axis, _, gutter, _, _) in axes {
+ let label = tl!("Gutter:");
+ if let Some(v) = cell(ui, label, format!("{axis} {label}"), true, f.number(gutter).unwrap_or(0.0), Some(lengths)) {
+ f.set(gutter, v);
}
- ui.end_row();
- for (_, axis, _, _, total, _) in axes {
- let label = tl!("Total:");
- if let Some(v) = cell(ui, label, format!("{axis} {label}"), true, f.number(total).unwrap_or(0.0), Some(lengths)) {
- f.set(total, v);
- }
+ }
+ for (_, axis, _, _, total, _) in axes {
+ let label = tl!("Total:");
+ if let Some(v) = cell(ui, label, format!("{axis} {label}"), true, f.number(total).unwrap_or(0.0), Some(lengths)) {
+ f.set(total, v);
}
- ui.end_row();
- })
- .response
+ }
+ if measure::effect(ui.ctx(), "Split Into Grid's fields edit their values") {
+ edited = Some(f);
+ }
+ });
+ if let Some(edited) = edited {
+ *f = edited;
+ }
+ shown.output
}
/// Split Into Grid's rows: the grid and Add Guides.
diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs
index a20c8c720b..edc9953497 100644
--- a/crates/ui-egui/src/dialogs/revolve.rs
+++ b/crates/ui-egui/src/dialogs/revolve.rs
@@ -175,8 +175,13 @@ impl Rows<'_> {
self.defaults.get(key).and_then(Value::as_f64).unwrap_or(0.0)
}
- fn range(&self, key: &str, label: &'static str, (lo, hi): (f64, f64), decimals: u32, unit: UnitKind) -> Param {
- Param::new(key, label, ParamKind::range(lo, hi, self.default_number(key), SliderScale::Linear)).decimals(decimals).unit(unit).resettable()
+ fn range(&self, key: &str, label: &'static str, range: (f64, f64), decimals: u32, unit: UnitKind) -> Param {
+ self.plain(key, label, range, decimals).unit(unit)
+ }
+
+ /// A slider over a number shown with no unit after it, such as a count.
+ fn plain(&self, key: &str, label: &'static str, (lo, hi): (f64, f64), decimals: u32) -> Param {
+ Param::new(key, label, ParamKind::range(lo, hi, self.default_number(key), SliderScale::Linear)).decimals(decimals).resettable()
}
fn degrees(&self, key: &str, label: &'static str, range: (f64, f64), decimals: u32) -> Param {
@@ -273,7 +278,7 @@ fn object_rows(data: &Data, rows: &Rows, effect: &str, place: Place) -> Vec Param {
let defaults = bevel_defaults();
let keys: Vec = defaults.keys().cloned().collect();
Param::custom("__bevelHeading", c3("Bevel"), move |ui, fields, _| {
- ui.horizontal(|ui| {
- ui.label(egui::RichText::new(c3("Bevel")).strong());
- ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if pressed(ui, tl!("Reset"), differs_from(fields, &defaults), None) {
- defaults.iter().for_each(|(k, v)| set_value(fields, k, v));
- }
- });
- })
- .response
+ let mut reset = false;
+ let changed = differs_from(fields, &defaults);
+ let shown = crate::panels::section(c3("Bevel"))
+ .id_salt("bevel")
+ .controls(|ui, _| reset = pressed(ui, tl!("Reset"), changed, None))
+ .show(ui, |_, _| {});
+ if reset {
+ defaults.iter().for_each(|(k, v)| set_value(fields, k, v));
+ }
+ shown.output.response
})
.companions(keys)
.full_width()
@@ -413,7 +419,7 @@ fn differs_from(fields: &DialogFields, defaults: &serde_json::Map
/// Revolve's Rotation page: shape, view and the advanced settings.
fn revolve_rows(rows: &Rows, effect: &str, place: Place) -> Vec {
- let mut advanced = vec![rows.range("segments", tl!("Segments"), (8.0, 128.0), 0, UnitKind::Pixels)];
+ let mut advanced = vec![rows.plain("segments", tl!("Segments"), (8.0, 128.0), 0)];
if place == Place::Dialog {
advanced.push(rows.flag("__showAxis", tl!("Show axis")));
}
diff --git a/crates/ui-egui/src/dialogs/revolve/tests.rs b/crates/ui-egui/src/dialogs/revolve/tests.rs
index 53f7a888fe..f0529ee590 100644
--- a/crates/ui-egui/src/dialogs/revolve/tests.rs
+++ b/crates/ui-egui/src/dialogs/revolve/tests.rs
@@ -406,6 +406,39 @@ fn the_bevel_reset_restores_the_bevel_settings_and_keeps_the_others() {
assert_eq!(doc(&h), before);
}
+/// The Bevel heading is a section named Bevel that holds its Reset, on its own line between Cap and Bevel Shape.
+#[test]
+fn the_bevel_heading_is_a_section_between_cap_and_bevel_shape() {
+ use craft::ui::contract::Role;
+ let mut h = drawn(SQUARE, EXTRUDE);
+ h.set("__page", json!("object"));
+ let (cap, reset, shape) = (h.target("Cap").rect, h.target("Reset").rect, h.target("Bevel Shape").rect);
+ let tree = h.fixture.tree();
+ let section = h.fixture.by_role(Role::GROUP).into_iter().find(|t| tree.name_of(t.node) == Some("Bevel")).map(|t| t.rect);
+ assert!(section.is_some_and(|s| s.contains_rect(reset)), "a section named Bevel holds Reset: {section:?} {reset:?}");
+ assert!(reset.top() >= cap.bottom(), "Reset is below Cap: {cap:?} {reset:?}");
+ assert!(shape.top() >= reset.bottom(), "Bevel Shape is below Reset: {reset:?} {shape:?}");
+ h.cancel();
+}
+
+/// The bevel's Repeat and Revolve's Segments are counts: their rows show no unit after the number, while Taper, a
+/// share, shows its percent sign.
+#[test]
+fn the_bevel_repeat_and_the_revolve_segments_show_no_unit() {
+ use craft::ui::patterns::form_dialogs::DialogFields;
+ use craft::ui::runtime::env::UnitKind;
+ let app = VectorcraftApp::new(Session::new(), crate::Services::default());
+ let unit = |effect: &str, page: &str, key: &str| {
+ let data = super::super::three_d::data(&app, Some(effect), &serde_json::Map::new());
+ let mut fields = DialogFields::new();
+ fields.set("__page", FieldValue::Text(page.into()));
+ super::params(&data, &fields, super::Place::Dialog).into_iter().find(|p| p.key == key).map(|p| p.unit)
+ };
+ assert_eq!(unit(EXTRUDE, "object", "bevelRepeat"), Some(None));
+ assert_eq!(unit(REVOLVE, "rotation", "segments"), Some(None));
+ assert_eq!(unit(EXTRUDE, "object", "taper"), Some(Some(UnitKind::Percent)));
+}
+
#[test]
fn reset_all_keeps_map_art_and_its_options() {
let mut h = drawn(SQUARE, CLASSIC_EXTRUDE);
diff --git a/crates/ui-egui/src/dialogs/script_run.rs b/crates/ui-egui/src/dialogs/script_run.rs
index 2dec50814d..7e15614537 100644
--- a/crates/ui-egui/src/dialogs/script_run.rs
+++ b/crates/ui-egui/src/dialogs/script_run.rs
@@ -32,11 +32,12 @@ use std::path::Path;
use craft::host::{PickRequest, Picked};
use craft::theme::variant::Tone;
use craft::ui::buttons::Button;
-use craft::ui::contract::{Bind, Outcome as _, Show as _};
+use craft::ui::contract::{Bind, Outcome as _, Props as _, Scroll, Show as _, ShowContainer as _};
use craft::ui::dialog::{
DialogHost, DialogId, DialogResult, DialogStack, FieldRefusal, Prompt, PromptChoice, StackDialog, StandardPrompt, dialog_id,
};
use craft::ui::display::Text;
+use craft::ui::layout_components::Stack;
use craft::ui::sections::{DialogRole, FooterButton};
use craft::ui::text::TextField;
use egui::Ui;
@@ -66,6 +67,8 @@ pub(crate) const BY_PERSON: &str = "Only the person at the keyboard can allow a
/// The note the file dialog shows when the person picked more files than a script is given.
const PICKED_LEFT_OUT: &str = "A script is given at most 2,048 files: the files picked after them were left out";
+/// The height of the Script File Access prompt's list of picked files before it scrolls, in points.
+const PICKED_LIST_HEIGHT: f32 = 120.0;
/// The warning before a script runs. One type per question, so the host's per-type results never
/// mix the three questions of this area.
@@ -359,7 +362,12 @@ impl StackDialog for ScriptFiles {
}
let rows = |ui: &mut Ui| paths.iter().for_each(|path| drop(Text::new(shown_text(path, false)).show(ui)));
if paths.len() > 1 {
- egui::ScrollArea::vertical().id_salt("script-picked").max_height(120.0).show(ui, rows);
+ Stack::new()
+ .label(tl!("Picked files"))
+ .scroll(Scroll::vertical())
+ .room_height(PICKED_LIST_HEIGHT)
+ .id_salt("script-picked")
+ .show(ui, |ui, _| rows(ui));
} else {
rows(ui);
}
diff --git a/crates/ui-egui/src/dialogs/tests_accessibility.rs b/crates/ui-egui/src/dialogs/tests_accessibility.rs
index 524c3ddcfc..0a060089d6 100644
--- a/crates/ui-egui/src/dialogs/tests_accessibility.rs
+++ b/crates/ui-egui/src/dialogs/tests_accessibility.rs
@@ -1,4 +1,5 @@
-//! The Split Into Grid dialog names its row and column fields with their axis, read from the access tree of the window.
+//! The Split Into Grid dialog names its row and column fields with their axis and lays them out in two columns, read
+//! from the access tree of the window.
use egui::accesskit::Role;
use serde_json::json;
@@ -27,3 +28,24 @@ fn split_into_grid_names_row_and_column_fields_with_context() {
assert!(names.contains(&name), "{name} among the text inputs: {names:?}");
}
}
+
+/// Split Into Grid lays its fields out as a grid: the columns' fields stand right of the rows' fields on the same
+/// lines, and Add Guides stands below the last of them.
+#[test]
+fn split_into_grid_lays_out_its_fields_above_add_guides() {
+ let mut app = app();
+ app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 120, "height": 80})).unwrap();
+ app.run("select.all", json!({})).unwrap();
+ assert!(super::object_dialogs::open_from_menu(&mut app, "object.path.splitIntoGrid"));
+ settle(&mut app);
+ let out = frame(&mut app, vec![]);
+ let update = out.platform_output.accesskit_update.expect("an accessibility tree");
+ let rect = |name: &str| {
+ let node = update.nodes.iter().map(|(_, node)| node).find(|node| node.label() == Some(name));
+ node.and_then(|node| node.bounds()).unwrap_or_else(|| panic!("{name} has a rect"))
+ };
+ let (rows, columns, guides) = (rect("Rows: Total:"), rect("Columns: Total:"), rect("Add Guides"));
+ assert!(columns.x0 > rows.x1, "the columns' fields stand right of the rows' fields: {rows:?} {columns:?}");
+ assert!(columns.y0 < rows.y1 && rows.y0 < columns.y1, "the two Total fields share a line: {rows:?} {columns:?}");
+ assert!(guides.y0 >= rows.y1.max(columns.y1), "Add Guides stands below the grid: {guides:?} {rows:?} {columns:?}");
+}
diff --git a/crates/ui-egui/src/tests/script_dialogs.rs b/crates/ui-egui/src/tests/script_dialogs.rs
index 94e1bb9311..7e90dba636 100644
--- a/crates/ui-egui/src/tests/script_dialogs.rs
+++ b/crates/ui-egui/src/tests/script_dialogs.rs
@@ -77,8 +77,8 @@ pub(super) fn open_blocker(app: &VectorcraftApp) {
}
/// One pass of the dialog host with `events`; a key pressed in it is let go in a second pass, as a
-/// person lets go of it.
-pub(super) fn frame(app: &VectorcraftApp, events: Vec) {
+/// person lets go of it. Returns the last pass's output.
+pub(super) fn frame(app: &VectorcraftApp, events: Vec) -> egui::FullOutput {
let ctx = app.ui_ctx.clone().unwrap();
let dialogs = app.dialogs().unwrap();
let released: Vec = events
@@ -92,10 +92,12 @@ pub(super) fn frame(app: &VectorcraftApp, events: Vec) {
.collect();
let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 800.0)));
let pressed = !released.is_empty();
+ let mut last = egui::FullOutput::default();
for events in std::iter::once(events).chain(pressed.then_some(released)) {
- let mut out = ctx.run_ui(egui::RawInput { events, screen_rect, ..Default::default() }, |ui| dialogs.with(|host| host.run(ui)));
- out.textures_delta.clear();
+ last = ctx.run_ui(egui::RawInput { events, screen_rect, ..Default::default() }, |ui| dialogs.with(|host| host.run(ui)));
+ last.textures_delta.clear();
}
+ last
}
pub(super) fn key(k: egui::Key) -> egui::Event {
diff --git a/crates/ui-egui/src/tests/script_run.rs b/crates/ui-egui/src/tests/script_run.rs
index 42d47ab1cd..b1cdf7cf95 100644
--- a/crates/ui-egui/src/tests/script_run.rs
+++ b/crates/ui-egui/src/tests/script_run.rs
@@ -505,3 +505,39 @@ fn a_scripts_file_dialog_keeps_at_most_2048_picked_files() {
cancel(&mut app, PICKER_KIND);
finish(&mut app);
}
+
+/// With two files picked, the file dialog lists them in a scrolled group named Picked files.
+#[test]
+fn a_scripts_file_dialog_lists_several_picked_files_in_a_named_group() {
+ let mut app = app();
+ app.session.prefs.show_external_script_warning = false;
+ menus::run_ui_command(&mut app, "ui.runScript", &json!({ "source": "File.openDialog('Pick', '', true);" })).unwrap().unwrap();
+ script_runs::poll(&mut app);
+ let given = vec!["/picked/a.txt".to_string(), "/picked/b.txt".to_string()];
+ script_run::with_host(&app, |host, _| host.get_mut::().map(|d| d.add(given, true, false))).unwrap();
+ frame(&app, vec![]);
+ let out = frame(&app, vec![]);
+ let update = out.platform_output.accesskit_update.expect("an accessibility tree");
+ let groups: Vec<_> =
+ update.nodes.iter().filter(|(_, node)| node.role() == egui::accesskit::Role::Group).filter_map(|(_, node)| node.label()).collect();
+ assert!(groups.contains(&"Picked files"), "a group named Picked files: {groups:?}");
+ let nodes: std::collections::HashMap<_, _> = update.nodes.iter().map(|(id, node)| (*id, node)).collect();
+ let (_, group) = update
+ .nodes
+ .iter()
+ .find(|(_, node)| node.role() == egui::accesskit::Role::Group && node.label() == Some("Picked files"))
+ .expect("the Picked files group");
+ let mut texts = Vec::new();
+ let mut pending = group.children().to_vec();
+ while let Some(id) = pending.pop() {
+ if let Some(node) = nodes.get(&id) {
+ texts.extend(node.label().into_iter().chain(node.value()).map(str::to_owned));
+ pending.extend_from_slice(node.children());
+ }
+ }
+ for path in ["/picked/a.txt", "/picked/b.txt"] {
+ assert!(texts.iter().any(|text| text == path), "{path} is inside the Picked files group: {texts:?}");
+ }
+ cancel(&mut app, PICKER_KIND);
+ finish(&mut app);
+}