mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 12:21:08 +01:00
Merge pull request #9249 from dotCooCoo/fix/ui-port-text-divider-notice
UI: dialog and panel labels, separators and notices use Text, Divider and Notice
This commit is contained in:
24 files changed
+222
-43
No files matched your search
@@ -141,6 +141,8 @@ Generated-in-code art is original and has no file to list. This covers the defau
|
||||
| `assets/icons/dc-arrow-down.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-arrow-extend.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-arrow-fill.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | The Selection and Direct Selection arrows' fill, painted black or white under their outline |
|
||||
| `assets/icons/dc-arrow-left.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-arrow-right.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-arrow-tip.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-arrow-up.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-artboard.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><path d="M19 12H5M10.5 6.5L5 12L10.5 17.5" stroke-width="1.6" /></svg>
|
||||
|
After Width: | Height: | Size: 253 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="butt" stroke-linejoin="miter"><path d="M5 12H19M13.5 6.5L19 12L13.5 17.5" stroke-width="1.6" /></svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -528,13 +528,18 @@ fn art_rows(object: bool) -> Vec<Param> {
|
||||
rows
|
||||
}
|
||||
|
||||
/// The direction of the art along the stroke: a segment per direction in [`DIRECTIONS`] order.
|
||||
/// The direction of the art along the stroke: an arrow segment per direction in [`DIRECTIONS`] order,
|
||||
/// named by its tooltip.
|
||||
fn direction_row() -> Param {
|
||||
// PLAN: the arrows are text until sh.S5's `APP_ICONS` names its arrow icons (with the tooltips Left to Right, Right to Left, Top to Bottom, Bottom to Top); a screen reader reads each segment as its glyph.
|
||||
let arrows = ["→", "←", "↓", "↑"];
|
||||
let arrows = [
|
||||
("dc-arrow-right", tl!("Left to Right")),
|
||||
("dc-arrow-left", tl!("Right to Left")),
|
||||
("dc-arrow-down", tl!("Top to Bottom")),
|
||||
("dc-arrow-up", tl!("Bottom to Top")),
|
||||
];
|
||||
Param::custom("direction", tl!("Direction"), move |ui, f, _| {
|
||||
let current = DIRECTIONS.iter().position(|d| *d == parse_field::<Direction>(f, "direction")).unwrap_or(0);
|
||||
let entries: Vec<Entry<usize>> = arrows.iter().enumerate().map(|(i, arrow)| Entry::new(i, *arrow)).collect();
|
||||
let entries: Vec<Entry<usize>> = arrows.iter().enumerate().map(|(i, (icon, tip))| Entry::new(i, *tip).icon(IconId::new(icon))).collect();
|
||||
let shown = Segmented::new(tl!("Direction"), Bind::given(current), &entries).show(ui);
|
||||
if let Some(dir) = shown.value().and_then(|i| DIRECTIONS.get(*i)) {
|
||||
f.set("direction", id_of(dir));
|
||||
|
||||
@@ -278,6 +278,26 @@ fn ok_redraws_the_strokes_painted_with_the_brush() {
|
||||
assert!((drawn_height(&app, id) - before).abs() < 1e-6);
|
||||
}
|
||||
|
||||
/// Art Brush Options draws each Direction segment as an arrow icon named by its tooltip, so the
|
||||
/// accessibility tree reads the direction instead of an arrow glyph.
|
||||
#[test]
|
||||
fn art_brush_direction_segments_are_named_by_their_tooltips() {
|
||||
let mut app = app();
|
||||
open(&mut app, "Arrow");
|
||||
crate::dialogs::tests::settle(&mut app);
|
||||
let out = crate::dialogs::tests::frame(&mut app, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
// Segmented gives each segment the radio button role.
|
||||
let segments: Vec<&str> =
|
||||
nodes.iter().filter(|(_, node)| node.role() == egui::accesskit::Role::RadioButton).filter_map(|(_, node)| node.label()).collect();
|
||||
for tip in ["Left to Right", "Right to Left", "Top to Bottom", "Bottom to Top"] {
|
||||
assert!(segments.contains(&tip), "no segment is named {tip} in {segments:?}");
|
||||
}
|
||||
for glyph in ["→", "←", "↓", "↑"] {
|
||||
assert!(!segments.contains(&glyph), "a segment is named {glyph}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_taken_name_keeps_the_dialog_open() {
|
||||
let mut app = app();
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
//! (asking where when there is no path); bad options keep the dialog open.
|
||||
|
||||
use craft::ui::contract::{Bind, Entry, Show as _, ShowContainer as _};
|
||||
use craft::ui::display::{Shade, Text};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind};
|
||||
use craft::ui::pickers::Select;
|
||||
use craft::ui::style::TypeRole;
|
||||
use craft::ui::text::NumberField;
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_cad::{ColorDepth, DxfPreset, DxfVersion, Preserve, RasterFormat};
|
||||
@@ -145,11 +147,11 @@ pub(crate) fn scale_param(disabled_when: Option<(&str, FieldValue)>) -> Param {
|
||||
let (lo, hi) = (*vectorcraft_cad::SCALE_RANGE.start(), *vectorcraft_cad::SCALE_RANGE.end());
|
||||
let shown = Row::new()
|
||||
.show(ui, |ui, _| {
|
||||
ui.label("1");
|
||||
Text::new("1").show(ui);
|
||||
Select::new(tl!("Unit"), Bind::bound(&mut unit), &units).show(ui);
|
||||
ui.label("=");
|
||||
Text::new("=").show(ui);
|
||||
NumberField::new(tl!("Scale"), Bind::bound(&mut scale)).range(lo..=hi).show(ui);
|
||||
ui.label(tl!("Units"));
|
||||
Text::new(tl!("Units")).show(ui);
|
||||
})
|
||||
.output;
|
||||
let scale = scale.unwrap_or(1.0);
|
||||
@@ -200,10 +202,13 @@ pub fn open_with(app: &mut VectorcraftApp, params: &Value, selection: bool) {
|
||||
.values(Bind::bound(fields))
|
||||
.ok_label(tl!("Export").into())
|
||||
.below(|ui, fields| {
|
||||
ui.weak(match fields.text("preserve").and_then(Preserve::from_id).unwrap_or_default() {
|
||||
Text::new(match fields.text("preserve").and_then(Preserve::from_id).unwrap_or_default() {
|
||||
Preserve::Appearance => tl!("Type becomes outlines, and strokes a CAD line can't draw become filled shapes."),
|
||||
Preserve::Editability => tl!("Type stays text, and every stroke is a line with its lineweight and dashes."),
|
||||
});
|
||||
})
|
||||
.role(TypeRole::Caption)
|
||||
.shade(Shade::Muted)
|
||||
.show(ui);
|
||||
})
|
||||
});
|
||||
export_host::open(app, Export::Dxf, selection, dialog);
|
||||
|
||||
@@ -17,8 +17,10 @@ use std::sync::Arc;
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::contract::{Bind, Show as _, ShowContainer as _, TooltipSpec};
|
||||
use craft::ui::dialog::DialogId;
|
||||
use craft::ui::display::{Shade, Text};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind};
|
||||
use craft::ui::style::TypeRole;
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_engine::cmd::{FlattenOptions, FlattenerPreset, fileio};
|
||||
use vectorcraft_eps::{Level, Overprint, Preview};
|
||||
@@ -139,11 +141,14 @@ pub fn open_with(app: &mut VectorcraftApp, params: &Value, selection: bool) {
|
||||
builtin_label(fields);
|
||||
normalise_level(fields);
|
||||
ParamDialog::new(KIND, tl!("EPS Options"), rows(&presets)).values(Bind::bound(fields)).ok_label(tl!("Export").into()).below(|ui, fields| {
|
||||
ui.weak(if fields.text("level").and_then(Level::from_id) == Some(Level::Two) || fields.bool("compatibleGradients") == Some(true) {
|
||||
Text::new(if fields.text("level").and_then(Level::from_id) == Some(Level::Two) || fields.bool("compatibleGradients") == Some(true) {
|
||||
tl!("Transparency is flattened with the preset. Type is written as outlines; gradients as bands of colour.")
|
||||
} else {
|
||||
tl!("Transparency is flattened with the preset. Type is written as outlines; gradients stay smooth.")
|
||||
});
|
||||
})
|
||||
.role(TypeRole::Caption)
|
||||
.shade(Shade::Muted)
|
||||
.show(ui);
|
||||
})
|
||||
});
|
||||
export_host::open(app, Export::Eps, selection, dialog);
|
||||
@@ -198,7 +203,10 @@ pub(super) fn custom_dialog(app: &VectorcraftApp, parent: DialogId, fields: &Dia
|
||||
ParamDialog::new(CUSTOM_KIND, tl!("Custom Transparency Flattener Options"), flatten::option_params(&FIXED, FIXED_REASON))
|
||||
.values(Bind::bound(fields))
|
||||
.below(|ui, _| {
|
||||
ui.weak(tl!("EPS has no alpha transparency, and Overprints sets whether overprints are kept."));
|
||||
Text::new(tl!("EPS has no alpha transparency, and Overprints sets whether overprints are kept."))
|
||||
.role(TypeRole::Caption)
|
||||
.shade(Shade::Muted)
|
||||
.show(ui);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use craft::ui::contract::Bind;
|
||||
use craft::ui::contract::{Bind, Show as _};
|
||||
use craft::ui::display::{Shade, Text};
|
||||
use craft::ui::patterns::form_dialogs::{DialogFields, HostedParamDialog, Param, ParamDialog, ParamKind};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::style::TypeRole;
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_engine::cmd::fileio::{self, ArtboardPick, Format};
|
||||
|
||||
@@ -127,7 +129,7 @@ fn open_dialog(app: &mut VectorcraftApp, format: Option<&str>, p: &Value) -> Res
|
||||
ParamDialog::new(KIND, tl!("Export As"), params())
|
||||
.values(Bind::bound(fields))
|
||||
.below(|ui, fields| {
|
||||
ui.weak(summary(fields));
|
||||
Text::new(summary(fields)).role(TypeRole::Caption).shade(Shade::Muted).show(ui);
|
||||
})
|
||||
.ok_label(Label::from("Export…"))
|
||||
});
|
||||
|
||||
@@ -12,15 +12,16 @@
|
||||
//! nothing.
|
||||
|
||||
use craft::behavior::IconId;
|
||||
use craft::theme::variant::Tone;
|
||||
use craft::theme::{Rgba, Srgba};
|
||||
use craft::ui::buttons::{Button, IconButton};
|
||||
use craft::ui::choice::{Radio, RadioGroup, Swatch};
|
||||
use craft::ui::contract::{Bind, Props as _, Scroll, Show as _, ShowContainer as _};
|
||||
use craft::ui::contract::{Bind, Politeness, Props as _, Scroll, Show as _, ShowContainer as _};
|
||||
use craft::ui::dialog::DialogId;
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::notices::{Notice, NoticeLayout};
|
||||
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog};
|
||||
use craft::ui::runtime::env::Env;
|
||||
use craft::ui::style::rgba_color;
|
||||
use craft::ui::text::TextField;
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_cad::hpgl::write::{DEFAULT_TOLERANCE, MAX_PENS, TOLERANCE_RANGE};
|
||||
@@ -209,8 +210,10 @@ fn pens_ui(ui: &mut egui::Ui, fields: &DialogFields) -> PensAsked {
|
||||
asked.table = Some(on);
|
||||
}
|
||||
if let Some(e) = fields.text(PEN_ERROR).filter(|_| asked.table != Some(false)) {
|
||||
let error = rgba_color(Env::of(ui).tokens.tokens().color.status.bad.fg);
|
||||
ui.colored_label(error, crate::i18n::message(crate::i18n::current(), e));
|
||||
Notice::new(Tone::Bad, crate::i18n::message(crate::i18n::current(), e).to_string())
|
||||
.layout(NoticeLayout::Inline)
|
||||
.announce(Politeness::Assertive)
|
||||
.show(ui);
|
||||
}
|
||||
// A table longer than a plot takes (set through `ui.dialog.set`) draws no rows: OK refuses it.
|
||||
let Some(mut pens) = list.filter(|a| asked.table.is_none() && a.len() <= MAX_PENS) else { return asked };
|
||||
@@ -225,7 +228,7 @@ fn pens_ui(ui: &mut egui::Ui, fields: &DialogFields) -> PensAsked {
|
||||
(remove, asked.pick) = (None, None);
|
||||
for (i, pen) in pens.iter().enumerate() {
|
||||
Row::new().id_salt(("hpgl-pen-row", i)).show(ui, |ui, _| {
|
||||
ui.label((i + 1).to_string());
|
||||
Text::new((i + 1).to_string()).show(ui);
|
||||
let mut color = pen.as_str().and_then(Rgba::from_hex).unwrap_or(Rgba::rgb(0, 0, 0));
|
||||
if Swatch::new(tl!("Pen color"), Srgba::from(color)).show(ui).clicked {
|
||||
asked.pick = Some((i, Srgba::from(color)));
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
//! Behavior reference: the help page
|
||||
//! <https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/use-kinsoku-for-japanese-line-breaking.html>.
|
||||
|
||||
use craft::theme::variant::Tone;
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::contract::{Bind, Entry, Politeness, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, HeldAnswer, HeldOk, StackDialog, dialog_id};
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::form::{Field, FieldGroup};
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::notices::{Notice, NoticeLayout};
|
||||
use craft::ui::patterns::presets::{
|
||||
NameCheck, NamedPresetEvent, NamedPresetRow, PickerField, PresetError, PresetPicker, PresetRow, PresetSource, PresetState,
|
||||
};
|
||||
@@ -408,9 +410,8 @@ impl KinsokuDialog {
|
||||
}
|
||||
|
||||
fn show_problem(&self, ui: &mut Ui) {
|
||||
// PLAN: craft_ui does not re-export `Tone`, which `Notice` needs, so the reason shows as plain text.
|
||||
if let Some(problem) = &self.problem {
|
||||
Text::new(problem.clone()).show(ui);
|
||||
Notice::new(Tone::Bad, problem.clone()).layout(NoticeLayout::Inline).announce(Politeness::Assertive).show(ui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// 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::ui::dialog::DialogId;
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::form::Field;
|
||||
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind};
|
||||
use craft::ui::runtime::env::{LengthUnits, UnitKind};
|
||||
@@ -286,7 +287,7 @@ fn counts_row(ui: &mut egui::Ui, f: &DialogFields) {
|
||||
if let Some(FieldValue::Json(c)) = f.get(COUNTS)
|
||||
&& let (Some(before), Some(after)) = (c["before"].as_u64(), c["after"].as_u64())
|
||||
{
|
||||
ui.label(format!("{} {before} → {after}", crate::i18n::colon(tl!("Anchor Points"))));
|
||||
Text::new(format!("{} {before} → {after}", crate::i18n::colon(tl!("Anchor Points")))).show(ui);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ fn resolution_row() -> Param {
|
||||
fn size_row(w: f64, h: f64) -> Param {
|
||||
Param::custom("__sizeText", tl!("Size:"), move |ui, fields, _| {
|
||||
let (pw, ph) = vectorcraft_render::region_pixels(vectorcraft_geom::Rect::new(0.0, 0.0, w, h), fields.number("ppi").unwrap_or(72.0) / 72.0);
|
||||
ui.label(format!("{pw} × {ph} px"))
|
||||
Text::new(format!("{pw} × {ph} px")).show(ui)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ use craft::ui::pickers::{Anchor9, ReferencePoint, ReferencePointLook};
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::runtime::env::{LengthUnits, UnitKind};
|
||||
use craft::ui::shell::WindowDialogs;
|
||||
use craft::ui::text::{LinkMode, LinkedFields, NumberField};
|
||||
use craft::ui::text::{LinkMode, LinkedFields, NumberField, SelectableText};
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_color::cms::Intent;
|
||||
use vectorcraft_engine::cmd::printpresets::DEFAULT_PRESET;
|
||||
@@ -669,9 +669,9 @@ fn scaling_ids(tiles: bool) -> Vec<&'static str> {
|
||||
PrintScaling::ALL.iter().filter(|s| s.tiles() == tiles).map(|s| s.id()).collect()
|
||||
}
|
||||
|
||||
/// A summary line that the pump fills (`key` is a `__` companion of the fields).
|
||||
fn shown(key: &'static str) -> Param {
|
||||
Param::custom(key, "", move |ui, fields, _| ui.label(fields.text(key).unwrap_or_default()))
|
||||
/// A summary line that the pump fills (`key` is a `__` companion of the fields), selectable and named `label`.
|
||||
fn shown(key: &'static str, label: &'static str) -> Param {
|
||||
Param::custom(key, "", move |ui, fields, _| SelectableText::new(label, fields.text(key).unwrap_or_default()).multiline().show(ui))
|
||||
}
|
||||
|
||||
/// The sections of the dialog, with the rows of each.
|
||||
@@ -827,11 +827,11 @@ fn sections(lists: &Lists) -> Vec<PrintSection> {
|
||||
];
|
||||
let summary = vec![
|
||||
Param::section(tl!("Pages")),
|
||||
shown("__summary.pages"),
|
||||
shown("__summary.pages", tl!("Pages")),
|
||||
Param::section(tl!("Options")),
|
||||
shown("__summary.options"),
|
||||
shown("__summary.options", tl!("Options")),
|
||||
Param::section(tl!("Warnings")),
|
||||
shown("__summary.warnings"),
|
||||
shown("__summary.warnings", tl!("Warnings")),
|
||||
];
|
||||
[general, marks, output, graphics, color, advanced, summary]
|
||||
.into_iter()
|
||||
|
||||
@@ -36,6 +36,7 @@ use vectorcraft_eps::{Level, Overprint, Preview};
|
||||
use craft::theme::variant::Tone;
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::contract::{Bind, CollectionEvent, Show as _, ShowCollection as _, ShowContainer as _, TooltipSpec};
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::list::{ThumbAspect, ToggleState};
|
||||
use craft::ui::notices::Notice;
|
||||
@@ -404,7 +405,7 @@ fn boards_picker(ui: &mut egui::Ui, fields: &mut DialogFields, menus: &Menus) ->
|
||||
.show(ui, |ui, _| {
|
||||
// Each run of the body starts from the checks as they stood: a check flips them, and the body may run twice.
|
||||
boards.clone_from(&before);
|
||||
ui.label(tl!("A legacy .ai file holds one artboard: each artboard you check is saved as a separate file."));
|
||||
Notice::new(Tone::Info, tl!("A legacy .ai file holds one artboard: each artboard you check is saved as a separate file.")).show(ui);
|
||||
Row::new().show(ui, |ui, _| {
|
||||
if Button::new(tl!("Select All")).show(ui).clicks > 0 {
|
||||
boards.iter_mut().for_each(|b| *b = true);
|
||||
@@ -414,7 +415,7 @@ fn boards_picker(ui: &mut egui::Ui, fields: &mut DialogFields, menus: &Menus) ->
|
||||
}
|
||||
let checked = boards.iter().filter(|b| **b).count();
|
||||
let (count, total) = (checked.to_string(), n.to_string());
|
||||
ui.label(crate::i18n::fmt(tl!("{count} of {total} artboards"), &[("count", &count), ("total", &total)]));
|
||||
Text::new(crate::i18n::fmt(tl!("{count} of {total} artboards"), &[("count", &count), ("total", &total)])).show(ui);
|
||||
});
|
||||
if !boards.iter().any(|b| *b) {
|
||||
Notice::new(Tone::Warn, tl!("Check an artboard to save.")).show(ui);
|
||||
|
||||
@@ -247,6 +247,29 @@ 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.
|
||||
#[test]
|
||||
fn legacy_ai_names_its_note_and_artboard_count_in_the_accessibility_tree() {
|
||||
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> {
|
||||
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 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()
|
||||
};
|
||||
let shown = labels(&mut app);
|
||||
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);
|
||||
assert!(shown.iter().any(|l| l == "1 of 2 artboards") && !shown.iter().any(|l| l == "2 of 2 artboards"), "{shown:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_a_copy_and_template_suggest_their_names() {
|
||||
let (mut app, written, picks) = desktop("copy.vectorcraft");
|
||||
|
||||
@@ -206,6 +206,67 @@ fn export_as_png_picks_the_file_then_shows_png_options() {
|
||||
assert_eq!(&written.borrow()[0].1[16..20], 120u32.to_be_bytes(), "60 pt at 144 ppi");
|
||||
}
|
||||
|
||||
/// PNG Options' pixel size is in the window's accessibility tree, and it follows the resolution.
|
||||
#[test]
|
||||
fn png_options_name_the_pixel_size_in_the_accessibility_tree() {
|
||||
let (mut app, _) = app(1);
|
||||
app.run("file.export.png", json!({})).unwrap();
|
||||
answer_saves(&mut app);
|
||||
let sizes = |app: &mut VectorcraftApp| -> Vec<String> {
|
||||
super::tests::settle(app);
|
||||
let out = super::tests::frame(app, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
nodes.iter().filter_map(|(_, node)| node.label()).filter(|label| label.ends_with(" px")).map(str::to_owned).collect()
|
||||
};
|
||||
let at_72 = sizes(&mut app);
|
||||
assert_eq!(at_72, ["60 × 40 px"]);
|
||||
set(&mut app, "ppi", json!(144));
|
||||
assert_eq!(sizes(&mut app), ["120 × 80 px"]);
|
||||
}
|
||||
|
||||
/// The role and name of each node of the window's accessibility tree, in a frame drawn once the dialogs have settled.
|
||||
fn access_names(app: &mut VectorcraftApp) -> Vec<(egui::accesskit::Role, String)> {
|
||||
super::tests::settle(app);
|
||||
let out = super::tests::frame(app, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
nodes.iter().filter_map(|(_, node)| node.label().map(|label| (node.role(), label.to_owned()))).collect()
|
||||
}
|
||||
|
||||
/// The hints under Export As, DXF Options and EPS Options, the words of the DXF scale row and the HP-GL pen numbers
|
||||
/// are in the window's accessibility tree, and the HP-GL pen error is announced as an alert.
|
||||
#[test]
|
||||
fn export_dialogs_name_their_hints_rows_and_errors_in_the_accessibility_tree() {
|
||||
let names = |app: &mut VectorcraftApp| -> Vec<String> { access_names(app).into_iter().map(|(_, name)| name).collect() };
|
||||
let (mut app, _) = app(1);
|
||||
app.run("file.exportAs", json!({"format": "png", "useArtboards": false})).unwrap();
|
||||
let shown = names(&mut app);
|
||||
assert!(shown.iter().any(|n| n == "The bounds of the visible art."), "{shown:?}");
|
||||
cancel(&mut app);
|
||||
|
||||
crate::menus::invoke(&mut app, "ui.dxfOptionsDialog", json!({}));
|
||||
let shown = names(&mut app);
|
||||
for word in ["=", "Units"] {
|
||||
assert!(shown.iter().any(|n| n == word), "{word} is not named in {shown:?}");
|
||||
}
|
||||
assert!(shown.iter().any(|n| n.starts_with("Type becomes outlines")), "{shown:?}");
|
||||
cancel(&mut app);
|
||||
|
||||
crate::menus::invoke(&mut app, "ui.epsOptionsDialog", json!({}));
|
||||
let shown = names(&mut app);
|
||||
assert!(shown.iter().any(|n| n.starts_with("Transparency is flattened with the preset.")), "{shown:?}");
|
||||
cancel(&mut app);
|
||||
|
||||
app.run("ui.hpglOptionsDialog", json!({})).unwrap();
|
||||
set(&mut app, "pens", json!(["#ff0000", "#000000"]));
|
||||
set(&mut app, "__penError", json!("The pens could not be listed."));
|
||||
let shown = access_names(&mut app);
|
||||
assert!(shown.iter().any(|(_, n)| n == "2"), "the second pen's number is not named in {shown:?}");
|
||||
assert!(
|
||||
shown.iter().any(|(role, n)| *role == egui::accesskit::Role::Alert && n.contains("The pens could not be listed.")),
|
||||
"the pen error is not an alert in {shown:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// File › Export › Export As PNG… exports the artboard in use, not the first (#5502), and each
|
||||
/// artboard the Artboard tool has selected, one file each.
|
||||
#[test]
|
||||
|
||||
@@ -115,6 +115,18 @@ fn simplify_opens_a_slider_whose_drag_previews_fewer_or_more_points() {
|
||||
assert_eq!(anchor_count(&app), 2);
|
||||
}
|
||||
|
||||
/// The Simplify dialog's count of anchor points before and after is in the window's accessibility tree.
|
||||
#[test]
|
||||
fn the_simplify_dialog_names_its_anchor_point_counts() {
|
||||
let mut app = app_with_dense_path();
|
||||
open_simplify_dialog(&mut app);
|
||||
settle(&mut app);
|
||||
let out = frame(&mut app, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
let names: Vec<&str> = nodes.iter().filter_map(|(_, node)| node.label()).collect();
|
||||
assert!(names.iter().any(|n| n.starts_with("Anchor Points:") && n.contains('→')), "{names:?}");
|
||||
}
|
||||
|
||||
/// A wave of 20 anchors `width` pt wide and `width / 5` pt high, selected.
|
||||
fn app_with_wave(width: f64) -> VectorcraftApp {
|
||||
let mut app = window(VectorcraftApp::new(Session::new(), Default::default()));
|
||||
|
||||
@@ -399,6 +399,23 @@ fn the_control_channel_fills_and_confirms_the_dialog() {
|
||||
assert_eq!(jobs.borrow().len(), 1);
|
||||
}
|
||||
|
||||
/// The Summary section's Pages, Options and Warnings are each named in the window's accessibility tree, with their
|
||||
/// summary text as the value.
|
||||
#[test]
|
||||
fn the_summary_names_its_pages_options_and_warnings() {
|
||||
let (mut app, _) = app();
|
||||
app.run("file.print", json!({})).unwrap();
|
||||
pump(&mut app);
|
||||
set(&mut app, "section", json!("Summary"));
|
||||
pump(&mut app);
|
||||
let ctx = ctx(&app);
|
||||
let out = crate::testing::app_frame(&mut app, &ctx, Default::default());
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
for name in ["Pages", "Options", "Warnings"] {
|
||||
assert!(nodes.iter().any(|(_, n)| n.label() == Some(name) && n.value().is_some_and(|v| !v.is_empty())), "{name} has no summary");
|
||||
}
|
||||
}
|
||||
|
||||
/// Scale W and H of the open dialog, and its link.
|
||||
fn scale(app: &VectorcraftApp) -> (f64, f64, bool) {
|
||||
let f = fields(app);
|
||||
|
||||
@@ -13,7 +13,7 @@ use craft::ui::canvas::Canvas;
|
||||
use craft::ui::canvas::{CanvasSpace, canvas_space};
|
||||
use craft::ui::canvas_controls::SelectionOutline;
|
||||
use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::display::Picture;
|
||||
use craft::ui::display::{Picture, Text};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, FieldValue, HostedParamDialog, Param, ParamKind};
|
||||
@@ -315,7 +315,7 @@ fn navigator(count: usize, seen: Vec<bool>) -> Param {
|
||||
}
|
||||
}
|
||||
if !seen.get(current - 1).copied().unwrap_or(true) {
|
||||
ui.label(tl!("Hidden"));
|
||||
Text::new(tl!("Hidden")).show(ui);
|
||||
}
|
||||
});
|
||||
let shown = next.map_or(current, |n| n.clamp(1, count));
|
||||
|
||||
@@ -48,6 +48,8 @@ pub static ICONS: &[(&str, &[u8])] = &[
|
||||
("dc-arc-three-point", include_bytes!("../../../assets/icons/dc-arc-three-point.svg")),
|
||||
("dc-arrow-down", include_bytes!("../../../assets/icons/dc-arrow-down.svg")),
|
||||
("dc-arrow-extend", include_bytes!("../../../assets/icons/dc-arrow-extend.svg")),
|
||||
("dc-arrow-left", include_bytes!("../../../assets/icons/dc-arrow-left.svg")),
|
||||
("dc-arrow-right", include_bytes!("../../../assets/icons/dc-arrow-right.svg")),
|
||||
("dc-arrow-tip", include_bytes!("../../../assets/icons/dc-arrow-tip.svg")),
|
||||
("dc-arrow-up", include_bytes!("../../../assets/icons/dc-arrow-up.svg")),
|
||||
("dc-artboard", include_bytes!("../../../assets/icons/dc-artboard.svg")),
|
||||
|
||||
@@ -20,7 +20,7 @@ use craft::behavior::{EditEvent, GesturePhase, IconId, Selection};
|
||||
use craft::ui::contract::{
|
||||
Bind, DropAt, DropPayload, DropPlace, Entry, ListDrag, MemoProps, PopupKind, ReorderMove, SelectMode, Show as _, ShowContainer as _, Trigger,
|
||||
};
|
||||
use craft::ui::display::{Divider, Picture, PictureSize};
|
||||
use craft::ui::display::{Divider, Picture, PictureSize, Text};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::{Menu, MenuItem, PanelRow};
|
||||
use craft::ui::patterns::presets::{
|
||||
@@ -404,7 +404,7 @@ fn large_tip(app: &VectorcraftApp, thumbs: &StyleThumbs, ui: &mut Ui, key: &Styl
|
||||
})
|
||||
.extent(PictureSize::Fill)
|
||||
.show(ui);
|
||||
ui.label(key);
|
||||
Text::new(key.clone()).show(ui);
|
||||
}
|
||||
|
||||
// ---------- the panel ----------
|
||||
|
||||
@@ -507,6 +507,18 @@ fn context_menu_others_actions_sublayer_state_enables_all_commands() {
|
||||
assert!(lock_enabled, "locked sublayer enables Unlock All Layers");
|
||||
}
|
||||
|
||||
/// The footer's layer count is in the accessibility tree, and it follows the document's layers.
|
||||
#[test]
|
||||
fn the_footer_counts_the_layers() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
let (app, _, _) = two_rects();
|
||||
let mut panel = Panel::new(app, show);
|
||||
assert!(panel.shows("1 Layer"));
|
||||
panel.app().session.execute("layer.new", &json!({})).unwrap();
|
||||
panel.frame();
|
||||
assert!(panel.shows("2 Layers") && !panel.shows("1 Layer"));
|
||||
}
|
||||
|
||||
/// Names object `id` `name`, so its target circle is "Target {name}".
|
||||
fn name_row(app: &mut VectorcraftApp, id: NodeId, name: &str) {
|
||||
app.session.execute("layer.setProps", &json!({"ids": [id.0], "name": name})).unwrap();
|
||||
|
||||
@@ -11,6 +11,7 @@ use craft::keymap::CommandRef;
|
||||
use craft::ui::buttons::IconButton;
|
||||
use craft::ui::choice::Segmented;
|
||||
use craft::ui::contract::{Bind, Entry, FieldLabelRole, Props as _, Show as _, ShowContainer as _, SideLabel, Sizing, TooltipSpec};
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::form::Field;
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::menu::PanelRow;
|
||||
@@ -387,9 +388,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if let (Some(new), Some(field)) = (output.events.landed(), output.field) {
|
||||
apply_style(app, &style, new.clone(), field);
|
||||
}
|
||||
ui.separator();
|
||||
Divider::horizontal().show(ui);
|
||||
arrow_rows(app, ui, st.as_ref());
|
||||
ui.separator();
|
||||
Divider::horizontal().show(ui);
|
||||
Field::new(tl!("Profile")).show(ui, |ui, _| {
|
||||
Row::new().wrap(true).show(ui, |ui, _| {
|
||||
profile_select(app, ui);
|
||||
|
||||
@@ -2,7 +2,8 @@ use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::ui::contract::{Entry, MemoKey, MemoProps};
|
||||
use craft::ui::contract::{Entry, MemoKey, MemoProps, Show as _};
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::patterns::presets::PresetRow;
|
||||
use craft::ui::primitives::ContentPainterCx;
|
||||
use egui::{Rect, Ui};
|
||||
@@ -163,10 +164,10 @@ impl LibraryKind for SwatchLibraries {
|
||||
if item(ui, tl!("Default Swatches"), app.session.active().is_some(), None) {
|
||||
app.run("swatch.resetDefaults", json!({})).ok();
|
||||
}
|
||||
ui.separator();
|
||||
Divider::horizontal().show(ui);
|
||||
}
|
||||
fn menu_tail(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
ui.separator();
|
||||
Divider::horizontal().show(ui);
|
||||
// As a command, so its file dialog, shown off the UI thread, loads the library when it
|
||||
// answers.
|
||||
if item(ui, tl!("Other Library…"), true, None)
|
||||
|
||||
Reference in new issue
Block a user