mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-22 20:48:59 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c369c3a20b | ||
|
|
0ce25a8d6d | ||
|
|
3d2d9a3d9b | ||
|
|
e34e841b8f | ||
|
|
9409bc7763 | ||
|
|
d7085aabde | ||
|
|
9cfe513477 | ||
|
|
f1decbad01 | ||
|
|
139f3a2c7e | ||
|
|
a5d5ee8a29 | ||
|
|
08fe7bbb70 | ||
|
|
9f1f2cfb4f | ||
|
|
dda2b45e3c | ||
|
|
b8627a2373 | ||
|
|
993d39c723 | ||
|
|
33d874c1f5 | ||
|
|
85370b265f | ||
|
|
edd33f9db5 | ||
|
|
f005c58134 | ||
|
|
8fb8a5b789 | ||
|
|
616b43bb74 | ||
|
|
fbade3d8c2 | ||
|
|
ec483a4fb0 | ||
|
|
1094d3c35e | ||
|
|
cc9778ebe1 | ||
|
|
442d1c3f53 | ||
|
|
3e0b11df2f | ||
|
|
ecb3633aff |
@@ -135,6 +135,7 @@ The UI icons are SVG files in `crates/ui-egui/icons/`, one row each below. Gener
|
||||
| `crates/ui-egui/icons/designMode.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/dictate.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/discord.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/discordPill.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/distributeCols.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/distributeRows.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
| `crates/ui-egui/icons/docPrefs.svg` | WordCraft contributors | original: exported from WordCraft's own code-drawn icons (`crates/ui-egui/src/icons.rs` before the craft port), text glyphs redrawn as paths | MIT OR Apache-2.0 | UI icon |
|
||||
|
||||
Generated
+122
-241
File diff suppressed because it is too large
Load Diff
+52
-52
@@ -37,20 +37,20 @@ wordcraft-pdf = { path = "crates/pdf" }
|
||||
# reads the ca-valencia pack), #589 (French elision suggestions first), #497 (flag-based
|
||||
# compounding), #496 (review follow-ups, en-AU) and the merged #482–#490/#495 stack; the font
|
||||
# store's `language-pack` kind is #486 (CP4.1).
|
||||
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
wordcraft-engine = { path = "crates/engine" }
|
||||
wordcraft-mcp = { path = "crates/mcp" }
|
||||
wordcraft-zotero = { path = "crates/zotero" }
|
||||
wordcraft-control-key = { path = "crates/control-key" }
|
||||
wordcraft-ui-egui = { path = "crates/ui-egui" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
|
||||
# foundation
|
||||
kurbo = { version = "0.13", features = ["serde"] }
|
||||
@@ -81,28 +81,28 @@ wuff = "0.2.9"
|
||||
brotli-decompressor = "5"
|
||||
vello_cpu = "0.2"
|
||||
image = { version = "0.25", default-features = false }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", version = "=0.1.0" }
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", version = "=0.1.0" }
|
||||
# zlib streams (compressed metafile pictures in `.doc` drawings); already in the lock as a dependency of other crates.
|
||||
miniz_oxide = "0.9"
|
||||
cfb = "0.15"
|
||||
@@ -170,27 +170,27 @@ debug = 0
|
||||
# The framework's patches, which Cargo does not carry over to dependents: its vendored crates from craft-libs,
|
||||
# and the egui and winit forks it builds with.
|
||||
[patch.crates-io]
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "7e1c30d142bc7879d043e74b5ceb3ecfe7f51329" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "72cb386ac73dc0ade2b2d15cc8314e236a8e5eb1" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ fn save(doc: &wordcraft_doc::Document) -> BTreeMap<String, Vec<u8>> {
|
||||
}
|
||||
|
||||
const SETTINGS: &str = r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 w15"><w:zoom w:percent="120"/><w:removePersonalInformation/><w:removeDateAndTime/><w:proofState w:spelling="clean" w:grammar="clean"/><w:mailMerge><w:mainDocumentType w:val="formLetters"/><w:dataSource r:id="rId9"/></w:mailMerge><w:trackRevisions/><w:defaultTabStop w:val="708"/><w:hyphenationZone w:val="425"/><w:characterSpacingControl w:val="doNotCompress"/><w:compat><w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/><w:compatSetting w:name="overrideTableStyleFontSizeAndJustification" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/><w:compatSetting w:name="enableOpenTypeFeatures" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/></w:compat><w:docVars><w:docVar w:name="ClauseSet" w:val="B"/></w:docVars><w:rsids><w:rsidRoot w:val="00A1B2C3"/><w:rsid w:val="00A1B2C3"/></w:rsids><m:mathPr><m:mathFont m:val="Cambria Math"/><m:smallFrac m:val="0"/></m:mathPr><w:themeFontLang w:val="pl-PL"/><w:decimalSymbol w:val=","/><w:listSeparator w:val=";"/><w14:docId w14:val="1A2B3C4D"/></w:settings>"#;
|
||||
<w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 w15"><w:zoom w:percent="120"/><w:removePersonalInformation/><w:removeDateAndTime/><w:proofState w:spelling="clean" w:grammar="clean"/><w:trackRevisions/><w:defaultTabStop w:val="708"/><w:hyphenationZone w:val="425"/><w:characterSpacingControl w:val="doNotCompress"/><w:compat><w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/><w:compatSetting w:name="overrideTableStyleFontSizeAndJustification" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/><w:compatSetting w:name="enableOpenTypeFeatures" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/></w:compat><w:docVars><w:docVar w:name="ClauseSet" w:val="B"/></w:docVars><w:rsids><w:rsidRoot w:val="00A1B2C3"/><w:rsid w:val="00A1B2C3"/></w:rsids><m:mathPr><m:mathFont m:val="Cambria Math"/><m:smallFrac m:val="0"/></m:mathPr><w:themeFontLang w:val="pl-PL"/><w:decimalSymbol w:val=","/><w:listSeparator w:val=";"/><w14:docId w14:val="1A2B3C4D"/></w:settings>"#;
|
||||
|
||||
fn pos(s: &str, needle: &str) -> usize {
|
||||
s.find(needle).unwrap_or_else(|| panic!("{needle} missing from {s}"))
|
||||
|
||||
@@ -66,7 +66,15 @@ const SETTINGS: &str = r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?
|
||||
<w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 w15"><w:zoom w:percent="120"/><w:removePersonalInformation/><w:removeDateAndTime/><w:proofState w:spelling="clean" w:grammar="clean"/><w:mailMerge><w:mainDocumentType w:val="formLetters"/><w:dataSource r:id="rId9"/></w:mailMerge><w:trackRevisions/><w:defaultTabStop w:val="708"/><w:hyphenationZone w:val="425"/><w:characterSpacingControl w:val="doNotCompress"/><w:compat><w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/><w:compatSetting w:name="overrideTableStyleFontSizeAndJustification" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/><w:compatSetting w:name="enableOpenTypeFeatures" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/></w:compat><w:docVars><w:docVar w:name="ClauseSet" w:val="B"/></w:docVars><w:rsids><w:rsidRoot w:val="00A1B2C3"/><w:rsid w:val="00A1B2C3"/></w:rsids><m:mathPr><m:mathFont m:val="Cambria Math"/><m:smallFrac m:val="0"/></m:mathPr><w:themeFontLang w:val="pl-PL"/><w:decimalSymbol w:val=","/><w:listSeparator w:val=";"/><w14:docId w14:val="1A2B3C4D"/></w:settings>"#;
|
||||
|
||||
fn with_settings(settings: &str) -> Vec<u8> {
|
||||
package("<w:p><w:r><w:t>Text</w:t></w:r></w:p>", &[("rId1", &format!("{REL}/settings"), "settings.xml")], &[], &[("word/settings.xml", settings)])
|
||||
let sources = format!(
|
||||
r#"<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId9" Type="{REL}/mailMergeSource" Target="file:///__wordcraft_missing_source__/letters.xlsx" TargetMode="External"/></Relationships>"#
|
||||
);
|
||||
package(
|
||||
"<w:p><w:r><w:t>Text</w:t></w:r></w:p>",
|
||||
&[("rId1", &format!("{REL}/settings"), "settings.xml")],
|
||||
&[],
|
||||
&[("word/settings.xml", settings), ("word/_rels/settings.xml.rels", &sources)],
|
||||
)
|
||||
}
|
||||
|
||||
fn pos(s: &str, needle: &str) -> usize {
|
||||
@@ -97,11 +105,12 @@ fn unmodelled_settings_survive_a_save_and_owned_ones_follow_the_model() {
|
||||
] {
|
||||
assert!(s.contains(kept), "{kept} lost: {s}");
|
||||
}
|
||||
// Owned: Track Changes was turned off; one compatibility mode; the mail merge source (a
|
||||
// relationship that isn't carried) is dropped rather than left dangling.
|
||||
// Owned: Track Changes was turned off; one compatibility mode. Mail merge keeps its external
|
||||
// source relationship.
|
||||
assert!(!s.contains("trackRevisions"), "{s}");
|
||||
assert_eq!(s.matches("compatibilityMode").count(), 1, "{s}");
|
||||
assert!(!s.contains("mailMerge") && !s.contains("rId9"), "{s}");
|
||||
assert!(s.contains("mailMerge"), "{s}");
|
||||
assert!(text(&files, "word/_rels/settings.xml.rels").contains("file:///__wordcraft_missing_source__/letters.xlsx"));
|
||||
// The privacy options are the model's (#1062): written once each, and gone when turned off.
|
||||
assert_eq!(s.matches("removePersonalInformation").count(), 1, "{s}");
|
||||
assert_eq!(s.matches("removeDateAndTime").count(), 1, "{s}");
|
||||
|
||||
@@ -16,7 +16,7 @@ craft = { workspace = true, features = [
|
||||
"color", "color-ui", "control", "draw", "font-manager", "gpu", "menu", "pages", "print", "review", "table", "text",
|
||||
"text-find", "web-api", "web-host", "window",
|
||||
] }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
wordcraft-geom = { workspace = true, features = ["image"] }
|
||||
wordcraft-doc = { workspace = true }
|
||||
wordcraft-fonts = { workspace = true }
|
||||
@@ -65,13 +65,18 @@ wordcraft-engine = { workspace = true, features = ["test-support"] }
|
||||
# kittest's own dev-dependencies do not propagate their font features. Declare the fonts the
|
||||
# interface tests lay out explicitly: default faces plus monochrome emoji fallbacks.
|
||||
egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] }
|
||||
egui_kittest = { workspace = true, features = ["wgpu", "snapshot"] }
|
||||
egui_kittest = { workspace = true, features = ["wgpu", "snapshot", "eframe"] }
|
||||
# The app-window tests run `WordApp` as an `eframe::App` (`test_harness`), so the runtime gets the app's input before
|
||||
# every pass as on the desktop. The desktop app's feature set, so a workspace build shares one eframe.
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "clipboard", "wayland", "x11", "links"] }
|
||||
craft-zip = { workspace = true }
|
||||
# The window tests' frame driver for child viewports; it is not part of the `craft` facade.
|
||||
craft-ui-test-kit = { workspace = true }
|
||||
# The interface tests' fixture and access tree (`craft::ui::testing`).
|
||||
craft = { workspace = true, features = ["ui-testing"] }
|
||||
|
||||
[build-dependencies]
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "243d68e12d05e89122db6d154924bf1992e10d38", features = ["subset"] }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", features = ["subset"] }
|
||||
serde_json = { workspace = true }
|
||||
toml = "1"
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
|
||||
<path d="M3 6 L7 3.5 L13 3.5 L17 6 L17.5 14 L13.5 16.5 L6.5 16.5 L2.5 14 Z M6 10.5 A1.5 1.5 0 1 0 9 10.5 A1.5 1.5 0 1 0 6 10.5 Z M11 10.5 A1.5 1.5 0 1 0 14 10.5 A1.5 1.5 0 1 0 11 10.5 Z" fill="currentColor" fill-rule="evenodd"/>
|
||||
<path d="M3 6 L7 3.5 L13 3.5 L17 6 L17.5 14 L13.5 16.5 L6.5 16.5 L2.5 14 Z M6 10.5 A1.5 1.5 0 1 0 9 10.5 A1.5 1.5 0 1 0 6 10.5 Z M11 10.5 A1.5 1.5 0 1 0 14 10.5 A1.5 1.5 0 1 0 11 10.5 Z" fill="#1E6FD9" class="accent" fill-rule="evenodd"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 322 B After Width: | Height: | Size: 332 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="20" height="20">
|
||||
<path d="M3 6 L7 3.5 L13 3.5 L17 6 L17.5 14 L13.5 16.5 L6.5 16.5 L2.5 14 Z M6 10.5 A1.5 1.5 0 1 0 9 10.5 A1.5 1.5 0 1 0 6 10.5 Z M11 10.5 A1.5 1.5 0 1 0 14 10.5 A1.5 1.5 0 1 0 11 10.5 Z" fill="currentColor" fill-rule="evenodd"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 322 B |
@@ -6,6 +6,7 @@ use super::{
|
||||
theme, updates_ui, window_ui, windows, zotero,
|
||||
};
|
||||
use craft::platform::clock::monotonic_ms;
|
||||
use craft::theme::ComponentSet;
|
||||
use craft::ui::runtime::commands::CommandInput;
|
||||
use craft::ui::runtime::env::{AltCodePages, ResolvedRoot, RootEnv, WheelSpeed};
|
||||
use craft::ui::runtime::frame::{FrameInput, FrameOutput};
|
||||
@@ -184,7 +185,7 @@ impl WordApp {
|
||||
}
|
||||
|
||||
/// This frame's root values: the wheel speed, the Alt-code pages, the interface mode,
|
||||
/// motion, scale and direction. Built from the saved settings every frame, so a change
|
||||
/// motion, scale, direction and the component set (WordCraft takes the productivity set). Built from the saved settings every frame, so a change
|
||||
/// applies at once.
|
||||
pub fn root_env(&self) -> RootEnv {
|
||||
let lang = i18n::Lang::from_pref(&self.ui.language);
|
||||
@@ -204,7 +205,8 @@ impl WordApp {
|
||||
.direction(direction)
|
||||
.mode(self.ui.theme.mode())
|
||||
.wheel_speed(WheelSpeed::new(line, point))
|
||||
.alt_code_pages(AltCodePages::new(ansi, oem));
|
||||
.alt_code_pages(AltCodePages::new(ansi, oem))
|
||||
.set(ComponentSet::Productivity);
|
||||
env.motion = self.ui.animations.motion();
|
||||
env.sizes = std::sync::Arc::clone(&APP_SIZES);
|
||||
env
|
||||
|
||||
@@ -52,6 +52,21 @@ const GATED_UI_COMMANDS: &[(&str, &str)] = &[
|
||||
("ui.zotero.removeCodes", "Unlink Citations"),
|
||||
];
|
||||
|
||||
/// Word feature catalog entries whose command is not yet registered in `registry`: each gets a
|
||||
/// catalog entry without a chord (preventing unregistered-command warnings) and a disabled state
|
||||
/// until an engine command takes its id.
|
||||
fn unimplemented_catalog_commands(registry: &wordcraft_engine::Registry) -> impl Iterator<Item = (&'static str, &'static str)> + '_ {
|
||||
let mut seen = HashSet::new();
|
||||
wordcraft_engine::catalog::CATALOG.lines().filter_map(move |line| {
|
||||
let mut parts = line.split('|');
|
||||
let _tab = parts.next()?;
|
||||
let _group = parts.next()?;
|
||||
let feature = parts.next()?;
|
||||
let id = parts.next()?;
|
||||
(registry.get(id).is_none() && seen.insert(id)).then_some((id, feature))
|
||||
})
|
||||
}
|
||||
|
||||
/// The default chords of an engine command: its `shortcut`, one binding per `" / "` piece.
|
||||
fn default_bindings(shortcut: &str) -> impl Iterator<Item = Binding> + '_ {
|
||||
shortcut.split(" / ").filter(|piece| !piece.is_empty()).filter_map(|piece| Binding::parse(piece).ok())
|
||||
@@ -123,6 +138,11 @@ impl WordApp {
|
||||
for (id, label) in GATED_UI_COMMANDS {
|
||||
defs.push(CommandDef::new(CommandRef::new(*id), tl!(*label), Scope::app()));
|
||||
}
|
||||
for (id, feature) in unimplemented_catalog_commands(®istry) {
|
||||
if seen.insert(id) {
|
||||
defs.push(CommandDef::new(CommandRef::new(id), tl!(feature), Scope::app()));
|
||||
}
|
||||
}
|
||||
// Word's Alt chords (Alt+Q, Alt+F7, Ctrl+Alt+1…) fire while the person types in the page:
|
||||
// plain keys type, and every modified chord is offered to the keymap first.
|
||||
match AppCatalog::new(defs, generation) {
|
||||
@@ -174,6 +194,14 @@ impl WordApp {
|
||||
for id in ids {
|
||||
states.set(CommandRef::new(id), CommandState::new().enabled(command_enabled(self, id)));
|
||||
}
|
||||
let unavailable_hint: Option<Arc<str>> = crate::widgets::command_hint("", "", Some("")).map(Arc::from);
|
||||
for (id, _) in unimplemented_catalog_commands(®istry) {
|
||||
let mut state = CommandState::new().enabled(command_enabled(self, id));
|
||||
if let Some(hint) = unavailable_hint.as_ref() {
|
||||
state = state.hint(Arc::clone(hint));
|
||||
}
|
||||
states.set(CommandRef::new(id), state);
|
||||
}
|
||||
let commands = CommandRef::with_params("ui.dialog", json!({"name": "commands"}));
|
||||
states.set(commands, CommandState::new().enabled(command_enabled(self, "ui.dialog")));
|
||||
if *self.command_states != states {
|
||||
@@ -277,4 +305,20 @@ mod tests {
|
||||
crate::undo_marks::apply_edits(&mut app, end, apply);
|
||||
assert_eq!(app.session.undo_depth(), after_undo, "the late Commit of the taken-back gesture adds no step");
|
||||
}
|
||||
|
||||
/// #7310: unimplemented Word feature catalog commands publish a disabled state so ribbon
|
||||
/// buttons and keytips bound to them resolve disabled instead of falling back to enabled.
|
||||
#[test]
|
||||
fn unimplemented_catalog_commands_publish_disabled_state() {
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
let _ = app.command_input();
|
||||
for id in ["tools.dictate", "draw.inkToMath", "review.translate", "review.blockAuthors"] {
|
||||
assert!(app.session.registry.get(id).is_none(), "{id} is still an unimplemented stub");
|
||||
let state = app.command_states.get(&CommandRef::new(id));
|
||||
assert!(
|
||||
state.is_some_and(|s| !s.is_enabled()),
|
||||
"unimplemented catalog command {id} must publish an explicit disabled state, got {state:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::contract::{Bind, Props as _, Show as _, clicked};
|
||||
use craft::ui::shell::{RecentFile, RecentList, RecentSort, RecentView, StartAction, StartLayout, StartScreen, Template};
|
||||
use egui::Ui;
|
||||
use craft::ui::style::DataColor;
|
||||
use egui::{Color32, Ui};
|
||||
use serde_json::json;
|
||||
|
||||
use super::{HOME_TEMPLATES, TEMPLATES, TemplateThumbs, error_line, heading, label, open_recent, thumbs};
|
||||
@@ -77,7 +78,9 @@ pub(super) fn home(ui: &mut Ui, app: &mut WordApp) {
|
||||
let recent = recent_files(app);
|
||||
let cards = template_cards(&TEMPLATES[..HOME_TEMPLATES.min(TEMPLATES.len())]);
|
||||
let store = thumbs::store(&ctx);
|
||||
let source = TemplateThumbs { region: app.session.region() };
|
||||
let region = app.session.region();
|
||||
let (wide, high) = thumbs::page_aspect(®ion);
|
||||
let source = TemplateThumbs { region };
|
||||
let (mut view, mut sort) = (RecentView::List, RecentSort::Opened);
|
||||
let out = StartScreen::new(Bind::bound(&mut view), Bind::bound(&mut sort), &recent)
|
||||
.layout(StartLayout::Greeting)
|
||||
@@ -85,6 +88,9 @@ pub(super) fn home(ui: &mut Ui, app: &mut WordApp) {
|
||||
.templates(&cards)
|
||||
.more_templates(label("More templates →"))
|
||||
.max_recent(app.ui.recent_shown())
|
||||
.picture_aspect(wide, high)
|
||||
.card_zoom(1.0)
|
||||
.page_paper(DataColor::new(Color32::WHITE))
|
||||
.thumbnails(&store, &source)
|
||||
.show(ui);
|
||||
run_actions(app, &ctx, out.actions);
|
||||
@@ -112,12 +118,6 @@ pub(super) fn open(ui: &mut Ui, app: &mut WordApp) {
|
||||
error_line(ui, &error);
|
||||
}
|
||||
let recent = recent_files(app);
|
||||
let store = thumbs::store(&ctx);
|
||||
let source = TemplateThumbs { region: app.session.region() };
|
||||
let out = RecentList::new(&recent)
|
||||
.max_recent(app.ui.recent_shown())
|
||||
.empty(label("Documents you open will show up here."))
|
||||
.thumbnails(&store, &source)
|
||||
.show(ui);
|
||||
let out = RecentList::new(&recent).max_recent(app.ui.recent_shown()).empty(label("Documents you open will show up here.")).show(ui);
|
||||
run_actions(app, &ctx, out.actions);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@ use craft::ui::contract::{
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::notices::Notice;
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::primitives::{ContentPainterCx, IconSpec};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::shell::{Template, ThumbKey};
|
||||
use craft::ui::style::DataColor;
|
||||
use craft::ui::text::TextField;
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
use egui::Ui;
|
||||
use egui::{Color32, Rect, Shape, Ui, vec2};
|
||||
use serde_json::json;
|
||||
|
||||
use super::home::template_cards;
|
||||
@@ -30,13 +31,13 @@ const PAGE_WIDE: u16 = 3;
|
||||
const PAGE_HIGH: u16 = 4;
|
||||
|
||||
/// A grid of template tiles, one per card, that reports the chosen key.
|
||||
fn grid(name: Label) -> TileGrid<'static, String> {
|
||||
fn grid(name: Label, wide: u16, high: u16) -> TileGrid<'static, String> {
|
||||
TileGrid::<String>::new(name)
|
||||
.select(SelectMode::Single)
|
||||
.activate(ActivateOn::Click)
|
||||
.caption(CaptionPlace::Below)
|
||||
.card()
|
||||
.aspect(f32::from(PAGE_WIDE) / f32::from(PAGE_HIGH))
|
||||
.aspect(f32::from(wide) / f32::from(high))
|
||||
.sizing(Sizing::FillWidth)
|
||||
.natural_height(true)
|
||||
}
|
||||
@@ -58,6 +59,14 @@ fn read_listing(app: &WordApp) -> PersonalListing {
|
||||
PersonalListing { key, folder, templates }
|
||||
}
|
||||
|
||||
/// Paints a personal template card thumbnail: a white page surface with a centered 44×44 pt
|
||||
/// `documentTemplate` icon (#7373).
|
||||
pub(super) fn paint_personal_card(cx: &ContentPainterCx, rect: Rect) {
|
||||
cx.data_shapes([Shape::rect_filled(rect, 2.0, Color32::WHITE)]);
|
||||
let icon_rect = Rect::from_center_size(rect.center(), vec2(44.0, 44.0));
|
||||
cx.icon(icon_rect, &IconSpec::svg(IconId::new("documentTemplate")).data_color(DataColor::new(Color32::from_gray(150))));
|
||||
}
|
||||
|
||||
/// New: the whole template gallery with a search box, then the personal templates (#2852); no
|
||||
/// Recent list (that is on Home and Open). The search covers both.
|
||||
///
|
||||
@@ -87,16 +96,18 @@ pub(super) fn show(ui: &mut Ui, app: &mut WordApp) {
|
||||
return;
|
||||
}
|
||||
let store = thumbs::store(&ctx);
|
||||
let source = thumbs::TemplateThumbs { region: app.session.region() };
|
||||
let region = app.session.region();
|
||||
let (wide, high) = thumbs::page_aspect(®ion);
|
||||
let source = thumbs::TemplateThumbs { region };
|
||||
if !found.is_empty() {
|
||||
let (store, source) = (&store, &source);
|
||||
let cards = template_cards(&found);
|
||||
let items = keyed(&cards, |t: &Template| t.id.clone()).with_text(|t| Cow::Borrowed(t.name.as_str()));
|
||||
let out = grid(label("Templates")).show_items(ui, &items, &mut |id, _| {
|
||||
let out = grid(label("Templates"), wide, high).show_items(ui, &items, &mut |id, _| {
|
||||
let Some(card) = cards.iter().find(|c| &c.id == id) else { return Tile::new(Label::Empty) };
|
||||
let thumb = ThumbKey::Template(card.id.clone());
|
||||
Tile::new(Label::from(card.name.clone()))
|
||||
.thumb(ThumbAspect::new(PAGE_WIDE, PAGE_HIGH), move |cx, rect| thumbs::paint(cx, rect, store, source, &thumb))
|
||||
.thumb(ThumbAspect::new(wide, high), move |cx, rect| thumbs::paint(cx, rect, store, source, &thumb))
|
||||
});
|
||||
for id in activated(out.response.events) {
|
||||
let _ = app.run("file.new", json!({"template": id}));
|
||||
@@ -131,9 +142,9 @@ pub(super) fn show(ui: &mut Ui, app: &mut WordApp) {
|
||||
let tiles: Vec<&PersonalTemplate> = personal_found.iter().filter(|p| p.category == category).collect();
|
||||
let items = keyed(&tiles, |p: &&PersonalTemplate| p.path.clone()).with_text(|p| Cow::Borrowed(p.label.as_str()));
|
||||
let name = if category.is_empty() { label("Personal templates") } else { Label::from(category.to_owned()) };
|
||||
let out = grid(name).id_salt(("personal-templates", category.to_owned())).show_items(ui, &items, &mut |path, _| {
|
||||
let out = grid(name, PAGE_WIDE, PAGE_HIGH).id_salt(("personal-templates", category.to_owned())).show_items(ui, &items, &mut |path, _| {
|
||||
let Some(p) = tiles.iter().find(|p| &p.path == path) else { return Tile::new(Label::Empty) };
|
||||
Tile::new(Label::from(p.label.clone())).icon(IconSpec::svg(IconId::new("documentTemplate"))).tooltip(p.path.clone())
|
||||
Tile::new(Label::from(p.label.clone())).thumb(ThumbAspect::new(PAGE_WIDE, PAGE_HIGH), paint_personal_card).tooltip(p.path.clone())
|
||||
});
|
||||
for path in activated(out.response.events) {
|
||||
let failed = open_personal(app, &path, &ctx).err();
|
||||
|
||||
@@ -353,6 +353,21 @@ fn new_lists_personal_templates_and_opens_one() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// #7373: Personal template cards in File › New paint a white page surface and document icon.
|
||||
#[test]
|
||||
fn personal_template_cards_render_as_page_cards() {
|
||||
let dir = personal_dir("card-paint");
|
||||
let memo = dir.join("Proposal.dotx");
|
||||
write_template(&memo, "Proposal template text");
|
||||
let h = new_page_harness(Some(dir.clone()));
|
||||
let card = h.query_by_label("Proposal");
|
||||
assert!(card.is_some(), "personal template tile exists");
|
||||
let rect = card.unwrap().rect();
|
||||
assert!(rect.height() > rect.width(), "personal template card is portrait oriented");
|
||||
drop(h);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// An empty (or not yet made) templates folder says where templates come from; no folder (the
|
||||
/// web) shows no Personal section. Home keeps only the built-ins.
|
||||
#[test]
|
||||
@@ -840,3 +855,40 @@ fn a_file_pages_title_is_productions_size() {
|
||||
assert!(title.size > section.size + 6.0, "the title stands above a section heading: {title:?} over {section:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The template cards on File › Home and File › New use the portrait aspect of the active region,
|
||||
/// and Home cards use card_zoom(1.0) so they do not stretch across the row (#7372, #7149 items 2-3).
|
||||
#[test]
|
||||
fn backstage_template_cards_aspect_and_zoom() {
|
||||
let mut letter_app = new_app();
|
||||
letter_app.session.system_region = wordcraft_geom::Region::from_tag("en-US");
|
||||
let (wide_us, high_us) = super::thumbs::page_aspect(&letter_app.session.region());
|
||||
assert_eq!((wide_us, high_us), (17, 22), "US region uses 17:22 (Letter) aspect");
|
||||
|
||||
let mut a4_app = new_app();
|
||||
a4_app.session.system_region = wordcraft_geom::Region::from_tag("en-GB");
|
||||
let (wide_gb, high_gb) = super::thumbs::page_aspect(&a4_app.session.region());
|
||||
assert_eq!((wide_gb, high_gb), (70, 99), "GB region uses 70:99 (A4) aspect");
|
||||
|
||||
// Home template cards: portrait and narrow (~150 pt wide, not stretched across the row)
|
||||
let h = file_page(new_app(), "home");
|
||||
let card = h.get_by_label("Blank document").rect();
|
||||
assert!(card.height() > card.width(), "Home template card is portrait: {card:?}");
|
||||
assert!(card.width() < 300.0, "card zoom keeps cards narrow instead of filling row: {card:?}");
|
||||
}
|
||||
|
||||
/// File › Open presents the recent list without thumbnail letterboxing (#7372).
|
||||
#[test]
|
||||
fn file_open_recent_list_has_no_thumbnail_letterboxing() {
|
||||
let app = new_app();
|
||||
let h = file_page(app, "open");
|
||||
assert!(h.query_by_label("Browse…").is_some(), "Browse button exists");
|
||||
assert!(h.query_all_by_label("Recent").next().is_some(), "Recent section exists");
|
||||
assert!(h.query_by_label("Documents you open will show up here.").is_some(), "empty state message exists");
|
||||
|
||||
let mut populated = new_app();
|
||||
populated.ui.recent = vec!["/tmp/sample.docx".into()];
|
||||
let h2 = file_page(populated, "open");
|
||||
let row = recent_row(&h2, "sample.docx").expect("recent row renders");
|
||||
assert!(row.rect().height() > 0.0, "recent row has non-zero height: {:?}", row.rect());
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
//! The template thumbnails of the File page: the first page of each built-in template, drawn in a
|
||||
//! throwaway session so the user's document is never touched.
|
||||
|
||||
use craft::ui::primitives::{ContentPainterCx, Priority, Revision, ThumbPaint, ThumbRender, ThumbRequest, ThumbSource, ThumbnailOptions, Thumbnails};
|
||||
use craft::ui::primitives::{
|
||||
ContentPainterCx, Priority, Revision, ThumbFit, ThumbPaint, ThumbRender, ThumbRequest, ThumbSource, ThumbnailOptions, Thumbnails,
|
||||
};
|
||||
use craft::ui::shell::ThumbKey;
|
||||
use craft::ui::style::{Corners, SurfaceKind};
|
||||
use craft::ui::style::{Corners, DataColor, SurfaceKind};
|
||||
use serde_json::json;
|
||||
|
||||
/// The shape of a document page in `region`, wide to high (Letter 17:22 or A4 70:99).
|
||||
pub(crate) fn page_aspect(region: &wordcraft_geom::Region) -> (u16, u16) {
|
||||
if region.uses_letter() { (17, 22) } else { (70, 99) }
|
||||
}
|
||||
|
||||
/// The salt every reader of the File page's thumbnails asks the store with, so New, Home and the
|
||||
/// recent rows share one loader and one set of pictures.
|
||||
const SALT: &str = "wordcraft.templates";
|
||||
@@ -20,7 +27,8 @@ pub(crate) fn store(ctx: &egui::Context) -> Thumbnails<ThumbKey> {
|
||||
pub(crate) fn paint(cx: &ContentPainterCx, rect: egui::Rect, store: &Thumbnails<ThumbKey>, source: &dyn ThumbSource<ThumbKey>, key: &ThumbKey) {
|
||||
let request = ThumbRequest::for_cell(rect.width().max(rect.height()), cx.pixels_per_point());
|
||||
let state = store.state(cx.painter.ctx(), source, key, &request, Priority::VISIBLE);
|
||||
if !store.paint(cx, rect, &state, &ThumbPaint::default()) {
|
||||
let paint = ThumbPaint::default().fit(ThumbFit::Cover).checker(false).paper(DataColor::new(egui::Color32::WHITE));
|
||||
if !store.paint(cx, rect, &state, &paint) {
|
||||
cx.surface(rect, SurfaceKind::Sunken, Corners::None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ use std::cell::RefCell;
|
||||
|
||||
use craft::behavior::IconId;
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::theme::ControlSize;
|
||||
use craft::theme::variant::Variant;
|
||||
use craft::ui::bars::{Bar, BarKind};
|
||||
use craft::ui::buttons::{Button, ButtonOutput, IconButton, ToggleButton};
|
||||
use craft::ui::contract::{Bind, BodyCx, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
|
||||
use craft::ui::contract::{Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
|
||||
use craft::ui::display::{Divider, Text};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::value_drag::{Slider, SliderScale};
|
||||
use egui::Ui;
|
||||
@@ -209,85 +211,92 @@ fn missing_fonts(app: &mut WordApp, ui: &mut Ui) {
|
||||
fn controls(app: &mut WordApp, ui: &mut Ui, fit: usize) -> Option<egui::Rect> {
|
||||
use craft::ui::contract::Outcome as _;
|
||||
let mut rects = Vec::new();
|
||||
let focus = if fit >= 2 {
|
||||
IconButton::command(IconId::new("focus"), CommandRef::new("view.focus")).label(tl!("Focus").to_string()).show(ui).response
|
||||
} else {
|
||||
Button::command(CommandRef::new("view.focus"))
|
||||
.label(tl!("Focus").to_string())
|
||||
.icon(IconId::new("focus"))
|
||||
.variant(Variant::GHOST)
|
||||
.show(ui)
|
||||
.response
|
||||
};
|
||||
rects.push(focus.rect);
|
||||
// Icons only, Read Mode first and Web Layout last, each named in its tooltip, the current view on (prod
|
||||
// `chrome.rs:925-943`).
|
||||
let (mode, read) = (app.session.view.mode, app.session.view.read_mode);
|
||||
for (id, icon, name, on) in [
|
||||
("view.readMode", "readMode", tl!("Read Mode"), read),
|
||||
("view.printLayout", "printLayout", tl!("Print Layout"), mode == wordcraft_layout::ViewMode::Print && !read),
|
||||
("view.webLayout", "webLayout", tl!("Web Layout"), mode == wordcraft_layout::ViewMode::Web),
|
||||
] {
|
||||
// No command carries a checked state, so the view is given at the button (S-L415).
|
||||
let out = ToggleButton::new(name.to_string(), Bind::given(on))
|
||||
.command(CommandRef::new(id))
|
||||
.icon(crate::icons::id(icon))
|
||||
.icon_only()
|
||||
.tooltip(TooltipSpec::new(name.to_string()))
|
||||
.show(ui);
|
||||
rects.push(out.response().rect);
|
||||
}
|
||||
let reading = app.session.view.read_mode;
|
||||
// Reading zoom changes only reading presentation, never the normal view zoom.
|
||||
let current = if reading { f64::from(app.session.view.read_zoom) } else { app.canvas.zoom() };
|
||||
let percent = (current * 100.0).round();
|
||||
let step = |app: &mut WordApp, plus: bool| {
|
||||
if reading {
|
||||
let value = if plus { (percent + 10.0).min(150.0) } else { (percent - 10.0).max(75.0) };
|
||||
let _ = app.run("view.readTextSize", json!({"value": value}));
|
||||
let _ = Row::new().gap(Gap::Section).show(ui, |ui, _| {
|
||||
let focus = if fit >= 2 {
|
||||
IconButton::command(IconId::new("focus"), CommandRef::new("view.focus")).label(tl!("Focus").to_string()).show(ui).response
|
||||
} else {
|
||||
let _ = app.run(if plus { "view.zoomIn" } else { "view.zoomOut" }, json!({}));
|
||||
}
|
||||
};
|
||||
let out = IconButton::new(IconId::new("wordcraft.minus"))
|
||||
.label(tl!("Zoom Out").to_string())
|
||||
.tooltip(TooltipSpec::new(tl!("Zoom Out").to_string()))
|
||||
.show(ui);
|
||||
rects.push(out.response.rect);
|
||||
if out.response.clicked() {
|
||||
step(app, false);
|
||||
}
|
||||
if fit < 1 {
|
||||
let mut value = current;
|
||||
let range = if reading { 0.75..=1.5 } else { 0.1..=5.0 };
|
||||
let name = if reading { tl!("Text Size") } else { tl!("Zoom") };
|
||||
let slider = Slider::new(Bind::bound(&mut value), range)
|
||||
.scale(if reading { SliderScale::Linear } else { SliderScale::Log })
|
||||
// A plain rail, as the old zoom slider's (prod `chrome.rs:911`): no fill up to the thumb.
|
||||
.fill(false)
|
||||
.label(name.to_string())
|
||||
.show(ui);
|
||||
rects.push(slider.response().rect);
|
||||
if let Some(v) = slider.value() {
|
||||
let command = if reading { "view.readTextSize" } else { "view.zoom" };
|
||||
let _ = app.run(command, json!({"value": (*v * 100.0).round()}));
|
||||
}
|
||||
}
|
||||
let out = IconButton::new(IconId::new("wordcraft.plus"))
|
||||
.label(tl!("Zoom In").to_string())
|
||||
.tooltip(TooltipSpec::new(tl!("Zoom In").to_string()))
|
||||
.show(ui);
|
||||
rects.push(out.response.rect);
|
||||
if out.response.clicked() {
|
||||
step(app, true);
|
||||
}
|
||||
if !reading {
|
||||
// PLAN: assumed Button::room_for (ribbon-w2, S-L418)
|
||||
let out = Button::new(format!("{percent}%")).variant(Variant::GHOST).room_for(format!("{MOST_ZOOM_PERCENT}%")).show(ui);
|
||||
rects.push(out.response.rect);
|
||||
if out.clicked() {
|
||||
let _ = app.run("ui.dialog", json!({"name": "zoom"}));
|
||||
}
|
||||
}
|
||||
Button::command(CommandRef::new("view.focus"))
|
||||
.label(tl!("Focus").to_string())
|
||||
.icon(IconId::new("focus"))
|
||||
.variant(Variant::GHOST)
|
||||
.show(ui)
|
||||
.response
|
||||
};
|
||||
rects.push(focus.rect);
|
||||
// Icons only, Read Mode first and Web Layout last, each named in its tooltip, the current view on (prod
|
||||
// `chrome.rs:925-943`).
|
||||
let _ = Row::new().gap(Gap::Item).show(ui, |ui, _| {
|
||||
let (mode, read) = (app.session.view.mode, app.session.view.read_mode);
|
||||
for (id, icon, name, on) in [
|
||||
("view.readMode", "readMode", tl!("Read Mode"), read),
|
||||
("view.printLayout", "printLayout", tl!("Print Layout"), mode == wordcraft_layout::ViewMode::Print && !read),
|
||||
("view.webLayout", "webLayout", tl!("Web Layout"), mode == wordcraft_layout::ViewMode::Web),
|
||||
] {
|
||||
// No command carries a checked state, so the view is given at the button (S-L415).
|
||||
let out = ToggleButton::new(name.to_string(), Bind::given(on))
|
||||
.command(CommandRef::new(id))
|
||||
.icon(crate::icons::id(icon))
|
||||
.icon_only()
|
||||
.tooltip(TooltipSpec::new(name.to_string()))
|
||||
.show(ui);
|
||||
rects.push(out.response().rect);
|
||||
}
|
||||
});
|
||||
let reading = app.session.view.read_mode;
|
||||
// Reading zoom changes only reading presentation, never the normal view zoom.
|
||||
let current = if reading { f64::from(app.session.view.read_zoom) } else { app.canvas.zoom() };
|
||||
let percent = (current * 100.0).round();
|
||||
let step = |app: &mut WordApp, plus: bool| {
|
||||
if reading {
|
||||
let value = if plus { (percent + 10.0).min(150.0) } else { (percent - 10.0).max(75.0) };
|
||||
let _ = app.run("view.readTextSize", json!({"value": value}));
|
||||
} else {
|
||||
let _ = app.run(if plus { "view.zoomIn" } else { "view.zoomOut" }, json!({}));
|
||||
}
|
||||
};
|
||||
let _ = Row::new().show(ui, |ui, _| {
|
||||
let out = IconButton::new(IconId::new("wordcraft.minus"))
|
||||
.label(tl!("Zoom Out").to_string())
|
||||
.tooltip(TooltipSpec::new(tl!("Zoom Out").to_string()))
|
||||
.show(ui);
|
||||
rects.push(out.response.rect);
|
||||
if out.response.clicked() {
|
||||
step(app, false);
|
||||
}
|
||||
if fit < 1 {
|
||||
let mut value = current;
|
||||
let range = if reading { 0.75..=1.5 } else { 0.1..=5.0 };
|
||||
let name = if reading { tl!("Text Size") } else { tl!("Zoom") };
|
||||
let slider = Slider::new(Bind::bound(&mut value), range)
|
||||
.size(ControlSize::Md)
|
||||
.scale(if reading { SliderScale::Linear } else { SliderScale::Log })
|
||||
// A plain rail, as the old zoom slider's (prod `chrome.rs:911`): no fill up to the thumb.
|
||||
.fill(false)
|
||||
.label(name.to_string())
|
||||
.show(ui);
|
||||
rects.push(slider.response().rect);
|
||||
if let Some(v) = slider.value() {
|
||||
let command = if reading { "view.readTextSize" } else { "view.zoom" };
|
||||
let _ = app.run(command, json!({"value": (*v * 100.0).round()}));
|
||||
}
|
||||
}
|
||||
let out = IconButton::new(IconId::new("wordcraft.plus"))
|
||||
.label(tl!("Zoom In").to_string())
|
||||
.tooltip(TooltipSpec::new(tl!("Zoom In").to_string()))
|
||||
.show(ui);
|
||||
rects.push(out.response.rect);
|
||||
if out.response.clicked() {
|
||||
step(app, true);
|
||||
}
|
||||
if !reading {
|
||||
// PLAN: assumed Button::room_for (ribbon-w2, S-L418)
|
||||
let out = Button::new(format!("{percent}%")).variant(Variant::GHOST).room_for(format!("{MOST_ZOOM_PERCENT}%")).show(ui);
|
||||
rects.push(out.response.rect);
|
||||
if out.clicked() {
|
||||
let _ = app.run("ui.dialog", json!({"name": "zoom"}));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
super::union(rects)
|
||||
}
|
||||
|
||||
@@ -550,3 +550,172 @@ fn title_bar_discord_button_keeps_accent_fill_and_icon_contrast_in_wide_and_narr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// #7445: the title bar's Discord community button uses the dedicated single-ink `discordPill` icon
|
||||
/// with `on_strong` contrast over the solid accent pill, while the ribbon's Review › Help › Community
|
||||
/// Discord button retains the branded `discord` icon with `class="accent"` ink.
|
||||
#[test]
|
||||
fn discord_icons_distinguish_title_bar_pill_and_ribbon_accent() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
fn to_color32(rgba: craft::theme::Rgba) -> egui::Color32 {
|
||||
egui::Color32::from(craft::theme::Srgba::from(rgba))
|
||||
}
|
||||
|
||||
fn collect_shapes<'a>(shapes: &'a [egui::epaint::ClippedShape], out: &mut Vec<&'a egui::Shape>) {
|
||||
for clipped in shapes {
|
||||
fn walk<'a>(shape: &'a egui::Shape, out: &mut Vec<&'a egui::Shape>) {
|
||||
match shape {
|
||||
egui::Shape::Vec(children) => {
|
||||
for child in children {
|
||||
walk(child, out);
|
||||
}
|
||||
}
|
||||
other => out.push(other),
|
||||
}
|
||||
}
|
||||
walk(&clipped.shape, out);
|
||||
}
|
||||
}
|
||||
|
||||
for theme in ["light", "dark"] {
|
||||
let mut a = new_app();
|
||||
a.ui.show_discord = true;
|
||||
a.ui.language = "en".into();
|
||||
a.run("ui.theme", json!({"value": theme})).unwrap();
|
||||
a.run("ui.tab", json!({"tab": "Help"})).unwrap();
|
||||
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 700.0)).build_ui_state(app_frame, a);
|
||||
crate::test_harness::frames(&mut h, 6);
|
||||
|
||||
let env = craft::ui::runtime::env::Env::of_root(&h.ctx);
|
||||
let on_strong = to_color32(env.tokens.color.text.on_strong);
|
||||
let accent_solid = to_color32(env.tokens.color.accent.solid);
|
||||
|
||||
let mut shapes = Vec::new();
|
||||
collect_shapes(&h.output().shapes, &mut shapes);
|
||||
|
||||
// 1. Title-bar button uses discordPill icon (single-ink text.on_strong).
|
||||
let title_bar_node = h.get_by_role_and_label(Role::Button, "Discord");
|
||||
let title_bar_rect = title_bar_node.rect();
|
||||
assert!(title_bar_rect.is_positive(), "{theme}: Title-bar Discord button must be laid out");
|
||||
|
||||
let title_bar_icon_on_strong = shapes.iter().any(|s| match s {
|
||||
egui::Shape::Mesh(mesh) => {
|
||||
let bounds = mesh.calc_bounds();
|
||||
title_bar_rect.expand(1.5).contains_rect(bounds) && !mesh.vertices.is_empty() && mesh.vertices.iter().all(|v| v.color == on_strong)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
assert!(title_bar_icon_on_strong, "{theme}: Title-bar Discord icon inside {title_bar_rect:?} must paint in text.on_strong ({on_strong:?})");
|
||||
|
||||
// 2. Ribbon Help › Community Discord button uses discord icon with class="accent".
|
||||
let ribbon_node = h
|
||||
.query_all_by_role(Role::Button)
|
||||
.find(|n| n.accesskit_node().label().is_some_and(|l| l.contains("Discord")) && n.rect() != title_bar_rect)
|
||||
.expect("Ribbon Community Discord button");
|
||||
let ribbon_rect = ribbon_node.rect();
|
||||
assert!(ribbon_rect.is_positive(), "{theme}: Ribbon Community Discord button must be laid out");
|
||||
|
||||
let ribbon_icon_accent = shapes.iter().any(|s| match s {
|
||||
egui::Shape::Mesh(mesh) => {
|
||||
let bounds = mesh.calc_bounds();
|
||||
ribbon_rect.expand(1.5).contains_rect(bounds) && !mesh.vertices.is_empty() && mesh.vertices.iter().all(|v| v.color == accent_solid)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
assert!(ribbon_icon_accent, "{theme}: Ribbon Community Discord icon inside {ribbon_rect:?} must paint in accent.solid ({accent_solid:?})");
|
||||
}
|
||||
}
|
||||
|
||||
/// #7319: view mode toggle buttons (Read Mode, Print Layout, Web Layout) in the status bar are grouped
|
||||
/// with `Gap::Item` intra-group spacing, separated from Focus and Zoom controls via `Gap::Section`.
|
||||
/// The Zoom slider has size `ControlSize::Md`, giving its thumb a 14 pt grab affordance matching sibling `IconButton`s.
|
||||
#[test]
|
||||
fn status_bar_view_mode_toggles_and_zoom_slider_proportions() {
|
||||
use egui::accesskit::Role;
|
||||
let h = harness(new_app());
|
||||
|
||||
let focus = h.get_by_role_and_label(Role::Button, "Focus").rect();
|
||||
let read_mode = h.get_by_role_and_label(Role::Button, "Read Mode").rect();
|
||||
let print_layout = h.get_by_role_and_label(Role::Button, "Print Layout").rect();
|
||||
let web_layout = h.get_by_role_and_label(Role::Button, "Web Layout").rect();
|
||||
let zoom_out = h.get_by_role_and_label(Role::Button, "Zoom Out").rect();
|
||||
let slider = h.get_by_role_and_label(Role::Slider, "Zoom").rect();
|
||||
let zoom_in = h.get_by_role_and_label(Role::Button, "Zoom In").rect();
|
||||
|
||||
let env = craft::ui::runtime::env::Env::of_root(&h.ctx);
|
||||
let gap_section = env.tokens.space.gap.section;
|
||||
let gap_item = env.tokens.space.gap.item;
|
||||
let gap_row = env.tokens.space.gap.row;
|
||||
let glyph_md = env.tokens.size.icon.glyph_md;
|
||||
|
||||
// 1. Spacing and grouping:
|
||||
// Focus -> View modes group gap is Gap::Section.
|
||||
let focus_to_views_gap = read_mode.min.x - focus.max.x;
|
||||
assert!(
|
||||
(focus_to_views_gap - gap_section).abs() <= 0.5,
|
||||
"Focus and Read Mode should be separated by Gap::Section ({gap_section} pt), got {focus_to_views_gap}"
|
||||
);
|
||||
|
||||
// Intra-group spacing between view mode toggle buttons is Gap::Item.
|
||||
let read_to_print_gap = print_layout.min.x - read_mode.max.x;
|
||||
let print_to_web_gap = web_layout.min.x - print_layout.max.x;
|
||||
assert!(
|
||||
(read_to_print_gap - gap_item).abs() <= 0.5,
|
||||
"Read Mode and Print Layout intra-group spacing should be Gap::Item ({gap_item} pt), got {read_to_print_gap}"
|
||||
);
|
||||
assert!(
|
||||
(print_to_web_gap - gap_item).abs() <= 0.5,
|
||||
"Print Layout and Web Layout intra-group spacing should be Gap::Item ({gap_item} pt), got {print_to_web_gap}"
|
||||
);
|
||||
|
||||
// View modes group -> Zoom controls group gap is Gap::Section.
|
||||
let views_to_zoom_gap = zoom_out.min.x - web_layout.max.x;
|
||||
assert!(
|
||||
(views_to_zoom_gap - gap_section).abs() <= 0.5,
|
||||
"Web Layout and Zoom Out should be separated by Gap::Section ({gap_section} pt), got {views_to_zoom_gap}"
|
||||
);
|
||||
|
||||
// Zoom controls intra-group spacing is default row gap (Gap::Row).
|
||||
let zoom_out_to_slider_gap = slider.min.x - zoom_out.max.x;
|
||||
let slider_to_zoom_in_gap = zoom_in.min.x - slider.max.x;
|
||||
assert!(
|
||||
(zoom_out_to_slider_gap - gap_row).abs() <= 0.5,
|
||||
"Zoom Out and Zoom Slider intra-group spacing should be Gap::Row ({gap_row} pt), got {zoom_out_to_slider_gap}"
|
||||
);
|
||||
assert!(
|
||||
(slider_to_zoom_in_gap - gap_row).abs() <= 0.5,
|
||||
"Zoom Slider and Zoom In intra-group spacing should be Gap::Row ({gap_row} pt), got {slider_to_zoom_in_gap}"
|
||||
);
|
||||
|
||||
// 2. Zoom slider thumb proportions:
|
||||
// Slider thumb is rendered as a round knob sized at glyph_md (14 pt) for ControlSize::Md.
|
||||
fn collect_shapes<'a>(shapes: &'a [egui::epaint::ClippedShape], out: &mut Vec<&'a egui::Shape>) {
|
||||
for clipped in shapes {
|
||||
fn walk<'a>(shape: &'a egui::Shape, out: &mut Vec<&'a egui::Shape>) {
|
||||
match shape {
|
||||
egui::Shape::Vec(children) => {
|
||||
for child in children {
|
||||
walk(child, out);
|
||||
}
|
||||
}
|
||||
other => out.push(other),
|
||||
}
|
||||
}
|
||||
walk(&clipped.shape, out);
|
||||
}
|
||||
}
|
||||
|
||||
let mut shapes = Vec::new();
|
||||
collect_shapes(&h.output().shapes, &mut shapes);
|
||||
|
||||
let has_14pt_knob = shapes.iter().any(|s| match s {
|
||||
egui::Shape::Rect(r) => {
|
||||
let rect = r.rect;
|
||||
slider.expand(2.0).contains_rect(rect) && (rect.width() - glyph_md).abs() <= 0.5 && (rect.height() - glyph_md).abs() <= 0.5
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
assert!(has_14pt_knob, "Zoom slider should paint a {glyph_md} pt thumb (ControlSize::Md) matching 14 pt IconButton icons inside {slider:?}");
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ fn trailing(app: &mut WordApp, ui: &mut Ui, step: usize) -> Option<egui::Rect> {
|
||||
if app.ui.show_discord {
|
||||
let tip = TooltipSpec::new(tl!("Join the ArtCraft community on Discord").to_string());
|
||||
let clicked = if step >= 1 {
|
||||
let out = IconButton::new(IconId::new("discord"))
|
||||
let out = IconButton::new(IconId::new("discordPill"))
|
||||
.label(tl!("Discord").to_string())
|
||||
.variant(Variant::Custom(DISCORD_ICON))
|
||||
.glyphs(GlyphRole::Tool)
|
||||
@@ -266,7 +266,7 @@ fn trailing(app: &mut WordApp, ui: &mut Ui, step: usize) -> Option<egui::Rect> {
|
||||
out.response.clicked()
|
||||
} else {
|
||||
let out =
|
||||
Button::new(tl!("Discord").to_string()).icon(IconId::new("discord")).variant(Variant::Custom(DISCORD_PILL)).tooltip(tip).show(ui);
|
||||
Button::new(tl!("Discord").to_string()).icon(IconId::new("discordPill")).variant(Variant::Custom(DISCORD_PILL)).tooltip(tip).show(ui);
|
||||
rects.push(out.response.rect);
|
||||
out.clicked()
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ use craft::ui::dialog::{DialogId, DialogResult, DialogStack, HeldAnswer, HeldOk,
|
||||
use craft::ui::display::{Kbd, Text};
|
||||
use craft::ui::form::Field;
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::list::{ListRow, ThumbAspect};
|
||||
use craft::ui::list::{ListRow, ThumbAspect, ThumbSize};
|
||||
use craft::ui::patterns::form_dialogs::{FormCx, FormDialog};
|
||||
use craft::ui::primitives::ContentPainterCx;
|
||||
use craft::ui::runtime::env::Label;
|
||||
@@ -639,6 +639,7 @@ fn recent_row(ui: &mut Ui, form: &mut SymbolForm, dark: bool) {
|
||||
let events = {
|
||||
let recent = &form.recent;
|
||||
TileGrid::new(word("Recently used symbols:"))
|
||||
.thumb_size(ThumbSize::Medium)
|
||||
.select(SelectMode::Single)
|
||||
.caption(CaptionPlace::None)
|
||||
.card_columns(RECENT_SYMBOLS)
|
||||
@@ -681,8 +682,12 @@ fn glyph_grid(ui: &mut Ui, form: &mut SymbolForm, dark: bool) -> bool {
|
||||
let font = form.shown_font().to_string();
|
||||
let events = {
|
||||
let chars = &form.chars;
|
||||
let mut grid =
|
||||
TileGrid::new(word("Symbols")).select(SelectMode::Single).max_rows(8).caption(CaptionPlace::None).selection(Bind::bound(&mut selection));
|
||||
let mut grid = TileGrid::new(word("Symbols"))
|
||||
.thumb_size(ThumbSize::Medium)
|
||||
.select(SelectMode::Single)
|
||||
.max_rows(8)
|
||||
.caption(CaptionPlace::None)
|
||||
.selection(Bind::bound(&mut selection));
|
||||
if let Some(at) = reveal {
|
||||
grid = grid.reveal(at);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use serde_json::json;
|
||||
|
||||
use super::*;
|
||||
@@ -118,6 +119,25 @@ fn symbol_dialog_inserts_with_its_font() {
|
||||
assert_eq!(f.params().unwrap(), json!({"char": "\u{2665}"}));
|
||||
}
|
||||
|
||||
/// #7326: Recently used symbols and Symbols map use compact tile sizing so the dialog
|
||||
/// fits comfortably within default window bounds without vertical overflow.
|
||||
#[test]
|
||||
fn symbol_dialog_uses_compact_tile_grids() {
|
||||
let mut a = app();
|
||||
remember_symbol(&mut a, "©", "DejaVu Sans");
|
||||
let mut h = testing::harness(a);
|
||||
let id = crate::dialogs::open(h.state_mut(), "symbol", &json!({})).expect("symbol dialog opens");
|
||||
h.run_steps(3);
|
||||
assert!(h.state().dialog_host.get_dyn(id).is_some(), "the symbol dialog is open");
|
||||
let dialog = h.get_by_role_and_label(egui::accesskit::Role::Dialog, "Symbol").rect();
|
||||
assert!(dialog.height() <= 900.0, "complete dialog should fit within default desktop viewport: {}", dialog.height());
|
||||
assert!(dialog.max.y <= 900.0, "complete dialog should not overflow viewport bottom: {}", dialog.max.y);
|
||||
let symbols = h.get_by_role_and_label(egui::accesskit::Role::ListBox, "Symbols").rect();
|
||||
assert!(symbols.height() < 500.0, "symbols grid should be compact: {}", symbols.height());
|
||||
let recent = h.get_by_role_and_label(egui::accesskit::Role::ListBox, "Recently used symbols:").rect();
|
||||
assert!(recent.height() < 80.0, "recently used symbols row should be compact: {}", recent.height());
|
||||
}
|
||||
|
||||
/// The Field dialog builds the field code from its options.
|
||||
#[test]
|
||||
fn field_dialog_builds_the_instruction() {
|
||||
|
||||
@@ -14,9 +14,9 @@ use craft::ui::patterns::form_dialogs::FormCx;
|
||||
use craft::ui::primitives::{ContentPainterCx, TextRun};
|
||||
use craft::ui::runtime::env::{Label, LengthUnits, UnitKind};
|
||||
use craft::ui::sections::Section;
|
||||
use craft::ui::style::{Corners, SurfaceKind, TypeRole};
|
||||
use craft::ui::style::TypeRole;
|
||||
use craft::ui::text::{NumberField, TextField};
|
||||
use egui::{Rect, Ui, pos2, vec2};
|
||||
use egui::{Color32, Rect, Ui, pos2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use wordcraft_doc::section::NumFormat;
|
||||
@@ -293,7 +293,10 @@ impl ListForm {
|
||||
/// being edited at full strength and the others faded.
|
||||
fn preview(rows: Vec<PreviewRow>, edited: usize) -> impl Fn(&ContentPainterCx, Rect) {
|
||||
move |cx: &ContentPainterCx, rect: Rect| {
|
||||
cx.surface(rect, SurfaceKind::Sunken, Corners::All);
|
||||
cx.data_shapes([
|
||||
egui::Shape::rect_filled(rect, 2.0, Color32::WHITE),
|
||||
egui::Shape::rect_stroke(rect, 2.0, egui::Stroke::new(1.0, Color32::from_gray(160)), egui::StrokeKind::Inside),
|
||||
]);
|
||||
let row = rect.height() / LEVELS as f32;
|
||||
// Positions are points, scaled so 4.5 inches fit.
|
||||
let scale = (rect.width() - 16.0).max(1.0) / 324.0;
|
||||
@@ -302,14 +305,20 @@ fn preview(rows: Vec<PreviewRow>, edited: usize) -> impl Fn(&ContentPainterCx, R
|
||||
let top = rect.top() + row * i as f32;
|
||||
let paint = |cx: &ContentPainterCx| {
|
||||
let run = TextRun::new(r.sample.clone()).role(TypeRole::Caption);
|
||||
let width = cx.with_draw(|draw| draw.layout(&run, f32::INFINITY).size().x);
|
||||
let layout = cx.with_draw(|draw| draw.layout(&run, f32::INFINITY));
|
||||
let width = layout.size().x;
|
||||
let x = x_of(r.aligned_at);
|
||||
let number_x = match r.align.as_str() {
|
||||
"center" => x - width / 2.0,
|
||||
"right" => x - width,
|
||||
_ => x,
|
||||
};
|
||||
cx.with_draw(|draw| draw.text(Rect::from_min_size(pos2(number_x, top), vec2(width + 1.0, row)), &run));
|
||||
let spare = if layout.galley.rows.len() <= 1 { (row - layout.size().y).max(0.0) } else { 0.0 };
|
||||
cx.data_shapes([egui::Shape::galley_with_override_text_color(
|
||||
pos2(number_x, top + spare / 2.0),
|
||||
layout.galley.clone(),
|
||||
Color32::BLACK,
|
||||
)]);
|
||||
let text_x = match r.follow.as_str() {
|
||||
"space" => number_x + width + 3.0,
|
||||
"nothing" => number_x + width,
|
||||
@@ -317,7 +326,7 @@ fn preview(rows: Vec<PreviewRow>, edited: usize) -> impl Fn(&ContentPainterCx, R
|
||||
};
|
||||
let bar = Rect::from_min_max(pos2(text_x, top + row / 2.0 - 2.0), pos2(rect.right() - 8.0, top + row / 2.0 + 2.0));
|
||||
if bar.width() > 0.0 {
|
||||
let draw_bar = |cx: &ContentPainterCx| cx.data_shapes([egui::Shape::rect_filled(bar, 1.0, cx.ink())]);
|
||||
let draw_bar = |cx: &ContentPainterCx| cx.data_shapes([egui::Shape::rect_filled(bar, 1.0, Color32::BLACK)]);
|
||||
cx.faded(0.45, draw_bar);
|
||||
}
|
||||
};
|
||||
@@ -789,4 +798,79 @@ mod tests {
|
||||
a.run("review.trackingOptions", json!({"moveToMark": v})).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/// #7325: the Define New Multilevel List dialog preview renders an opaque white paper sheet
|
||||
/// with a crisp stroke outline across both Light and Dark themes, and renders level samples
|
||||
/// and text bars in fixed dark ink.
|
||||
#[test]
|
||||
fn define_new_multilevel_list_preview_opaque_paper_in_both_themes() {
|
||||
use egui::epaint::ClippedShape;
|
||||
|
||||
fn collect_shapes<'a>(shapes: &'a [ClippedShape], out: &mut Vec<&'a egui::Shape>) {
|
||||
for clipped in shapes {
|
||||
fn walk<'a>(shape: &'a egui::Shape, out: &mut Vec<&'a egui::Shape>) {
|
||||
match shape {
|
||||
egui::Shape::Vec(children) => {
|
||||
for child in children {
|
||||
walk(child, out);
|
||||
}
|
||||
}
|
||||
other => out.push(other),
|
||||
}
|
||||
}
|
||||
walk(&clipped.shape, out);
|
||||
}
|
||||
}
|
||||
|
||||
for theme in ["light", "dark"] {
|
||||
let mut a = app();
|
||||
a.run("ui.theme", json!({"value": theme})).unwrap();
|
||||
let mut h = harness(a);
|
||||
assert_eq!(h.state_mut().run("list.define", json!({})).unwrap(), json!({"pending": "defineList"}));
|
||||
h.run_steps(2);
|
||||
|
||||
let mut shapes = Vec::new();
|
||||
collect_shapes(&h.output().shapes, &mut shapes);
|
||||
|
||||
// Verify the preview paper sheet is painted as an opaque white rect
|
||||
let white_rects: Vec<_> = shapes
|
||||
.iter()
|
||||
.filter_map(|s| match s {
|
||||
egui::Shape::Rect(r)
|
||||
if r.fill == egui::Color32::WHITE && (r.rect.width() - 80.0).abs() <= 5.0 && (r.rect.height() - 48.0).abs() <= 5.0 =>
|
||||
{
|
||||
Some(r)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(!white_rects.is_empty(), "{theme}: preview sheet must have an opaque white paper background");
|
||||
|
||||
// Verify crisp stroke border (StrokeKind::Inside with gray 160)
|
||||
let stroke_rects: Vec<_> = shapes
|
||||
.iter()
|
||||
.filter_map(|s| match s {
|
||||
egui::Shape::Rect(r)
|
||||
if r.stroke.color == egui::Color32::from_gray(160)
|
||||
&& (r.rect.width() - 80.0).abs() <= 5.0
|
||||
&& (r.rect.height() - 48.0).abs() <= 5.0 =>
|
||||
{
|
||||
Some(r)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(!stroke_rects.is_empty(), "{theme}: preview sheet must have a crisp stroke border");
|
||||
|
||||
// Verify sample text has black override text color in both themes
|
||||
let black_text_samples: Vec<_> = shapes
|
||||
.iter()
|
||||
.filter_map(|s| match s {
|
||||
egui::Shape::Text(t) if t.override_text_color == Some(egui::Color32::BLACK) => Some(t),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(!black_text_samples.is_empty(), "{theme}: preview text samples must override text color with black");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +315,8 @@ fn layout_tiles(ui: &mut Ui, theme: &[Rgb], form: &mut SmartArtForm) -> bool {
|
||||
let positions: Vec<usize> = (0..shown.len()).collect();
|
||||
let current = shown.iter().position(|l| *l == form.layout).unwrap_or(0);
|
||||
let out = TileGrid::<usize>::new(tl!("Layouts").to_string())
|
||||
.thumb_size(ThumbSize::Large)
|
||||
.zoom(1.4)
|
||||
.select(SelectMode::Single)
|
||||
.card_columns(3)
|
||||
// Production's picker is three tile rows high and scrolls the rest; the cap also makes the grid the one owner
|
||||
|
||||
@@ -272,6 +272,7 @@ fn edges_on(b: &Borders, edges: &str) -> bool {
|
||||
|
||||
/// A square showing which edges a border choice draws: the drawn edges in the icon colour, the
|
||||
/// others as faint dotted guides.
|
||||
#[derive(craft::ui::contract::MemoProps)]
|
||||
struct EdgeGlyph {
|
||||
edges: &'static str,
|
||||
}
|
||||
|
||||
@@ -699,14 +699,7 @@ pub(crate) mod testing {
|
||||
|
||||
/// A harness that runs the app's logic and UI each frame in a 1440×900 window.
|
||||
pub(crate) fn harness(app: WordApp) -> Harness<'static, WordApp> {
|
||||
crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
app,
|
||||
)
|
||||
crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app)
|
||||
}
|
||||
|
||||
/// Confirms the dialog `id` as OK does and runs the passes it takes to file the held OK and finish: the held OK
|
||||
|
||||
@@ -1785,3 +1785,18 @@ fn colour_fields_say_their_label_and_colour_in_the_interface_language() {
|
||||
assert!(present, "the translated field is {name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #7446: the SmartArt picker renders compact layout tiles capped at three rows (PICKER_HEIGHT = 304),
|
||||
/// instead of expanding each thumbnail to default card dimensions (~132×132 pt) and overflowing.
|
||||
#[test]
|
||||
fn smartart_layout_cells_keep_productions_size() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let mut h = app_harness(app_with("Text"));
|
||||
open_named(&mut h, "insertSmartArt", json!({}));
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
let cell = h.get_by_role_and_label(Role::ListItem, "Basic List").rect();
|
||||
assert!(cell.width() <= 80.0 && cell.height() <= 102.0, "a layout cell is 75×93, got {:?}", cell.size());
|
||||
let grid = h.get_by_role_and_label(Role::ListBox, "Layouts").rect();
|
||||
assert!(grid.height() <= 304.0, "the picker is three 96 pt rows, got {:?}", grid.size());
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ static WORDCRAFT_ICONS_TABLE: &[(&str, &[u8])] = &[
|
||||
("designMode", include_bytes!("../icons/designMode.svg")),
|
||||
("dictate", include_bytes!("../icons/dictate.svg")),
|
||||
("discord", include_bytes!("../icons/discord.svg")),
|
||||
("discordPill", include_bytes!("../icons/discordPill.svg")),
|
||||
("distributeCols", include_bytes!("../icons/distributeCols.svg")),
|
||||
("distributeRows", include_bytes!("../icons/distributeRows.svg")),
|
||||
("docPrefs", include_bytes!("../icons/docPrefs.svg")),
|
||||
@@ -427,16 +428,18 @@ pub fn for_command(id: &str) -> IconSpec<'static> {
|
||||
|
||||
/// An Insert › Icons library icon as a value glyph, drawn from the same path data the inserted
|
||||
/// picture is rendered from (`wordcraft_render::icon_lib`).
|
||||
pub struct LibraryGlyph<'a> {
|
||||
icon: &'a wordcraft_render::icon_lib::Icon,
|
||||
#[derive(craft::ui::contract::MemoProps)]
|
||||
pub struct LibraryGlyph {
|
||||
#[memo_props(address = "library icons are items of the static `ICONS`")]
|
||||
icon: &'static wordcraft_render::icon_lib::Icon,
|
||||
}
|
||||
|
||||
/// The glyph of a library icon; bind it to a local so `IconSpec::glyph(&glyph)` can borrow it.
|
||||
pub fn library_glyph(icon: &wordcraft_render::icon_lib::Icon) -> impl Glyph + '_ {
|
||||
pub fn library_glyph(icon: &'static wordcraft_render::icon_lib::Icon) -> impl Glyph {
|
||||
LibraryGlyph { icon }
|
||||
}
|
||||
|
||||
impl Glyph for LibraryGlyph<'_> {
|
||||
impl Glyph for LibraryGlyph {
|
||||
fn paint(&self, p: &Painter, _tokens: &UiTokens, r: Rect, c: Color32, _mirrored: bool) {
|
||||
use wordcraft_render::icon_lib::{GRID, STROKE};
|
||||
let s = r.width().min(r.height()) / GRID;
|
||||
|
||||
@@ -875,7 +875,9 @@ impl StackDialog for AddLanguage {
|
||||
let endonym = shown(&pack.name, MAX_BAR_NAME);
|
||||
let detail = if endonym == *name { pack.locale.clone() } else { format!("{endonym} · {}", pack.locale) };
|
||||
let wants = &wants;
|
||||
let mut row = ListRow::new(format!("{name} · {detail}"));
|
||||
// The licence is the row's wrapped secondary text: `below` components share one line, and the error
|
||||
// notice (or the progress bar while installing) needs the row's width there.
|
||||
let mut row = ListRow::new(format!("{name} · {detail}")).lines(licence_hover(pack));
|
||||
match progress(&pack.locale) {
|
||||
Some((done, total)) => {
|
||||
let locale = pack.locale.clone();
|
||||
@@ -897,7 +899,6 @@ impl StackDialog for AddLanguage {
|
||||
});
|
||||
}
|
||||
}
|
||||
row = row.below(Text::new(licence_hover(pack)).shade(Shade::Faint), |_| {});
|
||||
if let Some(e) = error_in(errors, &pack.locale) {
|
||||
row = row.below(Notice::new(Tone::Bad, e).id_salt(("row_error", at)), |_| {});
|
||||
}
|
||||
@@ -1632,6 +1633,19 @@ mod tests {
|
||||
assert!(a.packs_rt.errors.values().any(|e| e.contains("Only you")), "{:?}", a.packs_rt.errors);
|
||||
let tree = settled(&mut a, &ctx);
|
||||
assert!(labels(&tree).iter().any(|l| l.contains("Only you")), "the row says why: {:?}", labels(&tree));
|
||||
// The reason has room to be read: it is at least as wide as Install and within the list's width (the row may sit
|
||||
// partly below the list's visible edge).
|
||||
let rect = |pick: &dyn Fn(&egui::accesskit::Node) -> bool| {
|
||||
tree.nodes.iter().filter(|(_, n)| pick(n)).filter_map(|(_, n)| n.bounds()).collect::<Vec<_>>()
|
||||
};
|
||||
let list = rect(&|n| n.role() == egui::accesskit::Role::List && n.label() == Some("Languages"));
|
||||
let button = rect(&|n| n.label().is_some_and(|l| l.starts_with("Install (")));
|
||||
let why = rect(&|n| n.label().is_some_and(|l| l.contains("Only you")));
|
||||
let (list, button) = (list.first().expect("the list"), button.first().expect("an Install button"));
|
||||
assert!(
|
||||
why.iter().any(|w| w.width() >= button.width() && w.x0 >= list.x0 && w.x1 <= list.x1 && w.y0 < list.y1),
|
||||
"the reason is as wide as Install and within the list's width: {why:?}, Install {button:?}, list {list:?}"
|
||||
);
|
||||
// The person's own click on the same row turns it on.
|
||||
let install = spot(&tree, "Install").expect("the row still offers Install");
|
||||
user_click(&mut a, &ctx, install);
|
||||
|
||||
@@ -7,16 +7,19 @@ use craft::keymap::CommandRef;
|
||||
use craft::pages::ui::PageBody;
|
||||
use craft::ui::buttons::{IconButton, ToggleButton};
|
||||
use craft::ui::canvas_controls::TaskBar;
|
||||
use craft::ui::contract::{Bind, Entry, Hover, Props, Show as _};
|
||||
use craft::ui::contract::{Bind, Entry, Gap, Hover, Props, Show as _, ShowContainer as _};
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::pickers::ComboBox;
|
||||
use craft::ui::runtime::env::Label;
|
||||
use egui::{Rect, Ui};
|
||||
use egui::{Rect, Ui, pos2};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::WordApp;
|
||||
use crate::colors::{Remember, Target};
|
||||
|
||||
/// Distance from the selection's start at which the bar is centred.
|
||||
const ANCHOR_INSET: f32 = 4.0;
|
||||
/// Least height of a selection rectangle (screen points) that counts as visible for anchoring.
|
||||
const MIN_VISIBLE_H: f32 = 1.0;
|
||||
|
||||
@@ -98,7 +101,10 @@ pub(crate) fn show(app: &mut WordApp, ui: &mut Ui, body: &PageBody<'_>) {
|
||||
return;
|
||||
}
|
||||
let Some(anchor) = app.canvas.mini_anchor else { return };
|
||||
let points: Vec<_> = [anchor.left_top(), anchor.right_top(), anchor.right_bottom(), anchor.left_bottom()]
|
||||
// The bar centres over the selection's start rather than drifting to the centre of long selections (#7447).
|
||||
let start_x = anchor.min.x + ANCHOR_INSET;
|
||||
let anchor_box = Rect::from_min_max(pos2(start_x, anchor.min.y), pos2(start_x, anchor.max.y));
|
||||
let points: Vec<_> = [anchor_box.left_top(), anchor_box.right_top(), anchor_box.right_bottom(), anchor_box.left_bottom()]
|
||||
.into_iter()
|
||||
.map(|corner| body.view.to_doc(corner))
|
||||
.collect();
|
||||
@@ -149,78 +155,81 @@ pub(crate) fn members(app: &mut WordApp, ui: &mut Ui, preview: bool) {
|
||||
if preview && let Some(held) = app.canvas.list_preview.clone() {
|
||||
app.canvas.command_preview = Some(held);
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let mut family = st.get("font").and_then(Value::as_str).unwrap_or("").to_string();
|
||||
let picked = crate::widgets::font_box::font_box(ui, app, tl!("Font").to_string(), &mut family);
|
||||
follow_list(app, preview, &picked.preview, |f| Some(("format.font".to_string(), json!({"name": f}))));
|
||||
if let Some(f) = &picked.picked {
|
||||
let _ = app.run("format.font", json!({"name": f}));
|
||||
}
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
Row::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let mut family = st.get("font").and_then(Value::as_str).unwrap_or("").to_string();
|
||||
let picked = crate::widgets::font_box::font_box(ui, app, tl!("Font").to_string(), &mut family);
|
||||
follow_list(app, preview, &picked.preview, |f| Some(("format.font".to_string(), json!({"name": f}))));
|
||||
if let Some(f) = &picked.picked {
|
||||
let _ = app.run("format.font", json!({"name": f}));
|
||||
}
|
||||
|
||||
let size = st.get("size").and_then(Value::as_f64).map(number_text).unwrap_or_default();
|
||||
let sizes: Vec<Entry<String>> =
|
||||
wordcraft_engine::cmd::format::SIZES.iter().map(|s| Entry::new(number_text(f64::from(*s)), number_text(f64::from(*s)))).collect();
|
||||
let mut text = size.clone();
|
||||
let combo = ComboBox::new(tl!("Font Size").to_string(), Bind::bound(&mut text), &sizes).show(ui);
|
||||
follow_list(app, preview, &combo.preview, |v| v.trim().parse::<f64>().ok().map(|x| ("format.size".to_string(), json!({"size": x}))));
|
||||
// Only a pick or Enter applies the size: typing alone is an edit of the box's draft.
|
||||
let committed = combo.edit.submitted || combo.edit.events.iter().any(|e| matches!(e, EditEvent::Set { .. } | EditEvent::Commit { .. }));
|
||||
if committed
|
||||
&& text != size
|
||||
&& let Ok(x) = text.trim().parse::<f64>()
|
||||
{
|
||||
let _ = app.run("format.size", json!({"size": x}));
|
||||
}
|
||||
let size = st.get("size").and_then(Value::as_f64).map(number_text).unwrap_or_default();
|
||||
let sizes: Vec<Entry<String>> =
|
||||
wordcraft_engine::cmd::format::SIZES.iter().map(|s| Entry::new(number_text(f64::from(*s)), number_text(f64::from(*s)))).collect();
|
||||
let mut text = size.clone();
|
||||
let combo = ComboBox::new(tl!("Font Size").to_string(), Bind::bound(&mut text), &sizes).show(ui);
|
||||
follow_list(app, preview, &combo.preview, |v| v.trim().parse::<f64>().ok().map(|x| ("format.size".to_string(), json!({"size": x}))));
|
||||
// Only a pick or Enter applies the size: typing alone is an edit of the box's draft.
|
||||
let committed = combo.edit.submitted || combo.edit.events.iter().any(|e| matches!(e, EditEvent::Set { .. } | EditEvent::Commit { .. }));
|
||||
if committed
|
||||
&& text != size
|
||||
&& let Ok(x) = text.trim().parse::<f64>()
|
||||
{
|
||||
let _ = app.run("format.size", json!({"size": x}));
|
||||
}
|
||||
|
||||
for (id, icon) in [("format.growFont", "grow"), ("format.shrinkFont", "shrink")] {
|
||||
let b = IconButton::command(crate::icons::id(icon), CommandRef::new(id)).show(ui);
|
||||
preview_on_hover(app, b.hover, b.response.enabled(), id, json!({}), preview);
|
||||
}
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
for (id, key, icon) in [
|
||||
("format.bold", "bold", "bold"),
|
||||
("format.italic", "italic", "italic"),
|
||||
("format.underline", "underline", "underline"),
|
||||
("format.strikethrough", "strike", "strike"),
|
||||
] {
|
||||
toggle(ui, app, id, icon, flag(key), preview);
|
||||
}
|
||||
let _ = Divider::vertical().show(ui);
|
||||
|
||||
let hl = crate::colors::highlight_split(ui, app, tl!("Text Highlight Color").to_string());
|
||||
follow_list(app, preview, &hl.preview, |c| {
|
||||
wordcraft_doc::props::Highlight::ALL
|
||||
.iter()
|
||||
.find(|h| h.rgb().as_ref() == Some(c))
|
||||
.map(|h| ("format.highlight".to_string(), json!({"color": h.ooxml()})))
|
||||
for (id, icon) in [("format.growFont", "grow"), ("format.shrinkFont", "shrink")] {
|
||||
let b = IconButton::command(crate::icons::id(icon), CommandRef::new(id)).show(ui);
|
||||
preview_on_hover(app, b.hover, b.response.enabled(), id, json!({}), preview);
|
||||
}
|
||||
});
|
||||
// PLAN: assumed ColorPick::hover (ribbon-w11, S-L413)
|
||||
let color = app.canvas.last_highlight.clone();
|
||||
preview_on_hover(app, hl.hover, hl.response.enabled(), "format.highlight", json!({"color": color}), preview);
|
||||
if hl.picked.is_some() {
|
||||
app.canvas.focus_page(ui.ctx());
|
||||
}
|
||||
let fc = crate::colors::font_color_split(ui, app, tl!("Font Color").to_string(), Target::cmd("format.color").remember(Remember::FontColor));
|
||||
follow_list(app, preview, &fc.preview, |c| Some(("format.color".to_string(), json!({"color": c.hex()}))));
|
||||
// PLAN: assumed ColorPick::hover (ribbon-w11, S-L413)
|
||||
let color = app.canvas.last_font_color.clone();
|
||||
preview_on_hover(app, fc.hover, fc.response.enabled(), "format.color", json!({"color": color}), preview);
|
||||
if fc.picked.is_some() {
|
||||
app.canvas.focus_page(ui.ctx());
|
||||
}
|
||||
let _ = Divider::vertical().show(ui);
|
||||
|
||||
use wordcraft_doc::Align as A;
|
||||
for (id, icon, a) in [
|
||||
("para.alignLeft", "alignLeft", A::Left),
|
||||
("para.alignCenter", "alignCenter", A::Center),
|
||||
("para.alignRight", "alignRight", A::Right),
|
||||
("para.justify", "justify", A::Justify),
|
||||
] {
|
||||
toggle(ui, app, id, icon, align == a, preview);
|
||||
}
|
||||
Row::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
for (id, key, icon) in [
|
||||
("format.bold", "bold", "bold"),
|
||||
("format.italic", "italic", "italic"),
|
||||
("format.underline", "underline", "underline"),
|
||||
("format.strikethrough", "strike", "strike"),
|
||||
] {
|
||||
toggle(ui, app, id, icon, flag(key), preview);
|
||||
}
|
||||
let _ = Divider::vertical().show(ui);
|
||||
|
||||
let hl = crate::colors::highlight_split(ui, app, tl!("Text Highlight Color").to_string());
|
||||
follow_list(app, preview, &hl.preview, |c| {
|
||||
wordcraft_doc::props::Highlight::ALL
|
||||
.iter()
|
||||
.find(|h| h.rgb().as_ref() == Some(c))
|
||||
.map(|h| ("format.highlight".to_string(), json!({"color": h.ooxml()})))
|
||||
});
|
||||
// PLAN: assumed ColorPick::hover (ribbon-w11, S-L413)
|
||||
let color = app.canvas.last_highlight.clone();
|
||||
preview_on_hover(app, hl.hover, hl.response.enabled(), "format.highlight", json!({"color": color}), preview);
|
||||
if hl.picked.is_some() {
|
||||
app.canvas.focus_page(ui.ctx());
|
||||
}
|
||||
let fc =
|
||||
crate::colors::font_color_split(ui, app, tl!("Font Color").to_string(), Target::cmd("format.color").remember(Remember::FontColor));
|
||||
follow_list(app, preview, &fc.preview, |c| Some(("format.color".to_string(), json!({"color": c.hex()}))));
|
||||
// PLAN: assumed ColorPick::hover (ribbon-w11, S-L413)
|
||||
let color = app.canvas.last_font_color.clone();
|
||||
preview_on_hover(app, fc.hover, fc.response.enabled(), "format.color", json!({"color": color}), preview);
|
||||
if fc.picked.is_some() {
|
||||
app.canvas.focus_page(ui.ctx());
|
||||
}
|
||||
let _ = Divider::vertical().show(ui);
|
||||
|
||||
use wordcraft_doc::Align as A;
|
||||
for (id, icon, a) in [
|
||||
("para.alignLeft", "alignLeft", A::Left),
|
||||
("para.alignCenter", "alignCenter", A::Center),
|
||||
("para.alignRight", "alignRight", A::Right),
|
||||
("para.justify", "justify", A::Justify),
|
||||
] {
|
||||
toggle(ui, app, id, icon, align == a, preview);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,66 @@ fn every_control_fits_inside_the_bar() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7447: the mini toolbar anchors to the start of the selection rather than its center,
|
||||
/// so its position does not shift with the length of the selection.
|
||||
#[test]
|
||||
fn the_bar_anchors_to_the_selection_start_rather_than_its_center() {
|
||||
let h_short = bar_over("brown");
|
||||
let h_long = bar_over("brown fox jumps over the lazy dog");
|
||||
|
||||
let bar_from = |h: &H| {
|
||||
let c = canvas(h);
|
||||
h.query_all_by_role(Role::Group)
|
||||
.filter(|n| n.accesskit_node().label().as_deref() == Some("Formatting"))
|
||||
.map(|n| n.rect())
|
||||
.find(|r| c.contains_rect(*r))
|
||||
.expect("the selection bar is shown inside the canvas")
|
||||
};
|
||||
|
||||
let bar_short = bar_from(&h_short);
|
||||
let bar_long = bar_from(&h_long);
|
||||
|
||||
assert!(
|
||||
(bar_short.min.x - bar_long.min.x).abs() < 1e-3,
|
||||
"the toolbar's horizontal position must anchor to the selection start and not shift with selection length: short x={}, long x={}",
|
||||
bar_short.min.x,
|
||||
bar_long.min.x,
|
||||
);
|
||||
|
||||
// A selection starting at a later word on the same line tracks that word's start.
|
||||
let h_later = bar_over("jumps");
|
||||
let bar_later = bar_from(&h_later);
|
||||
assert!(
|
||||
bar_later.min.x > bar_short.min.x + 20.0,
|
||||
"a selection starting later on the line must place the toolbar further to the right: brown x={}, jumps x={}",
|
||||
bar_short.min.x,
|
||||
bar_later.min.x,
|
||||
);
|
||||
}
|
||||
|
||||
/// #7375: the bar's formatting controls are stacked into two rows: Row 2 controls (Bold,
|
||||
/// Align Left) sit strictly below Row 1 controls (Font, Font Size) rather than side-by-side.
|
||||
#[test]
|
||||
fn formatting_controls_stack_into_two_rows() {
|
||||
let h = bar_over("brown fox");
|
||||
let font = font_box(&h);
|
||||
let size = size_box(&h);
|
||||
let bold = member(&h, "Bold").expect("the bar has Bold");
|
||||
let align_left = member(&h, "Align Left").expect("the bar has Align Left");
|
||||
|
||||
// Row 1 controls sit on the top row together.
|
||||
assert!((font.min.y - size.min.y).abs() < 1.0, "Font and Font Size must share Row 1: font {font:?}, size {size:?}");
|
||||
|
||||
// Row 2 controls sit on the second row together.
|
||||
assert!((bold.min.y - align_left.min.y).abs() < 1.0, "Bold and Align Left must share Row 2: bold {bold:?}, align_left {align_left:?}");
|
||||
|
||||
// Row 2 controls sit strictly below Row 1 controls.
|
||||
assert!(bold.min.y >= font.max.y, "Bold ({bold:?}) must sit strictly below Font ({font:?})");
|
||||
assert!(bold.min.y >= size.max.y, "Bold ({bold:?}) must sit strictly below Font Size ({size:?})");
|
||||
assert!(align_left.min.y >= font.max.y, "Align Left ({align_left:?}) must sit strictly below Font ({font:?})");
|
||||
assert!(align_left.min.y >= size.max.y, "Align Left ({align_left:?}) must sit strictly below Font Size ({size:?})");
|
||||
}
|
||||
|
||||
/// Hovering any member of the bar previews its command on the selection; the pick is not made.
|
||||
#[test]
|
||||
fn hovering_a_bar_member_previews_its_command() {
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::menu::ribbon::{RibbonGroup, RibbonRow};
|
||||
use craft::ui::buttons::{Arrangement, Button};
|
||||
use craft::ui::contract::{Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
use craft::ui::contract::{Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
|
||||
use craft::ui::controls::disclosure::DisclosureGlyph;
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
@@ -18,11 +18,6 @@ use super::{Ui, WordApp, json};
|
||||
use crate::icons;
|
||||
use crate::undo_marks::apply_edits;
|
||||
|
||||
/// Whether the command a menu is about can run now; a menu about no command is always open.
|
||||
pub(super) fn about_enabled(ctx: &egui::Context, about: &str) -> bool {
|
||||
about.is_empty() || craft::ui::runtime::commands::resolve(ctx, CommandRef::new(about)).enabled
|
||||
}
|
||||
|
||||
/// The arrow after the label of a ribbon menu button: the small filled triangle of the old ribbon.
|
||||
pub(crate) static MENU_ARROW: DisclosureGlyph = DisclosureGlyph::new(1.0);
|
||||
|
||||
@@ -30,12 +25,16 @@ pub(crate) static MENU_ARROW: DisclosureGlyph = DisclosureGlyph::new(1.0);
|
||||
/// `face` is the caller's button; `about` is that command's id, `None` for a menu about no command.
|
||||
pub(crate) fn menu_button(
|
||||
ui: &mut Ui,
|
||||
face: Button<'_>,
|
||||
mut face: Button<'_>,
|
||||
name: impl Into<Label>,
|
||||
about: Option<&str>,
|
||||
body: impl FnMut(&mut Ui, &mut BodyCx<'_>),
|
||||
) -> MenuOutput {
|
||||
let enabled = about_enabled(ui.ctx(), about.unwrap_or(""));
|
||||
let resolved = about.filter(|id| !id.is_empty()).map(|id| craft::ui::runtime::commands::resolve(ui.ctx(), CommandRef::new(id)));
|
||||
let enabled = resolved.as_ref().is_none_or(|cmd| cmd.enabled);
|
||||
if !enabled && let Some(hint) = resolved.as_ref().and_then(|cmd| cmd.hint.clone()) {
|
||||
face = face.tooltip(TooltipSpec::new(hint.clone()).disabled_text(hint));
|
||||
}
|
||||
let opener = face.trailing_icon(IconSpec::glyph(&MENU_ARROW)).enabled(enabled).show(ui);
|
||||
Menu::new(name).opened_by(&opener.response, Trigger::Click).show(ui, body).output
|
||||
}
|
||||
|
||||
@@ -298,7 +298,8 @@ pub(crate) fn wordart(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp, comma
|
||||
.select(SelectMode::None)
|
||||
.activate(ActivateOn::Click)
|
||||
.card_columns(WORDART_COLUMNS)
|
||||
.content_cells()
|
||||
.thumb_size(ThumbSize::Small)
|
||||
.zoom(2.0)
|
||||
// Every style shows, as in production; the menu's body is the one scroll.
|
||||
.natural_height(true)
|
||||
.caption(CaptionPlace::None)
|
||||
|
||||
@@ -8,7 +8,7 @@ use craft::ui::contract::{
|
||||
};
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::list::{ThumbAspect, ThumbSize};
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::{HAlign, TextRun};
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
@@ -85,7 +85,7 @@ fn bullets_menu(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
|
||||
.select(SelectMode::None)
|
||||
.activate(ActivateOn::Click)
|
||||
.card_columns(BULLETS.len())
|
||||
.content_cells()
|
||||
.thumb_size(ThumbSize::Small)
|
||||
// One row, all shown; the menu's body is the one scroll.
|
||||
.natural_height(true)
|
||||
.show_items(ui, &source, &mut |c, _| {
|
||||
|
||||
@@ -57,25 +57,31 @@ pub(super) fn table_design(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
row.group(RibbonGroup::new("tableStyles", tl!("Table Styles").to_string(), IconId::new("tableStyles").into()), |ui| {
|
||||
super::galleries::table_styles(ui, app);
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let _ = menu_button(ui, Button::new(tl!("Styles").to_string()).icon(IconId::new("styles")), tl!("Styles").to_string(), None, |ui, _| {
|
||||
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "newTableStyle"})))
|
||||
.label(tl!("New Table Style…").to_string())
|
||||
.show(ui);
|
||||
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "modifyTableStyle"})))
|
||||
.label(tl!("Modify Table Style…").to_string())
|
||||
.enabled(can_modify)
|
||||
.show(ui);
|
||||
MenuItem::command(CommandRef::with_params("table.deleteStyle", json!({})))
|
||||
.label(tl!("Delete Table Style").to_string())
|
||||
.enabled(can_delete)
|
||||
.show(ui);
|
||||
});
|
||||
let _ = menu_button(
|
||||
ui,
|
||||
Button::new(tl!("Styles").to_string()).icon(IconId::new("styles")),
|
||||
tl!("Styles").to_string(),
|
||||
Some("table.style"),
|
||||
|ui, _| {
|
||||
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "newTableStyle"})))
|
||||
.label(tl!("New Table Style…").to_string())
|
||||
.show(ui);
|
||||
MenuItem::command(CommandRef::with_params("ui.dialog", json!({"name": "modifyTableStyle"})))
|
||||
.label(tl!("Modify Table Style…").to_string())
|
||||
.enabled(can_modify)
|
||||
.show(ui);
|
||||
MenuItem::command(CommandRef::with_params("table.deleteStyle", json!({})))
|
||||
.label(tl!("Delete Table Style").to_string())
|
||||
.enabled(can_delete)
|
||||
.show(ui);
|
||||
},
|
||||
);
|
||||
let _ = crate::colors::shading_split(ui, app, tl!("Shading").to_string(), Target::cmd("table.shading").remember(Remember::Shading));
|
||||
});
|
||||
});
|
||||
row.group(RibbonGroup::new("borders", tl!("Borders").to_string(), IconId::new("borders").into()), |ui| {
|
||||
let face = Button::new(tl!("Borders").to_string()).icon(IconId::new("borders")).arrangement(Arrangement::Stacked);
|
||||
let _ = menu_button(ui, face, tl!("Borders").to_string(), None, |ui, _| {
|
||||
let _ = menu_button(ui, face, tl!("Borders").to_string(), Some("table.borders"), |ui, _| {
|
||||
for (label, kind) in [
|
||||
("All Borders", "all"),
|
||||
("Outside Borders", "outside"),
|
||||
@@ -181,7 +187,7 @@ pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
});
|
||||
row.group(RibbonGroup::new("rowsColumns", tl!("Rows & Columns").to_string(), IconId::new("insertAbove").into()), |ui| {
|
||||
let face = Button::new(tl!("Delete").to_string()).icon(IconId::new("deleteTable")).arrangement(Arrangement::Stacked);
|
||||
let _ = menu_button(ui, face, tl!("Delete").to_string(), None, |ui, _| {
|
||||
let _ = menu_button(ui, face, tl!("Delete").to_string(), Some("table.deleteTable"), |ui, _| {
|
||||
for (label, id) in [
|
||||
("Delete Cells", "table.deleteCells"),
|
||||
("Delete Columns", "table.deleteColumn"),
|
||||
@@ -214,7 +220,7 @@ pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
});
|
||||
row.group(RibbonGroup::new("cellSize", tl!("Cell Size").to_string(), IconId::new("autofit").into()), |ui| {
|
||||
let face = Button::new(tl!("AutoFit").to_string()).icon(IconId::new("autofit")).arrangement(Arrangement::Stacked);
|
||||
let _ = menu_button(ui, face, tl!("AutoFit").to_string(), None, |ui, _| {
|
||||
let _ = menu_button(ui, face, tl!("AutoFit").to_string(), Some("table.autofit"), |ui, _| {
|
||||
for (label, mode) in [("AutoFit Contents", "contents"), ("AutoFit Window", "window"), ("Fixed Column Width", "fixed")] {
|
||||
MenuItem::command(CommandRef::with_params("table.autofit", json!({"mode": mode}))).label(tl!(label).to_string()).show(ui);
|
||||
}
|
||||
|
||||
@@ -771,3 +771,168 @@ fn home_font_and_paragraph_buttons_stay_icon_only_and_styles_shows_six_tiles() {
|
||||
assert!(shown(style), "Home › Styles should show {style} at 1920 pt");
|
||||
}
|
||||
}
|
||||
|
||||
/// #7323: the Home › Bullets dropdown renders the Bullet Library grid as compact
|
||||
/// square preview tiles (~22×22 pt), rather than expanding to full card dimensions (~132 pt).
|
||||
#[test]
|
||||
fn bullets_dropdown_renders_compact_bullet_tiles() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Sample")), crate::Services::default());
|
||||
let mut h = tab_harness(app, "Home");
|
||||
h.ctx.set_missing_glyph_policy(egui::MissingGlyphPolicy::Tofu);
|
||||
|
||||
// The SplitButton has two button nodes: the command part and the arrow part.
|
||||
let arrow = h.query_all(By::new().role(Role::Button).label("Bullets")).nth(1).expect("Bullets split-button menu arrow");
|
||||
arrow.click();
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
|
||||
let bullet_tile = h.query_all(By::new().role(Role::ListItem).label("•")).next().expect("bullet tile •");
|
||||
let rect = bullet_tile.rect();
|
||||
assert!(
|
||||
rect.width() >= 16.0 && rect.width() <= 32.0,
|
||||
"bullet tile width ({:.1} pt) should be compact (expected ~22 pt, bound [16, 32])",
|
||||
rect.width()
|
||||
);
|
||||
assert!(
|
||||
rect.height() >= 16.0 && rect.height() <= 32.0,
|
||||
"bullet tile height ({:.1} pt) should be compact (expected ~22 pt, bound [16, 32])",
|
||||
rect.height()
|
||||
);
|
||||
assert!((rect.width() - rect.height()).abs() <= 2.0, "bullet tile should be square: {}x{}", rect.width(), rect.height());
|
||||
}
|
||||
|
||||
/// #7310: unimplemented stub ribbon buttons (Dictate, Ink to Math, Translate, Block Authors)
|
||||
/// resolve disabled in the ribbon UI and are known to the command catalog without warnings.
|
||||
#[test]
|
||||
fn unimplemented_stub_ribbon_buttons_are_disabled() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let cases = [
|
||||
("Home", "Dictate", "tools.dictate"),
|
||||
("Draw", "Ink to Math", "draw.inkToMath"),
|
||||
("Review", "Translate", "review.translate"),
|
||||
("Review", "Block Authors", "review.blockAuthors"),
|
||||
];
|
||||
|
||||
for (tab, expected_label, id) in cases {
|
||||
let app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Text")), crate::Services::default());
|
||||
let h = tab_harness(app, tab);
|
||||
|
||||
let keymap = craft::ui::runtime::commands::keymap(&h.ctx).expect("command board has a keymap");
|
||||
assert!(keymap.catalog().iter().any(|def| def.command.id == id), "{tab}: stub command {id} should be registered in the app catalog");
|
||||
|
||||
let button = h
|
||||
.query_all(By::new().role(Role::Button))
|
||||
.find(|n| n.accesskit_node().label().is_some_and(|l| l.split_whitespace().collect::<Vec<_>>().join(" ") == expected_label))
|
||||
.unwrap_or_else(|| panic!("{tab}: ribbon button '{expected_label}' should exist"));
|
||||
assert!(button.accesskit_node().is_disabled(), "{tab}: stub button {:?} ({id}) must be disabled", button.accesskit_node().label());
|
||||
}
|
||||
}
|
||||
|
||||
/// #7324: Table ribbon menu buttons (Styles, Borders, Delete, AutoFit) bind their command IDs
|
||||
/// so they disable when editing is protected or when no table is active.
|
||||
#[test]
|
||||
fn table_ribbon_menu_buttons_disable_when_unselected_or_protected() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let is_disabled = |h: &Harness, name: &str| {
|
||||
h.query_all(By::new().role(Role::Button).label(name))
|
||||
.next()
|
||||
.unwrap_or_else(|| panic!("button {name} not found"))
|
||||
.accesskit_node()
|
||||
.is_disabled()
|
||||
};
|
||||
|
||||
let description = |h: &Harness, name: &str| {
|
||||
h.query_all(By::new().role(Role::Button).label(name))
|
||||
.next()
|
||||
.unwrap_or_else(|| panic!("button {name} not found"))
|
||||
.accesskit_node()
|
||||
.description()
|
||||
.map(|s| s.to_string())
|
||||
};
|
||||
|
||||
// Configure Table Design & Table Layout as explicit ribbon tabs so they can be
|
||||
// displayed even when the cursor is outside a table.
|
||||
let make_table_tabs_app = |mut app: WordApp| {
|
||||
app.session.ribbon.tabs = vec![
|
||||
wordcraft_engine::ribbon::TabEntry { name: "Table Design".to_string(), custom: false, hidden: false, groups: Vec::new() },
|
||||
wordcraft_engine::ribbon::TabEntry { name: "Table Layout".to_string(), custom: false, hidden: false, groups: Vec::new() },
|
||||
];
|
||||
app
|
||||
};
|
||||
|
||||
// 1. Without a table active:
|
||||
let app_no_table = make_table_tabs_app(WordApp::new(Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default()));
|
||||
let h_design_empty = tab_harness(app_no_table, "Table Design");
|
||||
assert!(is_disabled(&h_design_empty, "Styles"), "Styles button should be disabled when not in table");
|
||||
assert!(is_disabled(&h_design_empty, "Borders"), "Borders button should be disabled when not in table");
|
||||
|
||||
let app_no_table2 = make_table_tabs_app(WordApp::new(Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default()));
|
||||
let h_layout_empty = tab_harness(app_no_table2, "Table Layout");
|
||||
assert!(is_disabled(&h_layout_empty, "Delete"), "Delete button should be disabled when not in table");
|
||||
assert!(is_disabled(&h_layout_empty, "AutoFit"), "AutoFit button should be disabled when not in table");
|
||||
|
||||
// 2. With an active table and no protection: buttons are enabled:
|
||||
let mut app_table = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app_table.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let h_design = tab_harness(app_table, "Table Design");
|
||||
assert!(!is_disabled(&h_design, "Styles"), "Styles button should be enabled in table");
|
||||
assert!(!is_disabled(&h_design, "Borders"), "Borders button should be enabled in table");
|
||||
|
||||
let mut app_table2 = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app_table2.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let h_layout = tab_harness(app_table2, "Table Layout");
|
||||
assert!(!is_disabled(&h_layout, "Delete"), "Delete button should be enabled in table");
|
||||
assert!(!is_disabled(&h_layout, "AutoFit"), "AutoFit button should be enabled in table");
|
||||
|
||||
// 3. With an active table under document protection (read-only): buttons are disabled:
|
||||
let mut app_protected_design = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app_protected_design.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
app_protected_design.session.doc.settings.protection = Some("readOnly".into());
|
||||
let h_prot_design = tab_harness(app_protected_design, "Table Design");
|
||||
assert!(is_disabled(&h_prot_design, "Styles"), "Styles button should be disabled under protection");
|
||||
assert!(is_disabled(&h_prot_design, "Borders"), "Borders button should be disabled under protection");
|
||||
assert!(
|
||||
description(&h_prot_design, "Styles").as_deref().unwrap_or("").contains("protected"),
|
||||
"Styles should indicate protection in disabled hint"
|
||||
);
|
||||
|
||||
let mut app_protected_layout = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app_protected_layout.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
app_protected_layout.session.doc.settings.protection = Some("readOnly".into());
|
||||
let h_prot_layout = tab_harness(app_protected_layout, "Table Layout");
|
||||
assert!(is_disabled(&h_prot_layout, "Delete"), "Delete button should be disabled under protection");
|
||||
assert!(is_disabled(&h_prot_layout, "AutoFit"), "AutoFit button should be disabled under protection");
|
||||
assert!(
|
||||
description(&h_prot_layout, "Delete").as_deref().unwrap_or("").contains("protected"),
|
||||
"Delete should indicate protection in disabled hint"
|
||||
);
|
||||
}
|
||||
|
||||
/// #7374: the Decorative Text / WordArt Styles dropdown menu renders compact tiles (~40×36 pt)
|
||||
/// rather than expanding to default card thumbnail size (~132×119 pt).
|
||||
#[test]
|
||||
fn decorative_text_dropdown_renders_compact_wordart_tiles() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Sample")), crate::Services::default());
|
||||
let mut h = tab_harness(app, "Insert");
|
||||
click_button(&mut h, "Decorative Text");
|
||||
|
||||
let tile = h.query_all(By::new().role(Role::ListItem).label("Solid Accent")).next().expect("Solid Accent WordArt tile");
|
||||
let rect = tile.rect();
|
||||
assert!(
|
||||
rect.width() >= 32.0 && rect.width() <= 50.0,
|
||||
"WordArt tile width ({:.1} pt) should be compact (expected ~40 pt, bound [32, 50]), got {:.1}",
|
||||
rect.width(),
|
||||
rect.width()
|
||||
);
|
||||
assert!(
|
||||
rect.height() >= 28.0 && rect.height() <= 46.0,
|
||||
"WordArt tile height ({:.1} pt) should be compact (expected ~36 pt, bound [28, 46]), got {:.1}",
|
||||
rect.height(),
|
||||
rect.height()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
//! Use [`builder`] instead of `egui_kittest::Harness::builder()` (the framework lint `test/kit`
|
||||
//! flags direct use); chain `with_size`, `with_step_dt` and the rest on the result as before.
|
||||
//! [`builder_with`] takes a custom install spec, e.g. a memory clipboard or a fake system.
|
||||
//!
|
||||
//! A test of the whole app window builds with `build_eframe(|_| app)`: the harness then runs the app
|
||||
//! as the desktop driver does (the `eframe::App` impl below), handing the runtime the app's input
|
||||
//! before every pass, the build pass included.
|
||||
|
||||
use craft::ui::InstallSpec;
|
||||
use egui_kittest::HarnessBuilder;
|
||||
@@ -33,37 +37,12 @@ pub(crate) fn builder<S>() -> HarnessBuilder<S> {
|
||||
/// Like [`builder`], with the install spec `spec` makes (called when the context is set up).
|
||||
pub(crate) fn builder_with<S>(spec: impl FnOnce() -> InstallSpec + 'static) -> HarnessBuilder<S> {
|
||||
egui_kittest::Harness::builder().with_context_setup(move |ctx| {
|
||||
// Before the runtime's plugin: egui runs input hooks in registration order, and the runtime's key stage reads
|
||||
// the input this hands it.
|
||||
ctx.add_plugin(HandOver);
|
||||
// A frame may draw a file name or language name in CJK on its first pass; a CI runner has no CJK font.
|
||||
cjk_stand_in(ctx);
|
||||
craft::ui::shell::embed::install(ctx, spec(), &crate::ui_fonts(Lang::EN)).expect("the craft runtime installs on a fresh test context");
|
||||
})
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
/// The input the app made in the last pass ([`driver_logic`]), waiting for the next pass to start.
|
||||
static PENDING: std::cell::RefCell<Option<craft::ui::runtime::frame::FrameInput>> = const { std::cell::RefCell::new(None) };
|
||||
}
|
||||
|
||||
/// Hands the runtime the input [`driver_logic`] left, before the next pass begins (egui's input hook runs
|
||||
/// before `begin_pass`). The runtime refuses input during a pass, and a kittest harness has no eframe
|
||||
/// `raw_input_hook` to give it at the right time.
|
||||
struct HandOver;
|
||||
|
||||
impl egui::Plugin for HandOver {
|
||||
fn debug_name(&self) -> &'static str {
|
||||
"wordcraft::test_harness::HandOver"
|
||||
}
|
||||
|
||||
fn input_hook(&mut self, ctx: &egui::Context, _input: &mut egui::RawInput) {
|
||||
if let Some(input) = PENDING.with(|p| p.borrow_mut().take()) {
|
||||
craft::ui::runtime::frame::set_input(ctx, input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A bare egui context with the craft runtime installed (the framework's test spec), for a test that
|
||||
/// runs frames by hand (`ctx.run_ui`) instead of through a kittest harness. A frame on a context
|
||||
/// without the runtime has no command registry, so the canvas's publish of its view commands
|
||||
@@ -83,11 +62,12 @@ pub(crate) fn context_with(spec: impl FnOnce() -> InstallSpec) -> egui::Context
|
||||
ctx
|
||||
}
|
||||
|
||||
/// One frame of `h` as the app's driver runs it: the runtime is first handed the input the app makes
|
||||
/// (`WordApp::frame_input`: the command catalog, each command's state, the fired commands), as
|
||||
/// eframe's raw-input hook does (`embed::before_input`). `Harness::step` and `run_steps` skip the
|
||||
/// hook, so a command-bound control is named by its command id and a clicked control's command never
|
||||
/// runs. A test that finds such a control by its label, or needs its command to run, steps here.
|
||||
/// One frame of `h`, a harness built with a ui closure, as the app's driver runs it: the runtime is first handed the
|
||||
/// input the app makes (`WordApp::frame_input`: the command catalog, each command's state, the fired commands), as
|
||||
/// eframe's raw-input hook does (`embed::before_input`). On such a harness `Harness::step` and `run_steps` skip the
|
||||
/// hook, so a command-bound control is named by its command id and a clicked control's command never runs. A test
|
||||
/// that finds such a control by its label, or needs its command to run, steps here. A `build_eframe` harness hands
|
||||
/// the input itself on every step.
|
||||
pub(crate) fn frame(h: &mut egui_kittest::Harness<'_, crate::WordApp>) {
|
||||
let ctx = h.ctx.clone();
|
||||
craft::ui::shell::embed::before_input(&ctx, |out| h.state_mut().frame_input(out));
|
||||
@@ -153,14 +133,21 @@ pub(crate) fn logic(ctx: &egui::Context, app: &mut crate::WordApp) {
|
||||
craft::ui::shell::embed::logic(ctx, || app.close_decision());
|
||||
}
|
||||
|
||||
/// [`logic`] for a kittest closure, where the harness's `step` and `run_steps` skip eframe's input hook: the app
|
||||
/// makes its input (`WordApp::frame_input`) at the head of the pass, and the runtime takes it when the next pass
|
||||
/// begins (it refuses input during a pass), so command states, fired commands and focus requests reach the
|
||||
/// passes after it, one frame behind. Needs a harness from [`builder`] or [`builder_with`].
|
||||
pub(crate) fn driver_logic(ctx: &egui::Context, app: &mut crate::WordApp) {
|
||||
let input = app.frame_input(craft::ui::runtime::frame::take_output(ctx));
|
||||
PENDING.with(|p| *p.borrow_mut() = Some(input));
|
||||
logic(ctx, app);
|
||||
/// The app as the desktop driver runs it (apps/wordcraft's `eframe::App`), for a `build_eframe` harness: kittest
|
||||
/// calls the raw-input hook before every pass, so each pass has the app's input (the root env with the host, the
|
||||
/// command states, the fired commands), as in production.
|
||||
impl eframe::App for crate::WordApp {
|
||||
fn raw_input_hook(&mut self, ctx: &egui::Context, _raw: &mut egui::RawInput) {
|
||||
craft::ui::shell::embed::before_input(ctx, |out| self.frame_input(out));
|
||||
}
|
||||
|
||||
fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
logic(ctx, self);
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
crate::WordApp::ui(self, ui);
|
||||
}
|
||||
}
|
||||
|
||||
/// One frame of `app` on a bare context from [`context`], as the app's driver runs it: the runtime is handed the
|
||||
|
||||
+20
-104
@@ -80,10 +80,12 @@ fn press_ctrl_f1(h: &mut egui_kittest::Harness<'static, WordApp>) {
|
||||
/// A harness over the app, as the tables below drive it.
|
||||
type Rig = egui_kittest::Harness<'static, WordApp>;
|
||||
|
||||
/// One key press with `modifiers`, then a frame.
|
||||
/// One key press with `modifiers`, then two frames: the runtime fires the chord's command in the first, and the app
|
||||
/// runs it before the second (`raw_input_hook`), as on the desktop.
|
||||
fn press(h: &mut Rig, key: egui::Key, modifiers: egui::Modifiers) {
|
||||
h.event(egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers });
|
||||
h.step();
|
||||
h.step();
|
||||
}
|
||||
|
||||
/// The style of the first paragraph.
|
||||
@@ -180,9 +182,6 @@ fn row_bound_ctrl_f1_runs_the_bound_command() {
|
||||
let mut h = canvas_harness();
|
||||
// PLAN(shell-w7): sh.A11 `Session::keymap_mut` over `Overrides::insert`.
|
||||
h.state_mut().session.keymap_mut().insert("view.focus", vec!["Mod+F1".into()]);
|
||||
// The harness hands the app's input (with the user's bindings) to the runtime one frame behind (`driver_logic`),
|
||||
// so the binding reaches the keymap in the frame after it is made, as in the row for Mod+Shift+0.
|
||||
h.step();
|
||||
press_ctrl_f1(&mut h);
|
||||
assert!(h.state().session.view.focus_mode, "the bound command ran");
|
||||
assert!(!h.state().ui.ribbon_collapsed, "the ribbon is unchanged");
|
||||
@@ -271,14 +270,15 @@ fn row_mod_shift_0_resets_the_interface_size_unless_bound() {
|
||||
assert_eq!(body_text(h.state()), "}", "AltGr+0 types the character");
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: Some(egui::Key::Num0), pressed: true, repeat: false, modifiers: chord });
|
||||
h.step();
|
||||
h.step();
|
||||
assert!(h.state().ui.interface_size.is_auto(), "Ctrl+Shift+0 returns to Auto");
|
||||
// A binding the user made for the chord wins.
|
||||
h.state_mut().run("ui.interfaceSize", json!({"percent": 300})).unwrap();
|
||||
// PLAN(shell-w7): sh.A11 `Session::keymap_mut` over `Overrides::insert`.
|
||||
h.state_mut().session.keymap_mut().insert("view.focus", vec!["Mod+Shift+0".into()]);
|
||||
h.step();
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: Some(egui::Key::Num0), pressed: true, repeat: false, modifiers: chord });
|
||||
h.step();
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.interface_size.percent(), Some(300), "the size stays");
|
||||
assert!(h.state().session.view.focus_mode, "the user's binding runs");
|
||||
}
|
||||
@@ -296,7 +296,7 @@ fn row_mod_shift_equals_stays_superscript() {
|
||||
let chord = egui::Modifiers { alt: false, ctrl: true, shift: true, mac_cmd: false, command: true };
|
||||
h.event(egui::Event::Key { key: egui::Key::Equals, physical_key: Some(egui::Key::Num0), pressed: true, repeat: false, modifiers: chord });
|
||||
h.step();
|
||||
// The chord fires its command in that pass; the app runs it when the next pass begins (`driver_logic`).
|
||||
// The chord fires its command in that pass; the app runs it before the next pass (`raw_input_hook`).
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.interface_size.percent(), Some(300), "Ctrl+Shift+= doesn't reset");
|
||||
let pos = wordcraft_doc::Pos { story: wordcraft_doc::StoryRef::Body, path: wordcraft_doc::Path::top(0), off: 0 };
|
||||
@@ -490,14 +490,7 @@ fn a_japanese_file_name_is_drawn_in_the_caption() {
|
||||
/// first frame fires that release builds and the components' own trials never reach.
|
||||
#[test]
|
||||
fn the_app_window_shows_for_a_few_frames() {
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
app(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app());
|
||||
h.run_steps(3);
|
||||
assert!(h.state().has_document(), "the window opened on a document");
|
||||
assert!(!h.state().quit_requested);
|
||||
@@ -633,14 +626,7 @@ fn display_server_is_a_ui_command_and_survives_a_restart() {
|
||||
}
|
||||
|
||||
fn harness(a: WordApp) -> egui_kittest::Harness<'static, WordApp> {
|
||||
crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
)
|
||||
crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a)
|
||||
}
|
||||
|
||||
/// #1908: with no document open the Home ribbon's split buttons grey out like the plain
|
||||
@@ -1539,14 +1525,7 @@ fn every_cut_entry_point_publishes_to_the_clipboard() {
|
||||
assert!(copied(&ctx).contains(&text), "ribbon Cut published {text:?}: {:?}", copied(&ctx));
|
||||
|
||||
// A real Cut key event through the app's key handling.
|
||||
let mut h = crate::test_harness::builder_with(spec).with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
typed(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder_with(spec).with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| typed());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -2009,14 +1988,7 @@ fn the_default_app_button_shows_only_with_the_hosts_hook() {
|
||||
}));
|
||||
}
|
||||
a.run("ui.backstage", json!({"value": true, "page": "options"})).unwrap();
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
h.run_steps(4);
|
||||
assert!(h.query_by_label("Show the community button in the title bar").is_some(), "hook {hook}: the Options page rendered");
|
||||
// The row carries the label too (macOS shows it, with Finder's steps instead of a button): ask for the button.
|
||||
@@ -2069,14 +2041,7 @@ fn the_host_hears_about_edits_made_while_drawing() {
|
||||
let mut a = app();
|
||||
let seen = reported.clone();
|
||||
a.services.on_dirty = Some(Box::new(move |d| seen.set(Some(d))));
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -2092,14 +2057,7 @@ fn the_host_hears_about_edits_made_while_drawing() {
|
||||
fn paragraph_alignment_keeps_the_canvas_focused_for_typing() {
|
||||
use wordcraft_doc::Align;
|
||||
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
typed(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| typed());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -2108,7 +2066,7 @@ fn paragraph_alignment_keeps_the_canvas_focused_for_typing() {
|
||||
[("Align Left", Align::Left, " left"), ("Center", Align::Center, " center"), ("Align Right", Align::Right, " right")]
|
||||
{
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, label).click();
|
||||
// The click fires the button's command in that pass; the app runs it when the next pass begins (`driver_logic`).
|
||||
// The click fires the button's command in that pass; the app runs it before the next pass (`raw_input_hook`).
|
||||
h.step();
|
||||
h.step();
|
||||
|
||||
@@ -2148,14 +2106,7 @@ fn type_after_click(h: &mut egui_kittest::Harness<'_, WordApp>, what: &str, text
|
||||
fn clicks_on_ribbon_and_status_bar_chrome_keep_typing_in_the_document() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
typed(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| typed());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -3354,21 +3305,14 @@ fn ctrl_shift_equals_on_the_zero_key_stays_superscript() {
|
||||
a.run("document.setText", json!({"text": "x"})).unwrap();
|
||||
a.run("select.all", json!({})).unwrap();
|
||||
a.run("ui.interfaceSize", json!({"percent": 300})).unwrap();
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let chord = egui::Modifiers { alt: false, ctrl: true, shift: true, mac_cmd: false, command: true };
|
||||
h.event(egui::Event::Key { key: egui::Key::Equals, physical_key: Some(egui::Key::Num0), pressed: true, repeat: false, modifiers: chord });
|
||||
h.step();
|
||||
// The chord fires its command in that pass; the app runs it when the next pass begins (`driver_logic`).
|
||||
// The chord fires its command in that pass; the app runs it before the next pass (`raw_input_hook`).
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.interface_size.percent(), Some(300), "Ctrl+Shift+= doesn't reset");
|
||||
let pos = wordcraft_doc::Pos { story: wordcraft_doc::StoryRef::Body, path: wordcraft_doc::Path::top(0), off: 0 };
|
||||
@@ -3381,14 +3325,7 @@ fn ctrl_shift_equals_on_the_zero_key_stays_superscript() {
|
||||
#[test]
|
||||
fn f11_and_escape_toggle_full_screen() {
|
||||
use egui::ViewportCommand::Fullscreen;
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
app(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -3432,14 +3369,7 @@ fn f11_and_escape_toggle_full_screen() {
|
||||
#[test]
|
||||
fn escape_collapses_a_selection_before_leaving_full_screen() {
|
||||
use egui::ViewportCommand::Fullscreen;
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
app(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -3578,14 +3508,7 @@ fn pasted_picture_inserts_only_when_the_page_is_the_edit_target() {
|
||||
fn paste_harness(a: WordApp) -> egui_kittest::Harness<'static, WordApp> {
|
||||
use craft::platform::clipboard::Clipboard;
|
||||
let spec = || crate::test_harness::install_spec().clipboard(Clipboard::new(LatePaste::default()));
|
||||
let mut h = crate::test_harness::builder_with(spec).with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder_with(spec).with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
@@ -3847,14 +3770,7 @@ fn render_without_a_path_replies_with_the_png() {
|
||||
#[test]
|
||||
fn shift_f10_opens_the_context_menu_at_the_caret() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
app(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ fn alt_q_opens_search_and_typing_goes_there() {
|
||||
// Both in one frame's input, as the platform sends them: kittest's `event` runs a frame for each queued event.
|
||||
h.input_mut().events.extend([open.clone(), egui::Event::Text("q".into())]);
|
||||
h.step();
|
||||
// The chord fires the command in that pass; the app runs it when the next pass begins (`driver_logic`).
|
||||
// The chord fires the command in that pass; the app runs it before the next pass (`raw_input_hook`).
|
||||
h.step();
|
||||
// The title bar shows the Search box, so Search opens there, in place (#5398).
|
||||
assert!(h.state().dialog_host.open_dialogs().is_empty(), "no Search Commands dialog over the page");
|
||||
|
||||
@@ -69,14 +69,7 @@ fn table_properties_dialog_sets_every_selected_row() {
|
||||
a.run("table.properties", json!({})).unwrap();
|
||||
|
||||
// Drawn: one click on the mixed box turns breaking on for every row.
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
for _ in 0..4 {
|
||||
h.step();
|
||||
}
|
||||
@@ -305,14 +298,7 @@ fn recipient_grid_edits_the_right_record_through_the_ui() {
|
||||
a.run("mailings.recipients", json!({"csv": "Name,City\nAda,London\nAlan,Wilmslow\nGrace,London\nÉmile,Paris"})).unwrap();
|
||||
a.run("mailings.filterRecipients", json!({"rules": [{"field": "City", "op": "equal", "value": "London"}]})).unwrap();
|
||||
dialogs::open(&mut a, "recipientList", &json!({})).expect("the dialog opens");
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut State| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
h.run_steps(4);
|
||||
let dlg = |h: &egui_kittest::Harness<'_, State>| {
|
||||
let d = h.state().dialog_host.get::<RecipientListDialog>().expect("the recipient dialog is open");
|
||||
@@ -436,14 +422,7 @@ fn an_existing_list_picked_on_the_web_loads_recipients() {
|
||||
/// pane's search box (with the selected text in it), not a dialog.
|
||||
#[test]
|
||||
fn find_replace_and_go_to_keys_like_word() {
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
app(),
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! Scrolling performance with a very large table (#811).
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::host::{Host, ManualJobs};
|
||||
use wordcraft_doc::table::{Cell, Table};
|
||||
use wordcraft_doc::{Block, Document, Path, StoryRef};
|
||||
|
||||
@@ -20,16 +23,13 @@ pub(crate) fn big_table_doc(rows: usize, cols: usize) -> Document {
|
||||
d
|
||||
}
|
||||
|
||||
fn harness(doc: Document) -> egui_kittest::Harness<'static, WordApp> {
|
||||
let a = WordApp::new(wordcraft_engine::Session::new(doc), Services::default());
|
||||
crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
)
|
||||
/// A harness over `doc` whose host runs a job only when the test runs its queue ([`ManualJobs`]): page pictures render
|
||||
/// on the test thread at the points the test picks, so what is resident never depends on the runner's load.
|
||||
fn harness(doc: Document) -> (egui_kittest::Harness<'static, WordApp>, Arc<ManualJobs>) {
|
||||
let jobs = Arc::new(ManualJobs::new());
|
||||
let host = Host::builder(crate::APP).i18n(crate::i18n::catalogs()).lang(craft::i18n::Lang::EN).jobs(jobs.clone()).build();
|
||||
let a = WordApp::new(wordcraft_engine::Session::new(doc), Services::default()).with_host(Arc::new(host));
|
||||
(crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a), jobs)
|
||||
}
|
||||
|
||||
/// Queues a pointer move to (720, 500) and a vertical point-unit wheel event that scrolls the view `dy` points.
|
||||
@@ -50,34 +50,43 @@ fn wheel(h: &mut egui_kittest::Harness<'static, WordApp>, dy: f32) {
|
||||
/// #811: scrolling through one very large table was slow because every frame fingerprinted every
|
||||
/// item of every page (thousands of cell borders a page) for the page texture cache, and every
|
||||
/// page ever shown kept its texture. Now a frame lays nothing out again, fingerprints a page once
|
||||
/// per layout and only when it is on screen, and keeps textures only near the view.
|
||||
/// per layout and only when it is on screen, and keeps textures only near the view. The pictures render on the
|
||||
/// host's jobs, which the test runs after each scroll step, so the renders for the view have finished when the next
|
||||
/// frame uploads them.
|
||||
#[test]
|
||||
fn scrolling_a_big_table_fingerprints_only_pages_coming_into_view() {
|
||||
let mut h = harness(big_table_doc(600, 8));
|
||||
let (mut h, jobs) = harness(big_table_doc(400, 8));
|
||||
h.run_steps(4);
|
||||
let layout = h.state_mut().session.layout();
|
||||
let pages = layout.pages.len();
|
||||
assert!(pages > 30, "the table runs over many pages ({pages})");
|
||||
// The scroll below crosses about 17 pages; the table runs well past that on every platform's fonts (29 pages on
|
||||
// macOS, more elsewhere), so the view never reaches its end.
|
||||
assert!(pages > 25, "the table runs over many pages ({pages})");
|
||||
let first = h.state().canvas.page_keys.hashed;
|
||||
assert!(first > 0 && first < 6, "only the pages on screen are fingerprinted, not all {pages}: {first}");
|
||||
// Idle frames do no per-page work.
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().canvas.page_keys.hashed, first, "idle frames fingerprint nothing");
|
||||
// Scroll a long way down: each newly shown page is fingerprinted once.
|
||||
assert!(jobs.waiting() > 0, "the pages in view render on the host's jobs");
|
||||
// Scroll a long way down: each newly shown page is fingerprinted once. The renders a step asks for finish before
|
||||
// the next step, whose frame uploads them.
|
||||
let mut max_textures = 0;
|
||||
for _ in 0..60 {
|
||||
wheel(&mut h, -400.0);
|
||||
for _ in 0..9 {
|
||||
wheel(&mut h, -2000.0);
|
||||
h.step();
|
||||
max_textures = max_textures.max(h.state().canvas.resident_pictures);
|
||||
jobs.run_all();
|
||||
}
|
||||
h.step();
|
||||
let offset = h.state().canvas.view.offset.1;
|
||||
assert!(offset > 20_000.0, "scrolled through many pages: {offset}");
|
||||
assert!(offset > 16_000.0, "scrolled through many pages: {offset}");
|
||||
let after = std::sync::Arc::clone(&h.state_mut().session.layout());
|
||||
assert!(std::sync::Arc::ptr_eq(&layout, &after), "scrolling never lays the document out again");
|
||||
let hashed = h.state().canvas.page_keys.hashed;
|
||||
// 60 steps of 400 pt cross about 24'000 / 1'056 ≈ 23 pages (at 100%, 1.33 px a point).
|
||||
assert!(hashed < pages && hashed <= first + 30, "pages fingerprinted: {hashed} of {pages}");
|
||||
// 9 steps of 2'000 pt cross about 18'000 / 1'056 ≈ 17 pages (at 100%, 1.33 px a point).
|
||||
assert!(hashed < pages && hashed <= first + 26, "pages fingerprinted: {hashed} of {pages}");
|
||||
// Textures stay bounded to the pages near the view.
|
||||
max_textures = max_textures.max(h.state().canvas.resident_pictures);
|
||||
assert!(max_textures <= 12, "textures kept while scrolling: {max_textures}");
|
||||
assert!(h.state().canvas.resident_pictures >= 1, "the pages in view stay rendered");
|
||||
}
|
||||
|
||||
@@ -85,14 +85,7 @@ fn picking_a_wordart_style_hands_the_keyboard_back_to_the_page() {
|
||||
use egui_kittest::kittest::{By, Queryable};
|
||||
let mut a = app();
|
||||
a.run("ui.tab", json!({"tab": "Insert"})).unwrap();
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
h.run_steps(4);
|
||||
// Insert › Decorative Text is the WordArt gallery's opener, under that name in production too.
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, "Decorative Text").click();
|
||||
@@ -158,14 +151,7 @@ fn citations_provider_menu_has_zotero_checked() {
|
||||
}
|
||||
assert_eq!(a.session.undo_depth(), depth, "not an undo step");
|
||||
a.run("ui.tab", json!({"tab": "Citations"})).unwrap();
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
crate::test_harness::driver_logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| a);
|
||||
h.run_steps(4);
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, "Provider").click();
|
||||
h.run_steps(3);
|
||||
|
||||
Reference in New Issue
Block a user