mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-23 22:33:36 -06:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e433bdb784 | ||
|
|
bf2be3cad8 | ||
|
|
805fb543fa | ||
|
|
73de5b5569 | ||
|
|
5e83839736 | ||
|
|
cf161d30a3 | ||
|
|
e4633540c0 | ||
|
|
73d3c71346 | ||
|
|
c939e644aa | ||
|
|
c406211ce9 | ||
|
|
720d6f4586 | ||
|
|
224b65101c | ||
|
|
ada0a0247d | ||
|
|
027dc1f197 | ||
|
|
57a9ff0dda | ||
|
|
4700018be7 | ||
|
|
700ce2f861 | ||
|
|
6088bf6f30 | ||
|
|
7fd0136bc8 | ||
|
|
f94728dea0 | ||
|
|
6837508ec9 | ||
|
|
262d036420 | ||
|
|
eb7d54c59d |
@@ -60,3 +60,4 @@ jobs:
|
||||
AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }}
|
||||
AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }}
|
||||
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
|
||||
ARTCRAFT_SERVICES_DISPATCH_TOKEN: ${{ secrets.ARTCRAFT_SERVICES_DISPATCH_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
# Accessibility
|
||||
|
||||
Source: `standards/app-accessibility.md` in [storytold/craft-contrib](https://github.com/storytold/craft-contrib/blob/main/standards/app-accessibility.md); do not edit this copy directly. Propose changes to the shared statement in [`storytold/craft-contrib`](https://github.com/storytold/craft-contrib).
|
||||
|
||||
We build the Craft applications so everyone can create, edit, and share work—including people who use screen readers, braille displays, screen magnifiers, voice control, high contrast, large text, reduced motion, or keyboard-only navigation.
|
||||
|
||||
## Priorities and target standard
|
||||
|
||||
- **Desktop builds** aim to meet **WCAG 2.2 Level AA** as applied to non-web software by W3C's [WCAG2ICT](https://www.w3.org/TR/wcag2ict-22/) (matching EN 301 549 Chapter 11).
|
||||
- **Web builds** (where published) aim to meet **[WCAG 2.2 Level AA](https://www.w3.org/TR/WCAG22/)** directly.
|
||||
- Accessibility is treated as a core engineering requirement alongside stability ([RFC-0014](https://github.com/storytold/craft-contrib/blob/main/rfcs/0014-accessibility.md)): every UI change is expected to support keyboard operation, real focus management, assistive-technology semantics, sufficient colour contrast, and spoken feedback.
|
||||
|
||||
## How accessibility works and supported environments
|
||||
|
||||
The Craft applications render their own interface in Rust using `egui` and expose accessibility trees to the operating system or browser through **AccessKit**:
|
||||
|
||||
- **Windows:** UI Automation (tested with Accessibility Insights / Axe.Windows; intended for NVDA, JAWS, and Narrator)
|
||||
- **macOS:** NSAccessibility (Accessibility Inspector; VoiceOver)
|
||||
- **Linux and FreeBSD:** AT-SPI (Accerciser; Orca)
|
||||
- **Web (WebAssembly):** Browser accessibility tree in modern evergreen browsers
|
||||
- **Visual and motion settings:** Light and dark themes with at least 4.5:1 text contrast and 3:1 control and focus-indicator contrast, plus respect for system high-contrast, text-scaling, and reduced-motion preferences
|
||||
- **Headless and command-line workflows:** Most Craft applications also ship a command-line and automation binary (`<app>-cli`) capable of inspecting and modifying documents from a terminal without driving the graphical interface; see [This application](#this-application) below
|
||||
|
||||
**Current verification status:** The Craft suite is in active early-alpha development. Automated widget-name checks (`egui_kittest`) run in tests, and platform accessibility checks are rolling out across repositories, but comprehensive manual screen-reader, braille, magnifier, and voice-control verification has not yet been completed across every surface.
|
||||
|
||||
## Known limitations and workarounds
|
||||
|
||||
These suite-wide barriers are actively tracked (shared framework work lives in [storytold/craft-libs#437](https://github.com/storytold/craft-libs/issues/437)):
|
||||
|
||||
- **Custom drawn surfaces (canvases, pages, grids, timelines, node graphs, and layer lists):** Some custom-painted views do not yet expose complete `AccessKit` nodes, caret bounds for magnifiers, or accurate editability states (for example, `AccessKit`'s Windows adapter reporting `Document` nodes as read-only, which can prevent typing echo in screen readers). *Workaround:* Use structured inspector panels where available, or run headless commands through `<app>-cli` when a task does not require interactive canvas drawing.
|
||||
- **Focus in menus, toolbars, and dialogs:** Some popups, menus, or keyboard access-key overlays may leave focus in the underlying document or fail to restore focus when closed. *Workaround:* Press `Escape` to dismiss open popups, `Alt` or `F10` for menu/toolbar navigation, and `F6` to cycle major regions where supported.
|
||||
- **Unannounced state changes:** Actions triggered away from focus—such as toggling formatting by keyboard shortcut or background export completion—do not yet consistently announce updates through a live region.
|
||||
- **Drag-dependent interactions:** Certain timeline, node-wiring, or object-manipulation gestures still lack complete non-dragging keyboard equivalents outside freehand drawing.
|
||||
|
||||
See [This application](#this-application) below for issues specific to this repository.
|
||||
|
||||
## Reporting an accessibility barrier
|
||||
|
||||
If something gets in your way, please open an issue using the link in [This application](#this-application) below (or let us know in the [ArtCraft Discord](https://discord.gg/artcraft) if GitHub's issue form is itself a barrier).
|
||||
|
||||
- **No personal disclosure required:** You never need to disclose a disability or explain why you use assistive technology.
|
||||
- **Screenshots and recordings are optional:** Plain-text descriptions are always enough.
|
||||
- **Helpful context to include (when available):**
|
||||
- The task you were trying to complete, what happened, and what you expected
|
||||
- Application version (or commit) and operating system or browser
|
||||
- Input method, display settings, or assistive technology and version (for example, NVDA, JAWS, Narrator, VoiceOver, Orca, screen magnifier, high contrast, 200% text scaling, or keyboard-only)
|
||||
|
||||
## How we respond and prioritize
|
||||
|
||||
- **Triage and labels:** Maintainers and triagers apply the `accessibility` label ("Barrier affecting people with disabilities") and assign priority during triage.
|
||||
- **Priority levels:** A barrier encountered with assistive technology or keyboard navigation is treated as a reproduced functional bug. Barriers that block a core task (opening, creating, editing, saving, reaching menus, or using dialogs) are triaged as `priority: high`; barriers that risk data or work loss are `priority: critical`.
|
||||
- **Verification builds (`needs screen reader test`):** Pull requests that fix a reported assistive-technology barrier or implement custom accessibility-tree or focus logic receive the `needs screen reader test` label. While manual testing never blocks merging fixes that pass automated checks, the label remains until someone verifies a build with assistive technology and posts what they observed; if the barrier remains, we reopen the issue.
|
||||
|
||||
## Expectations for contributors and coding agents
|
||||
|
||||
Every contributor and coding agent changing user interface code is expected to follow the Craft suite's [Accessibility standard](https://github.com/storytold/craft-contrib/blob/main/standards/accessibility.md) and the repository's `AGENTS.md`:
|
||||
|
||||
1. Ensure every action works by keyboard in visual order with no focus trap (`Escape` closes popups and restores focus), and provide non-dragging alternatives for pointer gestures.
|
||||
2. Move real `egui` focus (`request_focus`) rather than painting visual highlights alone, and expose accurate roles, translated names starting with visible labels, states, values, and platform-formatted shortcuts.
|
||||
3. Maintain at least 4.5:1 text contrast and 3:1 control/focus contrast across light and dark themes, and never rely on colour alone.
|
||||
4. Keep `egui_kittest` accessibility checks enabled, add keyboard and accessibility-tree assertions where warranted, and inspect the accessibility tree alongside any `ui.screenshot` check.
|
||||
5. Include an honest **Accessibility** section in UI pull requests stating what automated tree checks covered and what still needs human assistive-technology testing—never claim "works with screen readers" from tree tests alone.
|
||||
|
||||
## Ownership and maintenance
|
||||
|
||||
This statement and our accessibility practices are maintained by the `craft-app-team` maintainers in [`storytold`](https://github.com/storytold). Changes to the shared statement go through [`storytold/craft-contrib`](https://github.com/storytold/craft-contrib); repository-specific details live below.
|
||||
|
||||
## This application
|
||||
|
||||
**WordCraft** (`storytold/wordcraft`) is an open-source word processor written in pure Rust.
|
||||
|
||||
- **Published application builds:** macOS, Windows, Linux, FreeBSD, and Web (WebAssembly)
|
||||
- **Command-line and automation interface:** `wordcraft-cli` provides headless terminal and automation access for scripted workflows without the graphical interface
|
||||
- **Report an accessibility barrier:** [Open an issue in `storytold/wordcraft`](https://github.com/storytold/wordcraft/issues/new)
|
||||
- **Tracked accessibility issues:** [Open issues labelled `accessibility` in `storytold/wordcraft`](https://github.com/storytold/wordcraft/issues?q=is%3Aissue+state%3Aopen+label%3Aaccessibility)
|
||||
- **Pull requests awaiting assistive-technology verification:** [Pull requests labelled `needs screen reader test` in `storytold/wordcraft`](https://github.com/storytold/wordcraft/pulls?q=is%3Apr+label%3A%22needs+screen+reader+test%22)
|
||||
- **Contributor and agent rules for this repository:** [`AGENTS.md`](AGENTS.md)
|
||||
Generated
+162
-146
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 = "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-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", 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 = "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" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", 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 = "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-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
|
||||
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" }
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", 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 = "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" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use craft::host::{FileError, Files, PickId, PickRequest, Picked};
|
||||
use craft::host::{FileError, Files, PickId, PickRequest, Picked, WriteIntent};
|
||||
use craft::platform::browser_files::BrowserFiles;
|
||||
use craft::platform::open::{DropTarget, DroppedFile, IntakeSender};
|
||||
use craft::web_host::web::{FileData, Host, Message};
|
||||
@@ -175,8 +175,8 @@ impl Files for HostedFiles {
|
||||
self.inner.read(path)
|
||||
}
|
||||
|
||||
fn write(&self, path: &Path, bytes: &[u8]) -> Result<(), FileError> {
|
||||
self.inner.write(path, bytes)
|
||||
fn write(&self, path: &Path, bytes: &[u8], intent: WriteIntent) -> Result<bool, FileError> {
|
||||
self.inner.write(path, bytes, intent)
|
||||
}
|
||||
|
||||
fn last_folder(&self, purpose: &str) -> Option<PathBuf> {
|
||||
|
||||
@@ -16,7 +16,8 @@ mod objects;
|
||||
pub(crate) use header_footer::saved_copy;
|
||||
use header_footer::{create_hf, edit_hf, header_footer, new_empty_headers, strip_headers};
|
||||
pub use items::{
|
||||
DropCapState, default_date_picture, drop_cap_state, format_date, format_date_at, format_date_in, format_date_parts, format_date_parts_in,
|
||||
DropCapState, default_date_picture, drop_cap_state, format_date, format_date_at, format_date_at_in, format_date_in, format_date_parts,
|
||||
format_date_parts_in,
|
||||
};
|
||||
use items::{cover_page, date_time, drop_cap, drop_cap_off, field, page_number, symbol};
|
||||
use links::{bookmark, delete_bookmark, link, link_targets};
|
||||
|
||||
@@ -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 = "750a9bdd575b494055d7fb65b91f978b8eff651a" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
wordcraft-geom = { workspace = true, features = ["image"] }
|
||||
wordcraft-doc = { workspace = true }
|
||||
wordcraft-fonts = { workspace = true }
|
||||
@@ -76,7 +76,7 @@ craft-ui-test-kit = { workspace = true }
|
||||
craft = { workspace = true, features = ["ui-testing"] }
|
||||
|
||||
[build-dependencies]
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "750a9bdd575b494055d7fb65b91f978b8eff651a", features = ["subset"] }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", features = ["subset"] }
|
||||
serde_json = { workspace = true }
|
||||
toml = "1"
|
||||
|
||||
|
||||
@@ -633,7 +633,7 @@ impl WordApp {
|
||||
for item in intake.take() {
|
||||
match item {
|
||||
Intake::Dropped { files, target } => self.open_dropped(&files, target),
|
||||
Intake::Open(paths) => {
|
||||
Intake::Open(paths) | Intake::OpenFor { paths, .. } => {
|
||||
for p in paths {
|
||||
// A path that is not Unicode cannot be passed on as text: skipped.
|
||||
if let Some(path) = p.to_str()
|
||||
@@ -649,6 +649,14 @@ impl WordApp {
|
||||
Intake::Quit => {
|
||||
self.quit();
|
||||
}
|
||||
// An OS open request that arrived as bytes, with no path.
|
||||
Intake::Bytes { name, bytes } => {
|
||||
let data = wordcraft_engine::cmd::insert::base64_encode(bytes.as_ref());
|
||||
if let Err(e) = self.run("file.open", json!({"path": name, "data": data})) {
|
||||
self.report_open_failure(&name, &e);
|
||||
}
|
||||
self.ui.backstage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::sync::Arc;
|
||||
use craft::behavior::kurbo::{Point, Size};
|
||||
use craft::pages::layout::{Fit, LayoutOptions, PageDisplay, SCREEN_POINTS_PER_POINT};
|
||||
use craft::pages::ui::reading::{ReadingMetrics, reading_size};
|
||||
use craft::pages::ui::{MarkArea, MarkKind, PageBody, PageView, PageViewState, PlacedPage, ReadingNav, ReadingState, ReadingView, TextMarks};
|
||||
use craft::pages::ui::{GoTo, MarkArea, MarkKind, PageBody, PageView, PageViewState, PlacedPage, ReadingNav, ReadingState, ReadingView, TextMarks};
|
||||
use craft::ui::canvas::{Autoscroll, ContextSource, MiddleButton, NavigationOptions, ToolHost, ToolHostResponse, ToolPass, WheelScheme};
|
||||
use craft::ui::contract::Show as _;
|
||||
|
||||
@@ -371,7 +371,7 @@ impl CanvasState {
|
||||
|
||||
/// The comment whose balloon is selected, as the document's comment id.
|
||||
pub fn selected_balloon(&self) -> Option<u32> {
|
||||
self.comments.selected.and_then(|id| u32::try_from(id.0).ok())
|
||||
self.comments.selected.lead.and_then(|id| u32::try_from(id.0).ok())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ fn mark_areas(app: &mut WordApp, layout: &DocLayout, selected: &[(usize, wordcra
|
||||
fn navigation_options() -> NavigationOptions {
|
||||
let mut options = NavigationOptions::default();
|
||||
options.middle_button =
|
||||
if cfg!(any(target_os = "macos", target_os = "ios", target_arch = "wasm32")) { MiddleButton::Pan } else { MiddleButton::Autoscroll };
|
||||
if cfg!(any(target_os = "macos", target_os = "ios", target_arch = "wasm32")) { MiddleButton::Pan } else { MiddleButton::AutoScroll };
|
||||
options.wheel = WheelScheme::Document;
|
||||
options
|
||||
}
|
||||
@@ -754,7 +754,7 @@ fn show_pages(app: &mut WordApp, ui: &mut Ui, layout: &Arc<DocLayout>, full: Rec
|
||||
if let Some(c) = c
|
||||
&& let Some(page) = layout.pages.get(c.page)
|
||||
{
|
||||
state.go_to = Some((c.page, f64::from(c.top / page.h.max(1.0))));
|
||||
state.go_to = Some(GoTo::Top { page: c.page, fraction: f64::from(c.top / page.h.max(1.0)) });
|
||||
state.current = c.page;
|
||||
}
|
||||
}
|
||||
@@ -864,7 +864,7 @@ fn show_pages(app: &mut WordApp, ui: &mut Ui, layout: &Arc<DocLayout>, full: Rec
|
||||
} else {
|
||||
screen_rects(&selected, body.pages)
|
||||
};
|
||||
app.canvas.mini_anchor = crate::mini_toolbar::visible_anchor(anchor_rects, body.view.rect);
|
||||
app.canvas.mini_anchor = crate::mini_toolbar::visible_anchor(anchor_rects, body.view.rect, crate::mini_toolbar::starts_rtl(app));
|
||||
// The bar is its own floating layer: shown after the host, it keeps its buttons' presses (S-L410).
|
||||
crate::mini_toolbar::show(app, ui, body);
|
||||
}
|
||||
@@ -908,7 +908,7 @@ fn show_pages(app: &mut WordApp, ui: &mut Ui, layout: &Arc<DocLayout>, full: Rec
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
if let Some(go) = fix.go_to {
|
||||
state.go_to = Some(go);
|
||||
state.go_to = Some(GoTo::Top { page: go.0, fraction: go.1 });
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
// Dragging a selection past the view's edge scrolls on.
|
||||
@@ -920,7 +920,9 @@ fn show_pages(app: &mut WordApp, ui: &mut Ui, layout: &Arc<DocLayout>, full: Rec
|
||||
let per_unit = v.zoom.max(f64::EPSILON);
|
||||
let size = Size::new(out.layout.size.width / per_unit, out.layout.size.height / per_unit);
|
||||
if Autoscroll::scroll(&mut v, step, size).is_some() {
|
||||
out.adopt(&mut state, &v);
|
||||
// The view moved in document units; the state keeps screen points.
|
||||
state.offset.0 += (v.center.x - view.center.x) * view.zoom;
|
||||
state.offset.1 += (v.center.y - view.center.y) * view.zoom;
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! and its drafts are `CanvasState::comments`, the one copy the Comments pane shares.
|
||||
|
||||
use craft::review::ui::{BalloonItem, BalloonPlace, CommentBalloons, CommentEdit};
|
||||
use craft::review::{CommentAnchor, CommentMessage, CommentThread, ReviewStatus, Revision, RevisionKind, ThreadId};
|
||||
use craft::review::{CommentAnchor, CommentMessage, CommentThread, Revision, RevisionKind, ThreadId};
|
||||
|
||||
use super::geometry::{FLOAT_WIDTH, floating_comments, markup_width, shown_comment};
|
||||
use super::{Color32, CommentDisplay, DocLayout, Env, Pos, Pos2, StoryRef, Ui, WordApp, json};
|
||||
@@ -68,7 +68,8 @@ pub(crate) fn balloons(app: &mut WordApp, ui: &mut Ui, out: &craft::pages::ui::P
|
||||
/// Applies what a card reported through the commands the Comments pane uses.
|
||||
fn apply(app: &mut WordApp, cards: &[Card], edit: CommentEdit) {
|
||||
match edit {
|
||||
CommentEdit::Select(thread) => {
|
||||
CommentEdit::Select(threads) => {
|
||||
let Some(thread) = threads.first().copied() else { return };
|
||||
let Some(id) = app_id(thread) else { return };
|
||||
focus_balloon(app, id);
|
||||
let pos = cards.iter().find_map(|c| match &c.what {
|
||||
@@ -149,7 +150,7 @@ fn thread_of(app: &WordApp, id: u32, page: usize, anchor: Pos2, color: Color32)
|
||||
let c = app.session.doc.comments.get(&cid)?;
|
||||
let created = c.date_utc.as_deref().map(unix_seconds).filter(|t| *t > 0).unwrap_or_else(|| unix_seconds(&c.date));
|
||||
let text = app.session.doc.plain_text(StoryRef::Part(c.part)).trim().to_string();
|
||||
Some(CommentMessage { author: author_name(&c.author), created, modified: None, text, reactions: Vec::new(), read: true })
|
||||
Some(CommentMessage { author: author_name(&c.author), created, modified: None, text, reactions: Vec::new(), read: true, deletable: true })
|
||||
})
|
||||
.collect();
|
||||
Some(CommentThread {
|
||||
@@ -158,7 +159,8 @@ fn thread_of(app: &WordApp, id: u32, page: usize, anchor: Pos2, color: Color32)
|
||||
kind: None,
|
||||
color: Some([color.r(), color.g(), color.b()]),
|
||||
messages,
|
||||
status: ReviewStatus::None,
|
||||
statuses: Vec::new(),
|
||||
reply_statuses: Vec::new(),
|
||||
marked: false,
|
||||
locked: false,
|
||||
resolved: root.resolved,
|
||||
@@ -253,7 +255,7 @@ fn focus_balloon(app: &mut WordApp, id: u32) {
|
||||
let text = app.session.doc.comments.get(&id).filter(|_| editable).map(|c| app.session.doc.plain_text(StoryRef::Part(c.part)));
|
||||
let thread = thread_id(id);
|
||||
let comments = &mut app.canvas.comments;
|
||||
comments.selected = Some(thread);
|
||||
comments.selected = craft::behavior::Selection::single(thread);
|
||||
if comments.editing.as_ref().is_none_or(|(t, ..)| *t != thread) {
|
||||
comments.editing = text.map(|t| (thread, 0, t));
|
||||
}
|
||||
@@ -275,5 +277,5 @@ pub fn deselect_balloon(app: &mut WordApp) {
|
||||
// What was written is cleared by the write; a draft the document refused (read-only protection) stays, with its
|
||||
// reason on the status line, for when the balloon is selected again or the document is saved or closed (#1348).
|
||||
write_back(app, id);
|
||||
app.canvas.comments.selected = None;
|
||||
app.canvas.comments.selected = craft::behavior::Selection::default();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use craft::behavior::{Input, Metrics};
|
||||
use craft::pages::ui::{PageBody, PlacedPage};
|
||||
use craft::ui::canvas::ToolPass;
|
||||
use craft::ui::contract::{Access, Common, Component, Cx, MeasureCx, NoValue, Outcome, PaintUi, Props as _, Role, Show as _};
|
||||
use craft::ui::fonts::{FaceBytes, MAX_INTERFACE_FACE_BYTES};
|
||||
use craft::ui::fonts::FaceBytes;
|
||||
use craft::ui::primitives::{FaceRun, PaintShape, StrokeWidth, TextRun};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::style::{ComponentStyle, DataColor, StyleColor, StyleCx};
|
||||
@@ -293,14 +293,10 @@ pub(crate) fn face_key(face: wordcraft_fonts::FaceRef) -> String {
|
||||
format!("wordcraft-face:{}", face.id())
|
||||
}
|
||||
|
||||
/// The bytes, index and variation setting of `face`, read the first time it is drawn. A file larger than the framework
|
||||
/// draws over the interface fonts is not copied: the composition stays in the interface font (a document's CJK
|
||||
/// fallback can be 19 MB).
|
||||
/// The bytes, index and variation setting of `face`, read the first time it is drawn. The framework's document-face
|
||||
/// registry keeps the faces within its byte budget.
|
||||
fn face_bytes(face: wordcraft_fonts::FaceRef) -> Option<FaceBytes> {
|
||||
let data = face.data();
|
||||
if data.len() > MAX_INTERFACE_FACE_BYTES {
|
||||
return None;
|
||||
}
|
||||
Some(FaceBytes::new(std::sync::Arc::from(data), face.index()).coords(face.coords.iter().copied()))
|
||||
}
|
||||
|
||||
|
||||
@@ -427,20 +427,20 @@ fn selection_bar_clicks_select_lines() {
|
||||
page_to_screen(h.state_mut(), c.page, 30.0, c.top + c.height * (li + 0.5)).expect("on screen")
|
||||
};
|
||||
let line_start = |h: &mut H, at: Pos2| {
|
||||
let placed = *h.state().canvas.shown.pages.iter().find(|p| p.rect.contains(at)).expect("page");
|
||||
let placed = h.state().canvas.shown.pages.iter().find(|p| p.rect.contains(at)).expect("page").clone();
|
||||
let p = placed.to_page(at);
|
||||
let layout = h.state_mut().session.layout();
|
||||
layout.selection_bar_at(placed.page, p.x as f32, p.y as f32).expect("in the selection bar")
|
||||
};
|
||||
let span = |h: &mut H, pos: &Pos| h.state_mut().session.layout().line_span(pos, 0).expect("line");
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
let clicks_drag = |h: &mut H, from: Pos2, to: Pos2, clicks: usize| {
|
||||
let button = |at: Pos2, pressed: bool, modifiers: Modifiers| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers };
|
||||
let clicks_drag = |h: &mut H, from: Pos2, to: Pos2, clicks: usize, mods: Modifiers| {
|
||||
h.event(Event::PointerMoved(from));
|
||||
for i in 0..clicks {
|
||||
h.event(button(from, true));
|
||||
h.event(button(from, true, mods));
|
||||
h.app_frame();
|
||||
if i + 1 < clicks {
|
||||
h.event(button(from, false));
|
||||
h.event(button(from, false, mods));
|
||||
h.app_frame();
|
||||
}
|
||||
}
|
||||
@@ -448,7 +448,7 @@ fn selection_bar_clicks_select_lines() {
|
||||
h.event(Event::PointerMoved(from + (to - from) * (k as f32 / 4.0)));
|
||||
h.app_frame();
|
||||
}
|
||||
h.event(button(to, false));
|
||||
h.event(button(to, false, mods));
|
||||
for _ in 0..3 {
|
||||
h.app_frame();
|
||||
}
|
||||
@@ -462,22 +462,22 @@ fn selection_bar_clicks_select_lines() {
|
||||
let at = margin(&mut h, Pos::body(0, 0), 1.0);
|
||||
let l2 = line_start(&mut h, at);
|
||||
assert!(l2.off > 0 && l2.path == wordcraft_doc::Path::top(0));
|
||||
clicks_drag(&mut h, at, at, 1);
|
||||
clicks_drag(&mut h, at, at, 1, Modifiers::NONE);
|
||||
let (_, l2_end, _) = span(&mut h, &l2);
|
||||
assert_eq!(h.state().session.sel.ordered(), (l2.clone(), l2_end.clone()), "the line");
|
||||
// Double-click: the paragraph, mark included.
|
||||
pause(&mut h);
|
||||
clicks_drag(&mut h, at, at, 2);
|
||||
clicks_drag(&mut h, at, at, 2, Modifiers::NONE);
|
||||
assert_eq!(h.state().session.sel.ordered(), (Pos::body(0, 0), Pos::body(1, 0)), "the paragraph");
|
||||
// Triple-click: the whole document.
|
||||
pause(&mut h);
|
||||
clicks_drag(&mut h, at, at, 3);
|
||||
clicks_drag(&mut h, at, at, 3, Modifiers::NONE);
|
||||
assert_eq!(h.state().session.sel.ordered(), (Pos::body(0, 0), Pos::body(2, 10)), "everything");
|
||||
// Drag from beside the first line down past the third: three whole lines.
|
||||
pause(&mut h);
|
||||
let (from, to) = (margin(&mut h, Pos::body(0, 0), 0.0), margin(&mut h, Pos::body(0, 0), 2.0));
|
||||
let l3 = line_start(&mut h, to);
|
||||
clicks_drag(&mut h, from, to, 1);
|
||||
clicks_drag(&mut h, from, to, 1, Modifiers::NONE);
|
||||
let (_, l3_end, _) = span(&mut h, &l3);
|
||||
let sel = h.state().session.sel.clone();
|
||||
assert_eq!((sel.anchor, sel.focus), (Pos::body(0, 0), l3_end), "three lines");
|
||||
@@ -486,7 +486,7 @@ fn selection_bar_clicks_select_lines() {
|
||||
let second = margin(&mut h, Pos::body(1, 0), 0.0);
|
||||
h.event(Event::ModifiersChanged(Modifiers::SHIFT));
|
||||
h.app_frame();
|
||||
clicks_drag(&mut h, second, second, 1);
|
||||
clicks_drag(&mut h, second, second, 1, Modifiers::SHIFT);
|
||||
h.event(Event::ModifiersChanged(Modifiers::default()));
|
||||
h.app_frame();
|
||||
let sel = h.state().session.sel.clone();
|
||||
@@ -1227,15 +1227,14 @@ fn a_cjk_composition_uses_the_cjk_ui_font() {
|
||||
assert_eq!(row.glyphs.len(), 3, "one glyph per composed kana");
|
||||
let family = composition_font(&drawn).map(|f| f.family).expect("a font");
|
||||
assert_eq!(family, egui::FontFamily::Name(format!("face+ui:{}", super::caret::face_key(run.requested_face)).into()), "in the text's face");
|
||||
let (chain, interface) = h.ctx.fonts(|f| {
|
||||
let families = &f.definitions().families;
|
||||
(families.get(&family).cloned().unwrap_or_default(), families.get(&egui::FontFamily::Proportional).cloned().unwrap_or_default())
|
||||
});
|
||||
// The framework serves the face with the interface fonts behind it; what the face lacks is drawn from them, so each
|
||||
// kana has a full-width glyph (a missing one would be a narrow box or nothing).
|
||||
let size = composition_font(&drawn).map(|f| f.size).expect("a size");
|
||||
assert!(
|
||||
!interface.is_empty() && interface.iter().all(|f| chain.contains(f)),
|
||||
"the face's chain goes on with the interface fonts: {chain:?} {interface:?}"
|
||||
row.glyphs.iter().all(|g| g.advance_width >= size * 0.8),
|
||||
"the kana come from the interface fonts: {:?}",
|
||||
row.glyphs.iter().map(|g| g.advance_width).collect::<Vec<_>>()
|
||||
);
|
||||
assert_eq!(chain.len(), interface.len() + 1, "and no other document face is borrowed: {chain:?}");
|
||||
}
|
||||
|
||||
/// The composition is drawn in the font and size of the text it goes into, as Word draws it, its
|
||||
|
||||
@@ -259,7 +259,7 @@ fn comment_harness() -> (H, u32) {
|
||||
/// Click comment `id`'s balloon (from no selected balloon): the card is selected and its own
|
||||
/// edit has the keyboard in its field.
|
||||
fn click_balloon(h: &mut H, id: u32) {
|
||||
h.state_mut().canvas.comments.selected = None;
|
||||
h.state_mut().canvas.comments.selected = craft::behavior::Selection::default();
|
||||
steps(h, 2);
|
||||
let card = h.state().canvas.balloon_rects.iter().find(|(i, _)| *i == id).map(|(_, r)| *r).expect("the comment has a balloon");
|
||||
click_at(h, card.left_top() + vec2(30.0, 8.0));
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! control library
|
||||
//! - `ui.clickText {page, x, y}`: click at a page position (points from the page's top-left)
|
||||
//! - `ui.dialog.set`, `ui.dialog.confirm`, `ui.dialog.cancel`: the open dialogs' fields and answers
|
||||
//! - `ui.screenshot {path?}`: PNG of the window; `ui.render {path?, page?, scale?}`: page PNG
|
||||
//! - `ui.screenshot {path?, region?}`: PNG of the window (or of `region` `[x0, y0, x1, y1]` in points); `ui.render {path?, page?, scale?}`: page PNG
|
||||
//! (without `path`, both reply with the PNG as base64 `png`)
|
||||
//! - `ui.resize`, `ui.focus`, `ui.closeWindow`, `ui.clipboard`, `ui.replayAt`, `ui.accessTree`
|
||||
//! - `ui.parity`: feature catalog parity
|
||||
|
||||
@@ -376,10 +376,13 @@ fn handle_request(app: &mut WordApp, ctx: &egui::Context, req: &ControlRequest)
|
||||
"ui.inspect" => ok(inspect(app, ctx)),
|
||||
"ui.parity" => ok(wordcraft_engine::catalog::parity(&app.session.registry)),
|
||||
"ui.clickText" => click_text(app, ctx, p),
|
||||
"ui.screenshot" => {
|
||||
let token = app.next_capture_token();
|
||||
Reply::screenshot(token, s("path").map(str::to_string), app.active_viewport())
|
||||
}
|
||||
"ui.screenshot" => match craft::automation::screenshot::ScreenshotParams::from_params(p) {
|
||||
Ok(params) => {
|
||||
let token = app.next_capture_token();
|
||||
Reply::screenshot(token, params, app.active_viewport())
|
||||
}
|
||||
Err(e) => err(e),
|
||||
},
|
||||
"ui.render" => {
|
||||
let page = p.get("page").and_then(Value::as_u64).unwrap_or(1);
|
||||
let scale = p.get("scale").and_then(Value::as_f64).map_or(2.0, |v| v as f32);
|
||||
|
||||
@@ -307,7 +307,8 @@ fn control_keyboard_reaches_the_background_document_once() {
|
||||
assert_eq!(body_text(h.state()), "Seed", "one Undo reverses the one text input");
|
||||
}
|
||||
|
||||
/// Control text and keys target the focused widget of a dialog, not the document, and Escape closes it.
|
||||
/// Control text and keys target the focused widget of a dialog, not the document. The Find dialog is modeless, so the
|
||||
/// first Escape reverts the field's typing and the second closes the dialog.
|
||||
#[test]
|
||||
fn control_keyboard_keeps_the_background_widget_target() {
|
||||
let mut a = app();
|
||||
@@ -325,7 +326,10 @@ fn control_keyboard_keeps_the_background_widget_target() {
|
||||
assert_eq!(body_text(h.state()), "Seed", "the Find field, not the document, owns the input");
|
||||
send(&mut h, "ui.key", json!({"key": "Escape"}));
|
||||
frames(&mut h, 6);
|
||||
assert_eq!(open(&mut h), 0, "Escape closes the dialog");
|
||||
assert!(open(&mut h) > 0, "the first Escape reverts the field and leaves the dialog open");
|
||||
send(&mut h, "ui.key", json!({"key": "Escape"}));
|
||||
frames(&mut h, 6);
|
||||
assert_eq!(open(&mut h), 0, "the second Escape closes the dialog");
|
||||
assert_eq!(body_text(h.state()), "Seed");
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ pub(crate) fn show(app: &mut WordApp, ui: &mut Ui, layout: &DocLayout, body: &Pa
|
||||
);
|
||||
}
|
||||
}
|
||||
if out.apply || out.discard {
|
||||
if out.apply.is_some() || out.discard {
|
||||
leave(app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use craft::ui::contract::{
|
||||
use craft::ui::dialog::DialogId;
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::list::{ListRow, ThumbAspect};
|
||||
use craft::ui::list::{ListRow, ThumbAspect, ThumbSize};
|
||||
// PLAN: assumed `FormCx::accept` (dialogs-w5, S-L285)
|
||||
use craft::ui::patterns::form_dialogs::FormCx;
|
||||
use craft::ui::primitives::DataWidth;
|
||||
@@ -22,7 +22,7 @@ use craft::ui::runtime::env::Label;
|
||||
use craft::ui::style::DataColor;
|
||||
use craft::ui::table::Table;
|
||||
use craft::ui::text::TextField;
|
||||
use craft::ui::tile_grid::{Tile, TileGrid};
|
||||
use craft::ui::tile_grid::{GridZoom, Tile, TileGrid};
|
||||
use egui::{Color32, Ui, Vec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
@@ -272,6 +272,9 @@ fn chart_grid(ui: &mut Ui, colors: [Color32; 3], form: &mut ChartTypeForm) -> bo
|
||||
let current = kinds.iter().position(|k| *k == form.kind).unwrap_or(0);
|
||||
let source = keyed(&positions, |i| *i);
|
||||
let out = TileGrid::<usize>::new(tl!("Chart types").to_string())
|
||||
.thumb_size(ThumbSize::Large)
|
||||
.zoom(GridZoom::Fixed(1.6))
|
||||
.aspect(19.0 / 15.0)
|
||||
.select(SelectMode::Single)
|
||||
.card_columns(3)
|
||||
// Every type shows, as in production, so the dialog's body is the one scroll.
|
||||
|
||||
@@ -26,7 +26,7 @@ pub(crate) mod symbol;
|
||||
pub use columns::DropCapForm;
|
||||
pub use date_time::DateTimeForm;
|
||||
#[cfg(test)]
|
||||
pub(crate) use date_time::date_time_preview_matches;
|
||||
pub(crate) use date_time::date_time_previews_at;
|
||||
pub use field::{DATE_FORMATS, FIELD_CATEGORIES, FIELDS, FieldForm, FieldKind, NUMBER_FORMATS, STYLEREF_SWITCHES, field_kind};
|
||||
pub(crate) use symbol::SymbolDialog;
|
||||
pub use symbol::{RECENT_SYMBOLS, RecentSymbol, SPECIAL, SUBSETS, SymbolForm, remember_symbol, subset_of};
|
||||
|
||||
@@ -35,14 +35,16 @@ const PT_DATE_FORMATS: &[&str] = &[
|
||||
"HH:mm:ss",
|
||||
];
|
||||
|
||||
/// The date preview list consists of document values (not interface strings).
|
||||
/// The i18n audit recognizes these dynamic values instead of treating month names as UI labels.
|
||||
/// What the Date and Time preview list shows at the instant `unix`: document values, not
|
||||
/// interface strings. The i18n audit recognizes these instead of treating month names, dates and
|
||||
/// times as labels.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn date_time_preview_matches(value: &str) -> bool {
|
||||
PT_DATE_FORMATS.iter().chain(DATE_FORMATS.iter()).any(|picture| {
|
||||
wordcraft_engine::cmd::insert::format_date_in(picture, Some("pt-BR")) == value
|
||||
|| wordcraft_engine::cmd::insert::format_date_in(picture, Some("en-US")) == value
|
||||
})
|
||||
pub(crate) fn date_time_previews_at(unix: u64) -> impl Iterator<Item = String> {
|
||||
let offset = wordcraft_engine::cmd::local_offset_secs(unix);
|
||||
PT_DATE_FORMATS
|
||||
.iter()
|
||||
.chain(DATE_FORMATS.iter())
|
||||
.flat_map(move |picture| ["pt-BR", "en-US"].map(|lang| wordcraft_engine::cmd::insert::format_date_at_in(picture, Some(lang), unix, offset)))
|
||||
}
|
||||
|
||||
/// State of the Word-like Insert > Date & Time dialog.
|
||||
|
||||
@@ -29,7 +29,7 @@ use craft::ui::runtime::focus::{self, FocusTarget};
|
||||
// PLAN: assumed `RuleKind` re-exported from `craft::ui::style`
|
||||
use craft::ui::style::{DataColor, RuleKind};
|
||||
use craft::ui::text::TextField;
|
||||
use craft::ui::tile_grid::{Tile, TileGrid};
|
||||
use craft::ui::tile_grid::{GridZoom, Tile, TileGrid};
|
||||
use egui::{Color32, CornerRadius, Pos2, Rect, Ui, pos2, vec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
@@ -316,7 +316,7 @@ fn layout_tiles(ui: &mut Ui, theme: &[Rgb], form: &mut SmartArtForm) -> bool {
|
||||
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)
|
||||
.zoom(GridZoom::Fixed(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
|
||||
|
||||
@@ -1800,3 +1800,18 @@ fn smartart_layout_cells_keep_productions_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());
|
||||
}
|
||||
|
||||
/// #7456: the Insert Chart dialog renders compact chart type tiles in its 3-column gallery,
|
||||
/// instead of expanding each thumbnail to default card dimensions (~132×104 pt) and ballooning the grid.
|
||||
#[test]
|
||||
fn insert_chart_tiles_render_within_compact_bounds() {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let mut h = app_harness(app_with("Text"));
|
||||
open_named(&mut h, "insertChart", json!({}));
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
let cell = h.get_by_role_and_label(Role::ListItem, "Clustered Column").rect();
|
||||
assert!(cell.width() <= 90.0 && cell.height() <= 92.0, "chart tile should be compact (~85×87 pt), got {:?}", cell.size());
|
||||
let grid = h.get_by_role_and_label(Role::ListBox, "Chart types").rect();
|
||||
assert!(grid.width() <= 380.0, "3-column chart types grid should not exceed comfortable dialog proportions (~360 pt), got {:?}", grid.size());
|
||||
}
|
||||
|
||||
@@ -237,10 +237,15 @@ pub fn is_word_template(path: &str) -> bool {
|
||||
/// The name an open document goes by in the window: the engine's title, with an untitled
|
||||
/// document's `Document2` in the interface language.
|
||||
pub fn display_title(d: &DocInfo) -> String {
|
||||
if d.path.is_none() {
|
||||
return untitled_title(&d.title).unwrap_or_else(|| d.title.clone());
|
||||
// NUL cannot go into an X11 window title (C string); a title of only NUL reads as untitled (#3634).
|
||||
let title: String = d.title.chars().filter(|&c| c != '\0').collect();
|
||||
if title.is_empty() && !d.title.is_empty() {
|
||||
return tl!("Document1").into();
|
||||
}
|
||||
d.title.clone()
|
||||
if d.path.is_none() {
|
||||
return untitled_title(&title).unwrap_or(title);
|
||||
}
|
||||
title
|
||||
}
|
||||
|
||||
/// `Document2` (the engine's English name for an untitled document) in the interface language,
|
||||
|
||||
@@ -14,12 +14,14 @@ use craft::behavior::IconId;
|
||||
use craft::theme::Variant;
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::choice::Checkbox;
|
||||
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _, clicked};
|
||||
use craft::ui::contract::{Bind, Pad, Props as _, Show as _, ShowContainer as _, clicked};
|
||||
use craft::ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, StackDialog, dialog_id};
|
||||
use craft::ui::display::{Badge, Icon, Shade, Text};
|
||||
use craft::ui::layout_components::Row as Line;
|
||||
use craft::ui::display::{Badge, Elide, Icon, Shade, Text};
|
||||
use craft::ui::layout::RowAlign;
|
||||
use craft::ui::layout_components::{Row as Line, Stack};
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::sections::{DialogRole, FooterButton, GroupBox};
|
||||
use craft::ui::sections::{DialogRole, FooterButton};
|
||||
use craft::ui::style::{SurfaceKind, TypeRole};
|
||||
use egui::Ui;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -272,15 +274,22 @@ impl StackDialog for FontBox {
|
||||
.shade(Shade::Faint)
|
||||
.show(ui);
|
||||
for (at, g) in groups(fonts).into_iter().enumerate() {
|
||||
// The names are the document's own words, not interface text.
|
||||
GroupBox::new(g.fonts.join(", "), None).id_salt(("download", at)).show(ui, |ui, _| {
|
||||
let shown_as =
|
||||
crate::i18n::fmt(tl!("Shown as {fonts} · {publisher}"), &[("fonts", &g.shown_as.join(", ")), ("publisher", g.publisher)]);
|
||||
Text::new(shown_as).shade(Shade::Faint).show(ui);
|
||||
if g.restricted {
|
||||
Text::new(tl!("Its licence limits who may use it: read the terms first.")).shade(Shade::Faint).show(ui);
|
||||
}
|
||||
Line::new().show(ui, |ui, _| {
|
||||
// One row per download, as before the craft port: the names, what they are shown as and the licence
|
||||
// note stacked at the start edge, the button at the end. The names are the document's own words.
|
||||
Stack::new().surface(SurfaceKind::Frame).pad(Pad::Regular).fill_width().id_salt(("download_group", at)).show(ui, |ui, _| {
|
||||
Line::new().fill_width().align(RowAlign::SpaceBetween).id_salt(("download", at)).show(ui, |ui, _| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
// One line cut at the end, whole in a tooltip: one unbroken name must not push the button out.
|
||||
Text::new(g.fonts.join(", ")).role(TypeRole::BodyStrong).elide(Elide::End).show(ui);
|
||||
let shown_as = crate::i18n::fmt(
|
||||
tl!("Shown as {fonts} · {publisher}"),
|
||||
&[("fonts", &g.shown_as.join(", ")), ("publisher", g.publisher)],
|
||||
);
|
||||
Text::new(shown_as).shade(Shade::Faint).show(ui);
|
||||
if g.restricted {
|
||||
Text::new(tl!("Its licence limits who may use it: read the terms first.")).shade(Shade::Faint).show(ui);
|
||||
}
|
||||
});
|
||||
if clicked(&Button::new(tl!("Download")).variant(Variant::PRIMARY).id_salt(("download_button", at)).show(ui)) {
|
||||
asks.push(Ask::Download(g.url.to_string()));
|
||||
}
|
||||
|
||||
@@ -233,3 +233,60 @@ fn only_so_many_documents_are_remembered() {
|
||||
assert_eq!(a.font_notice_seen.len(), REMEMBERED);
|
||||
assert_eq!(a.font_notice_seen.last(), Some(&(REMEMBERED as u64 + 49)));
|
||||
}
|
||||
|
||||
/// Each missing font's names, substitute and Download button sit in one compact row, not one under another, and a
|
||||
/// narrow window keeps them inside the box.
|
||||
#[test]
|
||||
fn each_download_is_one_row() {
|
||||
let row = |font: &str, shown: &str, url: &str| Row {
|
||||
font: font.into(),
|
||||
shown_as: vec![shown.into()],
|
||||
download: font.into(),
|
||||
publisher: "Microsoft".into(),
|
||||
url: url.into(),
|
||||
restricted: false,
|
||||
};
|
||||
for width in [1440.0, 520.0] {
|
||||
let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
let fonts = vec![row("Aptos", "Carlito", "https://a"), row("Cascadia Code", "Liberation Mono", "https://c")];
|
||||
open_with(&mut a, None, FontBox::new(fonts, false), DialogHooks { prepare: None, settle });
|
||||
let h = harness_sized(a, egui::vec2(width, 900.0));
|
||||
let buttons: Vec<_> = h.query_all_by_role_and_label(egui::accesskit::Role::Button, "Download").collect();
|
||||
assert_eq!(buttons.len(), 2);
|
||||
for (button, shown) in buttons.iter().zip(["Shown as Carlito · Microsoft", "Shown as Liberation Mono · Microsoft"]) {
|
||||
let shown = h.get_by_label(shown).rect();
|
||||
let button = button.rect();
|
||||
// The button is beside the text block, level with it, not under it.
|
||||
assert!(button.min.x >= shown.max.x, "{width}: {button:?} {shown:?}");
|
||||
assert!(button.center().y < shown.max.y, "{width}: button under the text: {button:?} {shown:?}");
|
||||
assert!(button.max.x <= width, "{width}: clipped {button:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One very long unbroken family name is cut inside its card and leaves the Download button inside the card too.
|
||||
#[test]
|
||||
fn a_long_unbroken_name_stays_inside_its_card() {
|
||||
let long = format!("Aptos {}", "W".repeat(200));
|
||||
let row = Row {
|
||||
font: long.clone(),
|
||||
shown_as: vec!["Carlito".into()],
|
||||
download: "Aptos".into(),
|
||||
publisher: "Microsoft".into(),
|
||||
url: "https://a".into(),
|
||||
restricted: false,
|
||||
};
|
||||
let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
open_with(&mut a, None, FontBox::new(vec![row], false), DialogHooks { prepare: None, settle });
|
||||
let h = harness_sized(a, egui::vec2(700.0, 900.0));
|
||||
let button = h.query_all_by_role_and_label(egui::accesskit::Role::Button, "Download").next().expect("button").rect();
|
||||
let name = h.get_by_label(&long).rect();
|
||||
let shown = h.get_by_label("Shown as Carlito · Microsoft").rect();
|
||||
// The card has no node of its own; the dialog it fills is the tightest box to hold both to.
|
||||
let dialog = h.query_all(egui_kittest::kittest::By::new().role(egui::accesskit::Role::Dialog)).next().expect("the dialog").rect();
|
||||
assert!(name.max.x <= button.min.x, "name runs under the button: {name:?} {button:?}");
|
||||
assert!(dialog.contains_rect(name) && dialog.contains_rect(button), "outside the dialog: {name:?} {button:?} {dialog:?}");
|
||||
// The card's padding stands between the button and the dialog's edge.
|
||||
assert!(button.max.x < dialog.max.x, "button reaches the dialog's edge: {button:?} {dialog:?}");
|
||||
assert!(name.min.x >= shown.min.x - 1.0 && name.width() > 0.0, "{name:?} {shown:?}");
|
||||
}
|
||||
|
||||
@@ -28,7 +28,17 @@ fn unmarked(text: &str) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
/// When the audit began: the Date and Time preview drawn at any moment since is clock data, not
|
||||
/// interface text, whatever second the audit compares it in (#7463).
|
||||
static CLOCK_START: std::sync::OnceLock<u64> = std::sync::OnceLock::new();
|
||||
|
||||
/// Seconds of clock `clock_text` catches up in one check after the clock jumps forward.
|
||||
const CLOCK_CATCH_UP: u64 = 60;
|
||||
|
||||
thread_local! {
|
||||
// Every date/time the preview list could show since `CLOCK_START`, up to the second last
|
||||
// looked at: (next second to add, strings).
|
||||
static CLOCK_TEXTS: std::cell::RefCell<(u64, std::collections::HashSet<String>)> = std::cell::RefCell::new(Default::default());
|
||||
// Input time, advanced every frame so tooltips and animations move on.
|
||||
static TIME: Cell<f64> = const { Cell::new(0.0) };
|
||||
// Process-wide names (font families, the custom dictionary) seen at any point of the run:
|
||||
@@ -36,6 +46,25 @@ thread_local! {
|
||||
static GLOBAL_NAMES: std::cell::RefCell<std::collections::HashSet<String>> = std::cell::RefCell::new(Default::default());
|
||||
}
|
||||
|
||||
/// Whether `text` is something the Date and Time preview list showed at any second since the audit began.
|
||||
fn clock_text(text: &str) -> bool {
|
||||
let start = *CLOCK_START.get_or_init(wordcraft_engine::cmd::now_unix);
|
||||
let now = wordcraft_engine::cmd::now_unix();
|
||||
CLOCK_TEXTS.with_borrow_mut(|(next, set)| {
|
||||
if *next == 0 {
|
||||
*next = start;
|
||||
}
|
||||
// A clock stepped back still adds the current second; one stepped far forward catches up
|
||||
// a minute at most, the longest a preview waits to be checked.
|
||||
let from = (*next).min(now).max(now.saturating_sub(CLOCK_CATCH_UP));
|
||||
for unix in from..=now {
|
||||
set.extend(crate::dialogs_insert::date_time_previews_at(unix));
|
||||
}
|
||||
*next = now + 1;
|
||||
set.contains(text)
|
||||
})
|
||||
}
|
||||
|
||||
/// Remember the process-wide names drawn this frame could have come from.
|
||||
fn note_global_names() {
|
||||
GLOBAL_NAMES.with_borrow_mut(|seen| {
|
||||
@@ -124,11 +153,16 @@ fn pseudo_app(ctx: &egui::Context) -> WordApp {
|
||||
}
|
||||
|
||||
fn fresh_app(ctx: &egui::Context) -> WordApp {
|
||||
CLOCK_START.get_or_init(wordcraft_engine::cmd::now_unix);
|
||||
ctx.all_styles_mut(|s| s.interaction.tooltip_delay = 0.0);
|
||||
let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_engine::sample::sample_document()), Default::default());
|
||||
// Read Aloud holds each sentence instead of starting the system's speech engine: no sound on
|
||||
// machines that have one, and no worker thread failing at its own pace on machines that don't.
|
||||
app.session.read_aloud.backend = wordcraft_engine::speech::Backend::Hold;
|
||||
// Help › Check for Updates answers "up to date" instead of asking GitHub, whose rate limit
|
||||
// would otherwise put the updater's error text on screen.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
app.stub_update_check();
|
||||
// Fonts install over the first frames.
|
||||
for _ in 0..2 {
|
||||
frame(ctx, &mut app);
|
||||
@@ -136,6 +170,11 @@ fn fresh_app(ctx: &egui::Context) -> WordApp {
|
||||
app
|
||||
}
|
||||
|
||||
/// A link: one `http(s)://` word.
|
||||
fn is_url(text: &str) -> bool {
|
||||
(text.starts_with("https://") || text.starts_with("http://")) && !text.contains(char::is_whitespace)
|
||||
}
|
||||
|
||||
/// Words (two or more ASCII letters in a row) drawn outside translation marks.
|
||||
fn english_words(text: &str) -> bool {
|
||||
let plain = unmarked(text);
|
||||
@@ -284,7 +323,8 @@ impl<'a> Exempt<'a> {
|
||||
|| matches!(plain, "WordCraft" | "WordCraft User" | "Discord" | "https://" | "auto" | "I. II. III." | "i. ii. iii." | "I, II, III, …" | "i, ii, iii, …")
|
||||
|| plain == "CONFIDENTIAL" // the watermark dialog's text: document content, kept as typed
|
||||
|| plain == "Figure 1" // the caption dialog's sample: the label goes into the document as is
|
||||
|| crate::dialogs_insert::date_time_preview_matches(plain)
|
||||
|| clock_text(plain) // the Date and Time preview: formatted from the clock
|
||||
|| is_url(plain) // a link is data, not wording
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,6 +340,41 @@ fn math_placeholders_are_exact_math_input_only() {
|
||||
assert!(!set.contains("Translate"), "ordinary interface wording is not exempt");
|
||||
}
|
||||
|
||||
/// Runtime data is exempt (links, the clock's dates and times), wording is not (#7463), and
|
||||
/// Check for Updates never reaches the network.
|
||||
#[test]
|
||||
fn runtime_data_is_exempt_and_wording_is_not() {
|
||||
let ctx = crate::test_harness::context();
|
||||
let mut app = fresh_app(&ctx);
|
||||
let none = std::collections::HashSet::new();
|
||||
let exempt = Exempt::new(&app, &none);
|
||||
let now = wordcraft_engine::cmd::now_unix();
|
||||
let offset = wordcraft_engine::cmd::local_offset_secs(now);
|
||||
for picture in ["M/d/yyyy h:mm:ss am/pm", "h:mm:ss am/pm", "dddd, MMMM d, yyyy"] {
|
||||
let drawn = wordcraft_engine::cmd::insert::format_date_at_in(picture, None, now, offset);
|
||||
assert!(exempt.allows(&app, &drawn), "{drawn:?} is the clock");
|
||||
}
|
||||
assert!(exempt.allows(&app, "https://github.com/storytold/wordcraft/releases"));
|
||||
assert!(!exempt.allows(&app, "Download the newest release"), "an unwrapped sentence is reported");
|
||||
assert!(!exempt.allows(&app, "See https://example.com now"), "a sentence with a link is not a link");
|
||||
assert!(!exempt.allows(&app, "11/22/1999 5:28:50 PM"), "a time before the audit began is not the preview");
|
||||
// A stubbed check finds no update and puts no updater error on screen.
|
||||
app.run("help.checkForUpdates", json!({})).expect("Check for Updates runs");
|
||||
let calls = app.updates_rt.stub_calls.clone();
|
||||
// The check runs on a worker thread: draw at least 30 frames, then until it has run (a loaded
|
||||
// runner can be slow to start the thread, so the cap is wall-clock time, not a frame count).
|
||||
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10);
|
||||
for n in 0.. {
|
||||
let drawn = frame(&ctx, &mut app);
|
||||
assert!(drawn.iter().all(|t| !t.contains("request limit")), "{drawn:?}");
|
||||
if n >= 30 && (calls.load(std::sync::atomic::Ordering::SeqCst) > 0 || std::time::Instant::now() > deadline) {
|
||||
break;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(2));
|
||||
}
|
||||
assert_eq!(calls.load(std::sync::atomic::Ordering::SeqCst), 1, "the check went through the stub, not GitHub");
|
||||
}
|
||||
|
||||
/// Fails on interface text drawn without going through the catalog, listed per UI state, and
|
||||
/// prints the missing-translation report (`report_catalog_gaps`). `cargo xtask i18n-report` runs it
|
||||
/// with `--nocapture`; `cargo xtask test` and `ci` run it that way instead of in the main test run.
|
||||
|
||||
@@ -5,33 +5,35 @@
|
||||
use craft::behavior::{EditEvent, Preview};
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::pages::ui::PageBody;
|
||||
use craft::ui::buttons::{IconButton, ToggleButton};
|
||||
use craft::ui::buttons::{Button, ControlPlace, GroupLevel, ToggleButton};
|
||||
use craft::ui::canvas_controls::TaskBar;
|
||||
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 craft::ui::runtime::env::{Label, with_env};
|
||||
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.
|
||||
/// Distance from the selection's start (its left edge, or right in a right-to-left paragraph) 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;
|
||||
|
||||
/// The part of the selection the bar anchors to: the topmost selection rectangle that is actually
|
||||
/// visible inside `clip` (the scroll viewport), cut down to its visible portion. `None` when no
|
||||
/// usable part of the selection is on screen. Rectangles that only touch the clip's edge, or are
|
||||
/// not finite, are ignored. Pure geometry, unit tested without a window.
|
||||
pub fn visible_anchor(selection_rects: impl IntoIterator<Item = Rect>, clip: Rect) -> Option<Rect> {
|
||||
/// The part of the selection the bar anchors to: the topmost visible line of the selection inside
|
||||
/// `clip` (the scroll viewport), cut down to its visible portion. `None` when no usable part of the
|
||||
/// selection is on screen. Rectangles that only touch the clip's edge, or are not finite, are ignored.
|
||||
/// For `rtl` the result spans every run on that line (see below); otherwise it is the first such
|
||||
/// rectangle. Pure geometry, unit tested without a window.
|
||||
pub fn visible_anchor(selection_rects: impl IntoIterator<Item = Rect>, clip: Rect, rtl: bool) -> Option<Rect> {
|
||||
if !clip.is_finite() || !clip.is_positive() {
|
||||
return None;
|
||||
}
|
||||
let mut first: Option<Rect> = None;
|
||||
let mut visible_rects = Vec::new();
|
||||
for sr in selection_rects {
|
||||
if !sr.is_finite() || !sr.intersects(clip) {
|
||||
continue;
|
||||
@@ -44,8 +46,26 @@ pub fn visible_anchor(selection_rects: impl IntoIterator<Item = Rect>, clip: Rec
|
||||
if first.is_none_or(|f| visible.min.y < f.min.y) {
|
||||
first = Some(visible);
|
||||
}
|
||||
visible_rects.push(visible);
|
||||
}
|
||||
first
|
||||
let top = first?;
|
||||
if !rtl {
|
||||
return Some(top);
|
||||
}
|
||||
// A bidirectional line is emitted as several visual runs, left to right: span the whole line, so
|
||||
// its right edge (the start of a right-to-left paragraph) is not that of the first run.
|
||||
Some(visible_rects.into_iter().filter(|r| (top.min.y..=top.max.y).contains(&r.center().y)).fold(top, |u, r| u.union(r)))
|
||||
}
|
||||
|
||||
/// The x the bar centres at over `anchor`: its start edge, less the inset, mirrored for right-to-left.
|
||||
fn start_x(anchor: Rect, rtl: bool) -> f32 {
|
||||
if rtl { anchor.max.x - ANCHOR_INSET } else { anchor.min.x + ANCHOR_INSET }
|
||||
}
|
||||
|
||||
/// Whether the paragraph where the selection starts is right-to-left.
|
||||
pub(crate) fn starts_rtl(app: &WordApp) -> bool {
|
||||
let start = app.session.sel.ordered().0;
|
||||
app.session.doc.para_at(&start).is_some_and(|p| app.session.doc.styles.resolve_para(&p.props).bidi)
|
||||
}
|
||||
|
||||
/// Whether the bar may be shown for the current app state.
|
||||
@@ -101,8 +121,9 @@ pub(crate) fn show(app: &mut WordApp, ui: &mut Ui, body: &PageBody<'_>) {
|
||||
return;
|
||||
}
|
||||
let Some(anchor) = app.canvas.mini_anchor else { return };
|
||||
// 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;
|
||||
// The bar centres over the selection's start rather than drifting to the centre of long selections (#7447);
|
||||
// a right-to-left paragraph at the start puts it at the right edge (#7464).
|
||||
let start_x = start_x(anchor, starts_rtl(app));
|
||||
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()
|
||||
@@ -155,82 +176,102 @@ 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);
|
||||
}
|
||||
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}));
|
||||
}
|
||||
with_env(
|
||||
ui,
|
||||
|overrides| {
|
||||
overrides.values.set(GroupLevel::Compact);
|
||||
overrides.values.set(ControlPlace::Ribbon);
|
||||
},
|
||||
|ui| {
|
||||
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);
|
||||
}
|
||||
});
|
||||
for (id, icon, tip) in
|
||||
[("format.growFont", "grow", tl!("Increase Font Size")), ("format.shrinkFont", "shrink", tl!("Decrease Font Size"))]
|
||||
{
|
||||
let b = Button::command(CommandRef::new(id)).icon(crate::icons::id(icon)).tooltip(tip.to_string()).show(ui);
|
||||
preview_on_hover(app, b.hover, b.response.enabled(), id, json!({}), 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);
|
||||
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()})))
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Keeps a bar list's preview: the framework reports `Shows` once, when the pointer reaches an
|
||||
|
||||
@@ -32,22 +32,22 @@ fn anchor_skips_rects_scrolled_offscreen_and_clips_partial_ones() {
|
||||
// Page 1's line is above the viewport, page 2's line is inside it.
|
||||
let above = Rect::from_min_size(pos2(100.0, clip.top() - 300.0), Vec2::new(200.0, 20.0));
|
||||
let inside = Rect::from_min_size(pos2(120.0, clip.top() + 50.0), Vec2::new(200.0, 20.0));
|
||||
assert_eq!(visible_anchor([above, inside], clip), Some(inside));
|
||||
assert_eq!(visible_anchor([above, inside], clip, false), Some(inside));
|
||||
// Partly scrolled off the top: anchored to the visible part, never above the viewport.
|
||||
let partial = Rect::from_min_size(pos2(100.0, clip.top() - 10.0), Vec2::new(200.0, 20.0));
|
||||
let a = visible_anchor([partial], clip).unwrap();
|
||||
let a = visible_anchor([partial], clip, false).unwrap();
|
||||
assert!((a.min.y - clip.top()).abs() < 1e-3 && (a.height() - 10.0).abs() < 1e-3);
|
||||
// Entirely off either end, or only touching the edge: nothing to anchor to.
|
||||
let below = Rect::from_min_size(pos2(100.0, clip.bottom() + 5.0), Vec2::new(200.0, 20.0));
|
||||
let touching = Rect::from_min_size(pos2(100.0, clip.top() - 20.0), Vec2::new(200.0, 20.0));
|
||||
assert_eq!(visible_anchor([above, below, touching], clip), None);
|
||||
assert_eq!(visible_anchor([], clip), None);
|
||||
assert_eq!(visible_anchor([above, below, touching], clip, false), None);
|
||||
assert_eq!(visible_anchor([], clip, false), None);
|
||||
// Input order does not matter: the topmost visible rectangle wins.
|
||||
let lower = Rect::from_min_size(pos2(100.0, clip.top() + 200.0), Vec2::new(200.0, 20.0));
|
||||
assert_eq!(visible_anchor([lower, inside], clip), Some(inside));
|
||||
assert_eq!(visible_anchor([lower, inside], clip, false), Some(inside));
|
||||
// Degenerate input is rejected, not propagated.
|
||||
let nan = Rect::from_min_size(pos2(f32::NAN, 0.0), Vec2::new(10.0, 10.0));
|
||||
assert_eq!(visible_anchor([nan], clip), None);
|
||||
assert_eq!(visible_anchor([nan], clip, false), None);
|
||||
}
|
||||
|
||||
/// The whole window over a document with `pick` selected, run until the bar is up.
|
||||
@@ -55,6 +55,11 @@ fn bar_over(pick: &str) -> H {
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
a.run("text.insert", json!({"text": "The quick brown fox jumps over the lazy dog"})).unwrap();
|
||||
a.run("select.text", json!({"text": pick})).unwrap();
|
||||
bar_over_app(a)
|
||||
}
|
||||
|
||||
/// `bar_over` for an app whose document and selection are already set up.
|
||||
fn bar_over_app(a: WordApp) -> H {
|
||||
let mut h = crate::test_harness::builder().with_size(Vec2::new(1440.0, 900.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
@@ -191,7 +196,20 @@ fn every_control_fits_inside_the_bar() {
|
||||
let h = bar_over("brown fox");
|
||||
let c = canvas(&h);
|
||||
let mut rects: Vec<(String, Rect)> = Vec::new();
|
||||
for label in ["Bold", "Italic", "Underline", "Align Left", "Center", "Align Right", "Justify", "Text Highlight Color", "Font Color"] {
|
||||
for label in [
|
||||
"Bold",
|
||||
"Italic",
|
||||
"Underline",
|
||||
"Strikethrough",
|
||||
"Align Left",
|
||||
"Center",
|
||||
"Align Right",
|
||||
"Justify",
|
||||
"Text Highlight Color",
|
||||
"Font Color",
|
||||
"Increase Font Size",
|
||||
"Decrease Font Size",
|
||||
] {
|
||||
let r = member(&h, label).unwrap_or_else(|| panic!("the bar has {label}"));
|
||||
rects.push((label.to_string(), r));
|
||||
}
|
||||
@@ -204,6 +222,7 @@ fn every_control_fits_inside_the_bar() {
|
||||
.map(|n| n.rect())
|
||||
.find(|r| c.contains_rect(*r))
|
||||
.expect("the selection bar lies inside the document area");
|
||||
assert!(bar.width() < 350.0, "bar width {} must not be bloated by text labels", bar.width());
|
||||
for (name, r) in &rects {
|
||||
assert!(bar.contains_rect(*r), "{name} {r:?} must stay inside the bar {bar:?}");
|
||||
}
|
||||
@@ -214,6 +233,14 @@ fn every_control_fits_inside_the_bar() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7482: Text Highlight Color appearance follows the picked highlight choice.
|
||||
#[test]
|
||||
fn highlight_button_appearance_follows_the_picked_colour() {
|
||||
assert_eq!(crate::colors::highlight_button_appearance("cyan"), ("highlight", Some(egui::Color32::from_rgb(0, 255, 255)), "cyan"));
|
||||
assert_eq!(crate::colors::highlight_button_appearance("none"), ("highlightNoColor", None, "none"));
|
||||
assert_eq!(crate::colors::highlight_button_appearance("unknown"), ("highlightNoColor", None, "none"));
|
||||
}
|
||||
|
||||
/// #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]
|
||||
@@ -260,9 +287,15 @@ fn formatting_controls_stack_into_two_rows() {
|
||||
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");
|
||||
let grow = member(&h, "Increase Font Size").expect("the bar has Increase Font Size");
|
||||
let shrink = member(&h, "Decrease Font Size").expect("the bar has Decrease Font Size");
|
||||
|
||||
// Row 1 controls sit on the top row together.
|
||||
// Row 1 controls sit on the top row together and align in height.
|
||||
assert!((font.min.y - size.min.y).abs() < 1.0, "Font and Font Size must share Row 1: font {font:?}, size {size:?}");
|
||||
assert!((grow.min.y - size.min.y).abs() < 1.0, "Grow Font and Font Size must share Row 1: grow {grow:?}, size {size:?}");
|
||||
assert!((shrink.min.y - size.min.y).abs() < 1.0, "Shrink Font and Font Size must share Row 1: shrink {shrink:?}, size {size:?}");
|
||||
assert!((grow.height() - size.height()).abs() < 2.0, "grow height ({}) aligns with row 1 height ({})", grow.height(), size.height());
|
||||
assert!((shrink.height() - size.height()).abs() < 2.0, "shrink height ({}) aligns with row 1 height ({})", shrink.height(), size.height());
|
||||
|
||||
// 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:?}");
|
||||
@@ -274,6 +307,20 @@ fn formatting_controls_stack_into_two_rows() {
|
||||
assert!(align_left.min.y >= size.max.y, "Align Left ({align_left:?}) must sit strictly below Font Size ({size:?})");
|
||||
}
|
||||
|
||||
/// #7482: Hovering the split buttons for highlight and font colour previews their command.
|
||||
#[test]
|
||||
fn hovering_the_colour_buttons_previews_their_colour() {
|
||||
let mut h = bar_over("brown fox");
|
||||
let viewport = canvas(&h);
|
||||
for (label, id) in [("Text Highlight Color", "format.highlight"), ("Font Color", "format.color")] {
|
||||
let r = member(&h, label).expect("the bar has the button");
|
||||
assert!(viewport.contains_rect(r), "{label} is inside viewport");
|
||||
hover_at(&mut h, r.center());
|
||||
let previewed = h.state().canvas.command_previewed.clone();
|
||||
assert!(previewed.is_some_and(|(p, _)| p == id), "{label} previews {id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// 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() {
|
||||
@@ -468,6 +515,45 @@ fn context_menu_toolbar_respects_read_mode_and_the_toolbar_preference() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7482: The companion toolbar fits within window bounds even in a narrow window (~380 pt).
|
||||
#[test]
|
||||
fn context_menu_toolbar_fits_near_the_bottom_right_of_a_narrow_window() {
|
||||
let mut h = bar_over("brown fox");
|
||||
h.set_size(Vec2::new(380.0, 650.0));
|
||||
steps(&mut h);
|
||||
h.state_mut().run("ui.contextMenu", json!({})).unwrap();
|
||||
steps(&mut h);
|
||||
h.state_mut().canvas.context_menu_at = Some(pos2(370.0, 640.0));
|
||||
steps(&mut h);
|
||||
let screen = h.ctx.content_rect();
|
||||
let bold = h.query_all_by_label("Bold").map(|n| n.rect()).find(|r| r.min.y > 200.0).expect("the context toolbar is shown");
|
||||
assert!(screen.contains_rect(bold), "the toolbar stays inside the window: {bold:?} in {screen:?}");
|
||||
let copy = h.query_all_by_label_contains("Copy").map(|n| n.rect()).find(|r| r.min.y > 200.0).expect("the menu has Copy");
|
||||
assert!(screen.contains_rect(copy), "the menu stays inside the window: {copy:?} in {screen:?}");
|
||||
let align = h.query_all_by_label("Justify").map(|n| n.rect()).find(|r| r.min.y > 200.0).expect("the last toolbar control is shown");
|
||||
assert!(screen.contains_rect(align), "all controls fit: {align:?} in {screen:?}");
|
||||
}
|
||||
|
||||
/// #7482: The command panel under the context toolbar keeps its own width, not stretched by the toolbar.
|
||||
#[test]
|
||||
fn context_menu_panel_keeps_its_own_width_under_the_toolbar() {
|
||||
let copy_width = |toolbar: bool| {
|
||||
let mut h = bar_over("brown fox");
|
||||
h.state_mut().ui.mini_toolbar = toolbar;
|
||||
h.state_mut().run("ui.contextMenu", json!({})).unwrap();
|
||||
steps(&mut h);
|
||||
let top = canvas(&h).top();
|
||||
let copy = h.query_all_by_label_contains("Copy").map(|n| n.rect()).find(|r| r.min.y > top).expect("the menu has Copy");
|
||||
let bar = h.query_all_by_label("Justify").map(|n| n.rect()).find(|r| r.min.y > top);
|
||||
(copy, bar)
|
||||
};
|
||||
let (plain, _) = copy_width(false);
|
||||
let (copy, justify) = copy_width(true);
|
||||
let justify = justify.expect("the context toolbar is shown");
|
||||
assert!((copy.width() - plain.width()).abs() < 0.5, "panel {} vs plain menu {}", copy.width(), plain.width());
|
||||
assert!(copy.max.x + 20.0 < justify.max.x, "the panel ({copy:?}) is narrower than the toolbar ({justify:?})");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_in_a_ribbon_list_does_not_open_the_context_menu() {
|
||||
let mut h = bar_over("brown fox");
|
||||
@@ -682,3 +768,67 @@ fn a_clicked_member_holds_its_preview_until_the_pointer_leaves() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The bar's centre, and the selection's first visible line (the anchor) it hangs from.
|
||||
fn bar_centre_and_anchor(h: &H) -> (f32, Rect) {
|
||||
let c = canvas(h);
|
||||
let bar = 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");
|
||||
(bar.center().x, h.state().canvas.mini_anchor.expect("the selection has an anchor"))
|
||||
}
|
||||
|
||||
/// A paragraph long enough to wrap onto several lines, with a selection from `from_char` to its end.
|
||||
fn wrapped_selection(text: &str, rtl: bool, from_char: usize) -> H {
|
||||
let text = text.repeat(40);
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text(&text)), Default::default());
|
||||
if rtl {
|
||||
a.run("select.all", json!({})).unwrap();
|
||||
a.run("para.rtl", json!({})).unwrap();
|
||||
}
|
||||
let off = text.char_indices().nth(from_char).map_or(0, |(i, _)| i);
|
||||
let end = text.len();
|
||||
a.session.sel = wordcraft_engine::Selection { anchor: wordcraft_doc::Pos::body(0, off), focus: wordcraft_doc::Pos::body(0, end) };
|
||||
bar_over_app(a)
|
||||
}
|
||||
|
||||
/// #7464: in a right-to-left paragraph the selection starts at the right, so the bar sits there,
|
||||
/// not at the left margin where the selection's first line ends.
|
||||
#[test]
|
||||
fn the_bar_anchors_at_the_right_in_a_right_to_left_paragraph() {
|
||||
let h = wrapped_selection("سلام دنیا ", true, 12);
|
||||
let (x, anchor) = bar_centre_and_anchor(&h);
|
||||
assert!(anchor.width() > 100.0, "the first selected line is a wide rect: {anchor:?}");
|
||||
assert!((x - anchor.max.x).abs() < (x - anchor.min.x).abs(), "the bar x={x} is nearer the start (right) edge of {anchor:?}");
|
||||
}
|
||||
|
||||
/// #7464: a left-to-right selection from mid-line 1 to a later line keeps the bar at its start.
|
||||
#[test]
|
||||
fn the_bar_anchors_at_the_start_of_a_multi_line_left_to_right_selection() {
|
||||
let h = wrapped_selection("The quick brown fox ", false, 12);
|
||||
let (x, anchor) = bar_centre_and_anchor(&h);
|
||||
assert!(anchor.width() > 100.0, "the first selected line is a wide rect: {anchor:?}");
|
||||
assert!((x - anchor.min.x).abs() < (x - anchor.max.x).abs(), "the bar x={x} is nearer the start (left) edge of {anchor:?}");
|
||||
}
|
||||
|
||||
/// #7464: a right-to-left line mixing Arabic with Latin words or digits is several visual runs
|
||||
/// (emitted left to right): the bar hangs from the whole line's right edge, not the first run's.
|
||||
#[test]
|
||||
fn the_anchor_spans_every_run_on_the_topmost_line() {
|
||||
let clip = vp();
|
||||
let run = |x: f32, y: f32| Rect::from_min_size(pos2(x, y), Vec2::new(50.0, 20.0));
|
||||
let line1 = [run(200.0, 100.0), run(300.0, 100.0), run(250.0, 100.0)];
|
||||
let later = run(900.0, 130.0);
|
||||
let rects = [line1[0], line1[1], line1[2], later];
|
||||
let a = visible_anchor(rects, clip, true).unwrap();
|
||||
assert!(line1.iter().all(|r| a.max.x >= r.max.x && a.min.x <= r.min.x), "spans every run of line 1: {a:?}");
|
||||
assert!(a.max.x < later.min.x && a.max.y <= later.min.y, "the later line is excluded: {a:?}");
|
||||
let x = start_x(a, true);
|
||||
assert!((x - a.max.x).abs() < (x - a.min.x).abs(), "RTL bar x={x} is nearer the line's right edge {}, not the left {}", a.max.x, a.min.x);
|
||||
// Left to right keeps the first rectangle (vertical text stacks whole lines at one y-range).
|
||||
let l = visible_anchor(rects, clip, false).unwrap();
|
||||
assert!(l.min.x == line1[0].min.x && l.max.x < a.max.x, "LTR anchor is the top run only: {l:?}");
|
||||
}
|
||||
|
||||
@@ -705,40 +705,38 @@ impl PreferencesModel for OptionsModel<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn custom_row(&mut self, ui: &mut Ui, key: &str) {
|
||||
fn custom_row(&mut self, ui: &mut Ui, key: &str) -> bool {
|
||||
match key {
|
||||
"general.defaultApp" => default_app_row(self.app, ui),
|
||||
"proofing.autoCorrect" => {
|
||||
if Button::new(tl!("AutoCorrect Options")).show(ui).clicked() {
|
||||
self.run("tools.autocorrect", json!({}));
|
||||
}
|
||||
}
|
||||
"proofing.autoCorrect" => self.command_button(ui, tl!("AutoCorrect Options"), "tools.autocorrect"),
|
||||
"proofing.customDictionaryFile" => self.custom_dictionary_file(ui),
|
||||
"proofing.customDictionary" => self.custom_dictionary(ui),
|
||||
"language.proofingLanguage" => {
|
||||
Text::new(self.strings.proofing_language.clone()).role(TypeRole::Caption).shade(Shade::Faint).show(ui);
|
||||
false
|
||||
}
|
||||
// PLAN: assumed `your_languages(app: &mut WordApp, ui: &mut Ui)` (chrome-w12)
|
||||
"language.yourLanguages" => crate::language_packs::your_languages(self.app, ui),
|
||||
"language.dictionaryFiles" => dictionary_files(ui),
|
||||
"advanced.customizeKeyboard" => {
|
||||
if Button::new(tl!("Customize…")).show(ui).clicked() {
|
||||
self.run("tools.customizeKeyboard", json!({}));
|
||||
}
|
||||
"language.yourLanguages" => {
|
||||
crate::language_packs::your_languages(self.app, ui);
|
||||
false
|
||||
}
|
||||
"advanced.customizeRibbon" if Button::new(tl!("Customize…")).show(ui).clicked() => {
|
||||
self.run("tools.customizeRibbon", json!({}));
|
||||
"language.dictionaryFiles" => {
|
||||
dictionary_files(ui);
|
||||
false
|
||||
}
|
||||
_ => {}
|
||||
"advanced.customizeKeyboard" => self.command_button(ui, tl!("Customize…"), "tools.customizeKeyboard"),
|
||||
"advanced.customizeRibbon" => self.command_button(ui, tl!("Customize…"), "tools.customizeRibbon"),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn custom_page(&mut self, ui: &mut Ui, page: &str) {
|
||||
fn custom_page(&mut self, ui: &mut Ui, page: &str) -> bool {
|
||||
if page == "agents" {
|
||||
Text::new(tl!("Agents")).role(TypeRole::Heading).show(ui);
|
||||
Text::new(tl!("Every command is available to scripts and AI agents: run `wordcraft-cli mcp` for an MCP server, or start the app with `--control <port>` for the JSON control channel."))
|
||||
.show(ui);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn reset_page(&mut self, page: &str) {
|
||||
@@ -762,21 +760,32 @@ impl OptionsModel<'_> {
|
||||
/// Enter or focus loss. The field is given the saved path and never writes it: the framework
|
||||
/// holds the draft while an edit is open and drops it when the saved path changes (an agent's
|
||||
/// `file.options`) or the page is left, so no edit open always shows the saved path.
|
||||
fn custom_dictionary_file(&mut self, ui: &mut Ui) {
|
||||
/// A button that runs `command` when clicked; whether it did.
|
||||
fn command_button(&mut self, ui: &mut Ui, label: impl Into<craft::ui::runtime::env::Label>, command: &str) -> bool {
|
||||
let clicked = Button::new(label).show(ui).clicked();
|
||||
if clicked {
|
||||
self.run(command, json!({}));
|
||||
}
|
||||
clicked
|
||||
}
|
||||
|
||||
fn custom_dictionary_file(&mut self, ui: &mut Ui) -> bool {
|
||||
let saved = self.app.session.prefs.custom_dictionary.clone().unwrap_or_default();
|
||||
let out = TextField::new(tl!("Dictionary file:"), Bind::given(saved)).limit(None).show(ui);
|
||||
let committed = out.events.into_iter().find_map(|event| match event {
|
||||
EditEvent::Commit { after, .. } => Some(after),
|
||||
_ => None,
|
||||
});
|
||||
let changed = committed.is_some();
|
||||
if let Some(path) = committed {
|
||||
self.set("proofing.customDictionaryFile", PrefValue::Text(path));
|
||||
}
|
||||
changed
|
||||
}
|
||||
|
||||
/// The custom dictionary: the words Add to Dictionary kept, each with a Remove button, and a
|
||||
/// field to add one.
|
||||
fn custom_dictionary(&mut self, ui: &mut Ui) {
|
||||
fn custom_dictionary(&mut self, ui: &mut Ui) -> bool {
|
||||
let words = wordcraft_engine::proof::user_dictionary();
|
||||
if words.is_empty() {
|
||||
Text::new(tl!("No words yet. Add to Dictionary on a misspelled word puts it here.")).role(TypeRole::Caption).shade(Shade::Faint).show(ui);
|
||||
@@ -793,8 +802,10 @@ impl OptionsModel<'_> {
|
||||
}
|
||||
})
|
||||
});
|
||||
let mut changed = false;
|
||||
if let Some(w) = removed.take() {
|
||||
self.options(json!({"removeWords": [w]}));
|
||||
changed = true;
|
||||
}
|
||||
// Enter or Add files the draft and clears it.
|
||||
Row::new().show(ui, |ui, cx| {
|
||||
@@ -806,8 +817,10 @@ impl OptionsModel<'_> {
|
||||
if ok && (add || out.submitted) {
|
||||
self.options(json!({"addWords": [word]}));
|
||||
draft.clear();
|
||||
changed = true;
|
||||
}
|
||||
});
|
||||
changed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,7 +874,7 @@ fn language_name(lang: wordcraft_engine::proof::ProofLang) -> &'static str {
|
||||
/// the host can (`Services::make_default_app`: Windows opens Default apps, Linux and BSD use
|
||||
/// `xdg-mime`); macOS shows how to do it in Finder, the web shows nothing.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn default_app_row(app: &mut WordApp, ui: &mut Ui) {
|
||||
fn default_app_row(app: &mut WordApp, ui: &mut Ui) -> bool {
|
||||
if app.services.make_default_app.is_some() {
|
||||
let hint = if cfg!(target_os = "windows") {
|
||||
tl!("Opens Settings › Default apps, where you choose WordCraft for .docx and the other document types.")
|
||||
@@ -872,6 +885,7 @@ fn default_app_row(app: &mut WordApp, ui: &mut Ui) {
|
||||
// Only a person's click changes system defaults: an automation client's pass does not.
|
||||
if clicked && !WindowHost::of(ui.ctx()).injected_pass() {
|
||||
let _ = app.make_default_app();
|
||||
return true;
|
||||
}
|
||||
} else if cfg!(target_os = "macos") {
|
||||
Text::new(tl!("To open Word documents with WordCraft by default: select one in Finder, choose File › Get Info, pick WordCraft under Open with, then click Change All."))
|
||||
@@ -879,11 +893,14 @@ fn default_app_row(app: &mut WordApp, ui: &mut Ui) {
|
||||
.shade(Shade::Faint)
|
||||
.show(ui);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// The web has no system default apps to change: nothing to show.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn default_app_row(_app: &mut WordApp, _ui: &mut Ui) {}
|
||||
fn default_app_row(_app: &mut WordApp, _ui: &mut Ui) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// The Options page.
|
||||
pub fn page(app: &mut WordApp, ui: &mut Ui) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use craft::behavior::{EditEvent, IconId};
|
||||
use craft::behavior::{EditEvent, IconId, Selection};
|
||||
use craft::review::ThreadId;
|
||||
use craft::review::ui::CommentsPanelState;
|
||||
use craft::ui::buttons::Button;
|
||||
@@ -192,7 +192,7 @@ fn reply_id(document: u64, id: u32) -> egui::Id {
|
||||
/// keeps the field open with its text.
|
||||
fn reply_field(app: &mut WordApp, ui: &mut Ui, document: u64, id: u32) -> bool {
|
||||
let thread = thread_of(app, id);
|
||||
let selected = app.canvas.comments.selected.as_ref().is_some_and(|t| t.0 == thread.0);
|
||||
let selected = app.canvas.comments.selected.lead.as_ref().is_some_and(|t| t.0 == thread.0);
|
||||
let shown = if selected { app.canvas.comments.reply.clone() } else { String::new() };
|
||||
let editable = crate::app::command_board::command_enabled(app, "review.reply");
|
||||
let field = reply_id(document, id);
|
||||
@@ -208,12 +208,12 @@ fn reply_field(app: &mut WordApp, ui: &mut Ui, document: u64, id: u32) -> bool {
|
||||
match event {
|
||||
EditEvent::Update { value, .. } => {
|
||||
let d = drafts(app);
|
||||
d.selected = Some(thread);
|
||||
d.selected = Selection::single(thread);
|
||||
d.reply = value.clone();
|
||||
}
|
||||
EditEvent::Commit { after, .. } | EditEvent::Set { after, .. } => {
|
||||
let d = drafts(app);
|
||||
d.selected = Some(thread);
|
||||
d.selected = Selection::single(thread);
|
||||
d.reply = after.clone();
|
||||
done = commit_reply(app, id).is_ok();
|
||||
}
|
||||
@@ -235,7 +235,7 @@ fn reply_field(app: &mut WordApp, ui: &mut Ui, document: u64, id: u32) -> bool {
|
||||
pub(crate) fn commit_reply(app: &mut WordApp, id: u32) -> Result<(), String> {
|
||||
let thread = thread_of(app, id);
|
||||
let d = drafts(app);
|
||||
if !d.selected.as_ref().is_some_and(|t| t.0 == thread.0) {
|
||||
if !d.selected.lead.as_ref().is_some_and(|t| t.0 == thread.0) {
|
||||
return Ok(());
|
||||
}
|
||||
let text = d.reply.clone();
|
||||
@@ -266,7 +266,7 @@ pub(crate) fn flush_comment_drafts(app: &mut WordApp) -> Result<(), String> {
|
||||
first = r;
|
||||
}
|
||||
}
|
||||
let selected = drafts(app).selected.as_ref().and_then(|t| u32::try_from(t.0).ok());
|
||||
let selected = drafts(app).selected.lead.as_ref().and_then(|t| u32::try_from(t.0).ok());
|
||||
if let Some(id) = selected {
|
||||
let r = commit_reply(app, id);
|
||||
if first.is_ok() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Localized print-page wording around the shared, backend-independent controls.
|
||||
pub use craft::print::ui::{Discover, Duplex, Feedback, Printer, Settings, State};
|
||||
pub use craft::print::ui::{Destination, Discover, Duplex, Feedback, Printer, Settings, State};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::print_page::{NO_SCALING, ORIENTATIONS, PAGES_PER_SHEET, PARITIES, PrintPage, RANGES};
|
||||
@@ -43,7 +43,7 @@ pub fn settings(state: &mut State, params: &Value, discover: Option<&Discover>)
|
||||
if !state.printers.iter().any(|available| available.name == printer) {
|
||||
return Err("printer must be a name from the discovered list".into());
|
||||
}
|
||||
next.printer = printer.to_owned();
|
||||
next.destination = Destination::Printer(printer.to_owned());
|
||||
}
|
||||
if let Some(value) = object.get("copies") {
|
||||
let copies = value.as_u64().filter(|copies| (1..=999).contains(copies)).ok_or("copies must be an integer from 1 to 999")?;
|
||||
@@ -82,7 +82,7 @@ pub fn settings(state: &mut State, params: &Value, discover: Option<&Discover>)
|
||||
Some(_) => ("idle", ""),
|
||||
};
|
||||
Ok(json!({
|
||||
"printer": state.settings.printer, "copies": state.settings.copies,
|
||||
"printer": printer_name(&state.settings), "copies": state.settings.copies,
|
||||
"duplex": match state.settings.duplex { None => "printerDefault", Some(Duplex::LongEdge) => "longEdge", Some(Duplex::ShortEdge) => "shortEdge", Some(_) => "off" },
|
||||
"grayscale": state.settings.grayscale,
|
||||
"printers": state.printers.iter().map(|printer| json!({"name": printer.name, "default": printer.default})).collect::<Vec<Value>>(),
|
||||
@@ -228,11 +228,19 @@ pub fn pwg_media(paper: &str) -> Option<&'static str> {
|
||||
})
|
||||
}
|
||||
|
||||
/// The chosen printer's name; empty when none is chosen or the destination is not a printer.
|
||||
pub(crate) fn printer_name(settings: &Settings) -> &str {
|
||||
match &settings.destination {
|
||||
Destination::Printer(name) => name,
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
|
||||
/// The spooler's job for `settings`: the app's choices, shrink-to-fit paper and the options list.
|
||||
// PLAN: assumed `craft::print` is reachable from ui-egui (the Job is built here, as apps/wordcraft/src/print.rs did).
|
||||
fn job_of(settings: &Settings, collate: bool, options: Vec<(String, String)>) -> craft::print::Job {
|
||||
craft::print::Job {
|
||||
printer: (!settings.printer.is_empty()).then(|| settings.printer.clone()),
|
||||
printer: Some(printer_name(settings)).filter(|name| !name.is_empty()).map(str::to_owned),
|
||||
copies: settings.copies.clamp(1, 999),
|
||||
collate,
|
||||
duplex: settings.duplex.map(|value| match value {
|
||||
@@ -254,6 +262,11 @@ pub fn submit(app: &mut crate::WordApp, params: &Value) -> Result<Value, String>
|
||||
let Some(spool) = app.services.print.clone() else {
|
||||
return Err("printing to the system print dialog isn't available here; export a PDF instead".into());
|
||||
};
|
||||
// Save as PDF is WordCraft's own route, not the spooler's.
|
||||
if app.printing.settings.destination == Destination::File {
|
||||
app.print_pdf_dialog();
|
||||
return Ok(json!({"saveAsPdf": true}));
|
||||
}
|
||||
let chooses = spool.chooses_printer();
|
||||
if chooses && !app.printing.ready() {
|
||||
return Err("Select an available printer in File > Print before submitting.".into());
|
||||
|
||||
@@ -15,7 +15,7 @@ use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::primitives::textures::Revision;
|
||||
use craft::ui::runtime::commands::resolve;
|
||||
use craft::ui::runtime::env::Env;
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
use craft::ui::tile_grid::{CaptionPlace, GridZoom, Tile, TileGrid};
|
||||
use egui::{Color32, ColorImage, Pos2, Ui};
|
||||
use serde_json::json;
|
||||
use wordcraft_doc::props::CharProps;
|
||||
@@ -230,7 +230,10 @@ pub(crate) fn table_styles(ui: &mut Ui, app: &mut WordApp) {
|
||||
let doc = &app.session.doc;
|
||||
let makers: Vec<Maker<'_>> = entries.iter().map(|(id, _)| Box::new(move || table_style_image(doc, id, ppp, dark)) as Maker<'_>).collect();
|
||||
let items = image_items("table", &entries, &makers, ppp, revision);
|
||||
Gallery::new(tl!("Table Styles"), &items, None).tiles(7, 4).show(ui)
|
||||
// Each tile shows a 5×4 table sample at the large thumbnail size in the 3:2 landscape
|
||||
// ratio `table_style_image` renders (112×74 pt including margins), matching the sibling
|
||||
// `Styles` and `Style Sets` galleries and v0.18.1's ribbon previews.
|
||||
Gallery::new(tl!("Table Styles"), &items, None).tiles(7, 4).thumb(ThumbSize::Large).aspect(ThumbAspect::new(3, 2)).show(ui)
|
||||
};
|
||||
if let Some(style) = out.picked {
|
||||
let _ = app.run("table.style", json!({"style": style}));
|
||||
@@ -299,7 +302,7 @@ pub(crate) fn wordart(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp, comma
|
||||
.activate(ActivateOn::Click)
|
||||
.card_columns(WORDART_COLUMNS)
|
||||
.thumb_size(ThumbSize::Small)
|
||||
.zoom(2.0)
|
||||
.zoom(GridZoom::Fixed(2.0))
|
||||
// Every style shows, as in production; the menu's body is the one scroll.
|
||||
.natural_height(true)
|
||||
.caption(CaptionPlace::None)
|
||||
|
||||
@@ -152,8 +152,12 @@ fn cell_size_boxes(ui: &mut Ui, app: &mut WordApp) {
|
||||
pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
row.group(RibbonGroup::new("table", tl!("Table").to_string(), IconId::new("table").into()), |ui| {
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let _ =
|
||||
menu_button(ui, Button::new(tl!("Select").to_string()).icon(IconId::new("selectTable")), tl!("Select").to_string(), None, |ui, _| {
|
||||
let _ = menu_button(
|
||||
ui,
|
||||
Button::new(tl!("Select").to_string()).icon(IconId::new("selectTable")),
|
||||
tl!("Select").to_string(),
|
||||
Some("table.selectTable"),
|
||||
|ui, _| {
|
||||
for (label, id) in [
|
||||
("Select Cell", "table.selectCell"),
|
||||
("Select Column", "table.selectColumn"),
|
||||
@@ -162,7 +166,8 @@ pub(super) fn table_layout(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
] {
|
||||
MenuItem::command(CommandRef::new(id)).label(tl!(label).to_string()).show(ui);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
ToggleButton::command(CommandRef::new("table.viewGridlines"))
|
||||
.label(tl!("View Gridlines").to_string())
|
||||
.icon(IconId::new("gridlines"))
|
||||
|
||||
@@ -729,6 +729,57 @@ fn table_shading_split_keeps_palette_and_apply_separate() {
|
||||
assert_eq!(first_cell_shading(h.state()), Some(red), "No Color is undone in one step");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn table_styles_gallery_uses_large_landscape_thumbnails() {
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::{By, Queryable};
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let mut h = tab_harness(app, "Design");
|
||||
let style_set_height = h
|
||||
.query_all(By::new().role(Role::RadioButton).label_contains("Style set:"))
|
||||
.next()
|
||||
.expect("Design › Style Sets renders its large gallery tiles")
|
||||
.rect()
|
||||
.height();
|
||||
|
||||
h.state_mut().run("ui.tab", json!({"tab": "Table Design"})).unwrap();
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
|
||||
let mut styles: Vec<(bool, String)> = h
|
||||
.state()
|
||||
.session
|
||||
.doc
|
||||
.styles
|
||||
.styles
|
||||
.iter()
|
||||
.filter(|s| s.kind == wordcraft_doc::StyleKind::Table && !s.hidden)
|
||||
.map(|s| (s.builtin, crate::i18n::style_name(s)))
|
||||
.collect();
|
||||
styles.sort_by_key(|(builtin, _)| *builtin);
|
||||
let expected: Vec<String> = styles.into_iter().take(7).map(|(_, name)| name).collect();
|
||||
assert_eq!(expected.len(), 7, "built-in document has at least seven table styles");
|
||||
|
||||
let tiles: Vec<(String, egui::Rect)> = expected
|
||||
.iter()
|
||||
.filter_map(|name| h.query_all(By::new().role(Role::RadioButton).label(name)).next().map(|node| (name.clone(), node.rect())))
|
||||
.collect();
|
||||
assert_eq!(tiles.len(), expected.len(), "all seven Table Styles tiles render at full ribbon width: {tiles:?}");
|
||||
|
||||
for (name, rect) in &tiles {
|
||||
assert!(
|
||||
rect.height() >= style_set_height - 1.0,
|
||||
"Table Styles tile `{name}` height should be at least Design › Style Sets' Large thumbnail height ({style_set_height}), got {rect:?}"
|
||||
);
|
||||
let ratio = rect.width() / rect.height();
|
||||
assert!(
|
||||
(1.25..=1.75).contains(&ratio),
|
||||
"Table Styles tile `{name}` should use a landscape aspect ratio matching its 3:2 table preview, got {ratio:.2} ({rect:?})"
|
||||
);
|
||||
}
|
||||
assert!(tiles.windows(2).all(|w| w[0].1.max.x <= w[1].1.min.x + 0.01), "Table Styles tiles sit side by side without overlapping: {tiles:?}");
|
||||
}
|
||||
|
||||
/// #7308: the compact menu and split buttons of Home › Font and Home › Paragraph show their icons
|
||||
/// alone (keeping their names for access and tooltips) even in a wide window, leaving room for all
|
||||
/// six tiles of the Styles gallery at 1920 pt.
|
||||
@@ -830,7 +881,7 @@ fn unimplemented_stub_ribbon_buttons_are_disabled() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7324: Table ribbon menu buttons (Styles, Borders, Delete, AutoFit) bind their command IDs
|
||||
/// #7324, #7457: Table ribbon menu buttons (Styles, Borders, Select, 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() {
|
||||
@@ -871,8 +922,13 @@ fn table_ribbon_menu_buttons_disable_when_unselected_or_protected() {
|
||||
|
||||
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, "Select"), "Select button should be disabled when not in table");
|
||||
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");
|
||||
assert!(
|
||||
description(&h_layout_empty, "Select").as_deref().unwrap_or("").to_ascii_lowercase().contains("the cursor isn't in a table"),
|
||||
"Select should indicate outside table in disabled hint"
|
||||
);
|
||||
|
||||
// 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());
|
||||
@@ -884,10 +940,11 @@ fn table_ribbon_menu_buttons_disable_when_unselected_or_protected() {
|
||||
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, "Select"), "Select button should be enabled in table");
|
||||
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:
|
||||
// 3. With an active table under document protection (read-only): mutating 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());
|
||||
@@ -903,6 +960,7 @@ fn table_ribbon_menu_buttons_disable_when_unselected_or_protected() {
|
||||
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, "Select"), "Select button should remain enabled under protection");
|
||||
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!(
|
||||
|
||||
@@ -229,7 +229,7 @@ impl<'a> TableMouse<'a> {
|
||||
/// A press went down at `start.origin` on part `index` of `page` with `mods` held: a selection area selects, an
|
||||
/// insert button inserts, a handle waits.
|
||||
fn press(&mut self, cx: &mut Cx<'_, Self>, start: PressStart, mods: Mods, page: usize, index: u64) {
|
||||
let Some(placed) = self.pages.iter().find(|placed| placed.page == page).copied() else { return };
|
||||
let Some(placed) = self.pages.iter().find(|placed| placed.page == page).cloned() else { return };
|
||||
let (x, y) = page_point(&placed, start.origin);
|
||||
let reach = reach_on(self.pages, page);
|
||||
let story = self.app.session.sel.focus.story;
|
||||
|
||||
@@ -231,7 +231,7 @@ impl<'a> TableBorders<'a> {
|
||||
|
||||
/// A press went down at `origin` on `target`, the border of part `index` on `page`: the drag starts there.
|
||||
fn press(&mut self, cx: &mut Cx<'_, Self>, origin: Pos2, page: usize, index: u64, mut target: ResizeTarget) {
|
||||
let Some(placed) = self.pages.iter().find(|placed| placed.page == page).copied() else { return };
|
||||
let Some(placed) = self.pages.iter().find(|placed| placed.page == page).cloned() else { return };
|
||||
let from = page_point(&placed, origin);
|
||||
target.limit_to_selection(&self.app.session, from.1);
|
||||
self.app.canvas.table_resize = Some(ResizeDrag { page, from, to: from, target, ruler: false });
|
||||
|
||||
@@ -46,8 +46,10 @@ pub(crate) fn screen(h: &mut H, x: f32, y: f32) -> Pos2 {
|
||||
crate::canvas::page_to_screen(h.state_mut(), 0, x, y).unwrap()
|
||||
}
|
||||
|
||||
/// A primary button event carrying the modifiers held, as platforms send it.
|
||||
pub(crate) fn button(h: &H, at: Pos2, pressed: bool) {
|
||||
h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() });
|
||||
let modifiers = h.ctx.input(|i| i.modifiers);
|
||||
h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers });
|
||||
}
|
||||
|
||||
pub(crate) fn steps(h: &mut H, n: usize) {
|
||||
|
||||
@@ -127,7 +127,11 @@ fn discover_printers(a: &mut WordApp) {
|
||||
}
|
||||
// Discovery runs on native hosts only: where the test host isn't one, the app has found the
|
||||
// recorder's printer and chosen it, as `native_print.rs` sets its own up.
|
||||
let name = if a.printing.settings.printer.is_empty() { "Test queue".to_string() } else { a.printing.settings.printer.clone() };
|
||||
let name = if crate::printing::printer_name(&a.printing.settings).is_empty() {
|
||||
"Test queue".to_string()
|
||||
} else {
|
||||
crate::printing::printer_name(&a.printing.settings).to_string()
|
||||
};
|
||||
if !a.printing.printers.iter().any(|p| p.name == name) {
|
||||
a.printing.printers.push(crate::printing::Printer::new(name.clone()).is_default(true));
|
||||
}
|
||||
@@ -634,7 +638,7 @@ fn return_on_the_print_page_prints() {
|
||||
fn a_successful_native_print_returns_to_the_document() {
|
||||
for ok in [true, false] {
|
||||
let mut a = app();
|
||||
a.printing.settings.printer = "Test Printer".into();
|
||||
a.printing.settings.destination = crate::printing::Destination::Printer("Test Printer".into());
|
||||
a.services.print = Some(Recorder::new(if ok { Reply::Sent } else { Reply::Fail("no paper") }).with_printers(["Test Printer"]).spool());
|
||||
discover_printers(&mut a);
|
||||
a.run("file.print", json!({})).unwrap();
|
||||
@@ -666,7 +670,7 @@ fn cancelling_a_waiting_print_job_frees_the_print_page() {
|
||||
let mut texts: [Option<String>; 2] = [None, None];
|
||||
for (never_sent, close_document) in [(true, false), (false, false), (true, true), (false, true)] {
|
||||
let mut a = app();
|
||||
a.printing.settings.printer = "Office".into();
|
||||
a.printing.settings.destination = crate::printing::Destination::Printer("Office".into());
|
||||
a.printing.settings.copies = 3;
|
||||
// The worker never answers, as when the driver doesn't.
|
||||
let rec = Recorder::cancelling(Reply::Hold, never_sent).with_printers(["Office"]);
|
||||
@@ -688,7 +692,7 @@ fn cancelling_a_waiting_print_job_frees_the_print_page() {
|
||||
assert_eq!(reply["cancelled"], never_sent);
|
||||
assert_eq!(rec.asked_to_cancel(), 1, "the backend was asked to stop the job");
|
||||
assert_eq!(a.printing.busy(), !never_sent, "never_sent {never_sent}: whether the page is still locked");
|
||||
assert_eq!(a.printing.settings.printer, "Office", "the chosen printer is kept");
|
||||
assert_eq!(crate::printing::printer_name(&a.printing.settings), "Office", "the chosen printer is kept");
|
||||
assert_eq!(a.printing.settings.copies, 3, "the settings are kept");
|
||||
assert_eq!(a.printing.printers.len(), 1, "the printer list is kept");
|
||||
let text = said(&a);
|
||||
|
||||
@@ -16,6 +16,9 @@ pub(crate) struct Runtime {
|
||||
/// The desktop app turns the check at start on; tests and the web build leave it off.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
startup_check: bool,
|
||||
/// How many times the test stub answered a check (see `stub_update_check`).
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
pub(crate) stub_calls: std::sync::Arc<std::sync::atomic::AtomicUsize>,
|
||||
}
|
||||
|
||||
impl Default for Runtime {
|
||||
@@ -25,6 +28,8 @@ impl Default for Runtime {
|
||||
updater: Updater::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).with_translator(translate),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
startup_check: false,
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
stub_calls: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +58,20 @@ impl WordApp {
|
||||
rt.updater = Updater::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).with_translator(translate).with_source(refused_check());
|
||||
}
|
||||
|
||||
/// Answers every update check with "up to date" instead of asking GitHub, so a test's result
|
||||
/// doesn't depend on the network or its rate limit (#7463).
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
pub(crate) fn stub_update_check(&mut self) {
|
||||
let rt = &mut self.updates_rt;
|
||||
rt.startup_check = false;
|
||||
let calls = rt.stub_calls.clone();
|
||||
rt.updater =
|
||||
Updater::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).with_translator(translate).with_source(std::sync::Arc::new(move || {
|
||||
calls.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
Ok(None)
|
||||
}));
|
||||
}
|
||||
|
||||
/// Starts the helper of an update that is ready, so that it installs once the process has
|
||||
/// ended. Call it once the exit is certain, before a path that ends the process without
|
||||
/// dropping the app. Later calls do nothing.
|
||||
@@ -68,7 +87,7 @@ impl WordApp {
|
||||
fn refused_check() -> craft::update::updater::CheckSource {
|
||||
let why = tl!("Updates are off in this window: WordCraft was started with another program's AppImage settings. Start WordCraft from its own menu entry to update it.")
|
||||
.to_string();
|
||||
std::sync::Arc::new(move || Err(why.clone()))
|
||||
std::sync::Arc::new(move || Err(why.clone().into()))
|
||||
}
|
||||
|
||||
/// Help ▸ Check for Updates. The result dialog opens from [`run`] while the updater has a status.
|
||||
|
||||
@@ -23,11 +23,13 @@ struct Rig {
|
||||
commands: Vec<(ViewportId, ViewportCommand)>,
|
||||
/// The viewports that drew in the last frame, in order.
|
||||
drawn: Vec<ViewportId>,
|
||||
/// How the viewports asked to open their windows in every frame so far.
|
||||
builders: Vec<egui::ViewportBuilder>,
|
||||
}
|
||||
|
||||
impl Rig {
|
||||
fn new() -> Rig {
|
||||
Rig { kit: Kit::new(), focused: None, closing: Vec::new(), commands: Vec::new(), drawn: Vec::new() }
|
||||
Rig { kit: Kit::new(), focused: None, closing: Vec::new(), commands: Vec::new(), drawn: Vec::new(), builders: Vec::new() }
|
||||
}
|
||||
|
||||
fn ctx(&self) -> egui::Context {
|
||||
@@ -58,6 +60,7 @@ impl Rig {
|
||||
craft::ui::shell::embed::logic(ui.ctx(), || a.close_decision());
|
||||
a.ui(ui);
|
||||
});
|
||||
self.builders.extend(out.builders.into_iter().map(|(_, b)| b));
|
||||
self.commands = out.commands;
|
||||
self.drawn = out.trees.iter().map(|(v, _)| *v).collect();
|
||||
self.closing.clear();
|
||||
@@ -514,3 +517,30 @@ fn every_open_replaces_an_untouched_blank_document_in_its_window() {
|
||||
}
|
||||
std::fs::remove_dir_all(second.parent().unwrap()).ok();
|
||||
}
|
||||
|
||||
/// #3634: a NUL in the document title never reaches an OS window title (X11 and Wayland panic on
|
||||
/// it): not a native window's builder, not a `Title` command, not the window menu. Checks what the
|
||||
/// frames send, so a new title source that skips `display_title` fails here.
|
||||
#[test]
|
||||
fn nul_in_the_document_title_never_reaches_an_os_window_title() {
|
||||
for raw in ["\u{0}", "a\u{0}b"] {
|
||||
let mut rig = Rig::new();
|
||||
let mut a = app("x");
|
||||
a.run("file.properties", json!({"title": raw})).unwrap();
|
||||
let mut sent = Vec::new();
|
||||
for i in 0..6 {
|
||||
if i == 3 {
|
||||
a.run("view.newWindow", json!({})).unwrap();
|
||||
assert_eq!(a.window_count(), 2);
|
||||
}
|
||||
rig.frame(&mut a);
|
||||
sent.extend(rig.commands.iter().filter_map(|(_, c)| if let ViewportCommand::Title(t) = c { Some(t.clone()) } else { None }));
|
||||
}
|
||||
sent.extend(rig.builders.iter().filter_map(|b| b.title.clone()));
|
||||
sent.extend(a.switch_windows_entries().into_iter().map(|e| e.1));
|
||||
assert!(rig.builders.iter().any(|b| b.title.is_some()), "the new window's builder carries a title");
|
||||
for t in &sent {
|
||||
assert!(std::ffi::CString::new(t.as_str()).is_ok(), "an OS window title without NUL ({raw:?}): {t:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use craft::menu::CommandRef;
|
||||
use craft::ui::contract::{ActivateOn, BodyCx, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _};
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::list::{ThumbAspect, ThumbSize};
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::ContentPainterCx;
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
@@ -184,6 +184,7 @@ pub fn transform_menu(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
|
||||
.select(SelectMode::None)
|
||||
.activate(ActivateOn::Click)
|
||||
.card_columns(4)
|
||||
.thumb_size(ThumbSize::Small)
|
||||
// Every warp shows; the menu's body is the one scroll.
|
||||
.natural_height(true)
|
||||
.show_items(ui, &source, &mut |id, _| {
|
||||
@@ -276,4 +277,26 @@ mod tests {
|
||||
a.run("caret.set", json!({"pos": wordcraft_doc::Pos::body(0, 2)})).unwrap();
|
||||
assert_eq!(current_outline(&a), None, "the body text has no outline");
|
||||
}
|
||||
|
||||
/// #7449: the Transform menu renders compact preview tiles (~46×32 pt)
|
||||
/// instead of expanding each warp thumbnail to default card dimensions (~132 pt).
|
||||
#[test]
|
||||
fn transform_menu_renders_compact_tiles() {
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
|
||||
let a = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Transform")), crate::Services::default());
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(600.0, 700.0)).build_ui_state(
|
||||
|ui, app: &mut WordApp| {
|
||||
Menu::inline("Transform").show(ui, |ui, cx| transform_menu(ui, cx, app));
|
||||
},
|
||||
a,
|
||||
);
|
||||
h.run_steps(2);
|
||||
|
||||
let tile = h.get_by_role_and_label(Role::ListItem, "Arch Up").rect();
|
||||
assert!(tile.width() <= 60.0 && tile.height() <= 45.0, "transform tile is compact (~46×32 pt), got {:?}", tile.size());
|
||||
let grid = h.get_by_role_and_label(Role::ListBox, "Transform").rect();
|
||||
assert!(grid.width() <= 260.0, "4-column transform menu grid width stays compact (~200 pt), got {:?}", grid.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ let apps move windows, so there Arrange All and Side by Side only resize.
|
||||
| `ui.wheel` | `x`, `y`, `dy`, `dx?`, `unit?` (`point`/`line`/`page`), `phase?` (`start`/`move`/`end`), modifiers | mouse-wheel or trackpad scroll at window coordinates (`dy` < 0 scrolls down) |
|
||||
| `ui.key` | `key` (`B`, `Enter`, `Left`…), `shift?`, `alt?`, `cmd?` | key press through egui (shortcuts apply) |
|
||||
| `ui.text` | `text` | typed text through egui |
|
||||
| `ui.screenshot` | `path?` | PNG of the window in the root viewport: written to `path`, or without one returned as base64 `png` in the reply. Capturing a secondary document window is not supported by the viewport renderer; select the root window with `view.switchWindows {"window": root}` first |
|
||||
| `ui.screenshot` | `path?`, `region?` (`[x0, y0, x1, y1]` in points) | PNG of the window (or of `region`) in the root viewport: written to `path`, or without one returned as base64 `png` in the reply. Capturing a secondary document window is not supported by the viewport renderer; select the root window with `view.switchWindows {"window": root}` first |
|
||||
| `ui.render` | `path?`, `page?` (1-based), `scale?`, `doc?` | PNG of a page, rendered by the engine: written to `path`, or without one returned as base64 `png` in the reply (never a fixed name in the shared temporary folder) |
|
||||
| `ui.parity` | — | feature-catalog parity |
|
||||
| `ui.resize` | `width`, `height` | asks for that window content size in points; sizes that aren't positive and finite are refused, the rest are clamped to the app's minimum (600 × 480, #5886) and to the largest surface the GPU can draw (at most 16384; that limit wins over the minimum), and the reply's `width` and `height` are the size asked for |
|
||||
|
||||
Reference in New Issue
Block a user