mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 11:45:55 +00:00
Merge pull request #9415 from dotCooCoo/fix/legacy-ai-artboards-grid-name
Legacy AI Save Options: the artboard grid uses the interface language
This commit is contained in:
@@ -422,7 +422,7 @@ fn boards_picker(ui: &mut egui::Ui, fields: &mut DialogFields, menus: &Menus) ->
|
||||
}
|
||||
// PLAN: assumed TileGrid::show_items(ui, &source, &mut |key, _| tile) as the framework's stories call it;
|
||||
// the checks arrive as `CollectionEvent::Item(key, TilePartEvent::Check { .. })` in `response.events`.
|
||||
let grid = TileGrid::new("Artboards").checks(true).max_rows(BOARD_ROWS).show_items(ui, &Boards(n), &mut |i, _| {
|
||||
let grid = TileGrid::new(tl!("Artboards")).checks(true).max_rows(BOARD_ROWS).show_items(ui, &Boards(n), &mut |i, _| {
|
||||
let on = boards.get(*i).copied().unwrap_or(false);
|
||||
let mut tile = Tile::new(menus.names.get(*i).cloned().unwrap_or_default()).check(if on { ToggleState::On } else { ToggleState::Off });
|
||||
if let Some(file) = files.get(*i).cloned().flatten() {
|
||||
|
||||
@@ -247,27 +247,31 @@ fn legacy_ai_saves_the_artboards_checked_in_its_picker() {
|
||||
assert_eq!(boards_in(&dialog(&mut app)), Some(vec![true, false, true, false]));
|
||||
}
|
||||
|
||||
/// The legacy picker's note and its count of checked artboards are in the window's accessibility tree, and the count
|
||||
/// follows the checks.
|
||||
/// The legacy picker's note, grid name and count are announced. The count follows the checks and
|
||||
/// the grid name follows the interface language.
|
||||
#[test]
|
||||
fn legacy_ai_names_its_note_and_artboard_count_in_the_accessibility_tree() {
|
||||
fn legacy_ai_announces_its_note_grid_name_and_artboard_count() {
|
||||
let (mut app, _, _) = desktop("art.ai");
|
||||
app.run("artboard.new", json!({"x": 200, "y": 0, "width": 100, "height": 80})).unwrap();
|
||||
save_as(&mut app, "file.saveAs");
|
||||
set(&mut app, "aiVersion", json!("7"));
|
||||
let labels = |app: &mut VectorcraftApp| -> Vec<String> {
|
||||
let labels = |app: &mut VectorcraftApp, role: Option<egui::accesskit::Role>| -> Vec<String> {
|
||||
frame(app);
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
let out = crate::testing::part_frame(app, &ctx, egui::RawInput::default(), |app, ui| app.ui(ui));
|
||||
let out = crate::testing::app_frame(app, &ctx, egui::RawInput::default());
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
nodes.iter().filter_map(|(_, node)| node.label()).map(str::to_owned).collect()
|
||||
nodes.iter().filter(|(_, node)| role.is_none_or(|role| node.role() == role)).filter_map(|(_, node)| node.label()).map(str::to_owned).collect()
|
||||
};
|
||||
let shown = labels(&mut app);
|
||||
let shown = labels(&mut app, None);
|
||||
assert!(shown.iter().any(|l| l.starts_with("A legacy .ai file holds one artboard")), "{shown:?}");
|
||||
assert!(shown.iter().any(|l| l == "2 of 2 artboards"), "{shown:?}");
|
||||
set(&mut app, "boards", json!([true, false]));
|
||||
let shown = labels(&mut app);
|
||||
let shown = labels(&mut app, None);
|
||||
assert!(shown.iter().any(|l| l == "1 of 2 artboards") && !shown.iter().any(|l| l == "2 of 2 artboards"), "{shown:?}");
|
||||
|
||||
app.session.prefs.interface_language = "fr".into();
|
||||
let shown = labels(&mut app, Some(egui::accesskit::Role::ListBox));
|
||||
assert!(shown.iter().any(|label| label == "Plans de travail"), "{shown:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user