mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 18:25:34 +01:00
Merge main into feat/match-objects-to-key
This commit is contained in:
133 files changed
+6479
-891
No files matched your search
@@ -38,27 +38,32 @@
|
||||
"applicability": "required"
|
||||
},
|
||||
{
|
||||
"name": "gate / test 1/5 (ubuntu-24.04)",
|
||||
"name": "gate / test 1/6 (ubuntu-24.04)",
|
||||
"app_id": 15368,
|
||||
"applicability": "required"
|
||||
},
|
||||
{
|
||||
"name": "gate / test 2/5 (ubuntu-24.04)",
|
||||
"name": "gate / test 2/6 (ubuntu-24.04)",
|
||||
"app_id": 15368,
|
||||
"applicability": "required"
|
||||
},
|
||||
{
|
||||
"name": "gate / test 3/5 (ubuntu-24.04)",
|
||||
"name": "gate / test 3/6 (ubuntu-24.04)",
|
||||
"app_id": 15368,
|
||||
"applicability": "required"
|
||||
},
|
||||
{
|
||||
"name": "gate / test 4/5 (ubuntu-24.04)",
|
||||
"name": "gate / test 4/6 (ubuntu-24.04)",
|
||||
"app_id": 15368,
|
||||
"applicability": "required"
|
||||
},
|
||||
{
|
||||
"name": "gate / test 5/5 (ubuntu-24.04)",
|
||||
"name": "gate / test 5/6 (ubuntu-24.04)",
|
||||
"app_id": 15368,
|
||||
"applicability": "required"
|
||||
},
|
||||
{
|
||||
"name": "gate / test 6/6 (ubuntu-24.04)",
|
||||
"app_id": 15368,
|
||||
"applicability": "required"
|
||||
},
|
||||
|
||||
@@ -39,11 +39,12 @@ jobs:
|
||||
dev-strip: true
|
||||
# The workspace crates also build without line tables. A panic still names its file and line.
|
||||
dev-debug: "0"
|
||||
# Five legs instead of one: shards 1 to 4 each build and run the tests of their own crates,
|
||||
# and shard 5 runs the other `cargo xtask ci` steps (xtask/src/shards.rs). `gate (<os>)`
|
||||
# passes only when all five did. On pushes to main, a `cache warm` leg builds what every
|
||||
# shard builds and saves the dependency cache.
|
||||
test-shards: 5
|
||||
# Six legs instead of one: shards 1 and 2 each build vectorcraft-ui-egui's tests and run
|
||||
# half of them, shards 3 to 5 each build and run the tests of their own crates, and shard 6
|
||||
# runs the other `cargo xtask ci` steps (xtask/src/shards.rs). `gate (<os>)` passes only
|
||||
# when all six did. On pushes to main, a `cache warm` leg builds what every shard builds and
|
||||
# saves the dependency cache.
|
||||
test-shards: 6
|
||||
shard-command: cargo xtask ci shard
|
||||
warm-command: cargo xtask ci warm
|
||||
# The dependency cache also keeps the compiled workspace crates and test executables, so a
|
||||
|
||||
@@ -7,9 +7,26 @@ on:
|
||||
- "apps/vectorcraft/Cargo.toml"
|
||||
- "apps/vectorcraft/src/printing.rs"
|
||||
- "apps/vectorcraft/src/printing/**"
|
||||
- "crates/ui-egui/Cargo.toml"
|
||||
- "crates/ui-egui/src/print.rs"
|
||||
- "crates/ui-egui/src/tests/printps.rs"
|
||||
- ".github/workflows/print.yml"
|
||||
# A push to main saves the Windows cache entry that pull requests restore.
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "Cargo.toml"
|
||||
- "Cargo.lock"
|
||||
- "apps/vectorcraft/Cargo.toml"
|
||||
- "apps/vectorcraft/src/printing.rs"
|
||||
- "apps/vectorcraft/src/printing/**"
|
||||
- "crates/ui-egui/Cargo.toml"
|
||||
- "crates/ui-egui/src/print.rs"
|
||||
- "crates/ui-egui/src/tests/printps.rs"
|
||||
- ".github/workflows/print.yml"
|
||||
# A weekly run on main saves a fresh entry after a new stable Rust changes the cache key.
|
||||
schedule:
|
||||
- cron: "23 6 * * 1"
|
||||
workflow_dispatch:
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -18,15 +35,14 @@ concurrency:
|
||||
group: print-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
jobs:
|
||||
# Desktop printing on Windows, through the suite's shared gate. Pull requests restore the cache
|
||||
# but never save one; a manual run on main saves the cache they restore.
|
||||
# Desktop printing on Windows, through the suite's shared gate. Pushes to main, the weekly run and
|
||||
# manual runs on main save the cache; pull requests restore it and never save one.
|
||||
windows:
|
||||
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
|
||||
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
|
||||
with:
|
||||
os: '["windows-2022"]'
|
||||
# A change to Cargo.lock finds no cache (only main saves one) and builds everything cold:
|
||||
# about 55 minutes for `-p vectorcraft` alone, then the UI crate's tests.
|
||||
# A run that finds no cache builds everything cold, which took 76 to 126 minutes.
|
||||
timeout-minutes: 150
|
||||
# As in ci.yml: test binaries without debug info or symbols, and workspace crates without
|
||||
# line tables. A panic still names its file and line.
|
||||
@@ -36,10 +52,14 @@ jobs:
|
||||
craft-fonts-ref: ""
|
||||
tools: ""
|
||||
targets: ""
|
||||
# A filter that matches nothing still passes, so the printps run fails unless some test ran.
|
||||
# Both test runs select the same two packages, so Cargo resolves features once and the
|
||||
# second run reuses the first run's dependencies. The first runs every test of the app
|
||||
# (`--bin vectorcraft --test it`), the second the UI crate's `tests::printps` tests. A filter
|
||||
# that matches nothing still passes, so the printps run fails unless some test ran.
|
||||
command: |
|
||||
set -o pipefail
|
||||
cargo clippy --locked -p vectorcraft --all-targets -- -D warnings
|
||||
cargo test --locked -p vectorcraft
|
||||
cargo test --locked -p vectorcraft -p vectorcraft-ui-egui --bin vectorcraft --test it
|
||||
log="$RUNNER_TEMP/printps.log"
|
||||
cargo test --locked -p vectorcraft-ui-egui --lib -- tests::printps | tee "$log"
|
||||
cargo test --locked -p vectorcraft -p vectorcraft-ui-egui --lib -- tests::printps | tee "$log"
|
||||
grep -Eq 'test result: ok\. [1-9][0-9]* passed' "$log" || { echo "::error::tests::printps matched no tests"; exit 1; }
|
||||
@@ -1,6 +1,7 @@
|
||||
name: SonarCloud
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
Generated
+99
-99
@@ -1239,7 +1239,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
@@ -1280,7 +1280,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-affinity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1291,7 +1291,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-appkit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.5",
|
||||
@@ -1302,7 +1302,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-atomic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"rustix 1.1.6",
|
||||
]
|
||||
@@ -1310,7 +1310,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-automation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1335,7 +1335,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-behavior"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"bitflags 2.13.2",
|
||||
@@ -1353,7 +1353,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-browse"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-docpath",
|
||||
@@ -1371,7 +1371,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cdr"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1380,7 +1380,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cloud-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
@@ -1388,7 +1388,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cms"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"md-5",
|
||||
"rayon",
|
||||
@@ -1397,12 +1397,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-codepage"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
|
||||
[[package]]
|
||||
name = "craft-color-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-cms",
|
||||
@@ -1422,7 +1422,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-control-protocol",
|
||||
"craft-platform",
|
||||
@@ -1433,7 +1433,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control-protocol"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"serde_json",
|
||||
@@ -1443,7 +1443,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dds"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
@@ -1451,7 +1451,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dialogs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"craft-appkit",
|
||||
@@ -1477,7 +1477,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-doc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"craft-ecproj-format",
|
||||
@@ -1493,7 +1493,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1501,7 +1501,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-draw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1520,7 +1520,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dxf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"encoding_rs",
|
||||
@@ -1532,7 +1532,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ecproj-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1542,12 +1542,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-eps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"fontique",
|
||||
"harfrust 0.13.3",
|
||||
@@ -1562,7 +1562,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-manager"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -1581,7 +1581,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-os-windows"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"windows-registry",
|
||||
"windows-sys 0.61.2",
|
||||
@@ -1590,7 +1590,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"cap-primitives",
|
||||
"craft-atomic",
|
||||
@@ -1613,12 +1613,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
|
||||
[[package]]
|
||||
name = "craft-gif"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"gif",
|
||||
]
|
||||
@@ -1626,7 +1626,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-gzip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
]
|
||||
@@ -1634,7 +1634,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-i18n",
|
||||
@@ -1647,7 +1647,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"fixed_decimal",
|
||||
@@ -1675,7 +1675,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-image-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-dds",
|
||||
"craft-jpeg",
|
||||
@@ -1702,7 +1702,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-imaging"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1720,7 +1720,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1728,7 +1728,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jxl"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"brotli-decompressor 5.0.3",
|
||||
"jixel",
|
||||
@@ -1739,7 +1739,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-keymap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
@@ -1754,7 +1754,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -1768,7 +1768,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-menu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1786,7 +1786,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metadata"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"brotli-decompressor 6.3.2",
|
||||
"chrono",
|
||||
@@ -1798,7 +1798,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metafile"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"image",
|
||||
@@ -1809,7 +1809,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mime"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-codepage",
|
||||
@@ -1819,7 +1819,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pages"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -1835,7 +1835,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -1846,7 +1846,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"hayro-interpret",
|
||||
"hayro-syntax",
|
||||
@@ -1858,7 +1858,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-platform"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io",
|
||||
@@ -1889,7 +1889,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-plotter"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"kurbo 0.13.1",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1898,7 +1898,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1922,7 +1922,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-proof"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"log",
|
||||
"miniz_oxide 0.9.1",
|
||||
@@ -1933,7 +1933,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-eps",
|
||||
"flate2",
|
||||
@@ -1947,7 +1947,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-psd"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
@@ -1958,7 +1958,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-quit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"egui",
|
||||
@@ -1971,7 +1971,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-review"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1990,7 +1990,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-settings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
@@ -2007,7 +2007,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-stream-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"fax",
|
||||
"hayro-ccitt",
|
||||
@@ -2018,7 +2018,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-image-codecs",
|
||||
"craft-xml",
|
||||
@@ -2039,7 +2039,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-table"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2051,7 +2051,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-manager",
|
||||
@@ -2076,7 +2076,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-tracked",
|
||||
@@ -2091,7 +2091,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2106,7 +2106,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tiff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2116,7 +2116,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-time"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2125,7 +2125,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-timeline"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2140,12 +2140,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tracked"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-cloud-ui",
|
||||
"craft-ui-canvas",
|
||||
@@ -2159,7 +2159,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-canvas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -2175,7 +2175,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-contract"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"craft-behavior",
|
||||
@@ -2213,7 +2213,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2224,7 +2224,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-panels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2242,7 +2242,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-patterns"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2263,7 +2263,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-shell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2284,7 +2284,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-widgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2303,7 +2303,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
@@ -2335,7 +2335,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-vectorcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -2346,7 +2346,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-wayland"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"raw-window-handle",
|
||||
"wayland-backend",
|
||||
@@ -2356,7 +2356,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-api"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde_json",
|
||||
@@ -2367,7 +2367,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-win32"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"winsafe",
|
||||
]
|
||||
@@ -2375,7 +2375,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-window"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"craft-appkit",
|
||||
"craft-atomic",
|
||||
@@ -2407,7 +2407,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -2752,7 +2752,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"emath",
|
||||
@@ -2785,7 +2785,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -2820,7 +2820,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
@@ -2839,7 +2839,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-wgpu"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -2858,7 +2858,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"accesskit_winit",
|
||||
"arboard",
|
||||
@@ -2883,7 +2883,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_extras"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"egui",
|
||||
@@ -2897,7 +2897,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -2910,7 +2910,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_kittest"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"dify",
|
||||
"eframe",
|
||||
@@ -2936,7 +2936,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
@@ -3017,7 +3017,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -3043,7 +3043,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint_default_fonts"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
@@ -3762,7 +3762,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
|
||||
[[package]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"brotli",
|
||||
"hayro-postscript",
|
||||
@@ -3771,7 +3771,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -3789,7 +3789,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -3807,12 +3807,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -4795,7 +4795,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "krilla"
|
||||
version = "0.8.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bumpalo",
|
||||
@@ -4952,7 +4952,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
|
||||
[[package]]
|
||||
name = "linesweeper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=610c86792a02aa3d416926ee44e3ec3788dea853#610c86792a02aa3d416926ee44e3ec3788dea853"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"kurbo 0.13.1",
|
||||
@@ -10762,14 +10762,14 @@ dependencies = [
|
||||
[[patch.unused]]
|
||||
name = "egui_demo_lib"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_inspection"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_system_font_provider"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443"
|
||||
+49
-49
@@ -11,46 +11,46 @@ rust-version = "1.95"
|
||||
repository = "https://github.com/storytold/vectorcraft"
|
||||
|
||||
[workspace.dependencies]
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", default-features = false, features = ["interpret", "write"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["interpret", "write"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON.
|
||||
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile.
|
||||
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", features = ["pcraft-pixels"] }
|
||||
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["pcraft-pixels"] }
|
||||
# Native Affinity documents (craft-libs#914).
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778).
|
||||
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# SVG parsing, limits, SVGZ and writer (craft-libs#778).
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", features = ["tree"] }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", features = ["tree"] }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# EPS container, previews, ASCII85 and DSC comments (craft-libs#778).
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# DXF tags, reader and writer (craft-libs#778, #926, #927).
|
||||
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# WMF, EMF and EMF+ reader (craft-libs#778).
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", default-features = false, features = ["read", "write"] }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", default-features = false, features = ["read", "write"] }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names
|
||||
# the members it imports.
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui
|
||||
# without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes.
|
||||
craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
# internal
|
||||
vectorcraft-geom = { path = "crates/geom" }
|
||||
vectorcraft-color = { path = "crates/color" }
|
||||
@@ -193,25 +193,25 @@ lto = "thin"
|
||||
codegen-units = 1
|
||||
|
||||
[patch.crates-io]
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
@@ -27,7 +27,7 @@ log = { workspace = true }
|
||||
# `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback.
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] }
|
||||
# The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft.
|
||||
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", version = "0.1.0" }
|
||||
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", version = "0.1.0" }
|
||||
|
||||
wasm-bindgen = "0.2"
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -225,7 +225,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Symbol Options…",
|
||||
[],
|
||||
None,
|
||||
"{name?, newName?, registration?: 0..8, exportType?: movieClip|graphic, nineSlice?: bool, nineSliceGuides?: array, type?: static|dynamic, alignToPixelGrid?: bool} rename a symbol (its instances and the graphics and Map Art maps on 3D objects follow the new name) and/or set Symbol Options › Registration, Export Type, 9-slice guides (nineSliceGuides [left, top, right, bottom] fractions in from each edge, each -16..16, with left + right < 1 and top + bottom < 1), Symbol Type (a dynamic symbol's instances may change the appearance of objects in its art and stay linked; making it static drops those changes) and Align to Pixel Grid (on: the horizontal and vertical straight segments of the paths in the symbol's art snap to whole points, or half points for an odd centered stroke, at the symbol's natural size, its stroke weights become whole points, and every instance placed at that size, reflected across one axis or not, moves to whole points and goes back to them after each move; a scaled, rotated (a half turn included) or sheared instance, and an instance in another symbol's art, is left where it is; the art snaps again after it is edited); alignToPixelGrid alone with the value the symbol already has changes nothing and adds no undo step; default name: current → {name, registration, exportType, nineSlice, type, alignToPixelGrid}",
|
||||
"{name?, newName?, registration?: 0..8, exportType?: movieClip|graphic, nineSlice?: bool, nineSliceGuides?: array, type?: static|dynamic, alignToPixelGrid?: bool} rename a symbol (its instances and the graphics and Map Art maps on 3D objects follow the new name) and/or set Symbol Options › Registration, Export Type, 9-slice guides (nineSliceGuides [left, top, right, bottom] fractions in from each edge, each -16..16, with left + right < 1 and top + bottom < 1), Symbol Type (a dynamic symbol's instances may change the appearance of objects in its art and stay linked; making it static drops those changes) and Align to Pixel Grid (on: the horizontal and vertical straight segments of the paths in the symbol's art snap to whole points, or half points for an odd centered stroke, at the symbol's natural size, its stroke weights become whole points, and every instance placed at that size, reflected across one axis or not, moves to whole points and goes back to them after each move; a scaled, rotated (a half turn included) or sheared instance, and an instance in another symbol's art, is left where it is; the art snaps again after it is edited); values the symbol already has, newName included, change nothing and add no undo step; default name: current → {name, registration, exportType, nineSlice, type, alignToPixelGrid}",
|
||||
has_doc,
|
||||
symbol_options
|
||||
),
|
||||
@@ -289,7 +289,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Replace Symbol",
|
||||
[],
|
||||
None,
|
||||
"{name, ids?|id?} swap the symbol of the selected instances (an instance given a different symbol drops its appearance changes; one given its own symbol keeps them) → {ids}",
|
||||
"{name, ids?|id?} swap the symbol of the selected instances (an instance given a different symbol drops its appearance changes; one given its own symbol keeps them; when every instance already shows the symbol, nothing changes and no undo step is recorded) → {ids}",
|
||||
has_selection,
|
||||
symbol_replace
|
||||
),
|
||||
|
||||
@@ -347,13 +347,8 @@ pub(super) fn symbol_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let dynamic = type_param(p, C)?;
|
||||
let pixel = pixel_grid_param(p, C)?;
|
||||
let new_name = str_param(p, "newName").map(str::trim).filter(|n| !n.is_empty()).map(str::to_string);
|
||||
if new_name.is_none() && export.is_none() && reg.is_none() && nine.is_none() && dynamic.is_none() {
|
||||
match pixel {
|
||||
None => return Err(bad(C, "pass newName, registration, exportType, nineSlice, type and/or alignToPixelGrid")),
|
||||
// Align to Pixel Grid alone, already as asked: nothing changes and no undo step is added.
|
||||
Some(on) if on == s.doc()?.doc.symbol_pixel_aligned(&name) => return Ok(options_json(&s.doc()?.doc, &name)),
|
||||
Some(_) => {}
|
||||
}
|
||||
if new_name.is_none() && export.is_none() && reg.is_none() && nine.is_none() && dynamic.is_none() && pixel.is_none() {
|
||||
return Err(bad(C, "pass newName, registration, exportType, nineSlice, type and/or alignToPixelGrid"));
|
||||
}
|
||||
if let Some(ref n) = new_name
|
||||
&& n != &name
|
||||
@@ -362,7 +357,8 @@ pub(super) fn symbol_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Err(bad(C, format!("a symbol named `{n}` already exists")));
|
||||
}
|
||||
let final_name = new_name.clone().unwrap_or_else(|| name.clone());
|
||||
s.edit("Symbol Options", |d, _| {
|
||||
// Values the symbol already has leave the document as it is, and no undo step is added.
|
||||
crate::cmd::colorcmds::edit_if_changed(s, "Symbol Options", |before, d| {
|
||||
if let Some(ref n) = new_name
|
||||
&& n != &name
|
||||
{
|
||||
@@ -439,7 +435,7 @@ pub(super) fn symbol_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let Some(on) = pixel {
|
||||
d.set_symbol_pixel_aligned(&final_name, on);
|
||||
}
|
||||
Ok(())
|
||||
Ok(((), before != &*d))
|
||||
})?;
|
||||
Ok(options_json(&s.doc()?.doc, &final_name))
|
||||
}
|
||||
@@ -859,7 +855,8 @@ pub(super) fn symbol_replace(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if ids.is_empty() {
|
||||
return Err(EngineError::Other("no symbol instances selected".into()));
|
||||
}
|
||||
s.edit("Replace Symbol", |d, _| {
|
||||
// Instances that already show the symbol leave the document as it is, and no undo step is added.
|
||||
crate::cmd::colorcmds::edit_if_changed(s, "Replace Symbol", |before, d| {
|
||||
let new = natural_size(d, &name);
|
||||
for id in &ids {
|
||||
let (old, other) = match d.node(*id).map(|n| &n.kind) {
|
||||
@@ -877,7 +874,7 @@ pub(super) fn symbol_replace(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
fit_overrides(d, &ids);
|
||||
Ok(())
|
||||
Ok(((), ids.iter().any(|id| before.node(*id) != d.node(*id))))
|
||||
})?;
|
||||
Ok(json!({ "ids": ids_json(&ids) }))
|
||||
}
|
||||
|
||||
@@ -920,7 +920,8 @@ pub(crate) fn anchor_from_json(v: &Value, cmd: &str) -> Result<Anchor> {
|
||||
};
|
||||
let mut anchor = Anchor::with_handles(p, handle("in")?, handle("out")?);
|
||||
match v.get("smooth").filter(|b| !b.is_null()) {
|
||||
None | Some(Value::Bool(false)) => {}
|
||||
None => {}
|
||||
Some(Value::Bool(false)) => anchor.kind = AnchorKind::Corner,
|
||||
Some(Value::Bool(true)) => anchor.kind = AnchorKind::Smooth,
|
||||
Some(_) => return Err(bad(cmd, "anchor `smooth` must be true or false")),
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
//! and strokes, effects, opacity and blend mode, and the link to the style) or, with the Appearance
|
||||
//! panel's New Art Has Basic Appearance off, the whole appearance of the last selection. With the
|
||||
//! option on (the default) an inherited appearance gives new art its top stroke's options only,
|
||||
//! and a change of selection loads only the proxies. `paint.default` resets it.
|
||||
//! and a change of selection loads only the proxies. `paint.default` resets it, and
|
||||
//! `appearance.setNewArt` sets its fill, stroke and stroke options whatever is selected.
|
||||
//!
|
||||
//! A document whose Default Graphic Style no longer has the shipped look (a New Document profile
|
||||
//! redefined it) gives the reset that style's fills, strokes and effects instead, and `file.new`
|
||||
@@ -34,7 +35,7 @@ pub(crate) struct NewArtSource {
|
||||
|
||||
use super::gradient::unplaced;
|
||||
use super::paint::SelectionPaints;
|
||||
use super::{CommandSpec, Result, Session, always, cmd, switch_or};
|
||||
use super::{CommandSpec, Result, Session, always, bad, cmd, switch_or};
|
||||
use crate::doc_state::{SelectionRecord, objects_only};
|
||||
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
@@ -57,9 +58,181 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
always,
|
||||
describe
|
||||
),
|
||||
cmd!(
|
||||
"appearance.setNewArt",
|
||||
"Set New Art Appearance",
|
||||
[],
|
||||
None,
|
||||
"{fill?: {color?, none?, swatch?, tint?, gradient?, keepModel?} (a paint as paint.setFill takes it), stroke?: (a paint, as fill), weight?: 0..1000 pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?: 1..500, dash?: [lengths, each 0..1000000 pt, at most 64, not all 0]|null (null: a solid line), dashOffset?: -1000000..1000000 pt (with a dash pattern), fillOverprint?: bool, strokeOverprint?: bool} set the fill, stroke and stroke options the next object drawn gets, whatever is selected: the selection and its art, the active proxy and the recent colors stay as they are. Without `weight` the stored stroke weight stays; a stroke painted on new art without one gets 1 pt only when that stored weight is 0. A bad value is an error with nothing changed, and so is any change while New Art Has Basic Appearance is off and an object is selected (new art takes that object's appearance then) → {changed: whether the next object drawn looks different}",
|
||||
always,
|
||||
set_new_art
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// The most dash and gap lengths `appearance.setNewArt` takes.
|
||||
const MAX_DASHES: usize = 64;
|
||||
/// The settings a `fill` or `stroke` paint of `appearance.setNewArt` takes.
|
||||
const PAINT_KEYS: [&str; 6] = ["color", "none", "swatch", "tint", "gradient", "keepModel"];
|
||||
/// The largest dash, gap or dash offset `appearance.setNewArt` takes, in points.
|
||||
const MAX_DASH_LENGTH: f64 = 1_000_000.0;
|
||||
|
||||
/// What [`dash_fault`] finds wrong with a list of dash and gap lengths.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub(crate) enum DashFault {
|
||||
/// More than [`MAX_DASHES`] lengths.
|
||||
TooMany,
|
||||
/// A length that is not a number from 0 to [`MAX_DASH_LENGTH`].
|
||||
OutOfRange,
|
||||
/// Lengths that are all 0.
|
||||
AllZero,
|
||||
}
|
||||
|
||||
/// What is wrong with the dash and gap lengths `lengths`, which `appearance.setNewArt` and the
|
||||
/// scripts' `strokeDashes` and `defaultStrokeDashes` check the same way; `None` when they are good.
|
||||
/// An empty list (a solid line) is good.
|
||||
pub(crate) fn dash_fault(lengths: &[f64]) -> Option<DashFault> {
|
||||
if lengths.len() > MAX_DASHES {
|
||||
Some(DashFault::TooMany)
|
||||
} else if !lengths.iter().all(|n| n.is_finite() && (0.0..=MAX_DASH_LENGTH).contains(n)) {
|
||||
Some(DashFault::OutOfRange)
|
||||
} else if !lengths.is_empty() && lengths.iter().all(|n| *n == 0.0) {
|
||||
Some(DashFault::AllZero)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// `c` as `appearance.setNewArt` stores it without `keepModel`: an RGB color in the color mode of
|
||||
/// the document in front.
|
||||
pub(crate) fn stored_color(s: &Session, c: vectorcraft_color::Color) -> vectorcraft_color::Color {
|
||||
super::paint::new_color(s, &json!({}), c)
|
||||
}
|
||||
|
||||
/// `appearance.setNewArt`: new art's fill, stroke and stroke options, every value checked before
|
||||
/// anything changes.
|
||||
fn set_new_art(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "appearance.setNewArt";
|
||||
let paint = |key: &str, fill: bool| -> Result<Option<Paint>> {
|
||||
let Some(v) = p.get(key) else { return Ok(None) };
|
||||
if !v.is_object() {
|
||||
return Err(bad(C, format!("{key} must be a paint object (color, none, swatch or gradient), got {v}")));
|
||||
}
|
||||
if let Some(k) = v.as_object().and_then(|o| o.keys().find(|k| !PAINT_KEYS.contains(&k.as_str()))) {
|
||||
return Err(bad(C, format!("{key}: unknown setting `{k}` (a paint takes {})", PAINT_KEYS.join(", "))));
|
||||
}
|
||||
if v.get("swatch").is_some_and(|w| !w.is_string()) {
|
||||
return Err(bad(C, format!("{key}: `swatch` must be a swatch name")));
|
||||
}
|
||||
let pattern_only = |name: &str| s.doc().is_ok_and(|st| st.doc.swatch(name).is_none() && st.doc.pattern(name).is_some());
|
||||
if v.get("tint").is_some() && v.get("swatch").and_then(Value::as_str).is_none_or(pattern_only) {
|
||||
return Err(bad(C, format!("{key}: `tint` goes with a global or spot `swatch`")));
|
||||
}
|
||||
let given = super::paint::paint_from(s, v)?.ok_or_else(|| bad(C, format!("{key}: give color, none, swatch or gradient")))?;
|
||||
if !fill && matches!(&given, Paint::Gradient(g) if g.gradient.dither) && v.get("swatch").and_then(Value::as_str).is_none() {
|
||||
return Err(bad(C, "`dither` applies to gradient fills"));
|
||||
}
|
||||
Ok(Some(unplaced(&given)))
|
||||
};
|
||||
let (fill, stroke) = (paint("fill", true)?, paint("stroke", false)?);
|
||||
let number = |key: &str, min: f64, max: f64| -> Result<()> {
|
||||
match p.get(key) {
|
||||
None => Ok(()),
|
||||
Some(v) if v.as_f64().is_some_and(|n| n.is_finite() && (min..=max).contains(&n)) => Ok(()),
|
||||
Some(v) => Err(bad(C, format!("{key} must be a number from {min} to {max}, got {v}"))),
|
||||
}
|
||||
};
|
||||
number("weight", 0.0, 1000.0)?;
|
||||
number("miterLimit", 1.0, 500.0)?;
|
||||
number("dashOffset", -MAX_DASH_LENGTH, MAX_DASH_LENGTH)?;
|
||||
for key in ["cap", "join"] {
|
||||
if p.get(key).is_some_and(|v| !v.is_string()) {
|
||||
return Err(bad(C, format!("{key} must be a name")));
|
||||
}
|
||||
}
|
||||
match p.get("dash") {
|
||||
None | Some(Value::Null) => {}
|
||||
Some(Value::Array(a)) if a.len() > MAX_DASHES => return Err(bad(C, format!("dash takes at most {MAX_DASHES} lengths"))),
|
||||
Some(Value::Array(a)) => {
|
||||
let lengths: Option<Vec<f64>> = a.iter().map(Value::as_f64).collect();
|
||||
match lengths.map_or(Some(DashFault::OutOfRange), |l| dash_fault(&l)) {
|
||||
None => {}
|
||||
Some(DashFault::TooMany) => return Err(bad(C, format!("dash takes at most {MAX_DASHES} lengths"))),
|
||||
Some(DashFault::OutOfRange) => return Err(bad(C, format!("each dash length must be a number from 0 to {MAX_DASH_LENGTH}"))),
|
||||
Some(DashFault::AllZero) => return Err(bad(C, "dash needs a length that is not 0")),
|
||||
}
|
||||
}
|
||||
Some(v) => return Err(bad(C, format!("dash must be a list of lengths or null, got {v}"))),
|
||||
}
|
||||
let flag = |key: &str| -> Result<Option<bool>> {
|
||||
p.get(key).map(|v| v.as_bool().ok_or_else(|| bad(C, format!("{key} must be true or false, got {v}")))).transpose()
|
||||
};
|
||||
let (fill_overprint, stroke_overprint) = (flag("fillOverprint")?, flag("strokeOverprint")?);
|
||||
let options: serde_json::Map<String, Value> =
|
||||
["weight", "cap", "join", "miterLimit", "dash", "dashOffset"].iter().filter_map(|k| Some((k.to_string(), p.get(*k)?.clone()))).collect();
|
||||
let change = super::stroke::StrokeChange::parse(&Value::Object(options), C)?;
|
||||
let dashed = match p.get("dash") {
|
||||
Some(Value::Array(a)) => !a.is_empty(),
|
||||
Some(_) => false,
|
||||
None => s.new_art().stroke().is_some_and(|st| st.dash.is_some()),
|
||||
};
|
||||
if p.get("dashOffset").and_then(Value::as_f64).is_some_and(|o| o != 0.0) && !dashed {
|
||||
return Err(bad(C, "dashOffset needs a dash pattern"));
|
||||
}
|
||||
let nothing = fill.is_none() && stroke.is_none() && change.is_empty() && fill_overprint.is_none() && stroke_overprint.is_none();
|
||||
if !nothing
|
||||
&& !s.prefs.new_art_basic
|
||||
&& !(s.tool_paints(false) && s.tool_paints(true))
|
||||
&& s.active().is_some_and(|st| !st.selection.subjects().is_empty())
|
||||
{
|
||||
return Err(bad(
|
||||
C,
|
||||
"with New Art Has Basic Appearance off, new art takes the selected object's appearance: deselect it or turn the option on",
|
||||
));
|
||||
}
|
||||
let look = |s: &Session| {
|
||||
let (opacity, blend, style) = s.new_art_transparency();
|
||||
(s.new_art(), opacity, blend, style.map(str::to_string))
|
||||
};
|
||||
let (before, was) = (s.paint.clone(), look(s));
|
||||
if let Some(f) = fill {
|
||||
s.paint.fill = f;
|
||||
}
|
||||
if let Some(st) = stroke {
|
||||
if !st.is_none() && s.paint.stroke.is_none() && s.paint.stroke_width == 0.0 {
|
||||
s.paint.stroke_width = 1.0;
|
||||
}
|
||||
s.paint.stroke = st;
|
||||
}
|
||||
if let Some(w) = change.weight {
|
||||
s.paint.stroke_width = w;
|
||||
}
|
||||
if !change.is_empty()
|
||||
&& let Some(st) = s.new_art_stroke_mut()
|
||||
{
|
||||
change.apply(st);
|
||||
}
|
||||
if let Some(on) = fill_overprint {
|
||||
let t = s.new_art_template_mut();
|
||||
if t.fill().is_none() {
|
||||
t.items.insert(0, AppearanceItem::Fill(FillLayer::new(Paint::None)));
|
||||
}
|
||||
if let Some(f) = t.fill_mut() {
|
||||
f.overprint = on;
|
||||
}
|
||||
}
|
||||
if let Some(on) = stroke_overprint
|
||||
&& let Some(st) = s.new_art_stroke_mut()
|
||||
{
|
||||
st.overprint = on;
|
||||
}
|
||||
let changed = look(s) != was;
|
||||
if !changed {
|
||||
s.paint = before;
|
||||
}
|
||||
Ok(json!({ "changed": changed }))
|
||||
}
|
||||
|
||||
/// `t` reduced to a basic appearance: an empty fill under its top stroke (options kept, without
|
||||
/// its own transparency or effects).
|
||||
fn basic_of(t: &Appearance) -> Appearance {
|
||||
|
||||
@@ -180,8 +180,9 @@ pub struct DocSettings {
|
||||
pub layout: ArtboardLayout,
|
||||
/// Columns of a grid layout.
|
||||
pub columns: u32,
|
||||
/// Rows of a grid by column, in place of `columns` when more than 0.
|
||||
#[serde(skip_serializing_if = "is_zero")]
|
||||
/// Rows of a grid by column, in place of `columns` when more than 0, up to `MAX_ARTBOARDS` (a
|
||||
/// saved or Recent preset's larger value is read as `MAX_ARTBOARDS`).
|
||||
#[serde(skip_serializing_if = "is_zero", deserialize_with = "de_rows")]
|
||||
pub rows: u32,
|
||||
/// Space between artboards, points: 0 to `MAX_SPACING` (a saved or Recent preset's value
|
||||
/// outside that range is read as the nearer end).
|
||||
@@ -380,12 +381,25 @@ impl DocSettings {
|
||||
return Ok(());
|
||||
}
|
||||
let o = l.as_object().ok_or_else(|| bad(cmd, "artboardLayout must be {layout?, columns?, spacing?, rightToLeft?}"))?;
|
||||
let count = |v: &Value| v.as_f64().filter(|c| c.is_finite() && *c >= 1.0).map(|c| c.round().min(MAX_ARTBOARDS as f64) as u32);
|
||||
for (k, v) in o {
|
||||
match k.as_str() {
|
||||
"layout" => self.layout = v.as_str().and_then(ArtboardLayout::parse).ok_or_else(bad_layout)?,
|
||||
"columns" => self.columns = count(v).ok_or_else(|| bad(cmd, "artboardLayout.columns must be 1 or more"))?,
|
||||
"rows" => self.rows = count(v).ok_or_else(|| bad(cmd, "artboardLayout.rows must be 1 or more"))?,
|
||||
"columns" => {
|
||||
self.columns = v
|
||||
.as_f64()
|
||||
.filter(|c| c.is_finite() && *c >= 1.0)
|
||||
.ok_or_else(|| bad(cmd, "artboardLayout.columns must be 1 or more"))?
|
||||
.round()
|
||||
.min(MAX_ARTBOARDS as f64) as u32
|
||||
}
|
||||
"rows" => {
|
||||
self.rows = v
|
||||
.as_f64()
|
||||
.map(f64::round)
|
||||
.filter(|r| (1.0..=MAX_ARTBOARDS as f64).contains(r))
|
||||
.map(|r| r as u32)
|
||||
.ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be from 1 to {MAX_ARTBOARDS}")))?
|
||||
}
|
||||
"spacing" => {
|
||||
self.spacing = v
|
||||
.as_f64()
|
||||
@@ -590,6 +604,12 @@ fn de_artboards<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<u
|
||||
Ok(f64::deserialize(d)?.round().clamp(1.0, MAX_ARTBOARDS as f64) as u32)
|
||||
}
|
||||
|
||||
/// A saved or Recent preset's grid rows, kept to at most [`MAX_ARTBOARDS`]; 0 (columns in their
|
||||
/// place) stays 0.
|
||||
fn de_rows<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<u32, D::Error> {
|
||||
Ok(u32::deserialize(d)?.min(MAX_ARTBOARDS))
|
||||
}
|
||||
|
||||
/// A saved or Recent preset's artboard spacing, kept to 0 to [`MAX_SPACING`] points.
|
||||
fn de_spacing<'de, D: serde::Deserializer<'de>>(d: D) -> std::result::Result<f64, D::Error> {
|
||||
Ok(f64::deserialize(d)?.clamp(0.0, MAX_SPACING))
|
||||
|
||||
@@ -105,7 +105,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Transparency Info",
|
||||
[],
|
||||
None,
|
||||
"{id?|ids?} → {ids, opacity: 0..100, blend, isolate, knockout: \"on\"|\"off\"|\"neutral\", knockoutShape, editingMask, pageIsolatedBlending, pageKnockoutGroup} the Transparency panel's values for `ids`, the selection, or the object whose mask is being edited. A value is null where those objects differ (or there are none); editingMask is the id of the object whose mask is being edited, or null; the page values are the document's",
|
||||
"{id?|ids?} → {ids, opacity: 0..100, blend, isolate, knockout: \"on\"|\"off\"|\"neutral\", knockoutShape, editingMask, pageIsolatedBlending, pageKnockoutGroup} the Transparency panel's values for `ids`, the selection, or the object whose mask is being edited. A value is null where those objects differ (or there are none). Without ids or id, with an object of a dynamic symbol instance selected by Direct Selection, opacity and blend are that object's for this instance, as transparency.set changes them; editingMask is the id of the object whose mask is being edited, or null; the page values are the document's",
|
||||
has_doc,
|
||||
info
|
||||
),
|
||||
@@ -489,10 +489,16 @@ impl Session {
|
||||
|
||||
fn info(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let st = s.doc()?;
|
||||
let ids = transparency_targets(s, p)?;
|
||||
// The points `transparency.set` with the same `ids` (or none) fades.
|
||||
let points = if p.get("ids").is_none() && p.get("id").is_none() { s.mesh_points_picked() } else { super::paint::picked_mesh_points_of(s, &ids) };
|
||||
let i = TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points);
|
||||
// Without `ids` or `id`, the values `transparency.set` without them edits: those of the panel,
|
||||
// whose picked mesh points and selected dynamic symbol part take the opacity (and the part the
|
||||
// blend mode).
|
||||
let i = if p.get("ids").is_none() && p.get("id").is_none() {
|
||||
s.transparency_info()
|
||||
} else {
|
||||
let ids = transparency_targets(s, p)?;
|
||||
let points = super::paint::picked_mesh_points_of(s, &ids);
|
||||
TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points)
|
||||
};
|
||||
Ok(json!({
|
||||
"ids": i.ids.iter().map(|id| id.0).collect::<Vec<_>>(),
|
||||
"opacity": i.opacity,
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Set Anchors",
|
||||
[],
|
||||
None,
|
||||
"{id, subpaths: [{anchors: [{x,y,in?,out?}], closed}]} replace a path's geometry",
|
||||
"{id, subpaths: [{anchors: [{x,y,in?,out?,smooth?: bool (left out: smooth when both handles are pulled out and in line)}], closed}]} replace a path's geometry",
|
||||
has_doc,
|
||||
set_anchors
|
||||
),
|
||||
|
||||
@@ -105,6 +105,7 @@ pub(super) const ALLOWED: &[&str] = &[
|
||||
"appearance.removeItem",
|
||||
"appearance.setActiveItem",
|
||||
"appearance.setItem",
|
||||
"appearance.setNewArt",
|
||||
"appearance.showAllHidden",
|
||||
"appearance.targetContents",
|
||||
"appearance.transfer",
|
||||
|
||||
+162
-21
@@ -111,6 +111,13 @@ pub(super) fn after_command(h: &Host, before: Option<(u64, Vec<crate::doc::DataS
|
||||
variables::after_command(h, before);
|
||||
}
|
||||
|
||||
mod colors;
|
||||
mod defaults;
|
||||
mod paths;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use paths::POINT_LOOKS;
|
||||
|
||||
/// The error for a member read or called with no document open.
|
||||
pub const NO_ACTIVE_DOCUMENT: &str = "No active document";
|
||||
/// The error for an object that was deleted, or that came from an earlier run.
|
||||
@@ -161,14 +168,38 @@ const ARTBOARD_COORDS: &str = "CoordinateSystem.ARTBOARDCOORDINATESYSTEM";
|
||||
|
||||
/// What the object model keeps for one run: its coordinate system, the lists of page items and the
|
||||
/// answers of which objects are on a locked artboard for the last [`ITEM_LISTS`] documents read,
|
||||
/// each kept while its document is unchanged, whether a call's own savepoint ([`atomically`]) is
|
||||
/// open, the settings of each `DocumentPreset` the run made, with the size of the values they hold
|
||||
/// now and the most they may hold (the run's heap), and the `Variable` and `Dataset` objects it
|
||||
/// gave out.
|
||||
/// each kept while its document is unchanged, the lists of paths, the point changes of a path not
|
||||
/// written yet, how many times each path's points went stale and each path as the run last saw its
|
||||
/// points, whether a call's own savepoint ([`atomically`]) is open, the settings of each
|
||||
/// `DocumentPreset` the run made, with the size of the values they hold now and the most they may
|
||||
/// hold (the run's heap), and the `Variable` and `Dataset` objects it gave out.
|
||||
#[derive(Default)]
|
||||
pub(super) struct State {
|
||||
coords: Cell<Coords>,
|
||||
items: RefCell<Vec<ItemList>>,
|
||||
/// The last list of each document's paths ([`paths`]), kept while that document is unchanged.
|
||||
paths: RefCell<Vec<ItemList>>,
|
||||
/// A path and its subpaths with the point changes the run has made to it and not written yet
|
||||
/// ([`flush`]).
|
||||
pending: RefCell<Option<(Item, Vec<vectorcraft_geom::path::SubPath>)>>,
|
||||
/// The index of the first point of each subpath of the path whose points the run read last,
|
||||
/// and what they were counted from ([`paths`]).
|
||||
point_starts: RefCell<Option<(paths::Counted, Rc<Vec<usize>>)>>,
|
||||
/// How many times the points the run read of each path went stale, by document uid and path id
|
||||
/// ([`paths`]).
|
||||
point_cuts: RefCell<std::collections::HashMap<(u64, u64), u64>>,
|
||||
/// Each path whose points the run read, as the run last saw it, by document uid and then path
|
||||
/// id ([`paths`]).
|
||||
point_nodes: RefCell<std::collections::HashMap<u64, std::collections::HashMap<u64, Arc<crate::doc::Node>>>>,
|
||||
/// The path whose points the object model is writing with `path.setAnchors`, the only path
|
||||
/// that command changes ([`paths`]).
|
||||
one_path: Cell<Option<Item>>,
|
||||
/// Each document, by uid, as it was when the run last looked at all the paths in it whose
|
||||
/// points it read ([`paths`]).
|
||||
point_docs: RefCell<std::collections::HashMap<u64, Arc<Document>>>,
|
||||
/// The item the object model is changing ([`edit_item`]), whose points stay valid through the
|
||||
/// change.
|
||||
editing: Cell<Option<Item>>,
|
||||
locked: RefCell<Vec<LockedList>>,
|
||||
saving: Cell<bool>,
|
||||
text: text::TextState,
|
||||
@@ -223,6 +254,24 @@ fn atomically<T>(h: &Host, f: impl FnOnce(&Host) -> std::result::Result<T, HostE
|
||||
/// A document's uid, the document as it was, and the ids of its page items then.
|
||||
type ItemList = (u64, Arc<Document>, Rc<Vec<NodeId>>);
|
||||
|
||||
/// The most documents whose lists [`State`] keeps at once, the least recently listed going first.
|
||||
const KEPT_LISTS: usize = 8;
|
||||
|
||||
/// The list kept in `lists` for the document `st`, while that document is unchanged.
|
||||
fn kept_list(lists: &RefCell<Vec<ItemList>>, st: &DocState) -> Option<Rc<Vec<NodeId>>> {
|
||||
lists.borrow().iter().find(|(uid, doc, _)| *uid == st.uid && Arc::ptr_eq(doc, &st.doc)).map(|(_, _, ids)| ids.clone())
|
||||
}
|
||||
|
||||
/// Keeps `ids` in `lists` as the list of the document `st`, in place of the one it had.
|
||||
fn keep_list(lists: &RefCell<Vec<ItemList>>, st: &DocState, ids: &Rc<Vec<NodeId>>) {
|
||||
let mut l = lists.borrow_mut();
|
||||
l.retain(|(uid, ..)| *uid != st.uid);
|
||||
if l.len() >= KEPT_LISTS {
|
||||
l.remove(0);
|
||||
}
|
||||
l.push((st.uid, st.doc.clone(), ids.clone()));
|
||||
}
|
||||
|
||||
/// A document's uid, the document and its new art ([`Document::new_art`]) as they were, and for
|
||||
/// each object of a layer or sublayer asked about then, whether it was on a locked artboard.
|
||||
type LockedList = (u64, Arc<Document>, Arc<HashSet<NodeId>>, HashMap<NodeId, bool>);
|
||||
@@ -279,15 +328,40 @@ type Answer = std::result::Result<Data, HostError>;
|
||||
/// A member function: the run's host and the call's arguments, `this` first.
|
||||
type Member = fn(&Host, &[Data]) -> Answer;
|
||||
|
||||
/// A member function that first writes the point changes waiting in [`State`] ([`flush`]).
|
||||
fn function(link: &Link, f: Member) -> HostFunction {
|
||||
call(link, f, true)
|
||||
}
|
||||
|
||||
/// A member function of the points of a path, which reads and adds to the point changes waiting in
|
||||
/// [`State`] instead of writing them first.
|
||||
fn point_function(link: &Link, f: Member) -> HostFunction {
|
||||
call(link, f, false)
|
||||
}
|
||||
|
||||
fn call(link: &Link, f: Member, flushing: bool) -> HostFunction {
|
||||
let l = link.clone();
|
||||
Rc::new(move |a: Vec<Data>| {
|
||||
let h = current(&l)?;
|
||||
h.charge_call(16 + a.iter().map(data_size).sum::<u64>())?;
|
||||
if flushing {
|
||||
flush(&h)?;
|
||||
}
|
||||
f(&h, &a)
|
||||
})
|
||||
}
|
||||
|
||||
/// Writes the point changes of a path that wait in [`State`] with one command ([`paths::flush`]).
|
||||
pub(super) fn flush(h: &Host) -> std::result::Result<(), HostError> {
|
||||
paths::flush(h)
|
||||
}
|
||||
|
||||
/// Notes the changes a command made to the points of the paths the run has read
|
||||
/// ([`paths::see_all_points`]).
|
||||
pub(super) fn see_points(h: &Host) {
|
||||
paths::see_all_points(h)
|
||||
}
|
||||
|
||||
fn get(link: &Link, f: Member) -> HostMember {
|
||||
HostMember::Get(function(link, f))
|
||||
}
|
||||
@@ -300,6 +374,19 @@ fn method(link: &Link, f: Member) -> HostMember {
|
||||
HostMember::Method(function(link, f))
|
||||
}
|
||||
|
||||
/// [`get`], [`property`] and [`method`] for a member of the points of a path ([`point_function`]).
|
||||
fn point_get(link: &Link, f: Member) -> HostMember {
|
||||
HostMember::Get(point_function(link, f))
|
||||
}
|
||||
|
||||
fn point_property(link: &Link, g: Member, s: Member) -> HostMember {
|
||||
HostMember::Property { get: point_function(link, g), set: point_function(link, s) }
|
||||
}
|
||||
|
||||
fn point_method(link: &Link, f: Member) -> HostMember {
|
||||
HostMember::Method(point_function(link, f))
|
||||
}
|
||||
|
||||
/// A member of a class with what `reflect` tells of it.
|
||||
pub(super) type Described = (String, HostMember, MemberInfo);
|
||||
|
||||
@@ -315,8 +402,9 @@ pub(super) fn returns(data_type: &str, arguments: &[(&str, &str)]) -> MemberInfo
|
||||
}
|
||||
|
||||
/// A member the help pages list that is not available yet: reading or assigning it throws, after
|
||||
/// the check that a document, page item or text range `this` is still there. `hasOwnProperty` is
|
||||
/// false for it, so a script that checks for the member first skips it, and `reflect` leaves it out.
|
||||
/// the check that a document, page item, path point or text range `this` is still there.
|
||||
/// `hasOwnProperty` is false for it, so a script that checks for the member first skips it, and
|
||||
/// `reflect` leaves it out.
|
||||
pub(super) fn later(link: &Link, class: &'static str, name: &'static str) -> Described {
|
||||
let message = format!("{class}.{name} is not available yet");
|
||||
let l = link.clone();
|
||||
@@ -327,9 +415,12 @@ pub(super) fn later(link: &Link, class: &'static str, name: &'static str) -> Des
|
||||
"Document" => {
|
||||
doc_of(&h, arg(&a, 0), "Document")?;
|
||||
}
|
||||
"PageItem" | "TextFrame" => {
|
||||
"PageItem" | "PathItem" | "TextFrame" => {
|
||||
item_of(&h, arg(&a, 0))?;
|
||||
}
|
||||
"PathPoint" => {
|
||||
paths::this_point(&h, &a)?;
|
||||
}
|
||||
"TextRange" => {
|
||||
text::check_range(&h, arg(&a, 0))?;
|
||||
}
|
||||
@@ -656,6 +747,12 @@ fn restore_selection(h: &Host, doc: &Document, before: &crate::doc::Selection) -
|
||||
return Ok(());
|
||||
}
|
||||
let partial = |id: &NodeId| before.anchors.contains_key(id) || before.segments.contains_key(id);
|
||||
// Anchors and segments the change removed (a path opened or given fewer points) are left out.
|
||||
let left = |id: &NodeId, p: usize, test: &dyn Fn(&vectorcraft_geom::path::SubPath) -> bool| {
|
||||
doc.node(*id).and_then(|n| n.path_data()).is_some_and(|pd| pd.subpaths.get(p).is_some_and(test))
|
||||
};
|
||||
let anchor_left = |id: &NodeId, p: usize, k: usize| left(id, p, &|sp| k < sp.anchors.len());
|
||||
let segment_left = |id: &NodeId, p: usize, k: usize| left(id, p, &|sp| sp.has_segment(k, true));
|
||||
let kept: Vec<NodeId> = before.objects.iter().copied().filter(keep).collect();
|
||||
if kept.is_empty() {
|
||||
command(h, "select.none", &json!({}))?;
|
||||
@@ -668,7 +765,7 @@ fn restore_selection(h: &Host, doc: &Document, before: &crate::doc::Selection) -
|
||||
.iter()
|
||||
.map(|i| {
|
||||
let anchors: Vec<[usize; 2]> = match before.anchors.get(i) {
|
||||
Some(a) => a.iter().map(|(p, k)| [*p, *k]).collect(),
|
||||
Some(a) => a.iter().filter(|(p, k)| anchor_left(i, *p, *k)).map(|(p, k)| [*p, *k]).collect(),
|
||||
// A path with only segments selected gets them back below, with no anchors.
|
||||
None if before.segments.contains_key(i) => Vec::new(),
|
||||
None => doc.node(*i).and_then(|n| n.path_data()).map(|p| p.anchors().map(|(s, k, _)| [s, k]).collect()).unwrap_or_default(),
|
||||
@@ -679,7 +776,10 @@ fn restore_selection(h: &Host, doc: &Document, before: &crate::doc::Selection) -
|
||||
command(h, "select.anchorsMany", &json!({"items": items, "mode": "set"}))?;
|
||||
}
|
||||
for (i, segments) in before.segments.iter().filter(|(i, _)| keep(i)) {
|
||||
let segments: Vec<[usize; 2]> = segments.iter().map(|(p, k)| [*p, *k]).collect();
|
||||
let segments: Vec<[usize; 2]> = segments.iter().filter(|(p, k)| segment_left(i, *p, *k)).map(|(p, k)| [*p, *k]).collect();
|
||||
if segments.is_empty() {
|
||||
continue;
|
||||
}
|
||||
command(h, "select.segments", &json!({"id": i.0, "segments": segments, "mode": "add"}))?;
|
||||
}
|
||||
let guides: Vec<NodeId> = doc.ruler_guides().into_iter().filter_map(|g| g.id).collect();
|
||||
@@ -799,9 +899,15 @@ pub(super) fn after_kept_command(h: &Host) {
|
||||
text::styles::after_command(h);
|
||||
}
|
||||
|
||||
/// Runs `id` with `params` on the item's document, its selection kept.
|
||||
/// Runs `id` with `params` on the item's document, its selection kept, as one change: when the
|
||||
/// selection cannot be put back, the edit is undone too. The points the run read of the item's
|
||||
/// paths stay valid through the change ([`paths::see_all_points`]).
|
||||
fn edit_item(h: &Host, item: Item, id: &str, params: &Value) -> std::result::Result<Data, HostError> {
|
||||
on_doc(h, item.doc.uid, true, |h| command(h, id, params))
|
||||
paths::see_all_points(h);
|
||||
let kept = h.dom.editing.replace(Some(item));
|
||||
let r = atomically(h, |h| on_doc(h, item.doc.uid, true, |h| command(h, id, params)));
|
||||
h.dom.editing.set(kept);
|
||||
r
|
||||
}
|
||||
|
||||
/// Reads the document of `doc` with `f`.
|
||||
@@ -1208,6 +1314,22 @@ fn startup_preset(name: &str) -> Option<(Option<&'static str>, Option<&'static s
|
||||
})
|
||||
}
|
||||
|
||||
/// The `file.newPresets` fields `addDocument` gives `file.new`: those of the profile's first
|
||||
/// built-in preset with `presetSettings` over them.
|
||||
const BUILT_IN_SETTINGS: &[&str] = &[
|
||||
"width",
|
||||
"height",
|
||||
"units",
|
||||
"artboards",
|
||||
"artboardLayout",
|
||||
"bleed",
|
||||
"backgroundContents",
|
||||
"colorMode",
|
||||
"rasterEffectsPpi",
|
||||
"previewMode",
|
||||
"alignNewObjectsToPixelGrid",
|
||||
];
|
||||
|
||||
/// `documents.addDocument(startupPreset, presetSettings?, showOptionsDialog?)`: a new document from
|
||||
/// the New Document profile `startupPreset` names, with the settings `presetSettings` gives in
|
||||
/// place of the profile's.
|
||||
@@ -1254,15 +1376,25 @@ fn docs_add_document(h: &Host, a: &[Data]) -> Answer {
|
||||
Some(Data::Bool(true)) => return Err(HostError::Error(DIALOG_UNAVAILABLE.into())),
|
||||
Some(_) => return Err(HostError::Type("showOptionsDialog must be true or false".into())),
|
||||
}
|
||||
// The document starts from the first preset of the profile's category (Print: Letter).
|
||||
let first = profile.and_then(|n| crate::cmd::newdoc::category(&h.session.borrow(), n)?.into_iter().next());
|
||||
if let Some(first) = first {
|
||||
p.insert("preset".into(), json!(first.name));
|
||||
}
|
||||
p.insert("profile".into(), profile.map_or(Value::Null, |n| json!(n)));
|
||||
if let Some(m) = mode {
|
||||
p.entry("colorMode").or_insert_with(|| json!(m));
|
||||
}
|
||||
// The document starts from the first built-in preset of the profile's category (Print:
|
||||
// Letter) with `presetSettings` over it, given in full so that a saved preset of the same name
|
||||
// does not stand in for it. Settings the built-in preset refuses are an error.
|
||||
let first = profile.and_then(|n| crate::cmd::newdoc::category(&h.session.borrow(), n)?.into_iter().next());
|
||||
if let Some(first) = first {
|
||||
p.insert("preset".into(), json!(first.name));
|
||||
let full = first.with_params(&Value::Object(p.clone()), "file.new").map_err(|e| HostError::Error(e.to_string()))?;
|
||||
if let Value::Object(settings) = full.to_json() {
|
||||
for key in BUILT_IN_SETTINGS {
|
||||
if let Some(v) = settings.get(*key) {
|
||||
p.insert((*key).into(), v.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p.insert("profile".into(), profile.map_or(Value::Null, |n| json!(n)));
|
||||
// A profile whose file could not be read throws, and the document `file.new` made with the
|
||||
// defaults is put back, with the Recent sizes as they were.
|
||||
atomically(h, |h| {
|
||||
@@ -2681,6 +2813,7 @@ pub(super) fn install(realm: &mut Realm, link: &Link) -> std::result::Result<(),
|
||||
let blend_modes = BLEND_MODES.iter().map(|(m, _)| (m.to_string(), HostItem::Value(text(format!("BlendModes.{m}"))))).collect();
|
||||
realm.define_host_object("BlendModes", blend_modes)?;
|
||||
variables::define_enums(realm)?;
|
||||
paths::install_enums(realm)?;
|
||||
realm.define_host_classes(classes(link), vec![("app".into(), host_ref("Application", &[]))])?;
|
||||
let l = link;
|
||||
// The application's members a script may name without `app.`, assigned as `app.<member>` is.
|
||||
@@ -2778,17 +2911,17 @@ fn classes(link: &Link) -> Vec<HostClass> {
|
||||
returns("Array", &[("point", "Array"), ("source", "CoordinateSystem"), ("destination", "CoordinateSystem")]),
|
||||
),
|
||||
("pageItems", get(l, doc_page_items), MemberInfo { collection: true, ..typed("PageItems") }),
|
||||
("pathItems", get(l, paths::doc_path_items), MemberInfo { collection: true, ..typed("PathItems") }),
|
||||
("textFrames", text::doc_text_frames(l), MemberInfo { collection: true, ..typed("TextFrames") }),
|
||||
("stories", text::threads::doc_stories(l), MemberInfo { collection: true, ..typed("Stories") }),
|
||||
("selection", property(l, doc_selection, doc_set_selection), typed("*")),
|
||||
("views", get(l, doc_views), MemberInfo { collection: true, ..typed("Views") }),
|
||||
("toString", method(l, doc_to_string), returns("string", &[])),
|
||||
]);
|
||||
document.extend(defaults::document_members(l));
|
||||
document.extend(text::styles::doc_members(l));
|
||||
document.extend(
|
||||
["layers", "artboards", "pathItems", "groupItems", "swatches", "symbols", "activeLayer", "saveAs", "close"]
|
||||
.into_iter()
|
||||
.map(|m| later(l, "Document", m)),
|
||||
["layers", "artboards", "groupItems", "swatches", "symbols", "activeLayer", "saveAs", "close"].into_iter().map(|m| later(l, "Document", m)),
|
||||
);
|
||||
document.extend(variables::document_members(l));
|
||||
document.push(("tags".into(), get(l, tags::doc_tags), MemberInfo { collection: true, ..typed("Tags") }));
|
||||
@@ -2889,7 +3022,15 @@ fn classes(link: &Link) -> Vec<HostClass> {
|
||||
);
|
||||
page_item.extend(variables::page_item_members(l));
|
||||
classes.push(class("PageItem", None, page_item, None));
|
||||
classes.extend(ITEM_CLASSES.iter().filter(|c| **c != "TextFrame").map(|c| class(c, Some("PageItem"), variables::item_members(l, c), None)));
|
||||
classes.extend(ITEM_CLASSES.iter().filter(|c| **c != "TextFrame").map(|c| {
|
||||
let mut members = variables::item_members(l, c);
|
||||
if *c == "PathItem" {
|
||||
members.extend(paths::path_item_members(l));
|
||||
}
|
||||
class(c, Some("PageItem"), members, None)
|
||||
}));
|
||||
classes.extend(paths::classes(l));
|
||||
classes.extend(colors::classes(l));
|
||||
classes.extend(text::classes(l));
|
||||
classes.extend(variables::classes(l));
|
||||
classes.push(class(
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
//! The color classes of the script object model, as the help pages
|
||||
//! <https://ai-scripting.docsforadobe.dev/jsobjref/RGBColor/>,
|
||||
//! <https://ai-scripting.docsforadobe.dev/jsobjref/CMYKColor/>,
|
||||
//! <https://ai-scripting.docsforadobe.dev/jsobjref/GrayColor/>,
|
||||
//! <https://ai-scripting.docsforadobe.dev/jsobjref/LabColor/> and
|
||||
//! <https://ai-scripting.docsforadobe.dev/jsobjref/NoColor/> describe them.
|
||||
//!
|
||||
//! A color is plain data: `new RGBColor()` gives an object with `typename` and its components,
|
||||
//! which the script can change, and reading `fillColor` or `strokeColor` gives a new one each time.
|
||||
//! Components are checked when a color is assigned to an object, and a value out of range throws a
|
||||
//! `RangeError` with nothing changed.
|
||||
//!
|
||||
//! VectorCraft's own rules, which the help pages do not state: components left out count as 0;
|
||||
//! `new cmykColor()` is the same as `new CMYKColor()`; `LabColor.l` is 0 to 100 and `a` and `b`
|
||||
//! are -128 to 128. `GrayColor.gray` runs from 0 (black) to 100 (white), as the GrayColor page
|
||||
//! says. `GradientColor`, `SpotColor` and `PatternColor` can be read from an object but not
|
||||
//! assigned yet.
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use serde_json::Value;
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_js::{Data, HostClass, HostError, HostFunction};
|
||||
|
||||
use super::{Link, current, num, text};
|
||||
|
||||
/// The classes whose objects can be read from a fill or stroke but not assigned yet.
|
||||
const LATER: &[&str] = &["GradientColor", "SpotColor", "PatternColor"];
|
||||
|
||||
/// The components of each color class, with the value `new` gives them.
|
||||
const CLASSES: &[(&str, &[&str])] = &[
|
||||
("RGBColor", &["red", "green", "blue"]),
|
||||
("CMYKColor", &["cyan", "magenta", "yellow", "black"]),
|
||||
("GrayColor", &["gray"]),
|
||||
("LabColor", &["l", "a", "b"]),
|
||||
("NoColor", &[]),
|
||||
("GradientColor", &[]),
|
||||
("SpotColor", &["tint"]),
|
||||
("PatternColor", &[]),
|
||||
];
|
||||
|
||||
fn color_object(class: &str, values: &[(&str, f64)]) -> Data {
|
||||
let mut items = vec![("typename".to_string(), text(class))];
|
||||
items.extend(values.iter().map(|(k, v)| ((*k).to_string(), num(*v))));
|
||||
Data::Object(items)
|
||||
}
|
||||
|
||||
/// A component as the script sees it: `exact` rounded to the fewest decimals, from 4 to 9, that
|
||||
/// `back` turns into the stored `v` again, else `exact` itself, so that assigning a color read
|
||||
/// from an object gives that object the same color.
|
||||
fn shown_as(exact: f64, v: f32, back: impl Fn(f64) -> f32) -> f64 {
|
||||
let mut scale = 1e4;
|
||||
for _ in 4..=9 {
|
||||
let r = (exact * scale).round() / scale;
|
||||
if back(r) == v {
|
||||
return r;
|
||||
}
|
||||
scale *= 10.0;
|
||||
}
|
||||
exact
|
||||
}
|
||||
|
||||
/// A component stored as `v`, from 0 to 1, that the script sees times `scale`.
|
||||
fn shown(v: f32, scale: f64) -> f64 {
|
||||
shown_as(f64::from(v) * scale, v, |r| unit(r, scale))
|
||||
}
|
||||
|
||||
/// The color object for a solid color.
|
||||
fn of_color(c: &Color) -> Data {
|
||||
match *c {
|
||||
Color::Rgb { r, g, b } => color_object("RGBColor", &[("red", shown(r, 255.0)), ("green", shown(g, 255.0)), ("blue", shown(b, 255.0))]),
|
||||
Color::Cmyk { c, m, y, k } => color_object(
|
||||
"CMYKColor",
|
||||
&[("cyan", shown(c, 100.0)), ("magenta", shown(m, 100.0)), ("yellow", shown(y, 100.0)), ("black", shown(k, 100.0))],
|
||||
),
|
||||
Color::Gray { k } => color_object("GrayColor", &[("gray", shown_as((1.0 - f64::from(k)) * 100.0, k, |g| unit(100.0 - g, 100.0)))]),
|
||||
Color::Lab { l, a, b } => color_object("LabColor", &[("l", shown(l, 1.0)), ("a", shown(a, 1.0)), ("b", shown(b, 1.0))]),
|
||||
}
|
||||
}
|
||||
|
||||
/// What reading `fillColor` or `strokeColor` gives for `paint`: a new color object, a `SpotColor`
|
||||
/// with its `tint` for a color linked to a global or spot swatch.
|
||||
pub(super) fn of_paint(paint: &Paint) -> Data {
|
||||
match paint {
|
||||
Paint::None => color_object("NoColor", &[]),
|
||||
Paint::Solid { swatch: Some(_), tint, .. } => color_object("SpotColor", &[("tint", shown(*tint, 100.0))]),
|
||||
Paint::Solid { color, .. } => of_color(color),
|
||||
Paint::Gradient(_) => color_object("GradientColor", &[]),
|
||||
Paint::Pattern { .. } => color_object("PatternColor", &[]),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether assigning the color object `d`, read as `assigned`, leaves the paint `now` as it is: a
|
||||
/// `NoColor` on no paint, or on an unlinked color either a color equal to it once `store` makes
|
||||
/// it what the document stores, or the components reading `now` gives (a Gray value read back can
|
||||
/// stand for an ink amount that no Gray value names exactly).
|
||||
pub(super) fn unchanged(d: &Data, assigned: Option<Color>, now: &Paint, store: impl FnOnce(Color) -> Color) -> bool {
|
||||
match (assigned, now) {
|
||||
(None, Paint::None) => true,
|
||||
(Some(c), Paint::Solid { color, swatch: None, .. }) => store(c) == *color || shows(d, &of_color(color)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the color object `d` has the class and every component of `shown`.
|
||||
fn shows(d: &Data, shown: &Data) -> bool {
|
||||
let (Data::Object(a), Data::Object(b)) = (d, shown) else { return false };
|
||||
b.iter().all(|(k, v)| a.iter().any(|(n, w)| n == k && w == v))
|
||||
}
|
||||
|
||||
/// The component `key` of color object `o`, from `min` to `max` (0 when it is left out).
|
||||
fn component(o: &[(String, Data)], class: &str, key: &str, min: f64, max: f64) -> std::result::Result<f64, HostError> {
|
||||
match o.iter().find(|(k, _)| k == key).map(|(_, v)| v) {
|
||||
None | Some(Data::Undefined) => Ok(0.0),
|
||||
Some(Data::Number(n)) if n.is_finite() && (min..=max).contains(n) => Ok(*n),
|
||||
Some(Data::Number(_)) => Err(HostError::Range(format!("{class}.{key} must be from {min} to {max}"))),
|
||||
Some(_) => Err(HostError::Type(format!("{class}.{key} must be a number"))),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
fn unit(v: f64, scale: f64) -> f32 {
|
||||
(v / scale) as f32
|
||||
}
|
||||
|
||||
/// The color a script assigned, checked: `None` for a `NoColor`. `what` names the property.
|
||||
pub(super) fn assigned(d: &Data, what: &str) -> std::result::Result<Option<Color>, HostError> {
|
||||
let Data::Object(o) = d else { return Err(HostError::Type(format!("{what} must be a color object"))) };
|
||||
let class = match o.iter().find(|(k, _)| k == "typename").map(|(_, v)| v) {
|
||||
Some(Data::String(s)) => s.as_str(),
|
||||
_ => return Err(HostError::Type(format!("{what} must be a color object"))),
|
||||
};
|
||||
let c = |key: &str, min: f64, max: f64| component(o, class, key, min, max);
|
||||
Ok(Some(match class {
|
||||
"NoColor" => return Ok(None),
|
||||
"RGBColor" => {
|
||||
Color::Rgb { r: unit(c("red", 0.0, 255.0)?, 255.0), g: unit(c("green", 0.0, 255.0)?, 255.0), b: unit(c("blue", 0.0, 255.0)?, 255.0) }
|
||||
}
|
||||
"CMYKColor" => Color::Cmyk {
|
||||
c: unit(c("cyan", 0.0, 100.0)?, 100.0),
|
||||
m: unit(c("magenta", 0.0, 100.0)?, 100.0),
|
||||
y: unit(c("yellow", 0.0, 100.0)?, 100.0),
|
||||
k: unit(c("black", 0.0, 100.0)?, 100.0),
|
||||
},
|
||||
"GrayColor" => Color::Gray { k: unit(100.0 - c("gray", 0.0, 100.0)?, 100.0) },
|
||||
"LabColor" => Color::Lab { l: unit(c("l", 0.0, 100.0)?, 1.0), a: unit(c("a", -128.0, 128.0)?, 1.0), b: unit(c("b", -128.0, 128.0)?, 1.0) },
|
||||
l if LATER.contains(&l) => return Err(HostError::Error(format!("assigning a {l} is not available yet"))),
|
||||
_ => return Err(HostError::Type(format!("{what} must be a color object"))),
|
||||
}))
|
||||
}
|
||||
|
||||
/// `color` as `paint.setFill` and `paint.setStroke` take it.
|
||||
pub(super) fn param(color: &Color) -> Value {
|
||||
serde_json::to_value(color).unwrap_or(Value::Null)
|
||||
}
|
||||
|
||||
/// The constructors of the color classes, and `cmykColor`.
|
||||
pub(super) fn classes(link: &Link) -> Vec<HostClass> {
|
||||
let make = |name: &str, components: &'static [&'static str]| {
|
||||
let l = link.clone();
|
||||
let class = name.to_string();
|
||||
let f: HostFunction = Rc::new(move |_| {
|
||||
current(&l)?.charge_call(64)?;
|
||||
let zeros: Vec<(&str, f64)> = components.iter().map(|k| (*k, if *k == "tint" { 100.0 } else { 0.0 })).collect();
|
||||
Ok(color_object(&class, &zeros))
|
||||
});
|
||||
f
|
||||
};
|
||||
let mut out: Vec<HostClass> = CLASSES
|
||||
.iter()
|
||||
.map(|(name, components)| HostClass {
|
||||
name: (*name).into(),
|
||||
parent: None,
|
||||
members: Vec::new(),
|
||||
info: Vec::new(),
|
||||
index: None,
|
||||
construct: Some(make(name, components)),
|
||||
})
|
||||
.collect();
|
||||
out.push(HostClass {
|
||||
name: "cmykColor".into(),
|
||||
parent: None,
|
||||
members: Vec::new(),
|
||||
info: Vec::new(),
|
||||
index: None,
|
||||
construct: Some(make("CMYKColor", CLASSES[1].1)),
|
||||
});
|
||||
out
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
//! A document's default fill and stroke in the script object model, the `Document` members whose
|
||||
//! names start with `default` that the help page
|
||||
//! <https://ai-scripting.docsforadobe.dev/jsobjref/Document/> describes, and `scaleFactor`.
|
||||
//!
|
||||
//! The defaults are what the next object drawn gets ([`crate::Session::new_art`]), the same for
|
||||
//! every open document, as the help page says of these global settings. Reading one reads new
|
||||
//! art's top fill or stroke, and assigning one runs `appearance.setNewArt`, which leaves the
|
||||
//! selection, its art, the active proxy and the recent colors as they were. A value that changes
|
||||
//! nothing runs no command, and a bad value throws an error with nothing changed.
|
||||
//!
|
||||
//! VectorCraft's own rules, which the help page does not state:
|
||||
//! - A color is new art's fill or stroke itself: assigning a color also makes `defaultFilled` or
|
||||
//! `defaultStroked` true, and assigning a `NoColor` makes it false. `defaultFilled` or
|
||||
//! `defaultStroked` set to true with no default fill or stroke gives black.
|
||||
//! - An RGB color is stored in the color mode of the document in front, as `paint.setFill` stores
|
||||
//! it.
|
||||
//! - `defaultStrokeWidth` is 0 to 1000 points, a dash or gap 0 to 1,000,000 points (at most 64 of
|
||||
//! them, not all 0), and `defaultStrokeDashOffset` -1,000,000 to 1,000,000 points, which needs a
|
||||
//! dash pattern unless it is 0.
|
||||
//! - While New Art Has Basic Appearance is off and an object is selected, assigning a default
|
||||
//! throws an error, since new art then takes that object's appearance.
|
||||
//! - `scaleFactor` is 1: VectorCraft draws every document at its own size.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, LineCap, LineJoin};
|
||||
use vectorcraft_js::{Data, HostError, MemberInfo};
|
||||
|
||||
use super::paths::{CAPS, JOINS, MAX_STROKE_WIDTH, dash_lengths};
|
||||
use super::{Answer, Described, Host, Link, arg, boolean, colors, command, get, named, num, number, property, this_doc, typed};
|
||||
|
||||
/// New art's appearance, after the check that the document `this` names is still open.
|
||||
fn new_art(h: &Host, a: &[Data]) -> std::result::Result<Appearance, HostError> {
|
||||
this_doc(h, a)?;
|
||||
Ok(h.session.borrow().new_art())
|
||||
}
|
||||
|
||||
/// Runs `appearance.setNewArt` with `params`, unless `same`.
|
||||
fn set(h: &Host, same: bool, params: Value) -> Answer {
|
||||
if !same {
|
||||
command(h, "appearance.setNewArt", ¶ms)?;
|
||||
}
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
fn top_paint(ap: &Appearance, fill: bool) -> Paint {
|
||||
if fill { ap.fill_paint() } else { ap.stroke_paint() }
|
||||
}
|
||||
|
||||
fn default_color(h: &Host, a: &[Data], fill: bool) -> Answer {
|
||||
Ok(colors::of_paint(&top_paint(&new_art(h, a)?, fill)))
|
||||
}
|
||||
|
||||
fn set_default_color(h: &Host, a: &[Data], fill: bool) -> Answer {
|
||||
let what = if fill { "defaultFillColor" } else { "defaultStrokeColor" };
|
||||
let color = colors::assigned(arg(a, 1), what)?;
|
||||
let now = top_paint(&new_art(h, a)?, fill);
|
||||
let same = colors::unchanged(arg(a, 1), color, &now, |c| crate::cmd::newart::stored_color(&h.session.borrow(), c));
|
||||
let paint = match color {
|
||||
Some(c) => json!({"color": colors::param(&c)}),
|
||||
None => json!({"none": true}),
|
||||
};
|
||||
let key = if fill { "fill" } else { "stroke" };
|
||||
set(h, same, json!({ key: paint }))
|
||||
}
|
||||
|
||||
fn default_painted(h: &Host, a: &[Data], fill: bool) -> Answer {
|
||||
Ok(Data::Bool(!top_paint(&new_art(h, a)?, fill).is_none()))
|
||||
}
|
||||
|
||||
fn set_default_painted(h: &Host, a: &[Data], fill: bool) -> Answer {
|
||||
let on = boolean(arg(a, 1), if fill { "defaultFilled" } else { "defaultStroked" })?;
|
||||
let now = !top_paint(&new_art(h, a)?, fill).is_none();
|
||||
let paint = if on { json!({"color": colors::param(&Color::BLACK)}) } else { json!({"none": true}) };
|
||||
let key = if fill { "fill" } else { "stroke" };
|
||||
set(h, now == on, json!({ key: paint }))
|
||||
}
|
||||
|
||||
fn default_overprint(h: &Host, a: &[Data], fill: bool) -> Answer {
|
||||
let ap = new_art(h, a)?;
|
||||
Ok(Data::Bool(if fill { ap.fill().is_some_and(|f| f.overprint) } else { ap.stroke().is_some_and(|s| s.overprint) }))
|
||||
}
|
||||
|
||||
fn set_default_overprint(h: &Host, a: &[Data], fill: bool) -> Answer {
|
||||
let (key, what) = if fill { ("fillOverprint", "defaultFillOverprint") } else { ("strokeOverprint", "defaultStrokeOverprint") };
|
||||
let on = boolean(arg(a, 1), what)?;
|
||||
let now = default_overprint(h, a, fill)? == Data::Bool(on);
|
||||
set(h, now, json!({ key: on }))
|
||||
}
|
||||
|
||||
/// New art's top stroke option `f` reads, or `none` when new art has no stroke.
|
||||
fn stroke_option<T>(h: &Host, a: &[Data], none: T, f: impl FnOnce(&vectorcraft_doc::StrokeLayer) -> T) -> std::result::Result<T, HostError> {
|
||||
Ok(new_art(h, a)?.stroke().map_or(none, f))
|
||||
}
|
||||
|
||||
fn default_stroke_width(h: &Host, a: &[Data]) -> Answer {
|
||||
this_doc(h, a)?;
|
||||
Ok(num(h.session.borrow().paint.stroke_width))
|
||||
}
|
||||
|
||||
fn set_default_stroke_width(h: &Host, a: &[Data]) -> Answer {
|
||||
let w = number(arg(a, 1), "defaultStrokeWidth")?;
|
||||
if !(0.0..=MAX_STROKE_WIDTH).contains(&w) {
|
||||
return Err(HostError::Range("defaultStrokeWidth must be from 0 to 1000 points".into()));
|
||||
}
|
||||
this_doc(h, a)?;
|
||||
let now = h.session.borrow().paint.stroke_width;
|
||||
set(h, now == w, json!({"weight": w}))
|
||||
}
|
||||
|
||||
fn default_cap(h: &Host, a: &[Data]) -> Answer {
|
||||
let cap = stroke_option(h, a, LineCap::default(), |s| s.cap)?;
|
||||
Ok(Data::String(CAPS.iter().find(|c| c.0 == cap).map_or("StrokeCap.BUTTENDCAP", |c| c.1).into()))
|
||||
}
|
||||
|
||||
fn set_default_cap(h: &Host, a: &[Data]) -> Answer {
|
||||
let found = match arg(a, 1) {
|
||||
Data::String(s) => CAPS.iter().find(|c| c.1 == s),
|
||||
_ => None,
|
||||
};
|
||||
let Some(&(cap, _, name)) = found else { return Err(HostError::Type("defaultStrokeCap must be a StrokeCap value".into())) };
|
||||
let now = stroke_option(h, a, LineCap::default(), |s| s.cap)?;
|
||||
set(h, now == cap, json!({"cap": name}))
|
||||
}
|
||||
|
||||
fn default_join(h: &Host, a: &[Data]) -> Answer {
|
||||
let join = stroke_option(h, a, LineJoin::default(), |s| s.join)?;
|
||||
Ok(Data::String(JOINS.iter().find(|j| j.0 == join).map_or("StrokeJoin.MITERENDJOIN", |j| j.1).into()))
|
||||
}
|
||||
|
||||
fn set_default_join(h: &Host, a: &[Data]) -> Answer {
|
||||
let found = match arg(a, 1) {
|
||||
Data::String(s) => JOINS.iter().find(|j| j.1 == s),
|
||||
_ => None,
|
||||
};
|
||||
let Some(&(join, _, name)) = found else { return Err(HostError::Type("defaultStrokeJoin must be a StrokeJoin value".into())) };
|
||||
let now = stroke_option(h, a, LineJoin::default(), |s| s.join)?;
|
||||
set(h, now == join, json!({"join": name}))
|
||||
}
|
||||
|
||||
fn default_miter(h: &Host, a: &[Data]) -> Answer {
|
||||
Ok(num(stroke_option(h, a, 10.0, |s| s.miter_limit)?))
|
||||
}
|
||||
|
||||
fn set_default_miter(h: &Host, a: &[Data]) -> Answer {
|
||||
let v = number(arg(a, 1), "defaultStrokeMiterLimit")?;
|
||||
if !(1.0..=500.0).contains(&v) {
|
||||
return Err(HostError::Range("defaultStrokeMiterLimit must be from 1 to 500".into()));
|
||||
}
|
||||
let now = stroke_option(h, a, 10.0, |s| s.miter_limit)?;
|
||||
set(h, now == v, json!({"miterLimit": v}))
|
||||
}
|
||||
|
||||
fn dashes(h: &Host, a: &[Data]) -> std::result::Result<Vec<f64>, HostError> {
|
||||
stroke_option(h, a, Vec::new(), |s| s.dash.as_ref().map_or_else(Vec::new, |d| d.pattern.clone()))
|
||||
}
|
||||
|
||||
fn default_dashes(h: &Host, a: &[Data]) -> Answer {
|
||||
Ok(Data::Array(dashes(h, a)?.into_iter().map(num).collect()))
|
||||
}
|
||||
|
||||
fn set_default_dashes(h: &Host, a: &[Data]) -> Answer {
|
||||
let lengths = dash_lengths(arg(a, 1), "defaultStrokeDashes")?;
|
||||
let now = dashes(h, a)?;
|
||||
let dash = if lengths.is_empty() { Value::Null } else { json!(lengths) };
|
||||
set(h, now == lengths, json!({"dash": dash}))
|
||||
}
|
||||
|
||||
fn default_dash_offset(h: &Host, a: &[Data]) -> Answer {
|
||||
Ok(num(stroke_option(h, a, 0.0, |s| s.dash.as_ref().map_or(0.0, |d| d.offset))?))
|
||||
}
|
||||
|
||||
fn set_default_dash_offset(h: &Host, a: &[Data]) -> Answer {
|
||||
let v = number(arg(a, 1), "defaultStrokeDashOffset")?;
|
||||
if v.abs() > MAX_STROKE_WIDTH * 1000.0 {
|
||||
return Err(HostError::Range("defaultStrokeDashOffset must be from -1000000 to 1000000 points".into()));
|
||||
}
|
||||
if dashes(h, a)?.is_empty() && v != 0.0 {
|
||||
return Err(HostError::Error("defaultStrokeDashOffset needs defaultStrokeDashes first".into()));
|
||||
}
|
||||
let now = stroke_option(h, a, 0.0, |s| s.dash.as_ref().map_or(0.0, |d| d.offset))?;
|
||||
set(h, now == v, json!({"dashOffset": v}))
|
||||
}
|
||||
|
||||
fn scale_factor(h: &Host, a: &[Data]) -> Answer {
|
||||
this_doc(h, a)?;
|
||||
Ok(num(1.0))
|
||||
}
|
||||
|
||||
/// The `Document` members of this module.
|
||||
pub(super) fn document_members(l: &Link) -> Vec<Described> {
|
||||
named(vec![
|
||||
("defaultFillColor", property(l, |h, a| default_color(h, a, true), |h, a| set_default_color(h, a, true)), typed("Color")),
|
||||
("defaultFilled", property(l, |h, a| default_painted(h, a, true), |h, a| set_default_painted(h, a, true)), typed("boolean")),
|
||||
("defaultFillOverprint", property(l, |h, a| default_overprint(h, a, true), |h, a| set_default_overprint(h, a, true)), typed("boolean")),
|
||||
("defaultStrokeColor", property(l, |h, a| default_color(h, a, false), |h, a| set_default_color(h, a, false)), typed("Color")),
|
||||
("defaultStroked", property(l, |h, a| default_painted(h, a, false), |h, a| set_default_painted(h, a, false)), typed("boolean")),
|
||||
("defaultStrokeOverprint", property(l, |h, a| default_overprint(h, a, false), |h, a| set_default_overprint(h, a, false)), typed("boolean")),
|
||||
(
|
||||
"defaultStrokeWidth",
|
||||
property(l, default_stroke_width, set_default_stroke_width),
|
||||
MemberInfo { min: Some(0.0), max: Some(MAX_STROKE_WIDTH), ..typed("number") },
|
||||
),
|
||||
("defaultStrokeCap", property(l, default_cap, set_default_cap), typed("StrokeCap")),
|
||||
("defaultStrokeJoin", property(l, default_join, set_default_join), typed("StrokeJoin")),
|
||||
("defaultStrokeMiterLimit", property(l, default_miter, set_default_miter), typed("number")),
|
||||
("defaultStrokeDashes", property(l, default_dashes, set_default_dashes), typed("Array")),
|
||||
("defaultStrokeDashOffset", property(l, default_dash_offset, set_default_dash_offset), typed("number")),
|
||||
("scaleFactor", get(l, scale_factor), typed("number")),
|
||||
])
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1174,6 +1174,8 @@ struct Job {
|
||||
name: String,
|
||||
/// The file-access scope `script.run` came in, which every slice runs in.
|
||||
scope: crate::file_access::ScopeHandle,
|
||||
/// The script has ended, and the run waits for the person's growth answer before it is kept.
|
||||
finished: bool,
|
||||
}
|
||||
|
||||
/// The `Data` for a JSON value, within `limits`. When it does not fit, the error is the place in
|
||||
@@ -1402,6 +1404,8 @@ fn command(host: &Host, id: &str, params: &Value) -> std::result::Result<Data, H
|
||||
|
||||
/// [`command`], with the command's result as it gave it as well as the script's copy of it.
|
||||
fn command_value(host: &Host, id: &str, params: &Value) -> std::result::Result<(Data, Value), HostError> {
|
||||
// Point changes that wait in the object model are written before any command runs.
|
||||
dom::flush(host)?;
|
||||
let session = host.session.clone();
|
||||
let started = clock();
|
||||
let before = dom::before_command(host, id);
|
||||
@@ -1446,6 +1450,7 @@ fn command_value(host: &Host, id: &str, params: &Value) -> std::result::Result<(
|
||||
dom::after_command(host, before);
|
||||
// Style objects follow only a command that is kept.
|
||||
if crossed.is_ok() {
|
||||
dom::see_points(host);
|
||||
dom::after_kept_command(host);
|
||||
} else {
|
||||
session.borrow_mut().script_style_trail = StyleTrail::default();
|
||||
@@ -1517,6 +1522,7 @@ pub(crate) fn retained_style_lists(s: &Session) -> usize {
|
||||
/// A bounded snapshot of the active document, or `null` with none open. A snapshot past the limits
|
||||
/// of a crossing throws a `RangeError`.
|
||||
fn vc_document(host: &Host) -> std::result::Result<Data, HostError> {
|
||||
dom::flush(host)?;
|
||||
let s = host.session.borrow();
|
||||
let Some(st) = s.active() else { return Ok(Data::Null) };
|
||||
let ids: Vec<u64> = st.selection.objects.iter().take(1_000).map(|i| i.0).collect();
|
||||
@@ -2103,7 +2109,7 @@ impl Session {
|
||||
if h.waiting.replace(false) {
|
||||
h.continues.set(h.continues.get() + 1);
|
||||
h.allowance_objects.set(h.allowance_objects.get().saturating_add(growth_objects()));
|
||||
h.allowance_bytes.set(h.allowance_bytes.get().saturating_add(GROWTH_BYTES));
|
||||
h.allowance_bytes.set(h.allowance_bytes.get().saturating_add(growth_bytes()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2282,7 +2288,7 @@ impl Session {
|
||||
bytes_kept: Cell::new(0),
|
||||
bridge: Cell::new(0),
|
||||
allowance_objects: Cell::new(growth_objects()),
|
||||
allowance_bytes: Cell::new(GROWTH_BYTES),
|
||||
allowance_bytes: Cell::new(growth_bytes()),
|
||||
continues: Cell::new(0),
|
||||
waiting: Cell::new(false),
|
||||
log: RefCell::new(Vec::new()),
|
||||
@@ -2407,7 +2413,7 @@ impl Session {
|
||||
}
|
||||
let scope = crate::file_access::ScopeHandle::capture();
|
||||
let (run, line_name) = (host.run, host.name.clone());
|
||||
let job = Job { realm, host, link, engine, world: World::working(self), start_uids: open, name: name.clone(), scope };
|
||||
let job = Job { realm, host, link, engine, world: World::working(self), start_uids: open, name: name.clone(), scope, finished: false };
|
||||
let id = NEXT_JOB.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
JOBS.with(|jobs| jobs.borrow_mut().insert(id, job));
|
||||
self.script_key = Some(JobKey { id, run, name: line_name });
|
||||
@@ -2461,6 +2467,28 @@ impl Session {
|
||||
self.script_key = Some(key);
|
||||
return None;
|
||||
}
|
||||
// A run whose script ended past its growth allowance is kept once the person lets it go on,
|
||||
// and put back when they stop it.
|
||||
if job.finished {
|
||||
if self.script_stop.is_set() {
|
||||
let kind = LimitKind::Interrupted;
|
||||
let e =
|
||||
RunError { kind: RunErrorKind::Limit(kind), message: format!("limit reached: {kind:?}"), line: 0, column: 0, authored: false };
|
||||
return Some(self.script_failed(job, &e));
|
||||
}
|
||||
// One more allowance may still leave the growth past it: the person is asked again
|
||||
// while they may be, and past that the run ends unkept.
|
||||
if let Err(HostError::Abort(message)) = job.host.charge_growth(0, 0) {
|
||||
let e = RunError { kind: RunErrorKind::Limit(LimitKind::Host), message, line: 0, column: 0, authored: false };
|
||||
return Some(self.script_failed(job, &e));
|
||||
}
|
||||
if job.host.waiting.get() {
|
||||
JOBS.with(|jobs| jobs.borrow_mut().insert(key.id, job));
|
||||
self.script_key = Some(key);
|
||||
return None;
|
||||
}
|
||||
return Some(self.script_ended(job));
|
||||
}
|
||||
// A stop while a dialog waits ends the run there; the interpreter cannot go on from the call.
|
||||
if job.realm.waits() {
|
||||
let kind = LimitKind::Interrupted;
|
||||
@@ -2486,24 +2514,35 @@ impl Session {
|
||||
self.script_key = Some(key);
|
||||
None
|
||||
}
|
||||
Ok(Ok(Progress::Done(_))) if job.host.dialogs.unused() > 0 => {
|
||||
let n = job.host.dialogs.unused();
|
||||
let kind = LimitKind::Host;
|
||||
let message = if n == 1 {
|
||||
format!("`answers` has {n} answer the script did not use")
|
||||
} else {
|
||||
format!("`answers` has {n} answers the script did not use")
|
||||
};
|
||||
Some(self.script_failed(job, &RunError { kind: RunErrorKind::Limit(kind), message, line: 0, column: 0, authored: false }))
|
||||
}
|
||||
Ok(Ok(Progress::Done(_))) => {
|
||||
let r = self.script_commit(job);
|
||||
self.trim_histories();
|
||||
Some(r)
|
||||
// The point changes written as the script ended went past the growth allowance.
|
||||
Ok(Ok(Progress::Done(_))) if job.host.waiting.get() => {
|
||||
job.finished = true;
|
||||
JOBS.with(|jobs| jobs.borrow_mut().insert(key.id, job));
|
||||
self.script_key = Some(key);
|
||||
None
|
||||
}
|
||||
Ok(Ok(Progress::Done(_))) => Some(self.script_ended(job)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends the run whose script has ended: it fails when answers it was given went unused, and is
|
||||
/// kept otherwise.
|
||||
fn script_ended(&mut self, job: Job) -> Result<Value> {
|
||||
let n = job.host.dialogs.unused();
|
||||
if n > 0 {
|
||||
let kind = LimitKind::Host;
|
||||
let message = if n == 1 {
|
||||
format!("`answers` has {n} answer the script did not use")
|
||||
} else {
|
||||
format!("`answers` has {n} answers the script did not use")
|
||||
};
|
||||
return self.script_failed(job, &RunError { kind: RunErrorKind::Limit(kind), message, line: 0, column: 0, authored: false });
|
||||
}
|
||||
let r = self.script_commit(job);
|
||||
self.trim_histories();
|
||||
r
|
||||
}
|
||||
|
||||
fn script_failed(&mut self, job: Job, e: &RunError) -> Result<Value> {
|
||||
job.host.dialogs.stopped();
|
||||
job.host.disk.borrow_mut().picker = None;
|
||||
@@ -2823,6 +2862,7 @@ fn run_slice(s: &mut Session, job: &mut Job) -> std::result::Result<std::result:
|
||||
std::mem::swap(s, &mut *cell.borrow_mut());
|
||||
let scope = job.scope.clone();
|
||||
let realm = &mut job.realm;
|
||||
let host = &job.host;
|
||||
let started = clock();
|
||||
let r = scope.run(|| {
|
||||
guard::catch_panic(|| {
|
||||
@@ -2830,7 +2870,14 @@ fn run_slice(s: &mut Session, job: &mut Job) -> std::result::Result<std::result:
|
||||
if PANIC_IN_SLICE.with(Cell::get) {
|
||||
panic!("a slice failed");
|
||||
}
|
||||
realm.advance(SLICE_FUEL)
|
||||
// Point changes that still wait in the object model are written when the script ends. Between
|
||||
// slices the run's documents are put aside, so they can wait across slices.
|
||||
realm.advance(SLICE_FUEL).and_then(|progress| {
|
||||
if matches!(progress, Progress::Done(_)) {
|
||||
dom::flush(host).map_err(end_flush_error)?;
|
||||
}
|
||||
Ok(progress)
|
||||
})
|
||||
})
|
||||
});
|
||||
if let Some(started) = started {
|
||||
@@ -2844,6 +2891,17 @@ fn run_slice(s: &mut Session, job: &mut Job) -> std::result::Result<std::result:
|
||||
r
|
||||
}
|
||||
|
||||
/// The error that ends a run when the point changes waiting at the end of its script cannot be
|
||||
/// written.
|
||||
fn end_flush_error(e: HostError) -> RunError {
|
||||
let message = match e {
|
||||
HostError::Error(m) | HostError::Type(m) | HostError::Range(m) | HostError::Syntax(m) | HostError::Abort(m) => m,
|
||||
HostError::Marked { error, .. } => return end_flush_error(*error),
|
||||
HostError::Wait => "a host function waited for its result where the run cannot pause".into(),
|
||||
};
|
||||
RunError { kind: RunErrorKind::Limit(LimitKind::Host), message, line: 0, column: 0, authored: false }
|
||||
}
|
||||
|
||||
/// Tests: removes the session's running job while the session keeps its hold on it. → whether a
|
||||
/// job was removed.
|
||||
#[cfg(test)]
|
||||
@@ -2860,6 +2918,15 @@ fn growth_objects() -> u64 {
|
||||
GROWTH_OBJECTS
|
||||
}
|
||||
|
||||
/// The bytes of new document data a run may keep before it is asked to continue or stop.
|
||||
fn growth_bytes() -> u64 {
|
||||
#[cfg(test)]
|
||||
if let Some(n) = TEST_GROWTH_BYTES.with(Cell::get) {
|
||||
return n;
|
||||
}
|
||||
GROWTH_BYTES
|
||||
}
|
||||
|
||||
/// The data a run may pass to and from commands.
|
||||
fn bridge_bytes() -> u64 {
|
||||
#[cfg(test)]
|
||||
@@ -2886,6 +2953,8 @@ thread_local! {
|
||||
pub(crate) static PANIC_IN_SLICE: Cell<bool> = const { Cell::new(false) };
|
||||
/// Tests: the objects a run may add in place of [`GROWTH_OBJECTS`].
|
||||
pub(crate) static TEST_GROWTH: Cell<Option<u64>> = const { Cell::new(None) };
|
||||
/// Tests: the bytes a run may keep in place of [`GROWTH_BYTES`].
|
||||
pub(crate) static TEST_GROWTH_BYTES: Cell<Option<u64>> = const { Cell::new(None) };
|
||||
/// Tests: the data a run may pass to and from commands in place of [`MAX_BRIDGE_BYTES`].
|
||||
pub(crate) static TEST_BRIDGE_BYTES: Cell<Option<u64>> = const { Cell::new(None) };
|
||||
/// Tests: the heap of a named engine in place of [`ENGINE_HEAP_BYTES`].
|
||||
|
||||
@@ -180,6 +180,8 @@ mod script_console;
|
||||
mod script_dialogs;
|
||||
mod script_dollar;
|
||||
mod script_dom;
|
||||
mod script_dom_defaults;
|
||||
mod script_dom_paths;
|
||||
mod script_engines;
|
||||
mod script_folder;
|
||||
mod script_include;
|
||||
|
||||
@@ -3048,6 +3048,61 @@ fn symbol_export_type_defaults_to_movie_clip_and_round_trips() {
|
||||
assert!(s.execute("symbol.options", &json!({"name": "Renamed"})).is_err());
|
||||
}
|
||||
|
||||
/// `symbol.options` whose values are the ones the symbol already has changes neither the document
|
||||
/// nor its revision, and records no undo step.
|
||||
#[test]
|
||||
fn symbol_options_that_change_nothing_record_no_undo_step() {
|
||||
let mut s = session();
|
||||
make_symbol(&mut s);
|
||||
let state = |s: &Session| {
|
||||
let st = s.doc().unwrap();
|
||||
(st.doc.clone(), st.revision, st.history.undo.len())
|
||||
};
|
||||
let unchanged = [
|
||||
json!({"name": "Box", "newName": "Box"}),
|
||||
json!({"name": "Box", "newName": " Box "}),
|
||||
json!({"name": "Box", "registration": 4}),
|
||||
json!({"name": "Box", "exportType": "movieClip"}),
|
||||
json!({"name": "Box", "nineSlice": false}),
|
||||
json!({"name": "Box", "type": "static"}),
|
||||
json!({"name": "Box", "alignToPixelGrid": false}),
|
||||
json!({"name": "Box", "newName": "Box", "registration": 4, "exportType": "movieClip", "type": "static", "alignToPixelGrid": false}),
|
||||
];
|
||||
let before = state(&s);
|
||||
for p in &unchanged {
|
||||
assert_eq!(s.execute("symbol.options", p).unwrap()["name"], "Box");
|
||||
assert_eq!(state(&s), before, "{p} changes nothing");
|
||||
}
|
||||
s.execute("symbol.options", &json!({"name": "Box", "registration": 0, "exportType": "graphic", "type": "dynamic"})).unwrap();
|
||||
assert_eq!(undo_steps(&s), before.2 + 1, "changed options are one undo step");
|
||||
let before = state(&s);
|
||||
let r = s.execute("symbol.options", &json!({"name": "Box", "registration": 0, "exportType": "graphic", "type": "dynamic"})).unwrap();
|
||||
assert_eq!((r["registration"].clone(), r["exportType"].clone(), r["type"].clone()), (json!(0), json!("graphic"), json!("dynamic")));
|
||||
assert_eq!(state(&s), before, "setting the options again changes nothing");
|
||||
s.execute("symbol.options", &json!({"name": "Box", "newName": "Logo"})).unwrap();
|
||||
assert_eq!(undo_steps(&s), before.2 + 1, "a rename is one undo step");
|
||||
}
|
||||
|
||||
/// `symbol.replace` with the symbol the instances already show changes neither the document nor
|
||||
/// its revision, and records no undo step.
|
||||
#[test]
|
||||
fn symbol_replace_with_the_same_symbol_records_no_undo_step() {
|
||||
let mut s = session();
|
||||
let (inst, _, _) = make_symbol(&mut s);
|
||||
rect(&mut s, 0.0, 0.0, 20.0, 20.0);
|
||||
s.execute("symbol.new", &json!({"name": "Small"})).unwrap();
|
||||
let state = |s: &Session| {
|
||||
let st = s.doc().unwrap();
|
||||
(st.doc.clone(), st.revision, st.history.undo.len())
|
||||
};
|
||||
let before = state(&s);
|
||||
assert_eq!(s.execute("symbol.replace", &json!({"name": "Box", "ids": [inst.0]})).unwrap()["ids"], json!([inst.0]));
|
||||
assert_eq!(state(&s), before, "replacing an instance with its own symbol changes nothing");
|
||||
s.execute("symbol.replace", &json!({"name": "Small", "ids": [inst.0]})).unwrap();
|
||||
assert!(matches!(&node(&s, inst).kind, NodeKind::SymbolInstance { symbol, .. } if symbol == "Small"));
|
||||
assert_eq!(undo_steps(&s), before.2 + 1, "replacing it with another symbol is one undo step");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sprayer_command_creates_a_symbol_set_and_alt_removes() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -1184,6 +1184,28 @@ fn opacity_and_blend_on_a_picked_object_go_through_transparency_set() {
|
||||
assert!((node(&t, static_inst).opacity - 0.4).abs() < 1e-6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transparency_info_reports_the_picked_object_that_transparency_set_edits() {
|
||||
let mut s = session();
|
||||
let inst = pair(&mut s, "dynamic");
|
||||
s.execute("transparency.set", &json!({"ids": [inst.0], "opacity": 75, "blend": "screen", "isolate": true, "knockout": "on"})).unwrap();
|
||||
s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [1]})).unwrap();
|
||||
s.execute("transparency.set", &json!({"opacity": 50, "blend": "multiply"})).unwrap();
|
||||
let shown = |v: &Value| (v["ids"].clone(), v["opacity"].as_f64(), v["blend"].clone(), v["isolate"].clone(), v["knockout"].clone());
|
||||
// Without ids, the picked object's opacity and blend mode, and the instance's isolate and knockout.
|
||||
let info = s.execute("transparency.info", &json!({})).unwrap();
|
||||
assert_eq!(shown(&info), (json!([inst.0]), Some(50.0), json!("Multiply"), json!(true), json!("on")));
|
||||
let panel = s.transparency_info();
|
||||
assert_eq!((panel.opacity, panel.blend.map(vectorcraft_color::BlendMode::label)), (Some(50.0), Some("Multiply")));
|
||||
// The other object of the art draws as the symbol does.
|
||||
s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [0]})).unwrap();
|
||||
let info = s.execute("transparency.info", &json!({})).unwrap();
|
||||
assert_eq!(shown(&info), (json!([inst.0]), Some(100.0), json!("Normal"), json!(true), json!("on")));
|
||||
// With the instance's id, the instance itself, as transparency.set with that id edits it.
|
||||
let info = s.execute("transparency.info", &json!({"id": inst.0})).unwrap();
|
||||
assert_eq!(shown(&info), (json!([inst.0]), Some(75.0), json!("Screen"), json!(true), json!("on")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_part_refuses_hidden_and_locked_objects_of_the_art() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! The new-art template (M3.65): Stroke panel options and graphic styles chosen with nothing
|
||||
//! selected, New Art Has Basic Appearance and `paint.default`.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::{BlendMode, Paint};
|
||||
use vectorcraft_doc::{Appearance, Dash, LineCap, Node};
|
||||
@@ -377,3 +379,98 @@ fn fill_line_gives_a_new_line_the_current_fill() {
|
||||
assert_ne!(s.paint.fill, Paint::None);
|
||||
assert!(s.execute("shape.line", &json!({"x1": 0, "y1": 0, "x2": 1, "y2": 1, "fill": "yes"})).is_err());
|
||||
}
|
||||
|
||||
/// `appearance.setNewArt` sets what the next object gets while the selection keeps its own look.
|
||||
#[test]
|
||||
fn set_new_art_changes_the_next_object_and_not_the_selection() {
|
||||
let mut s = session();
|
||||
let picked = rect(&mut s, 20.0);
|
||||
run(&mut s, "select.set", json!({"ids": [picked.0]}));
|
||||
let (look, undo, recent, active) = (node(&s, picked).appearance, undo_len(&s), s.recent_colors.clone(), s.fill_active);
|
||||
let r = run(
|
||||
&mut s,
|
||||
"appearance.setNewArt",
|
||||
json!({"fill": {"color": "#ff0000"}, "stroke": {"none": true}, "weight": 4, "cap": "round", "dash": [3, 1], "dashOffset": 1, "fillOverprint": true}),
|
||||
);
|
||||
assert_eq!(r, json!({"changed": true}));
|
||||
assert_eq!(node(&s, picked).appearance, look, "the selected art kept its look");
|
||||
assert_eq!(s.doc().unwrap().selection.objects, vec![picked]);
|
||||
assert_eq!((undo_len(&s), &s.recent_colors, s.fill_active), (undo, &recent, active));
|
||||
run(&mut s, "select.none", json!({}));
|
||||
let id = rect(&mut s, 200.0);
|
||||
let ap = node(&s, id).appearance;
|
||||
let (fill, st) = (ap.fill().unwrap(), ap.stroke().unwrap());
|
||||
assert_eq!(fill.paint, Paint::solid(vectorcraft_color::Color::rgb(1.0, 0.0, 0.0)));
|
||||
assert!(fill.overprint);
|
||||
assert_eq!((st.paint.clone(), st.width, st.cap), (Paint::None, 4.0, LineCap::Round));
|
||||
assert_eq!(st.dash, Some(Dash { pattern: vec![3.0, 1.0], offset: 1.0, ..Default::default() }));
|
||||
// The same values again change nothing.
|
||||
assert_eq!(run(&mut s, "appearance.setNewArt", json!({"weight": 4, "cap": "round"})), json!({"changed": false}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_new_art_refuses_bad_values_with_nothing_changed() {
|
||||
let mut s = session();
|
||||
let before = s.paint.clone();
|
||||
for params in [
|
||||
json!({"weight": -1}),
|
||||
json!({"weight": 1001}),
|
||||
json!({"weight": "3"}),
|
||||
json!({"miterLimit": 0.5}),
|
||||
json!({"cap": "flat"}),
|
||||
json!({"join": 2}),
|
||||
json!({"dash": [0, 0]}),
|
||||
json!({"dash": [-1]}),
|
||||
json!({"dash": "4 2"}),
|
||||
json!({"dashOffset": 2}),
|
||||
json!({"fill": "#ff0000"}),
|
||||
json!({"fill": {}}),
|
||||
json!({"fill": {"color": "#ff0000"}, "weight": -1}),
|
||||
json!({"stroke": {"tint": 50, "color": "#000000"}}),
|
||||
json!({"fillOverprint": "yes"}),
|
||||
json!({"widht": 3}),
|
||||
// A setting a paint does not take, here or nested in it, is refused too.
|
||||
json!({"fill": {"color": "#ff0000", "opacity": 25}}),
|
||||
json!({"stroke": {"none": true, "weight": 2}}),
|
||||
] {
|
||||
assert!(s.execute("appearance.setNewArt", ¶ms).is_err(), "accepted {params}");
|
||||
assert_eq!(s.paint, before, "changed new art for {params}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_new_art_refuses_a_tint_on_a_pattern_without_a_swatch_entry() {
|
||||
let mut s = session();
|
||||
let id = rect(&mut s, 20.0);
|
||||
let name = run(&mut s, "object.pattern.make", json!({"ids": [id.0], "edit": false}))["name"].as_str().unwrap().to_string();
|
||||
run(&mut s, "select.none", json!({}));
|
||||
Arc::make_mut(&mut s.doc_mut().unwrap().doc).remove_swatch(&name);
|
||||
let before = s.paint.clone();
|
||||
assert!(s.execute("appearance.setNewArt", &json!({"fill": {"swatch": name, "tint": 50}})).is_err(), "accepted a tint on {name}");
|
||||
assert_eq!(s.paint, before);
|
||||
assert_eq!(run(&mut s, "appearance.setNewArt", json!({"fill": {"swatch": name}})), json!({"changed": true}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_new_art_refuses_a_swatch_that_is_not_a_name() {
|
||||
let mut s = session();
|
||||
let before = s.paint.clone();
|
||||
for p in [json!({"fill": {"swatch": 7, "color": "#ff0000"}}), json!({"stroke": {"swatch": null, "color": "#ff0000"}})] {
|
||||
assert!(s.execute("appearance.setNewArt", &p).is_err(), "accepted {p}");
|
||||
assert_eq!(s.paint, before, "{p} changed new art");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_new_art_refuses_while_new_art_takes_the_selected_look() {
|
||||
let mut s = session();
|
||||
let picked = rect(&mut s, 20.0);
|
||||
run(&mut s, "appearance.setNewArtBasic", json!({"on": false}));
|
||||
run(&mut s, "select.set", json!({"ids": [picked.0]}));
|
||||
let before = s.paint.clone();
|
||||
assert!(s.execute("appearance.setNewArt", &json!({"weight": 7})).is_err());
|
||||
assert_eq!(s.paint, before);
|
||||
run(&mut s, "select.none", json!({}));
|
||||
assert_eq!(run(&mut s, "appearance.setNewArt", json!({"weight": 7})), json!({"changed": true}));
|
||||
assert_eq!(s.new_art().stroke().unwrap().width, 7.0);
|
||||
}
|
||||
@@ -161,6 +161,8 @@ fn ppi_overprint_preview_and_bad_params() {
|
||||
json!({"artboardLayout": {"layout": "spiral"}}),
|
||||
json!({"artboardLayout": {"columns": 0}}),
|
||||
json!({"artboardLayout": {"rows": 0}}),
|
||||
json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0.4}}),
|
||||
json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1001}}),
|
||||
json!({"artboardLayout": {"tiles": 2}}),
|
||||
json!({"units": "furlongs"}),
|
||||
json!({"width": 160000, "artboards": 1000}),
|
||||
@@ -1212,3 +1214,11 @@ fn the_new_layer_takes_an_id_no_profile_art_has() {
|
||||
// Ids given out later skip the symbol's art too.
|
||||
assert!(d.peek_next_id() > d.layers[0].id.0 && d.peek_next_id() > next);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_saved_presets_rows_are_read_within_the_artboard_limit() {
|
||||
let rows = |n: u32| serde_json::from_value::<crate::cmd::newdoc::DocSettings>(json!({"rows": n})).unwrap().rows;
|
||||
assert_eq!(rows(1001), crate::cmd::newdoc::MAX_ARTBOARDS, "file.new takes the listed rows again");
|
||||
assert_eq!(rows(0), 0, "0 stays: columns in their place");
|
||||
assert_eq!(rows(12), 12, "more rows than artboards stay");
|
||||
}
|
||||
@@ -1017,7 +1017,7 @@ fn file_new_takes_the_rows_of_a_grid_by_column() {
|
||||
let (plain, spaced) = (plain.with_params(&to_row, "file.new").unwrap(), spaced.with_params(&to_row, "file.new").unwrap());
|
||||
assert_eq!(plain.grid_columns(), spaced.grid_columns());
|
||||
let e = s.execute("file.new", &json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0}})).unwrap_err().to_string();
|
||||
assert!(e.contains("rows must be 1 or more"), "{e}");
|
||||
assert!(e.contains("rows must be from 1 to 1000"), "{e}");
|
||||
for layout in ["gridByRow", "row", "column"] {
|
||||
let e = s.execute("file.new", &json!({"artboardLayout": {"layout": layout, "rows": 2}})).unwrap_err().to_string();
|
||||
assert!(e.contains("rows needs the gridByColumn layout"), "{layout}: {e}");
|
||||
@@ -1074,6 +1074,22 @@ fn an_edit_keeps_direct_selected_anchors() {
|
||||
assert!(s.journal.iter().any(|(id, _)| id == "select.anchorsMany"), "the journal holds the restore");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selecting_an_item_keeps_the_direct_selected_anchors_of_others() {
|
||||
let (mut s, a, b) = doc();
|
||||
s.execute("select.anchors", &json!({"id": a.0, "anchors": [[0, 1]], "mode": "set"})).unwrap();
|
||||
s.execute("select.add", &json!({"ids": [b.0]})).unwrap();
|
||||
let anchors = s.active().unwrap().selection.anchors.clone();
|
||||
assert!(anchors.contains_key(&a));
|
||||
// Lists start with the topmost object, so `b` is `pageItems[0]`.
|
||||
log(&mut s, "app.activeDocument.pageItems[0].selected = false;");
|
||||
let sel = &s.active().unwrap().selection;
|
||||
assert_eq!((sel.objects.clone(), sel.anchors.clone()), (vec![a], anchors.clone()));
|
||||
log(&mut s, "app.activeDocument.pageItems[0].selected = true;");
|
||||
let sel = &s.active().unwrap().selection;
|
||||
assert_eq!((sel.objects.clone(), sel.anchors.get(&a)), (vec![a, b], anchors.get(&a)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_edit_keeps_the_order_of_a_mixed_selection() {
|
||||
let (mut s, a, b) = doc();
|
||||
@@ -1259,9 +1275,11 @@ fn a_startup_preset_alone_gives_its_first_size() {
|
||||
#[test]
|
||||
fn page_item_members_not_built_yet_throw_on_read_and_assignment() {
|
||||
let (mut s, _, _) = doc();
|
||||
for source in
|
||||
["app.activeDocument.pageItems[0].isIsolated;", "app.activeDocument.pageItems[0].uuid = 'x';", "app.activeDocument.pageItems[0].rotate(5);"]
|
||||
{
|
||||
for source in [
|
||||
"app.activeDocument.pageItems[0].isIsolated;",
|
||||
"app.activeDocument.pageItems[0].uuid = 'x';",
|
||||
"app.activeDocument.pageItems[0].transform(5);",
|
||||
] {
|
||||
assert!(failure(&mut s, source).contains("is not available yet"), "{source}");
|
||||
}
|
||||
assert!(failure(&mut s, "app.activeDocument.layers = 1;").contains("Document.layers is not available yet"));
|
||||
@@ -1443,6 +1461,16 @@ fn note_is_the_attributes_note() {
|
||||
assert!(failure(&mut s, "app.activeDocument.pageItems[0].note = new Array(5000).join('n');").contains("too long"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_profile_starts_from_its_built_in_preset_and_not_a_saved_one_of_the_same_name() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.newPresets.save", &json!({"name": "Letter", "width": 100, "height": 50, "units": "Millimeters", "colorMode": "rgb"})).unwrap();
|
||||
let out = log(&mut s, "var d = app.documents.addDocument('Print'); vc.log([d.width, d.height, d.documentColorSpace]);");
|
||||
assert_eq!(out, vec![json!([612, 792, "DocumentColorSpace.CMYK"])]);
|
||||
let out = log(&mut s, "var p = new DocumentPreset(); p.width = 300; var d = app.documents.addDocument('Print', p); vc.log([d.width, d.height]);");
|
||||
assert_eq!(out, vec![json!([300, 792])], "presetSettings goes over the built-in preset");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn document_preset_applies_only_its_given_fields() {
|
||||
let mut s = Session::new();
|
||||
@@ -1477,6 +1505,17 @@ fn document_preset_applies_only_its_given_fields() {
|
||||
assert!(e.contains(part), "{source}: {e}");
|
||||
}
|
||||
assert_eq!(s.documents().len(), 2, "a refused preset makes no document");
|
||||
// A saved preset with the built-in preset's name does not make the refused settings fit.
|
||||
s.execute("file.newPresets.save", &json!({"name": "Letter", "artboardLayout": "column"})).unwrap();
|
||||
// With the layout unset, the built-in preset puts the five 1,000,000 pt artboards in one row,
|
||||
// which does not fit, while the saved preset would put them in one column.
|
||||
let e = failure(
|
||||
&mut s,
|
||||
"var p = new DocumentPreset(); p.width = 1000000; p.numArtboards = 5;\
|
||||
p.artboardLayout = undefined; p.artboardRowsOrCols = undefined; app.documents.addDocument('Print', p);",
|
||||
);
|
||||
assert!(e.contains("don't fit"), "{e}");
|
||||
assert_eq!(s.documents().len(), 2, "settings the built-in preset refuses make no document");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2149,7 +2188,7 @@ fn page_items_report_their_available_members_as_their_own() {
|
||||
vc.log([p.hasOwnProperty('opacity'), p.hasOwnProperty('typename'), p.hasOwnProperty('duplicate'),\
|
||||
Object.prototype.hasOwnProperty.call(p, 'name'), p.propertyIsEnumerable('opacity'), d.hasOwnProperty('selection'),\
|
||||
app.hasOwnProperty('activeDocument')]);\
|
||||
vc.log([p.hasOwnProperty('isIsolated'), p.hasOwnProperty('rotate'), d.hasOwnProperty('layers'),\
|
||||
vc.log([p.hasOwnProperty('isIsolated'), p.hasOwnProperty('transform'), d.hasOwnProperty('layers'),\
|
||||
p.hasOwnProperty('nosuch'), p.hasOwnProperty('hasOwnProperty'), p.hasOwnProperty('constructor')]);\
|
||||
vc.log([keys.indexOf('opacity') >= 0, keys.indexOf('typename') >= 0, keys.indexOf('duplicate'), keys.indexOf('isIsolated')]);",
|
||||
);
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
//! The script object model's document defaults for new art and `scaleFactor`.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::LineCap;
|
||||
|
||||
use crate::*;
|
||||
|
||||
fn run(s: &mut Session, source: &str) -> Result<Value> {
|
||||
s.execute("script.run", &json!({"source": source, "name": "t.js"}))
|
||||
}
|
||||
|
||||
/// What the run logged.
|
||||
fn log(s: &mut Session, source: &str) -> Vec<Value> {
|
||||
let r = run(s, source).unwrap_or_else(|e| panic!("{source}: {e}"));
|
||||
r["log"].as_array().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// A 400 × 300 pt document with one rectangle, selected.
|
||||
fn doc() -> (Session, NodeId) {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
let r = s.execute("shape.rectangle", &json!({"x": 10, "y": 20, "width": 30, "height": 40})).unwrap();
|
||||
let id = NodeId(r["id"].as_u64().unwrap());
|
||||
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
|
||||
(s, id)
|
||||
}
|
||||
|
||||
fn undo_steps(s: &Session) -> usize {
|
||||
s.active().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
fn node(s: &Session, id: NodeId) -> crate::doc::Node {
|
||||
s.active().unwrap().doc.node(id).unwrap().clone()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wider_default_stroke_goes_to_the_next_path_drawn() {
|
||||
let (mut s, picked) = doc();
|
||||
let (look, steps) = (node(&s, picked).appearance, undo_steps(&s));
|
||||
let wider = s.paint.stroke_width + 1.0;
|
||||
let r = run(&mut s, "var d = app.activeDocument; d.defaultStrokeWidth += 1; vc.log(d.defaultStrokeWidth);").unwrap();
|
||||
assert_eq!(r["log"][0].as_f64(), Some(wider));
|
||||
assert_eq!(undo_steps(&s), steps, "a default alone is no undo step");
|
||||
assert_eq!(node(&s, picked).appearance, look, "the selected path kept its stroke");
|
||||
assert_eq!(s.new_art().stroke().unwrap().width, wider);
|
||||
let out = log(&mut s, "var p = app.activeDocument.pathItems.rectangle(200, 100, 50, 50); vc.log(p.strokeWidth);");
|
||||
assert_eq!(out.iter().map(Value::as_f64).collect::<Vec<_>>(), vec![Some(wider)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bad_default_throws_and_changes_nothing() {
|
||||
let (mut s, _) = doc();
|
||||
let before = s.paint.clone();
|
||||
for (source, name) in [
|
||||
("app.activeDocument.defaultStrokeWidth = -1", "RangeError"),
|
||||
("app.activeDocument.defaultStrokeWidth = 1001", "RangeError"),
|
||||
("app.activeDocument.defaultStrokeWidth = 'wide'", "TypeError"),
|
||||
("app.activeDocument.defaultStrokeMiterLimit = 0", "RangeError"),
|
||||
("app.activeDocument.defaultStrokeCap = 'round'", "TypeError"),
|
||||
("app.activeDocument.defaultStrokeJoin = 1", "TypeError"),
|
||||
("app.activeDocument.defaultStrokeDashes = [0, 0]", "RangeError"),
|
||||
("app.activeDocument.defaultStrokeDashes = '4 2'", "TypeError"),
|
||||
("app.activeDocument.defaultStrokeDashOffset = 3", "Error"),
|
||||
("app.activeDocument.defaultFillColor = 5", "TypeError"),
|
||||
("var c = new RGBColor(); c.red = 300; app.activeDocument.defaultStrokeColor = c", "RangeError"),
|
||||
("app.activeDocument.defaultFilled = 1", "TypeError"),
|
||||
("app.activeDocument.defaultStrokeOverprint = 'yes'", "TypeError"),
|
||||
] {
|
||||
let out = log(&mut s, &format!("try {{ {source}; vc.log('ran'); }} catch (e) {{ vc.log(e.name); }}"));
|
||||
assert_eq!(out, vec![json!(name)], "{source}");
|
||||
assert_eq!(s.paint, before, "{source} changed new art");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_colors_and_flags_read_back_and_paint_the_next_path() {
|
||||
let (mut s, picked) = doc();
|
||||
let look = node(&s, picked).appearance;
|
||||
let out = log(
|
||||
&mut s,
|
||||
"var d = app.activeDocument, c = new RGBColor(); c.red = 255;\
|
||||
d.defaultFillColor = c; vc.log(d.defaultFillColor.typename); vc.log(d.defaultFillColor.red); vc.log(d.defaultFilled);\
|
||||
d.defaultStroked = false; vc.log(d.defaultStroked); vc.log(d.defaultStrokeColor.typename);\
|
||||
d.defaultStrokeColor = new GrayColor(); vc.log(d.defaultStroked);\
|
||||
d.defaultFillColor = new NoColor(); vc.log(d.defaultFilled); d.defaultFilled = true; vc.log(d.defaultFilled);\
|
||||
d.defaultFillColor = c;",
|
||||
);
|
||||
assert_eq!(out, vec![json!("RGBColor"), json!(255), json!(true), json!(false), json!("NoColor"), json!(true), json!(false), json!(true)]);
|
||||
assert_eq!(node(&s, picked).appearance, look);
|
||||
let id = NodeId(s.execute("shape.rectangle", &json!({"x": 200, "y": 20, "width": 30, "height": 40})).unwrap()["id"].as_u64().unwrap());
|
||||
let ap = node(&s, id).appearance;
|
||||
assert_eq!(ap.fill_paint(), Paint::solid(Color::rgb(1.0, 0.0, 0.0)));
|
||||
assert!(!ap.stroke_paint().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_stroke_options_read_back_and_a_same_value_runs_no_command() {
|
||||
let (mut s, _) = doc();
|
||||
let out = log(
|
||||
&mut s,
|
||||
"var d = app.activeDocument; d.defaultStrokeCap = StrokeCap.ROUNDENDCAP; d.defaultStrokeJoin = StrokeJoin.BEVELENDJOIN;\
|
||||
d.defaultStrokeMiterLimit = 7; d.defaultStrokeDashes = [6, 2]; d.defaultStrokeDashOffset = 1;\
|
||||
d.defaultStrokeOverprint = true; d.defaultFillOverprint = true;\
|
||||
vc.log([d.defaultStrokeCap, d.defaultStrokeJoin, d.defaultStrokeMiterLimit, d.defaultStrokeDashes, d.defaultStrokeDashOffset,\
|
||||
d.defaultStrokeOverprint, d.defaultFillOverprint]);",
|
||||
);
|
||||
assert_eq!(out, vec![json!(["StrokeCap.ROUNDENDCAP", "StrokeJoin.BEVELENDJOIN", 7, [6, 2], 1, true, true])]);
|
||||
let st = s.new_art().stroke().unwrap().clone();
|
||||
assert_eq!((st.cap, st.miter_limit, st.overprint), (LineCap::Round, 7.0, true));
|
||||
let r = run(
|
||||
&mut s,
|
||||
"var d = app.activeDocument; d.defaultStrokeCap = StrokeCap.ROUNDENDCAP; d.defaultStrokeMiterLimit = 7;\
|
||||
d.defaultStrokeDashes = [6, 2]; d.defaultStrokeOverprint = true; d.defaultStrokeWidth = d.defaultStrokeWidth;\
|
||||
d.defaultFillColor = d.defaultFillColor;",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(r["slowestCommands"], json!([]), "the same values run no command");
|
||||
// `{}` and `[]` give a solid line.
|
||||
assert_eq!(log(&mut s, "var d = app.activeDocument; d.defaultStrokeDashes = {}; vc.log(d.defaultStrokeDashes.length);"), vec![json!(0)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_slightly_different_number_reaches_new_art() {
|
||||
let (mut s, _) = doc();
|
||||
log(&mut s, "var d = app.activeDocument; d.defaultStrokeWidth = 1; d.defaultStrokeMiterLimit = 7; d.defaultStrokeDashes = [6, 2];");
|
||||
log(
|
||||
&mut s,
|
||||
"var d = app.activeDocument; d.defaultStrokeWidth = 1.0000000005; d.defaultStrokeMiterLimit = 7.0000000005;\
|
||||
d.defaultStrokeDashOffset = 0.0000000005;",
|
||||
);
|
||||
let st = s.new_art().stroke().unwrap().clone();
|
||||
assert_eq!(st.width, 1.000_000_000_5);
|
||||
assert_eq!(st.miter_limit, 7.000_000_000_5);
|
||||
assert_eq!(st.dash.map(|d| d.offset), Some(0.000_000_000_5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_rgb_default_in_a_cmyk_document_runs_no_command_the_second_time() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 300, "colorMode": "cmyk"})).unwrap();
|
||||
let set = "var d = app.activeDocument, c = new RGBColor(); c.red = 200; c.green = 40; c.blue = 90; d.defaultFillColor = c;";
|
||||
let first = run(&mut s, set).unwrap();
|
||||
assert_ne!(first["slowestCommands"], json!([]), "the first assignment changes new art");
|
||||
let again = run(&mut s, set).unwrap();
|
||||
assert_eq!(again["slowestCommands"], json!([]), "the same RGB value runs no command");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scale_factor_is_one_and_read_only() {
|
||||
let (mut s, _) = doc();
|
||||
let out = log(&mut s, "var d = app.activeDocument; vc.log(d.scaleFactor); d.scaleFactor = 4; vc.log(d.scaleFactor);");
|
||||
assert_eq!(out, vec![json!(1), json!(1)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn defaults_refuse_while_new_art_takes_the_selected_look() {
|
||||
let (mut s, _) = doc();
|
||||
s.execute("appearance.setNewArtBasic", &json!({"on": false})).unwrap();
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
s.execute("select.all", &json!({})).unwrap();
|
||||
let before = s.paint.clone();
|
||||
let out = log(
|
||||
&mut s,
|
||||
"try { app.activeDocument.defaultStrokeWidth = 9; } catch (e) { vc.log(e.message.indexOf('New Art Has Basic Appearance') >= 0); }",
|
||||
);
|
||||
assert_eq!(out, vec![json!(true)]);
|
||||
assert_eq!(s.paint, before);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,7 +5,7 @@ use std::cell::Cell;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::script::{PANIC_IN_SLICE, TEST_GROWTH, TEST_RESULT_BYTES};
|
||||
use crate::script::{PANIC_IN_SLICE, TEST_GROWTH, TEST_GROWTH_BYTES, TEST_RESULT_BYTES};
|
||||
use crate::*;
|
||||
|
||||
fn rect(x: i64) -> Value {
|
||||
@@ -1371,6 +1371,54 @@ fn a_person_can_let_a_growing_run_go_on_or_stop_it() {
|
||||
assert_eq!(state(&s), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn point_changes_written_as_the_script_ends_wait_for_the_growth_answer() {
|
||||
// The point change waits in the object model until the script ends.
|
||||
let source = "app.activeDocument.pathItems[0].pathPoints[0].anchor = [3, -4];";
|
||||
let mut s = two_docs();
|
||||
let start = s.documents()[1].doc.clone();
|
||||
assert_eq!(run(&mut s, source).unwrap()["ok"], true);
|
||||
let added = start.retained_bytes_each(&s.documents()[1].doc).1 as u64;
|
||||
assert!(added >= 3, "{added}");
|
||||
// The change goes past this allowance and stays within twice it.
|
||||
TEST_GROWTH_BYTES.with(|g| g.set(Some(added * 2 / 3)));
|
||||
let run_to_the_question = |s: &mut Session| {
|
||||
s.script_frames = true;
|
||||
run(s, source).unwrap();
|
||||
for _ in 0..1_000 {
|
||||
if s.script_waiting() {
|
||||
break;
|
||||
}
|
||||
assert!(s.script_pump().is_none());
|
||||
}
|
||||
assert!(s.script_waiting());
|
||||
assert!(s.script_pump().is_none());
|
||||
assert!(s.script_running());
|
||||
};
|
||||
let mut s = two_docs();
|
||||
let before = state(&s);
|
||||
let undo = s.documents()[1].history.undo.len();
|
||||
run_to_the_question(&mut s);
|
||||
assert_eq!(state(&s), before);
|
||||
s.script_continue();
|
||||
assert!(!s.script_waiting());
|
||||
let done = s.script_pump().expect("the run ends once it may go on");
|
||||
assert_eq!(done.unwrap()["ok"], true);
|
||||
assert_eq!(s.documents()[1].history.undo.len(), undo + 1);
|
||||
assert_ne!(state(&s), before);
|
||||
|
||||
let mut s = two_docs();
|
||||
let before = state(&s);
|
||||
run_to_the_question(&mut s);
|
||||
assert_eq!(s.execute("script.stop", &json!({})).unwrap()["stopped"], true);
|
||||
let ended = s.script_pump().expect("a stopped run ends");
|
||||
TEST_GROWTH_BYTES.with(|g| g.set(None));
|
||||
assert!(ended.is_err());
|
||||
assert_eq!(s.script_report().unwrap()["kind"], "stopped");
|
||||
assert!(!s.script_running());
|
||||
assert_eq!(state(&s), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_run_waiting_to_grow_stops_at_the_next_slice_once_its_work_is_canceled() {
|
||||
TEST_GROWTH.with(|g| g.set(Some(20)));
|
||||
|
||||
@@ -83,7 +83,8 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
"",
|
||||
"activeDocument activeDocument= app Application BlendModes CoordinateSystem Document DocumentArtboardLayout DocumentColorSpace \
|
||||
DocumentPreset DocumentPresetType DocumentPreviewMode DocumentRasterResolution DocumentTransparencyGrid documents \
|
||||
Documents ElementPlacement Layer PageItem PageItems RulerUnits ScreenMode selection selection= Tag Tags View Views \
|
||||
Documents ElementPlacement Layer PageItem PageItems PathItem PathItems PathPoint PathPointSelection PathPoints PointType \
|
||||
PolarityValues RulerUnits ScreenMode selection selection= StrokeCap StrokeJoin Tag Tags Transformation View Views \
|
||||
ZOrderMethod",
|
||||
),
|
||||
("Application.", "prototype"),
|
||||
@@ -107,8 +108,13 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
(
|
||||
"Document.prototype.",
|
||||
"activeLayer activeLayer= artboards artboards= characterStyles close close= constructor convertCoordinate \
|
||||
documentColorSpace groupItems groupItems= height layers layers= name pageItems paragraphStyles parent pathItems \
|
||||
pathItems= rulerOrigin rulerOrigin= rulerUnits saveAs saveAs= selection selection= stories swatches swatches= \
|
||||
defaultFillColor defaultFillColor= defaultFillOverprint defaultFillOverprint= defaultFilled defaultFilled= \
|
||||
defaultStrokeCap defaultStrokeCap= defaultStrokeColor defaultStrokeColor= defaultStrokeDashOffset \
|
||||
defaultStrokeDashOffset= defaultStrokeDashes defaultStrokeDashes= defaultStrokeJoin defaultStrokeJoin= \
|
||||
defaultStrokeMiterLimit defaultStrokeMiterLimit= defaultStrokeOverprint defaultStrokeOverprint= \
|
||||
defaultStrokeWidth defaultStrokeWidth= defaultStroked defaultStroked= documentColorSpace groupItems \
|
||||
groupItems= height layers layers= name pageItems paragraphStyles parent pathItems rulerOrigin \
|
||||
rulerOrigin= rulerUnits saveAs saveAs= scaleFactor selection selection= stories swatches swatches= \
|
||||
symbols symbols= tags textFrames toString typename views width",
|
||||
),
|
||||
("Views.", "prototype"),
|
||||
@@ -129,6 +135,25 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
transform= translate translate= typename uRL uRL= uuid uuid= visibilityVariable visibilityVariable= visibleBounds \
|
||||
width width= wrapInside wrapInside= wrapOffset wrapOffset= wrapped wrapped= zOrder zOrderPosition",
|
||||
),
|
||||
("PathItems.", "prototype"),
|
||||
("PathItems.prototype.", "add constructor ellipse getByName index length parent polygon rectangle removeAll roundedRectangle star typename"),
|
||||
("PathItem.", "prototype"),
|
||||
(
|
||||
"PathItem.prototype.",
|
||||
"area clipping closed closed= constructor evenodd evenodd= fillColor fillColor= fillOverprint fillOverprint= filled \
|
||||
filled= guides guides= length pathPoints polarity polarity= resize resolution resolution= rotate selectedPathPoints \
|
||||
setEntirePath strokeCap strokeCap= strokeColor strokeColor= strokeDashOffset strokeDashOffset= \
|
||||
strokeDashes strokeDashes= strokeJoin strokeJoin= strokeMiterLimit strokeMiterLimit= strokeOverprint strokeOverprint= \
|
||||
strokeWidth strokeWidth= stroked stroked= translate",
|
||||
),
|
||||
("PathPoints.", "prototype"),
|
||||
("PathPoints.prototype.", "add constructor index length parent removeAll typename"),
|
||||
("PathPoint.", "prototype"),
|
||||
(
|
||||
"PathPoint.prototype.",
|
||||
"anchor anchor= constructor leftDirection leftDirection= parent pointType pointType= remove rightDirection \
|
||||
rightDirection= selected selected= typename",
|
||||
),
|
||||
("Tags.", "prototype"),
|
||||
("Tags.prototype.", "add constructor getByName index length parent removeAll typename"),
|
||||
("Tag.", "prototype"),
|
||||
@@ -150,8 +175,14 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
TransparencyGridNone TransparencyGridOrange TransparencyGridPurple TransparencyGridRed",
|
||||
),
|
||||
("ElementPlacement.", "INSIDE PLACEAFTER PLACEATBEGINNING PLACEATEND PLACEBEFORE"),
|
||||
("PathPointSelection.", "ANCHORPOINT LEFTDIRECTION LEFTRIGHTPOINT NOSELECTION RIGHTDIRECTION"),
|
||||
("PointType.", "CORNER SMOOTH"),
|
||||
("PolarityValues.", "NEGATIVE POSITIVE"),
|
||||
("RulerUnits.", "Centimeters Inches Millimeters Picas Pixels Points Qs Unknown"),
|
||||
("ScreenMode.", "DESKTOP FULLSCREEN MULTIWINDOW"),
|
||||
("StrokeCap.", "BUTTENDCAP PROJECTINGENDCAP ROUNDENDCAP"),
|
||||
("StrokeJoin.", "BEVELENDJOIN MITERENDJOIN ROUNDENDJOIN"),
|
||||
("Transformation.", "BOTTOM BOTTOMLEFT BOTTOMRIGHT CENTER DOCUMENTORIGIN LEFT RIGHT TOP TOPLEFT TOPRIGHT"),
|
||||
("ZOrderMethod.", "BRINGFORWARD BRINGTOFRONT SENDBACKWARD SENDTOBACK"),
|
||||
(
|
||||
"",
|
||||
@@ -282,9 +313,11 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
("TextFrame.prototype.", "contentVariable contentVariable="),
|
||||
];
|
||||
|
||||
/// The classes the host adds with nothing but a prototype and its constructor: the page item types.
|
||||
const BARE_CLASSES: &str = "BlendItem CompoundPathItem EnvelopeItem GraphItem GroupItem IntertwineItem MeshItem PathItem \
|
||||
PlacedDocumentItem PlacedItem RasterItem RepeatItem SymbolItem";
|
||||
/// The classes the host adds with nothing but a prototype and its constructor: the page item types
|
||||
/// other than `PathItem`, and the color classes.
|
||||
const BARE_CLASSES: &str = "BlendItem CMYKColor CompoundPathItem EnvelopeItem GradientColor GraphItem GrayColor GroupItem \
|
||||
IntertwineItem LabColor MeshItem NoColor PatternColor PlacedDocumentItem PlacedItem RGBColor RasterItem RepeatItem SpotColor \
|
||||
SymbolItem cmykColor";
|
||||
|
||||
/// The name the checker does not read, which also stands for its members: `vc` is VectorCraft's
|
||||
/// own API, and what `vc.run` does depends on the command it runs.
|
||||
|
||||
@@ -25,8 +25,9 @@ use crate::{Action, Overlay, PointerEvent, ToolContext};
|
||||
pub const DIALOG: &str = "corners";
|
||||
|
||||
/// Widgets sit at least this far inside their corner along each side of a right angle (screen px;
|
||||
/// √2 times it along the bisector, at any angle), further in once the radius is.
|
||||
const MIN_INSET_PX: f64 = 10.0;
|
||||
/// √2 times it along the bisector, at any angle), further in once the radius is. The canvas draws the
|
||||
/// widgets at the framework's `CornerWidgets::INSET`, which the UI's tests hold equal to this value.
|
||||
pub const MIN_INSET_PX: f64 = 10.0;
|
||||
/// Corners with a side shorter than this on screen (px) hide their widgets.
|
||||
const MIN_SIDE_PX: f64 = 3.0 * MIN_INSET_PX;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use craft::ui::contract::Role;
|
||||
use serde_json::json;
|
||||
use vectorcraft_doc::NodeId;
|
||||
use vectorcraft_engine::Session;
|
||||
@@ -109,6 +110,58 @@ fn real_opacity_edits_drive_validation_confirmation_and_cancel() {
|
||||
assert!((opacity(&panel, a) - 0.8).abs() < 1e-6 && (opacity(&panel, b) - 0.8).abs() < 1e-6);
|
||||
}
|
||||
|
||||
/// The objects of the first layer, from the back.
|
||||
fn stacking(panel: &Harness) -> Vec<NodeId> {
|
||||
panel.app().session.doc().unwrap().doc.layers[0].children().unwrap().iter().map(|n| n.id).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_replace_edits_reach_the_preview_and_confirmed_copies() {
|
||||
let (app, a, b) = app();
|
||||
let mut panel = Harness::new(app, crate::tests::picks::dialogs);
|
||||
click(&mut panel.app(), "Replace with Top Object…");
|
||||
panel.frame();
|
||||
panel.click_role("Size", Role::COMBO_BOX);
|
||||
panel.click("Bounds");
|
||||
panel.click_role("Keep Original", Role::CHECK_BOX);
|
||||
panel.frame();
|
||||
let id = host::dialog_id(&panel.app());
|
||||
let fields = host::read(&panel.app(), id, |f| (f.text("fit").map(str::to_owned), f.bool("keep")));
|
||||
assert_eq!(fields, (Some("bounds".to_owned()), Some(true)));
|
||||
// The copies of the top object: every object other than the two rectangles, with its bounds.
|
||||
let copies = |panel: &Harness| {
|
||||
let ids: Vec<NodeId> = stacking(panel).into_iter().filter(|id| ![a, b].contains(id)).collect();
|
||||
let app = panel.app();
|
||||
ids.into_iter().map(|id| bounds(&app, id)).collect::<Vec<_>>()
|
||||
};
|
||||
let preview = copies(&panel);
|
||||
assert_eq!(preview, vec![bounds(&panel.app(), a)], "one copy, fitted to the kept original's bounds");
|
||||
panel.click("OK");
|
||||
panel.frame();
|
||||
assert_eq!(copies(&panel), preview);
|
||||
assert_eq!(stacking(&panel).len(), 3, "Keep Original leaves the original in place");
|
||||
assert!(!panel.app().any_dialog_open());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn real_sort_edits_reach_the_preview_and_confirmed_stacking() {
|
||||
let (app, a, b) = app();
|
||||
let mut panel = Harness::new(app, crate::tests::picks::dialogs);
|
||||
click(&mut panel.app(), "Sort Objects…");
|
||||
panel.frame();
|
||||
assert_eq!(stacking(&panel), vec![a, b], "the smaller area is already at the back");
|
||||
panel.click_role("Order", Role::COMBO_BOX);
|
||||
panel.click("Large to Small");
|
||||
panel.frame();
|
||||
let id = host::dialog_id(&panel.app());
|
||||
assert_eq!(host::read(&panel.app(), id, |f| f.text("order").map(str::to_owned)), Some("descending".to_owned()));
|
||||
assert_eq!(stacking(&panel), vec![b, a], "the preview puts the larger area at the back");
|
||||
panel.click("OK");
|
||||
panel.frame();
|
||||
assert_eq!(stacking(&panel), vec![b, a]);
|
||||
assert!(!panel.app().any_dialog_open());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_size_of_each_sets_the_sides_ticked() {
|
||||
let (mut app, a, b) = app();
|
||||
|
||||
@@ -80,11 +80,14 @@ pub(crate) fn rows() -> Vec<PanelRow> {
|
||||
}
|
||||
|
||||
/// Dims the Select row of each status no image or placed document has ([`enabled`]), in the states of
|
||||
/// the commands the Links panel's menu shows.
|
||||
/// the commands the Links panel's menu shows, and names each row and its Shift alternate for its status: the
|
||||
/// catalog's label for the command is Select by Link Status's.
|
||||
pub(crate) fn states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
for &(status, ..) in &STATUSES {
|
||||
for &(status, label, _) in &STATUSES {
|
||||
let params = json!({ "status": status });
|
||||
states.set(CommandRef::with_params(COMMAND, params.clone()), CommandState::new().enabled(enabled(app, ¶ms)));
|
||||
let state = CommandState::new().enabled(enabled(app, ¶ms)).title(crate::i18n::t(label));
|
||||
states.set(CommandRef::with_params(COMMAND, with_shift(params.clone())), state.clone());
|
||||
states.set(CommandRef::with_params(COMMAND, params), state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -178,14 +178,20 @@ fn menu_items_are_on_for_the_statuses_present_and_shift_adds() {
|
||||
{
|
||||
assert_eq!(item(label).enabled, on, "{label}");
|
||||
}
|
||||
// The Links panel's rows follow the statuses present, per status.
|
||||
let enabled_of = |app: &VectorcraftApp| {
|
||||
// The Links panel's rows follow the statuses present, per status, and each row and its Shift alternate is named
|
||||
// for its status.
|
||||
let enabled_of = |app: &VectorcraftApp, shift: bool| {
|
||||
let mut all = CommandStates::new();
|
||||
states(app, &mut all);
|
||||
STATUSES.map(|(status, ..)| all.get(&CommandRef::with_params(COMMAND, json!({ "status": status }))).cloned())
|
||||
STATUSES.map(|(status, ..)| {
|
||||
let p = json!({ "status": status });
|
||||
all.get(&CommandRef::with_params(COMMAND, if shift { with_shift(p) } else { p })).cloned()
|
||||
})
|
||||
};
|
||||
let on = Some(CommandState::new().enabled(true));
|
||||
assert_eq!(enabled_of(&app), [on.clone(), on.clone(), on.clone(), Some(CommandState::new().enabled(false))]);
|
||||
let named = |on: bool, label: &str| Some(CommandState::new().enabled(on).title(label));
|
||||
let want = [named(true, "Select Linked"), named(true, "Select Embedded"), named(true, "Select Missing"), named(false, "Select Modified")];
|
||||
assert_eq!(enabled_of(&app, false), want);
|
||||
assert_eq!(enabled_of(&app, true), want, "the Shift alternates");
|
||||
// The item's params run as the menu runs them: Shift's alternate is `with_shift` of them.
|
||||
let run = |app: &mut VectorcraftApp, status: &str, shift: bool| {
|
||||
let p = json!({ "status": status });
|
||||
@@ -207,9 +213,9 @@ fn menu_items_are_on_for_the_statuses_present_and_shift_adds() {
|
||||
app.run("select.set", json!({"ids": [harbour]})).unwrap();
|
||||
app.run("edit.clear", json!({})).unwrap();
|
||||
refresh(&mut app, 1.0);
|
||||
let after = enabled_of(&app);
|
||||
assert_eq!(after[2], Some(CommandState::new().enabled(false)), "no missing image is left");
|
||||
assert_eq!(after[1], on, "the embedded one stays");
|
||||
let after = enabled_of(&app, false);
|
||||
assert_eq!(after[2], named(false, "Select Missing"), "no missing image is left");
|
||||
assert_eq!(after[1], named(true, "Select Embedded"), "the embedded one stays");
|
||||
}
|
||||
|
||||
/// A missing link kept only in a symbol's art can't be selected: Select Missing stays off and
|
||||
|
||||
@@ -246,7 +246,6 @@ impl VectorcraftApp {
|
||||
three_d_dialog: None,
|
||||
three_d: Default::default(),
|
||||
export_dialogs: Default::default(),
|
||||
slice_dialogs: Default::default(),
|
||||
package_document: None,
|
||||
web_export: Default::default(),
|
||||
flattener_preview: Default::default(),
|
||||
|
||||
@@ -405,15 +405,12 @@ fn compass(app: &VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option<Can
|
||||
})
|
||||
}
|
||||
|
||||
/// `rect` without the strip the vertical scroll bar takes along its right edge (the bar's thickness and its margin,
|
||||
/// the sizes `CanvasScrollbars` draws with), in the screen modes that show the scroll bars.
|
||||
/// `rect` without the strips the scroll bars take, in the screen modes that show them ([`scroll_bars`]).
|
||||
fn clear_of_scroll_bars(app: &VectorcraftApp, ui: &Ui, rect: egui::Rect) -> egui::Rect {
|
||||
if app.ui.screen_mode >= 2 {
|
||||
return rect;
|
||||
}
|
||||
let env = Env::of(ui);
|
||||
let strip = env.tokens.size.icon.md + env.tokens.space.gap.tight;
|
||||
egui::Rect::from_min_max(rect.min, egui::pos2((rect.right() - strip).max(rect.left()), rect.bottom()))
|
||||
CanvasScrollbars::clear_of(ui, rect, false, false)
|
||||
}
|
||||
|
||||
/// The scroll bars along the right and bottom edges (Normal and Full Screen with Menu Bar): the view
|
||||
|
||||
@@ -38,20 +38,12 @@ fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>
|
||||
|
||||
/// [`frame`] on a window `size` points large.
|
||||
fn frame_in(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>, size: egui::Vec2) -> Vec<Shape> {
|
||||
fn flat(s: Shape, out: &mut Vec<Shape>) {
|
||||
match s {
|
||||
Shape::Vec(v) => v.into_iter().for_each(|s| flat(s, out)),
|
||||
s => out.push(s),
|
||||
}
|
||||
}
|
||||
let raw =
|
||||
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, size)), max_texture_side: Some(8192), events, ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw, |ui| app.canvas_area(ui));
|
||||
// A pane's picture is uploaded once, maybe in this frame: [`wait_ready`] finds it later.
|
||||
note_uploads(&mut out.textures_delta);
|
||||
let mut shapes = vec![];
|
||||
out.shapes.into_iter().for_each(|c| flat(c.shape, &mut shapes));
|
||||
shapes
|
||||
crate::tests_labels::flat_painted_shapes(&out.shapes)
|
||||
}
|
||||
|
||||
/// A texture's picture: its pixels and size.
|
||||
@@ -627,15 +619,10 @@ fn art_carried_through_a_tab_drops_into_a_third_documents_pane() {
|
||||
// A tab's title starts with its document's name (an inactive tab shows the name alone).
|
||||
let names: Vec<String> = app.session.documents().iter().map(|d| d.title()).collect();
|
||||
let titles = |out: egui::FullOutput| -> Vec<egui::Rect> {
|
||||
let mut t: Vec<_> = out
|
||||
.shapes
|
||||
.iter()
|
||||
.filter_map(|s| match &s.shape {
|
||||
Shape::Text(t) if names.iter().any(|n| t.galley.text().starts_with(n.as_str())) => {
|
||||
Some(egui::Rect::from_min_size(t.pos, t.galley.size()))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
let mut t: Vec<_> = crate::tests_labels::text_shapes(&out)
|
||||
.into_iter()
|
||||
.filter(|(t, _)| names.iter().any(|n| t.galley.text().starts_with(n.as_str())))
|
||||
.map(|(t, transform)| transform * egui::Rect::from_min_size(t.pos, t.galley.size()))
|
||||
.collect();
|
||||
t.sort_by(|a, b| a.left().total_cmp(&b.left()));
|
||||
t
|
||||
@@ -1002,14 +989,15 @@ fn other_panes_draw_through_their_documents_profiles() {
|
||||
let fills = |out: &egui::FullOutput, rgb: [u8; 3]| {
|
||||
fn any(s: &Shape, f: &dyn Fn(Color32) -> bool) -> bool {
|
||||
match s {
|
||||
Shape::Vec(v) => v.iter().any(|s| any(s, f)),
|
||||
Shape::Path(p) => f(p.fill),
|
||||
Shape::Rect(r) => f(r.fill),
|
||||
Shape::Mesh(m) if m.texture_id == egui::TextureId::default() => m.vertices.iter().any(|v| f(v.color)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
out.shapes.iter().any(|c| any(&c.shape, &|c: Color32| c.a() == 255 && near([c.r(), c.g(), c.b()], rgb)))
|
||||
crate::tests_labels::painted_shapes(&out.shapes)
|
||||
.into_iter()
|
||||
.any(|(s, ..)| any(s, &|c: Color32| c.a() == 255 && near([c.r(), c.g(), c.b()], rgb)))
|
||||
};
|
||||
let ctx = crate::testing::ui_context();
|
||||
let raw = || egui::RawInput {
|
||||
|
||||
@@ -464,10 +464,12 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpac
|
||||
.show(ui, space.view.rect, |ui, _| {
|
||||
for (label, icon, cmd, params) in &offer.actions {
|
||||
if *cmd == TASK_BAR_FIDELITY {
|
||||
// The Smooth tool's Fidelity, labeled, sets the tool's option as it is typed or stepped.
|
||||
// The Smooth tool's Fidelity, labeled, sets the tool's option once a typed or stepped value is
|
||||
// committed; Escape leaves the option as it was.
|
||||
if let Some(v) = offer.fidelity {
|
||||
Text::new(*label).show(ui);
|
||||
if let Some(x) = crate::dialogs::freehand::fidelity_field(ui, "task-bar-fidelity", v, "smooth").filter(|x| *x != v) {
|
||||
let events = crate::dialogs::freehand::fidelity_field(ui, "task-bar-fidelity", v, "smooth");
|
||||
if let Some(x) = events.committed().and_then(|typed| typed.to_owned()).filter(|x| *x != v) {
|
||||
run = Some(("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": x}})));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,17 +956,10 @@ fn shapes(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec<Shape> {
|
||||
shapes
|
||||
}
|
||||
|
||||
/// The shapes of a frame's output, `Shape::Vec`s flattened: the canvas's picture slot holds the art's.
|
||||
/// The shapes of a frame's output, `Shape::Vec`s and retained paint chunks flattened: the canvas's
|
||||
/// picture slot holds the art's.
|
||||
fn flat_shapes(clipped: Vec<egui::epaint::ClippedShape>) -> Vec<Shape> {
|
||||
fn flat(s: Shape, out: &mut Vec<Shape>) {
|
||||
match s {
|
||||
Shape::Vec(v) => v.into_iter().for_each(|s| flat(s, out)),
|
||||
s => out.push(s),
|
||||
}
|
||||
}
|
||||
let mut v = vec![];
|
||||
clipped.into_iter().for_each(|c| flat(c.shape, &mut v));
|
||||
v
|
||||
crate::tests_labels::flat_painted_shapes(&clipped)
|
||||
}
|
||||
|
||||
/// One headless canvas frame → the shapes drawn ([`flat_shapes`]) and the textures uploaded by it
|
||||
|
||||
@@ -101,6 +101,12 @@ fn corner_widgets_hide_above_the_preference_angle() {
|
||||
assert!(corners(&app, app.session.tool_id(), app.view_info().zoom).is_none());
|
||||
}
|
||||
|
||||
/// The tools hit-test corner widgets at the inset the canvas draws them at.
|
||||
#[test]
|
||||
fn corner_widgets_are_hit_tested_at_the_inset_they_are_drawn_at() {
|
||||
assert_eq!(vectorcraft_tools::corners::MIN_INSET_PX, f64::from(CornerWidgets::INSET));
|
||||
}
|
||||
|
||||
/// #1232: the pointer within 5 screen points of a corner widget gives the cut of the corner it controls, in the
|
||||
/// layer colour, with Direct Selection, the Selection tool and the Rectangle tool. It gives none with a mouse button
|
||||
/// down (a press on the widget or a pan), during a drag from the widget, off the canvas, away from the widgets, or
|
||||
|
||||
@@ -241,7 +241,7 @@ fn show_navigation(p: &mut Navigation<'_>, ui: &mut Ui) {
|
||||
let (view, document) = (p.view, p.document);
|
||||
let zoom = Field::new(tl!("Zoom"))
|
||||
.side(SideLabel::new().kind(LabelKind::Hidden))
|
||||
.show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).show(ui));
|
||||
.show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).status_bar().show(ui));
|
||||
// The field edits the canvas view, whose zoom is divided by UI Scaling; `view.setZoom` takes the view's zoom.
|
||||
if let Some(zoom) = zoom.inner {
|
||||
if let Some(view) = zoom.view.committed() {
|
||||
@@ -500,6 +500,27 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The Zoom field draws in the status bar's look: no outline while it does not have the focus.
|
||||
#[test]
|
||||
fn the_zoom_field_draws_in_the_status_bars_look() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0));
|
||||
let mut panel = Panel::new(app, status_bar);
|
||||
panel.room(egui::vec2(1200.0, 300.0));
|
||||
panel.frame();
|
||||
let field = panel.rect("Zoom");
|
||||
let (shapes, _) = panel.paint_at(1.0);
|
||||
let outlines = shapes
|
||||
.iter()
|
||||
.filter(|shape| match shape {
|
||||
egui::Shape::Rect(rect) => rect.stroke.width > 0.0 && rect.stroke.color.a() > 0 && rect.rect.intersects(field),
|
||||
_ => false,
|
||||
})
|
||||
.count();
|
||||
assert_eq!(outlines, 0, "the status bar's Zoom field draws no outline");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_no_document_the_artboard_navigator_shows_a_dash() {
|
||||
let app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
|
||||
@@ -3292,13 +3292,6 @@ struct StyleFace {
|
||||
/// The Style field of the settled bar. `textures` holds the textures the frames uploaded since the fixture began
|
||||
/// recording; the uploads of these frames are applied to it.
|
||||
fn style_face(bar: &mut Shown, textures: &mut std::collections::HashMap<egui::TextureId, egui::ColorImage>) -> StyleFace {
|
||||
fn flat(shape: egui::Shape, out: &mut Vec<egui::Shape>) {
|
||||
if let egui::Shape::Vec(shapes) = shape {
|
||||
shapes.into_iter().for_each(|s| flat(s, out));
|
||||
} else {
|
||||
out.push(shape);
|
||||
}
|
||||
}
|
||||
let field = bar.settle().named("Graphic Styles").rect;
|
||||
let mut paint = bar.fixture.take_paint().expect("the fixture records what it paints");
|
||||
for (id, delta) in paint.textures_delta.set.iter().flat_map(|(id, deltas)| deltas.iter().map(move |delta| (id, delta))) {
|
||||
@@ -3320,10 +3313,7 @@ fn style_face(bar: &mut Shown, textures: &mut std::collections::HashMap<egui::Te
|
||||
}
|
||||
// The uploads are applied to `textures`, not to a renderer.
|
||||
paint.textures_delta.clear();
|
||||
let mut shapes = Vec::new();
|
||||
for clipped in std::mem::take(&mut paint.shapes) {
|
||||
flat(clipped.shape, &mut shapes);
|
||||
}
|
||||
let shapes = crate::tests_labels::flat_painted_shapes(&paint.shapes);
|
||||
let mut face = StyleFace { field, pictures: Vec::new(), fills: Vec::new() };
|
||||
for shape in shapes {
|
||||
match shape {
|
||||
|
||||
@@ -32,6 +32,7 @@ use craft::ui::buttons::{Button, IconButton};
|
||||
use craft::ui::contract::{Bind, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
use craft::ui::dialog::DialogResult;
|
||||
use craft::ui::display::{Divider, Shade, Text};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::patterns::form_dialogs::{
|
||||
DialogFields, FieldValue, HostedListManager, HostedParamDialog, ListManagerAction, ListManagerChoice, ListManagerEntry, ListManagerWords, Param,
|
||||
@@ -895,21 +896,29 @@ fn command_button(app: &VectorcraftApp, ui: &mut egui::Ui, bar: &str, look: &Com
|
||||
(Some(t), Some(keys)) => format!("{} {keys}", t.name),
|
||||
(Some(t), None) => t.name.clone(),
|
||||
};
|
||||
let button = match &look.text {
|
||||
Some(t) => Button::command(t.command.clone()).label(look.said()),
|
||||
None => Button::new(look.said()).enabled(false),
|
||||
};
|
||||
// The face paints the label; the accessible name stays `said`.
|
||||
let button = if look.own.is_some() { button.painted(look.label().to_string()) } else { button };
|
||||
let response = button.tooltip(tip).show(ui).response;
|
||||
let mut response = None;
|
||||
// A menu owned by a dimmed button takes no clicks, so the row around the button owns the menu and a right
|
||||
// click on the button opens it: Rename Button… and the rest work while the command is dimmed.
|
||||
let row = Row::new()
|
||||
.show(ui, |ui, _| {
|
||||
let button = match &look.text {
|
||||
Some(t) => Button::command(t.command.clone()).label(look.said()),
|
||||
None => Button::new(look.said()).enabled(false),
|
||||
};
|
||||
// The face paints the label; the accessible name stays `said`.
|
||||
let button = if look.own.is_some() { button.painted(look.label().to_string()) } else { button };
|
||||
response = Some(button.tooltip(tip.clone()).show(ui).response);
|
||||
})
|
||||
.output;
|
||||
if measuring {
|
||||
return;
|
||||
}
|
||||
let Some(response) = response else { return };
|
||||
let (i, n) = place;
|
||||
let moved = |at: usize| CommandRef::with_params("toolbar.addCommand", json!({ "command": look.id, "toolbar": bar, "at": at }));
|
||||
let removed = CommandRef::with_params("toolbar.removeCommand", json!({ "command": look.id, "toolbar": bar }));
|
||||
let renamed = CommandRef::with_params("toolbar.renameCommand", json!({ "command": look.id, "toolbar": bar }));
|
||||
Menu::context(look.name().to_string(), &response).show(ui, |ui, _| {
|
||||
Menu::context(look.name().to_string(), &row).opened_by(&response, Trigger::Context).show(ui, |ui, _| {
|
||||
MenuItem::command(moved(i.saturating_sub(1))).label(tl!("Move Up")).enabled(i > 0).show(ui);
|
||||
MenuItem::command(moved(i + 1)).label(tl!("Move Down")).enabled(i + 1 < n).show(ui);
|
||||
MenuItem::command(renamed.clone()).label(tl!("Rename Button…")).show(ui);
|
||||
|
||||
@@ -362,6 +362,52 @@ fn canceled_pattern_scale_edits_do_not_reach_the_brush() {
|
||||
assert_eq!(panel.app().run("brush.get", json!({"name": "Diamonds"})).unwrap(), original);
|
||||
}
|
||||
|
||||
/// Bristle Brush Options' sliders: a held drag ended with Escape leaves the open dialog's field as it
|
||||
/// opened, and OK then leaves the brush as it was; a released drag is kept by OK.
|
||||
#[test]
|
||||
fn canceled_bristle_slider_drags_do_not_reach_the_brush() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use craft::ui::contract::Role;
|
||||
use egui::{Key, Modifiers};
|
||||
|
||||
for (key, label, _) in BRISTLE {
|
||||
let mut app = app();
|
||||
let params = json!({"length": 150.0, "density": 50.0, "thickness": 50.0, "opacity": 50.0, "stiffness": 50.0});
|
||||
app.run("brush.options", json!({"name": "Bristle Round", "params": params})).unwrap();
|
||||
let original = app.run("brush.get", json!({"name": "Bristle Round"})).unwrap();
|
||||
let undo = app.session.active().unwrap().history.undo.len();
|
||||
let mut panel = Panel::new(app, draw_hosted_options);
|
||||
panel.room(egui::vec2(1000.0, 1000.0));
|
||||
open(&mut panel.app(), "Bristle Round");
|
||||
panel.frame();
|
||||
let initial = fields_of(&panel.app()).number(key).unwrap();
|
||||
panel.drag_hold_role(label, Role::SLIDER, egui::vec2(40.0, 0.0));
|
||||
assert_ne!(fields_of(&panel.app()).number(key), Some(initial), "the held drag previews another {key}");
|
||||
panel.key(Key::Escape, Modifiers::NONE);
|
||||
panel.release();
|
||||
assert!(is_open(&panel.app()));
|
||||
assert_eq!(fields_of(&panel.app()).number(key), Some(initial), "the canceled drag restores the opening {key}");
|
||||
panel.click("OK");
|
||||
panel.frame();
|
||||
assert!(!is_open(&panel.app()));
|
||||
assert_eq!(panel.app().run("brush.get", json!({"name": "Bristle Round"})).unwrap(), original, "OK after a canceled {key} drag");
|
||||
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo);
|
||||
|
||||
open(&mut panel.app(), "Bristle Round");
|
||||
panel.frame();
|
||||
panel.drag_hold_role(label, Role::SLIDER, egui::vec2(40.0, 0.0));
|
||||
panel.release();
|
||||
let accepted = fields_of(&panel.app()).number(key).unwrap();
|
||||
assert_ne!(accepted, initial);
|
||||
panel.click("OK");
|
||||
panel.frame();
|
||||
assert_eq!(panel.app().run("brush.get", json!({"name": "Bristle Round"})).unwrap()[key], accepted);
|
||||
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + 1);
|
||||
panel.app().run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(panel.app().run("brush.get", json!({"name": "Bristle Round"})).unwrap(), original);
|
||||
}
|
||||
}
|
||||
|
||||
/// What a step of the table expects at a JSON pointer of the saved brush.
|
||||
enum Expect {
|
||||
Is(Value),
|
||||
|
||||
@@ -1126,7 +1126,15 @@ macro_rules! style_dialog {
|
||||
}
|
||||
|
||||
fn show(&mut self, ui: &mut egui::Ui, stack: &craft::ui::dialog::DialogStack) -> Option<craft::ui::dialog::DialogResult<Self::Result>> {
|
||||
craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack)
|
||||
// A measuring run can end without running the dialog's body and then sets the first tab as the
|
||||
// shown one. The dialog keeps the tab that was shown before that run.
|
||||
let measuring = craft::ui::runtime::measure::active(ui.ctx());
|
||||
let tab = self.inner.tab();
|
||||
let shown = craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack);
|
||||
if measuring && self.inner.tab() != tab {
|
||||
let _ = craft::ui::dialog::StackDialog::set_json_field(&mut self.inner, ui.ctx(), "tab", serde_json::json!(tab));
|
||||
}
|
||||
shown
|
||||
}
|
||||
|
||||
fn key(&self) -> Option<&str> {
|
||||
|
||||
@@ -537,6 +537,20 @@ mod tests {
|
||||
assert_eq!(host::fields(&panel.app(), KIND)["scale"], 1.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_scale_the_field_refuses_on_tab_imports_the_scale_it_restores() {
|
||||
let mut panel = actual_dialog();
|
||||
panel.click("Scale");
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("2");
|
||||
assert_eq!(host::fields(&panel.app(), KIND)["scale"], 2.0);
|
||||
panel.type_text("*");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
assert!(host::is_open(&panel.app(), KIND));
|
||||
assert_eq!(host::fields(&panel.app(), KIND)["scale"], 1.0, "the refused text restores the scale from before the edit");
|
||||
accept_and_check_width(&mut panel, Unit::Millimeters, 100.0 * Unit::Millimeters.points());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn actual_layout_and_unit_enter_and_scale_blur_import_the_accepted_choices() {
|
||||
let mut panel = actual_dialog();
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::behavior::{ColumnKey, ColumnWidth, DisplayOrder, GesturePhase, IconId, ItemSource, SelectionChange};
|
||||
use craft::behavior::{ColumnKey, ColumnWidth, DisplayOrder, GesturePhase, IconId, ItemSource, Selection, SelectionChange};
|
||||
use craft::host::PickRequest;
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::choice::{Checkbox, Radio, RadioGroup, Segmented};
|
||||
use craft::ui::contract::{
|
||||
Bind, CollectionEvent, ColumnSpec, Entry, Props as _, Show as _, ShowCollection as _, ShowContainer as _, SpaceAction, SweepApply, SweepStep,
|
||||
ToggleColumn,
|
||||
Bind, CollectionEvent, ColumnSpec, Entry, Pad, Props as _, Show as _, ShowCollection as _, ShowContainer as _, SpaceAction, SweepApply,
|
||||
SweepStep, ToggleColumn,
|
||||
};
|
||||
use craft::ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, HeldAnswer, HeldOk, StackDialog, dialog_id};
|
||||
use craft::ui::display::{Shade, Text};
|
||||
@@ -46,6 +46,7 @@ use craft::ui::patterns::form_dialogs::{FormDialog, PathRow};
|
||||
use craft::ui::primitives::{ContentPainterCx, fit_rect};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::runtime::focus::Initial;
|
||||
use craft::ui::style::SurfaceKind;
|
||||
use craft::ui::tabs::{Tab, TabKind, TabStrip};
|
||||
use craft::ui::text::TextField;
|
||||
use craft::ui::tile_grid::{Tile, TileGrid, TilePartEvent};
|
||||
@@ -93,10 +94,11 @@ const SETTABLE: [&str; 20] = [
|
||||
/// The check column of the list view and its name column.
|
||||
const CHECK: ColumnKey = ColumnKey::new("check");
|
||||
const NAME: ColumnKey = ColumnKey::new("name");
|
||||
/// Rows of the list view and of the grid view the items pane shows before it scrolls, a pane as tall as the options
|
||||
/// column's first sections.
|
||||
/// How many items the list view and the grid view hold before they scroll, and how tall they are with fewer: a
|
||||
/// missing item counts a control row, so the pane stays about as tall as the options column's first sections with
|
||||
/// one artboard. The framework counts a grid's items, not its rows of tiles.
|
||||
const LIST_ROWS: u16 = 9;
|
||||
const GRID_ROWS: u16 = 3;
|
||||
const GRID_ITEMS: u16 = 4;
|
||||
|
||||
/// The longest side of an artboard thumbnail, in pixels.
|
||||
const THUMB_PX: u32 = 92;
|
||||
@@ -219,6 +221,7 @@ pub fn open(app: &mut VectorcraftApp) {
|
||||
pending: None,
|
||||
renaming_in: None,
|
||||
rename: None,
|
||||
leads: Default::default(),
|
||||
held: HeldAnswer::new(),
|
||||
};
|
||||
if let Some(dialogs) = app.dialogs() {
|
||||
@@ -541,6 +544,8 @@ pub(crate) struct ExportForScreensDialog {
|
||||
renaming_in: Option<(u64, u64)>,
|
||||
/// A committed artboard name: ((document uid, reverts), artboard id, name), for the pump to run.
|
||||
rename: Option<((u64, u64), u32, String)>,
|
||||
/// The lead and anchor of the Artboards and the Assets view, by tab.
|
||||
leads: [Selection<u64>; 2],
|
||||
held: HeldAnswer<Map<String, Value>>,
|
||||
}
|
||||
|
||||
@@ -616,7 +621,7 @@ impl ExportForScreensDialog {
|
||||
let checked = |at: usize| on.get(at).copied().unwrap_or(false);
|
||||
let shelf =
|
||||
Shelf { items: &items, enabled: text(fields, "select") != "full", reveal: None, caption: &caption, checked: &checked, paint: &paint };
|
||||
let picks = shelf.show(ui, text(fields, "view") == "list");
|
||||
let picks = shelf.show(ui, text(fields, "view") == "list", &mut self.leads[0]);
|
||||
for key in picks.toggled {
|
||||
if let Some(b) = items.index_of(&key).and_then(|at| on.get_mut(at)) {
|
||||
*b ^= true;
|
||||
@@ -654,7 +659,7 @@ impl ExportForScreensDialog {
|
||||
let checked = |at: usize| items.0.get(at).is_some_and(|(id, _)| on.contains(id));
|
||||
let reveal = fields.get("__scrollTo").and_then(Value::as_u64).filter(|id| items.index_of(id).is_some());
|
||||
let shelf = Shelf { items: &items, enabled: true, reveal, caption: &caption, checked: &checked, paint: &paint };
|
||||
let picks = shelf.show(ui, text(fields, "view") == "list");
|
||||
let picks = shelf.show(ui, text(fields, "view") == "list", &mut self.leads[1]);
|
||||
for id in picks.toggled {
|
||||
if on.contains(&id) {
|
||||
on.retain(|a| *a != id);
|
||||
@@ -724,23 +729,30 @@ struct Shelf<'a> {
|
||||
}
|
||||
|
||||
impl Shelf<'_> {
|
||||
/// Shows the items as a list of rows (`list`) or a grid of tiles → what the user did to them.
|
||||
fn show(self, ui: &mut Ui, list: bool) -> Picks {
|
||||
/// Shows the items as a list of rows (`list`) or a grid of tiles in a sunken frame, with the checked items
|
||||
/// selected → what the user did to them. `lead` holds the selection's lead and anchor from pass to pass; its
|
||||
/// items are the checked ones.
|
||||
fn show(self, ui: &mut Ui, list: bool, lead: &mut Selection<u64>) -> Picks {
|
||||
let Shelf { items, enabled, reveal, caption, checked, paint } = self;
|
||||
let mut picks = Picks::default();
|
||||
let rename = reveal.is_none();
|
||||
let at = |key: &u64| items.index_of(key).unwrap_or(usize::MAX);
|
||||
let state = |at: usize| if checked(at) { ToggleState::On } else { ToggleState::Off };
|
||||
let mut selection = Selection::new((0..items.len()).filter(|at| checked(*at)).map(|at| items.key(at)).collect(), lead.lead, lead.anchor);
|
||||
if list {
|
||||
let columns =
|
||||
vec![ColumnSpec::toggle(CHECK, Label::Empty, ToggleColumn::default()), ColumnSpec::new(NAME, Label::Empty, ColumnWidth::fill(1.0))];
|
||||
let mut view = List::<u64>::new(tl!("Export for Screens"))
|
||||
.surface(SurfaceKind::Sunken)
|
||||
.pad(Pad::Control)
|
||||
.header(false)
|
||||
.space(SpaceAction::ToggleCell)
|
||||
.columns(columns)
|
||||
.rename(rename)
|
||||
.enabled(enabled)
|
||||
.max_rows(LIST_ROWS);
|
||||
.min_rows(LIST_ROWS)
|
||||
.max_rows(LIST_ROWS)
|
||||
.selection(Bind::bound(&mut selection));
|
||||
if rename {
|
||||
view = view.rename_column(NAME);
|
||||
}
|
||||
@@ -763,7 +775,15 @@ impl Shelf<'_> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let mut grid = TileGrid::<u64>::new(tl!("Export for Screens")).checks(true).rename(rename).enabled(enabled).max_rows(GRID_ROWS);
|
||||
let mut grid = TileGrid::<u64>::new(tl!("Export for Screens"))
|
||||
.surface(SurfaceKind::Sunken)
|
||||
.pad(Pad::Control)
|
||||
.checks(true)
|
||||
.rename(rename)
|
||||
.enabled(enabled)
|
||||
.min_rows(GRID_ITEMS)
|
||||
.max_rows(GRID_ITEMS)
|
||||
.selection(Bind::bound(&mut selection));
|
||||
if let Some(key) = reveal {
|
||||
grid = grid.reveal(key);
|
||||
}
|
||||
@@ -778,6 +798,13 @@ impl Shelf<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A click picks the item it lands on as the lead; the checks alone say which items are selected.
|
||||
(lead.lead, lead.anchor) = (selection.lead, selection.anchor);
|
||||
// Space on a selected item flips that item first and then the other selected items to the same value. The
|
||||
// selection here is every checked item, so only the first item's flips are kept.
|
||||
if let Some(&first) = picks.toggled.first() {
|
||||
picks.toggled.retain(|key| *key == first);
|
||||
}
|
||||
picks
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
// PLAN: the imports below assume `craft_ui` paths as the framework's own code uses them; `ui::brush_settings`
|
||||
// of the draw crate is where `TipEllipse` and `TipAngle` live.
|
||||
use craft::behavior::EditEvents;
|
||||
use craft::draw::ui::brush_settings::{TipAngle, TipEllipse};
|
||||
use craft::ui::contract::{Bind, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::display::{Picture, PictureSize};
|
||||
@@ -116,9 +117,10 @@ fn fidelity_round(v: f64) -> f64 {
|
||||
}
|
||||
|
||||
/// The Fidelity field of tool `tool`, showing `v` to two decimals from the tool's lowest Fidelity to
|
||||
/// 100 and stepping by [`fidelity_step`], named by the label drawn just before it. Returns the value
|
||||
/// typed or stepped to. The Contextual Task Bar shows the Smooth tool's.
|
||||
pub(crate) fn fidelity_field(ui: &mut Ui, id: &str, v: f64, tool: &str) -> Option<f64> {
|
||||
/// 100 and stepping by [`fidelity_step`], named by the label drawn just before it. Returns the field's
|
||||
/// edit events: the value typed or stepped to as a proposal, then its commit, or the cancel that
|
||||
/// restores `v`. The Contextual Task Bar shows the Smooth tool's.
|
||||
pub(crate) fn fidelity_field(ui: &mut Ui, id: &str, v: f64, tool: &str) -> EditEvents<Option<f64>> {
|
||||
let min = vectorcraft_tools::draw2::min_fidelity(tool);
|
||||
NumberField::new(tl!("Fidelity"), Bind::given(Some(v)))
|
||||
.id_salt(id.to_owned())
|
||||
@@ -128,8 +130,7 @@ pub(crate) fn fidelity_field(ui: &mut Ui, id: &str, v: f64, tool: &str) -> Optio
|
||||
.stepper(|v, dir, scale| fidelity_step(v, f64::from(dir) * scale))
|
||||
.show(ui)
|
||||
.edit
|
||||
.value()
|
||||
.and_then(|typed| typed.to_owned())
|
||||
.events
|
||||
}
|
||||
|
||||
/// The Fidelity row: a logarithmic slider from the tool's lowest Fidelity to [`FIDELITY_MAX`] with the field at its
|
||||
@@ -145,10 +146,17 @@ fn fidelity_row(ui: &mut Ui, fields: &mut DialogFields, tool: &str) -> Response
|
||||
.label(tl!("Fidelity"))
|
||||
.id_salt("fidelity-slider")
|
||||
.show(ui);
|
||||
if let Some(x) = slid.value() {
|
||||
// The draft follows a drag unrounded, as a rounded value would end the slider's gesture, and takes the rounded
|
||||
// value once the drag ends. Escape puts back the value from before the drag or the typing, which the field
|
||||
// allows above the slider's end.
|
||||
if let Some(x) = slid.events.committed() {
|
||||
set = Some(fidelity_round(*x).clamp(min, FIDELITY_MAX));
|
||||
} else if let Some(x) = slid.events.value() {
|
||||
set = Some(x.clamp(min, FIDELITY_MAX));
|
||||
} else if let Some(x) = slid.events.landed() {
|
||||
set = Some(*x);
|
||||
}
|
||||
if let Some(x) = fidelity_field(ui, "fidelity-field", v, tool) {
|
||||
if let Some(x) = fidelity_field(ui, "fidelity-field", v, tool).landed().and_then(|typed| typed.to_owned()) {
|
||||
set = Some(x);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -416,3 +416,76 @@ fn the_blob_brush_size_offers_the_stylus_wheel() {
|
||||
let text = shown_text(&mut app);
|
||||
assert!(text.contains("Stylus Wheel"), "it shows again on the next open: {text}");
|
||||
}
|
||||
|
||||
/// The Fidelity the open Tool Options dialog holds, `None` once it is closed.
|
||||
fn draft_fidelity(panel: &crate::tests::panel_harness::Panel) -> Option<f64> {
|
||||
panel.app().dialogs().and_then(|d| d.with(|host| host.get::<HostedParamDialog>().and_then(|dialog| dialog.fields().number("fidelity"))))
|
||||
}
|
||||
|
||||
/// The Smooth tool's Fidelity slider and field: a drag or a typed value that Escape cancels leaves the dialog's Fidelity
|
||||
/// and the tool's as they were; a finished drag or a typed value left with Tab sets the dialog's, and OK sets the tool's.
|
||||
#[test]
|
||||
fn a_canceled_fidelity_drag_or_typed_value_leaves_the_dialog_and_the_tool() {
|
||||
use craft::ui::contract::Role;
|
||||
use egui::{Key, Modifiers, vec2};
|
||||
let mut app = app();
|
||||
app.run("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": 2.5}})).unwrap();
|
||||
let original = app.session.tool_options_of("smooth");
|
||||
let document = app.session.active().unwrap().doc.clone();
|
||||
let mut panel = crate::tests::panel_harness::Panel::new(app, crate::tests::picks::dialogs);
|
||||
panel.room(vec2(1000.0, 1200.0));
|
||||
crate::toolbar::open_options(&mut panel.app(), "smooth").unwrap();
|
||||
panel.frame();
|
||||
assert_eq!(draft_fidelity(&panel), Some(2.5));
|
||||
|
||||
// On the track, above the Accurate and Smooth marks.
|
||||
let track = |panel: &crate::tests::panel_harness::Panel| {
|
||||
let r = panel.rect_role("Fidelity", Role::SLIDER);
|
||||
egui::pos2(r.center().x, r.top() + 5.0)
|
||||
};
|
||||
let from = track(&panel);
|
||||
panel.drag_hold_between(from, from + vec2(60.0, 0.0));
|
||||
assert_ne!(draft_fidelity(&panel), Some(2.5), "the dialog's Fidelity follows the drag");
|
||||
panel.key(Key::Escape, Modifiers::NONE);
|
||||
panel.release();
|
||||
assert_eq!(draft_fidelity(&panel), Some(2.5), "Escape puts back the Fidelity from before the drag");
|
||||
|
||||
panel.click_role("Fidelity", Role::SPIN_BUTTON);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("7");
|
||||
panel.key(Key::Escape, Modifiers::NONE);
|
||||
assert_eq!(panel.app().session.tool_options_of("smooth"), original, "the canceled typed value leaves the tool");
|
||||
if draft_fidelity(&panel).is_none() {
|
||||
crate::toolbar::open_options(&mut panel.app(), "smooth").unwrap();
|
||||
panel.frame();
|
||||
}
|
||||
assert_eq!(draft_fidelity(&panel), Some(2.5), "the dialog shows the Fidelity from before the typing");
|
||||
|
||||
let from = track(&panel);
|
||||
panel.drag_hold_between(from, from + vec2(60.0, 0.0));
|
||||
panel.release();
|
||||
let dragged = draft_fidelity(&panel).unwrap();
|
||||
assert!(dragged > 2.5, "a finished drag sets the dialog's Fidelity: {dragged}");
|
||||
assert_eq!(dragged, fidelity_round(dragged), "to the slider's step");
|
||||
panel.click_role("Fidelity", Role::SPIN_BUTTON);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("7");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
assert_eq!(draft_fidelity(&panel), Some(7.0), "a typed value left with Tab sets the dialog's Fidelity");
|
||||
assert_eq!(panel.app().session.tool_options_of("smooth"), original, "the tool keeps its Fidelity until OK");
|
||||
panel.click("OK");
|
||||
panel.frame();
|
||||
assert_eq!(draft_fidelity(&panel), None, "OK closes the dialog");
|
||||
assert_eq!(panel.app().session.tool_options_of("smooth")["fidelity"].as_f64(), Some(7.0));
|
||||
assert_eq!(panel.app().session.active().unwrap().doc, document);
|
||||
|
||||
panel.app().run("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": 50}})).unwrap();
|
||||
crate::toolbar::open_options(&mut panel.app(), "smooth").unwrap();
|
||||
panel.frame();
|
||||
let from = track(&panel);
|
||||
panel.drag_hold_between(from, from - vec2(60.0, 0.0));
|
||||
assert!(draft_fidelity(&panel).is_some_and(|x| x <= FIDELITY_MAX), "the drag runs along the slider");
|
||||
panel.key(Key::Escape, Modifiers::NONE);
|
||||
panel.release();
|
||||
assert_eq!(draft_fidelity(&panel), Some(50.0), "Escape puts back a Fidelity above the slider's end");
|
||||
}
|
||||
@@ -1219,6 +1219,40 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A number or text row leaves the draft alone while its text is still being typed, and writes
|
||||
/// the typed value once Tab commits it.
|
||||
#[test]
|
||||
fn typed_number_and_text_rows_reach_the_draft_only_when_committed() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use craft::ui::contract::Role;
|
||||
use egui::{Key, Modifiers};
|
||||
|
||||
let mut app = app_with_graph("column");
|
||||
app.run(COMMAND, json!({"columnWidth": 80, "prefix": "USD"})).unwrap();
|
||||
let mut panel = Panel::new(app, crate::tests::picks::dialogs);
|
||||
panel.room(egui::vec2(900.0, 900.0));
|
||||
open(&mut panel.app()).unwrap();
|
||||
panel.frame();
|
||||
panel.click_role("Column Width", Role::SPIN_BUTTON);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("140");
|
||||
panel.frame();
|
||||
assert_eq!(field(&panel.app(), "columnWidth"), json!(80.0), "a number being typed is not in the draft");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
panel.frame();
|
||||
assert_eq!(field(&panel.app(), "columnWidth"), json!(140.0), "Tab commits the typed number");
|
||||
set(&panel.app(), PAGE, json!("valueAxis")).unwrap();
|
||||
panel.frame();
|
||||
panel.click_role("Prefix", Role::TEXT_INPUT);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("EUR");
|
||||
panel.frame();
|
||||
assert_eq!(field(&panel.app(), "prefix"), json!("USD"), "text being typed is not in the draft");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
panel.frame();
|
||||
assert_eq!(field(&panel.app(), "prefix"), json!("EUR"), "Tab commits the typed text");
|
||||
}
|
||||
|
||||
/// Object › Graph › Type… opens the dialog on the selected graph's options, on its Graph
|
||||
/// Options page; each page the type has can be shown, and Override Calculated Values of the
|
||||
/// right axis takes input only while that axis has a scale of its own.
|
||||
|
||||
@@ -207,7 +207,6 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
super::graph_design::pump,
|
||||
super::perspective_grid::pump,
|
||||
super::perspective_presets::pump,
|
||||
super::slices::pump,
|
||||
super::blend_options::pump,
|
||||
super::saved_names::pump,
|
||||
super::object_mosaic::pump,
|
||||
|
||||
@@ -441,7 +441,7 @@ fn pages_body(ui: &mut egui::Ui, s: &mut State, preview: Option<&(Revision, Arc<
|
||||
Text::new(crate::i18n::fmt(tl!("of {count}"), &[("count", &count.to_string())])).shade(Shade::Muted).show(ui);
|
||||
let next = nav(ui, "chevron-right", tl!("Next Page"), (current + 1).min(count), current < count);
|
||||
let last = nav(ui, "chevrons-right", tl!("Last Page"), count, current < count);
|
||||
to = first.or(previous).or(next).or(last).or(typed.value().copied().flatten().map(|v| v as usize));
|
||||
to = first.or(previous).or(next).or(last).or(typed.edit.events.landed().copied().flatten().map(|v| v as usize));
|
||||
});
|
||||
if let Some(page) = to {
|
||||
s.page = page.clamp(1, count.max(1));
|
||||
|
||||
@@ -980,6 +980,10 @@ mod tests {
|
||||
canceled_detail_number("Height", "150");
|
||||
}
|
||||
#[test]
|
||||
fn canceled_new_document_artboards_preserve_preset() {
|
||||
canceled_detail_number("Artboards", "3");
|
||||
}
|
||||
#[test]
|
||||
fn canceled_new_document_bleed_preserves_preset() {
|
||||
canceled_detail_number("Top", "3");
|
||||
}
|
||||
@@ -1084,16 +1088,13 @@ mod tests {
|
||||
/// did; before, it showed the words, and Landscape, cut short, ran into Artboards.
|
||||
#[test]
|
||||
fn orientation_shows_two_page_icons_beside_artboards() {
|
||||
fn texts(s: &egui::Shape, out: &mut Vec<(String, egui::Pos2)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect().center())),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut app = app();
|
||||
open(&mut app);
|
||||
let out = laid_out(&mut app);
|
||||
let drawn: Vec<(String, egui::Pos2)> = crate::tests_labels::text_shapes(&out)
|
||||
.into_iter()
|
||||
.map(|(t, transform)| (t.galley.text().to_string(), (transform * t.visual_bounding_rect()).center()))
|
||||
.collect();
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
let bounds = |label: &str, role: egui::accesskit::Role| {
|
||||
let (_, n) = nodes.iter().find(|(_, n)| n.label() == Some(label) && n.role() == role).unwrap_or_else(|| panic!("no {role:?} {label}"));
|
||||
@@ -1104,8 +1105,6 @@ mod tests {
|
||||
// Artboards follows Landscape on its line, or wraps below it when the column has no room for it.
|
||||
assert!(landscape.x1 <= artboards.x0 || landscape.y1 <= artboards.y0, "Landscape {landscape:?} stays clear of Artboards {artboards:?}");
|
||||
let group = bounds("Orientation", egui::accesskit::Role::RadioGroup);
|
||||
let mut drawn = Vec::new();
|
||||
out.shapes.iter().for_each(|s| texts(&s.shape, &mut drawn));
|
||||
let inside: Vec<_> = drawn
|
||||
.iter()
|
||||
.filter(|(_, at)| (group.x0..=group.x1).contains(&f64::from(at.x)) && (group.y0..=group.y1).contains(&f64::from(at.y)))
|
||||
|
||||
@@ -4,8 +4,7 @@ use super::path_ops::PathOp;
|
||||
use super::simplify_slider::StripKind;
|
||||
use super::{
|
||||
blend_options, dimension, flare_options, graph_data, graph_design, graph_type, indexed_color, live_paint_gaps, object_mosaic, option_form,
|
||||
path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, slices, smooth_slider, transform, transform_each,
|
||||
width_point,
|
||||
path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, smooth_slider, transform, transform_each, width_point,
|
||||
};
|
||||
use crate::VectorcraftApp;
|
||||
|
||||
@@ -58,7 +57,6 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
graph_design::pump(app, ctx);
|
||||
perspective_grid::pump(app, ctx);
|
||||
perspective_presets::pump(app, ctx);
|
||||
slices::pump(app, ctx);
|
||||
blend_options::pump(app, ctx);
|
||||
saved_names::pump(app, ctx);
|
||||
object_mosaic::pump(app, ctx);
|
||||
|
||||
@@ -507,6 +507,15 @@ pub(super) mod tests {
|
||||
crate::toolbar::open_options(&mut panel.app(), "livePaintBucket").unwrap();
|
||||
panel.frame();
|
||||
assert_eq!(fields(&panel.app()), before);
|
||||
panel.click_role("Width", Role::SPIN_BUTTON);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("9");
|
||||
assert_eq!(fields(&panel.app())["width"], 9.0, "typing proposes the width");
|
||||
panel.type_text("x");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
panel.frame();
|
||||
assert!(is_open(&panel.app()), "leaving the field keeps the dialog open");
|
||||
assert_eq!(fields(&panel.app()), before, "leaving the field on text that is not a number restores the opening width");
|
||||
if commit {
|
||||
panel.click_role("Width", Role::SPIN_BUTTON);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
@@ -530,7 +539,7 @@ pub(super) mod tests {
|
||||
/// Normal Gap Options supplies numeric points. This hosted row fixture separately checks
|
||||
/// the nullable length helper's contract, including restoring an empty opening value.
|
||||
#[test]
|
||||
fn a_nullable_length_row_restores_null_on_escape() {
|
||||
fn a_nullable_length_row_restores_null_when_its_typing_is_canceled() {
|
||||
static NULL_LENGTH: OptionSpec = OptionSpec {
|
||||
key: "nullableLengthTest",
|
||||
title: || "Nullable Length".into(),
|
||||
@@ -555,6 +564,15 @@ pub(super) mod tests {
|
||||
open(&mut panel.app(), &NULL_LENGTH, Map::from_iter([("length".into(), Value::Null)]), Value::Null).unwrap();
|
||||
panel.frame();
|
||||
assert_eq!(fields(&panel.app())["length"], Value::Null);
|
||||
panel.click_role("Length", Role::SPIN_BUTTON);
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("9 pt");
|
||||
assert_eq!(fields(&panel.app())["length"], 9.0);
|
||||
panel.type_text("x");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
panel.frame();
|
||||
assert!(is_open(&panel.app()), "leaving the field keeps the dialog open");
|
||||
assert_eq!(fields(&panel.app())["length"], Value::Null, "leaving the field on text that is not a length restores null");
|
||||
}
|
||||
|
||||
/// Whether `a` and `b` are the same value, numbers by their value.
|
||||
|
||||
@@ -609,7 +609,9 @@ fn tabs_buttons(unit: Unit) -> Param {
|
||||
let (rows, _, _) = tab_rows(fields);
|
||||
let can_add = new_tab_position(&rows, unit).is_some();
|
||||
let (mut add, mut delete, mut clear) = (false, false, false);
|
||||
let line = Row::new().wrap(true).show(ui, |ui, _| {
|
||||
// Wrap against the form's offered width rather than measuring an intrinsic-width
|
||||
// strip that may be clipped by the property group on small screens.
|
||||
let line = Row::new().fill_width().wrap(true).show(ui, |ui, _| {
|
||||
add = clicked(&Button::new(tl!("Add")).enabled(can_add).show(ui));
|
||||
delete = clicked(&Button::new(tl!("Delete Tab")).enabled(!rows.is_empty()).show(ui));
|
||||
clear = clicked(&Button::new(tl!("Clear All Tabs")).enabled(!rows.is_empty()).show(ui));
|
||||
|
||||
@@ -574,11 +574,17 @@ fn clear_all_tabs_can_be_clicked_in_a_narrow_viewport() {
|
||||
for _ in 0..5 {
|
||||
frame(&mut app, vec![]);
|
||||
}
|
||||
// The dialog's first frames measure it before its body runs; the Tabs pane picked before them stays shown.
|
||||
assert_eq!(fields(&app)["tab"], json!("tabs"), "the dialog left Tabs in its first frames at {width} points");
|
||||
let out = frame(&mut app, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.unwrap().nodes;
|
||||
let clear = nodes.iter().find(|(_, node)| node.role() == Role::Button && node.label() == Some("Clear All Tabs")).unwrap();
|
||||
let clear = nodes
|
||||
.iter()
|
||||
.find(|(_, node)| node.role() == Role::Button && node.label() == Some("Clear All Tabs"))
|
||||
.unwrap_or_else(|| panic!("Clear All Tabs is missing at {width} points"));
|
||||
let bounds = clear.1.bounds().unwrap();
|
||||
let at = pos2(((bounds.x0 + bounds.x1) * 0.5) as f32, ((bounds.y0 + bounds.y1) * 0.5) as f32);
|
||||
assert!(screen.contains(at), "Clear All Tabs at {bounds:?} is outside the {width}-point viewport");
|
||||
|
||||
assert_eq!(tab_rows(&app).len(), 2);
|
||||
frame(&mut app, vec![Event::PointerMoved(at)]);
|
||||
|
||||
@@ -532,14 +532,15 @@ fn labelled_controls(app: &mut VectorcraftApp) -> Vec<(String, egui::Rect)> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The bounds of the control labelled `label` in `controls`, with or without a final colon.
|
||||
/// The bounds of the control labelled `label` in `controls`, with or without a final colon. A check box and the text of
|
||||
/// its label are two nodes with the same name side by side, so the bounds take in every node so named on the first
|
||||
/// one's line.
|
||||
fn control(controls: &[(String, egui::Rect)], label: &str) -> egui::Rect {
|
||||
let bare = |l: &str| l.trim_end_matches(':').to_string();
|
||||
controls
|
||||
.iter()
|
||||
.find(|(l, _)| bare(l) == bare(label))
|
||||
.map(|(_, r)| *r)
|
||||
.unwrap_or_else(|| panic!("no control labelled {label:?} in {:?}", controls.iter().map(|(l, _)| l).collect::<Vec<_>>()))
|
||||
let named: Vec<egui::Rect> = controls.iter().filter(|(l, _)| bare(l) == bare(label)).map(|(_, r)| *r).collect();
|
||||
let first =
|
||||
*named.first().unwrap_or_else(|| panic!("no control labelled {label:?} in {:?}", controls.iter().map(|(l, _)| l).collect::<Vec<_>>()));
|
||||
named.iter().filter(|r| r.top() < first.bottom() && first.top() < r.bottom()).fold(first, |all, r| all.union(*r))
|
||||
}
|
||||
|
||||
/// The All and Range radios stand right under the artboard check box, and EPS's Transparent and Opaque radios right
|
||||
|
||||
@@ -24,12 +24,6 @@ pub const OPTIONS: &str = "sliceOptions";
|
||||
/// The dialog kind of Divide Slices.
|
||||
pub const DIVIDE: &str = "divideSlices";
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct SliceDialogs {
|
||||
options: Option<Target>,
|
||||
divide: Option<Target>,
|
||||
}
|
||||
|
||||
/// The document, its revert count and the effective slice selection used when opening either dialog.
|
||||
#[derive(PartialEq)]
|
||||
struct Target {
|
||||
@@ -134,12 +128,8 @@ pub fn open_options(app: &mut VectorcraftApp) -> Result<Value, String> {
|
||||
kinds.push(SliceKind::HtmlText);
|
||||
}
|
||||
let dialog = SliceOptionsDialog::new(options_of(&map)).kinds(&kinds);
|
||||
app.dialogs().ok_or("no window")?.with(|host| {
|
||||
host.open(dialog);
|
||||
// Replacing a still-open dialog leaves its Cancel behind.
|
||||
let _ = host.take::<SliceOptionsDialog>();
|
||||
});
|
||||
app.slice_dialogs.options = Some(source);
|
||||
crate::dialogs::host::open_held(app, dialog, move |app, o: &SliceOptions| apply(app, &source, "object.slice.options", options_json(o)))
|
||||
.ok_or("no window")?;
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
@@ -152,44 +142,27 @@ pub fn open_divide(app: &mut VectorcraftApp) -> Result<Value, String> {
|
||||
let source = Target::new(st.uid, st.reverts, selected);
|
||||
let (w, h) = first.map_or((50.0, 50.0), |r| (r.width() / 2.0, r.height() / 2.0));
|
||||
let dialog = DivideSlicesDialog::new(DivideSlices::new(Some(DivideBy::Count(2)), Some(DivideBy::Count(2)))).lengths(lengths).start_sizes(h, w);
|
||||
app.dialogs().ok_or("no window")?.with(|host| {
|
||||
host.open(dialog);
|
||||
let _ = host.take::<DivideSlicesDialog>();
|
||||
});
|
||||
app.slice_dialogs.divide = Some(source);
|
||||
crate::dialogs::host::open_held(app, dialog, move |app, d: &DivideSlices| apply(app, &source, "object.slice.divide", divide_json(d)))
|
||||
.ok_or("no window")?;
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
/// Run the answer of whichever slice dialog closed with OK. The framework dialogs hold no answer, so a
|
||||
/// refusal goes to the status line and the dialog is already closed.
|
||||
pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) {
|
||||
let Some(host) = app.dialogs() else { return };
|
||||
let (options, divide) = host.with(|h| (h.take::<SliceOptionsDialog>(), h.take::<DivideSlicesDialog>()));
|
||||
let answers = [
|
||||
options.and_then(|r| {
|
||||
let source = app.slice_dialogs.options.take();
|
||||
r.ok().map(|o| (source, "object.slice.options", options_json(&o)))
|
||||
}),
|
||||
divide.and_then(|r| {
|
||||
let source = app.slice_dialogs.divide.take();
|
||||
r.ok().map(|d| (source, "object.slice.divide", divide_json(&d)))
|
||||
}),
|
||||
];
|
||||
for (source, cmd, params) in answers.into_iter().flatten() {
|
||||
if source.as_ref().is_some_and(|source| source.reverted(app)) {
|
||||
app.status(tl!("The document was reverted. Reopen this dialog to continue."));
|
||||
} else if !source.is_some_and(|source| Some(source) == Target::current(app)) {
|
||||
app.status(tl!("The slice selection changed while the dialog was open."));
|
||||
} else if let Err(e) = app.run(cmd, params) {
|
||||
app.status(e);
|
||||
}
|
||||
/// Runs a slice dialog's OK on the document and slices it opened with. A refusal keeps the dialog open with
|
||||
/// what was typed and the reason under its rows.
|
||||
fn apply(app: &mut VectorcraftApp, source: &Target, cmd: &str, params: Value) -> Result<(), String> {
|
||||
if source.reverted(app) {
|
||||
return Err(tl!("The document was reverted. Reopen this dialog to continue.").to_owned());
|
||||
}
|
||||
if Target::current(app).as_ref() != Some(source) {
|
||||
return Err(tl!("The slice selection changed while the dialog was open.").to_owned());
|
||||
}
|
||||
app.run(cmd, params).map(|_| ())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use craft::ui::dialog::{DialogHost, DialogId};
|
||||
use craft::ui::dialog::{DialogHost, DialogId, HeldOk};
|
||||
use vectorcraft_doc::NodeId;
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
@@ -217,12 +190,20 @@ mod tests {
|
||||
host(app, |h| h.set_json_field(&ctx, id, field, value)).unwrap();
|
||||
}
|
||||
|
||||
/// OK on the open dialog, then the frame's pump runs its answer; whether OK was enabled.
|
||||
/// OK on the open dialog, then the frame's pump runs its held answer, and an accepted answer closes the
|
||||
/// dialog; whether OK was enabled.
|
||||
fn ok(app: &mut VectorcraftApp) -> bool {
|
||||
let (ctx, (id, _)) = (app.ui_ctx.clone().unwrap(), the_dialog(app));
|
||||
let enabled = host(app, |h| h.confirm_by_id(&ctx, id));
|
||||
let closed = host(app, |h| h.confirm_by_id(&ctx, id));
|
||||
if !closed && host(app, |h| h.held_state(id)) != Some(HeldOk::Waiting) {
|
||||
return false;
|
||||
}
|
||||
crate::dialogs::host::pump(app, &ctx);
|
||||
enabled
|
||||
if host(app, |h| h.held_state(id)) == Some(HeldOk::Accepted) {
|
||||
host(app, |h| h.confirm_by_id(&ctx, id));
|
||||
crate::dialogs::host::pump(app, &ctx);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn add_slice(app: &mut VectorcraftApp, x: f64) -> NodeId {
|
||||
@@ -235,15 +216,33 @@ mod tests {
|
||||
app.run("object.slice.select", json!({"slices": [id.0]})).unwrap();
|
||||
}
|
||||
|
||||
/// The reason the open dialog shows for its refused OK, if it has one.
|
||||
fn refusal(app: &VectorcraftApp) -> Option<String> {
|
||||
let (id, _) = the_dialog(app);
|
||||
match host(app, |h| h.held_state(id)) {
|
||||
Some(HeldOk::Refused(reason)) => Some(reason.as_str().to_string()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether either slice dialog is open.
|
||||
fn slice_dialog_open(app: &VectorcraftApp) -> bool {
|
||||
host(app, |h| h.is_open::<SliceOptionsDialog>() || h.is_open::<DivideSlicesDialog>())
|
||||
}
|
||||
|
||||
/// The field each dialog's test types into, and the value typed.
|
||||
fn draft(divide: bool) -> (&'static str, Value) {
|
||||
if divide { ("columns", json!(3)) } else { ("name", json!("Original")) }
|
||||
}
|
||||
|
||||
fn check_changed_selection(dialog: &str, divide: bool) {
|
||||
let mut app = app();
|
||||
let source = app.session.active().unwrap().doc.slice_ids()[0];
|
||||
let destination = add_slice(&mut app, 80.0);
|
||||
select_slice(&mut app, source);
|
||||
app.run(dialog, json!({})).unwrap();
|
||||
if !divide {
|
||||
set(&app, "name", json!("Original"));
|
||||
}
|
||||
let (field, typed) = draft(divide);
|
||||
set(&app, field, typed.clone());
|
||||
select_slice(&mut app, destination);
|
||||
let st = app.session.active().unwrap();
|
||||
let undo = st.history.undo.len();
|
||||
@@ -253,7 +252,22 @@ mod tests {
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!(*st.doc, *document, "the changed selection is untouched");
|
||||
assert_eq!(st.history.undo.len(), undo);
|
||||
assert_eq!(app.ui.status, "The slice selection changed while the dialog was open.");
|
||||
assert!(slice_dialog_open(&app), "the refused dialog stays open");
|
||||
assert_eq!(refusal(&app).as_deref(), Some("The slice selection changed while the dialog was open."));
|
||||
assert_eq!(the_dialog(&app).1[field], typed, "the refused dialog keeps what was typed");
|
||||
|
||||
// With the opening slice selected again, the same draft applies.
|
||||
select_slice(&mut app, source);
|
||||
assert!(ok(&mut app));
|
||||
assert!(!slice_dialog_open(&app), "the accepted dialog closes");
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!(st.history.undo.len(), undo + 1, "the accepted OK is one undo step");
|
||||
if divide {
|
||||
assert_eq!(st.doc.slices.len(), document.slices.len() + 6, "the opening slice is divided into six cells");
|
||||
} else {
|
||||
assert_eq!(st.doc.slice_options(source).unwrap().name, "Original");
|
||||
assert_eq!(st.doc.slice_options(destination).unwrap().name, "", "the other slice keeps its options");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -267,7 +281,7 @@ mod tests {
|
||||
}
|
||||
|
||||
/// Opens `dialog` on the saved document's slice, edits the document, reverts it and reselects the same slice id;
|
||||
/// OK then leaves the restored document as it is and reports the revert. Returns the app and the slice.
|
||||
/// OK then leaves the restored document as it is and the dialog open with the reason. Returns the app and the slice.
|
||||
fn check_refused_after_file_revert(dialog: &str, divide: bool, tag: &str) -> (VectorcraftApp, NodeId) {
|
||||
let mut app = app();
|
||||
let slice = app.session.active().unwrap().doc.slice_ids()[0];
|
||||
@@ -292,7 +306,8 @@ mod tests {
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!(*st.doc, *restored, "OK leaves the restored document's slices unchanged");
|
||||
assert_eq!(st.history.undo.len(), undo);
|
||||
assert_eq!(app.ui.status, "The document was reverted. Reopen this dialog to continue.");
|
||||
assert!(slice_dialog_open(&app), "the refused dialog stays open");
|
||||
assert_eq!(refusal(&app).as_deref(), Some("The document was reverted. Reopen this dialog to continue."));
|
||||
(app, slice)
|
||||
}
|
||||
|
||||
@@ -332,6 +347,8 @@ mod tests {
|
||||
let st = app.session.active().unwrap();
|
||||
assert_eq!(st.doc.slice_options(to).unwrap().name, "");
|
||||
assert_eq!(st.history.undo.len(), undo);
|
||||
assert_eq!(refusal(&app).as_deref(), Some("The slice selection changed while the dialog was open."), "the refused dialog stays open");
|
||||
assert_eq!(the_dialog(&app).1["name"], "Source", "the refused dialog keeps what was typed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -342,7 +359,7 @@ mod tests {
|
||||
select_slice(&mut app, other);
|
||||
app.run("object.slice.options", json!({})).unwrap();
|
||||
let ctx = app.ui_ctx.clone().unwrap();
|
||||
pump(&mut app, &ctx);
|
||||
crate::dialogs::host::pump(&mut app, &ctx);
|
||||
set(&app, "name", json!("Replacement"));
|
||||
|
||||
assert!(ok(&mut app));
|
||||
|
||||
@@ -678,3 +678,29 @@ fn an_empty_password_still_asks_for_the_password() {
|
||||
assert!(!import_pdf::offer_place_password(&mut app, &p), "a given password is placed with");
|
||||
assert!(!is_open(&app));
|
||||
}
|
||||
|
||||
/// A page number the Page field refuses when Tab leaves it goes back to the page shown before the edit, and OK places
|
||||
/// that page.
|
||||
#[test]
|
||||
fn a_page_the_field_refuses_on_tab_places_the_page_it_restores() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use egui::{Key, Modifiers};
|
||||
|
||||
let mut panel = Panel::new(app(), crate::tests::picks::dialogs);
|
||||
panel.room(egui::vec2(1000.0, 800.0));
|
||||
place(&mut panel.app(), &three_pages(), json!({"at": [100, 120], "link": false})).unwrap();
|
||||
panel.frame();
|
||||
panel.click("Page");
|
||||
panel.key(Key::A, Modifiers::COMMAND);
|
||||
panel.type_text("2");
|
||||
assert_eq!(field(&panel.app(), "page"), 2);
|
||||
panel.type_text("*");
|
||||
panel.key(Key::Tab, Modifiers::NONE);
|
||||
assert!(is_open(&panel.app()));
|
||||
assert_eq!(field(&panel.app(), "page"), 1, "the refused text restores the page from before the edit");
|
||||
panel.click("OK");
|
||||
panel.frame();
|
||||
assert!(!is_open(&panel.app()));
|
||||
let (_, bounds) = placed(&panel.app());
|
||||
assert_eq!((bounds.width(), bounds.height()), (100.0, 100.0), "the first page is placed");
|
||||
}
|
||||
@@ -295,18 +295,15 @@ fn checked_artboards_read_as_a_range() {
|
||||
|
||||
/// The rect the frame `shapes` paint `texture` over; `None` when none paints it.
|
||||
fn painted(shapes: &[egui::epaint::ClippedShape], texture: egui::TextureId) -> Option<egui::Rect> {
|
||||
fn walk(shape: &egui::Shape, texture: egui::TextureId, out: &mut Option<egui::Rect>) {
|
||||
match shape {
|
||||
egui::Shape::Vec(all) => all.iter().for_each(|s| walk(s, texture, out)),
|
||||
egui::Shape::Mesh(mesh) if mesh.texture_id == texture => {
|
||||
let at = mesh.calc_bounds();
|
||||
*out = Some(out.map_or(at, |r| r.union(at)));
|
||||
}
|
||||
_ => {}
|
||||
let mut out: Option<egui::Rect> = None;
|
||||
for (shape, transform, _) in crate::tests_labels::painted_shapes(shapes) {
|
||||
if let egui::Shape::Mesh(mesh) = shape
|
||||
&& mesh.texture_id == texture
|
||||
{
|
||||
let at = transform * mesh.calc_bounds();
|
||||
out = Some(out.map_or(at, |r| r.union(at)));
|
||||
}
|
||||
}
|
||||
let mut out = None;
|
||||
shapes.iter().for_each(|clipped| walk(&clipped.shape, texture, &mut out));
|
||||
out
|
||||
}
|
||||
|
||||
@@ -943,14 +940,11 @@ fn a_preset_export_reopens_on_its_rows() {
|
||||
}
|
||||
|
||||
fn screen_text_at(out: &egui::FullOutput, label: &str) -> egui::Pos2 {
|
||||
fn find(shape: &egui::Shape, label: &str) -> Option<egui::Pos2> {
|
||||
match shape {
|
||||
egui::Shape::Text(t) if t.galley.text().trim() == label => Some(t.visual_bounding_rect().center()),
|
||||
egui::Shape::Vec(v) => v.iter().find_map(|s| find(s, label)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
out.shapes.iter().find_map(|s| find(&s.shape, label)).unwrap_or_else(|| panic!("missing {label}: {}", crate::tests_labels::shapes_text(out)))
|
||||
crate::tests_labels::text_shapes(out)
|
||||
.into_iter()
|
||||
.find(|(t, _)| t.galley.text().trim() == label)
|
||||
.map(|(t, transform)| (transform * t.visual_bounding_rect()).center())
|
||||
.unwrap_or_else(|| panic!("missing {label}: {}", crate::tests_labels::shapes_text(out)))
|
||||
}
|
||||
|
||||
/// First-directory entries of the big-endian TIFF chosen below: tag, type, count, inline value.
|
||||
@@ -1670,3 +1664,87 @@ fn the_format_rows_fit_the_right_column_at_the_default_and_least_window_sizes()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The items pane, in the grid and in the list, with one artboard and with many: the artboards sit in a sunken frame
|
||||
/// at least one and a half tiles or five rows tall, the view buttons and the prefix sit under the frame, and the checked
|
||||
/// artboards are the selected ones.
|
||||
#[test]
|
||||
fn the_artboards_sit_in_a_framed_view_as_tall_as_the_pane_and_the_checked_ones_are_selected() {
|
||||
for (boards, view) in [(1, "grid"), (1, "list"), (12, "grid"), (12, "list")] {
|
||||
let (mut app, _) = app(boards, false);
|
||||
let mut w = Window::default();
|
||||
w.run(&mut app, vec![]);
|
||||
open(&mut app);
|
||||
set(&mut app, "view", json!(view));
|
||||
let shown = |w: &mut Window, app: &mut VectorcraftApp| {
|
||||
w.run(app, vec![]);
|
||||
let out = w.run(app, vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
(out.shapes, nodes)
|
||||
};
|
||||
let rect = |n: &egui::accesskit::Node| {
|
||||
n.bounds().map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32)))
|
||||
};
|
||||
let (shapes, nodes) = shown(&mut w, &mut app);
|
||||
let find = |label: &str, role: Role| {
|
||||
nodes
|
||||
.iter()
|
||||
.find(|(_, n)| n.label() == Some(label) && n.role() == role)
|
||||
.and_then(|(_, n)| rect(n))
|
||||
.unwrap_or_else(|| panic!("{view}: no {role:?} {label:?}"))
|
||||
};
|
||||
let pane = nodes
|
||||
.iter()
|
||||
.find(|(_, n)| n.label() == Some("Export for Screens") && matches!(n.role(), Role::ListBox | Role::List))
|
||||
.and_then(|(_, n)| rect(n))
|
||||
.unwrap_or_else(|| panic!("{boards} {view}: no items view"));
|
||||
let clear = find("Clear Selection", Role::Button);
|
||||
let tile = find("1 Artboard 1", Role::ListItem);
|
||||
// The frame: a filled or outlined rectangle that holds the items view.
|
||||
fn rects(shape: &egui::Shape, out: &mut Vec<egui::epaint::RectShape>) {
|
||||
match shape {
|
||||
egui::Shape::Rect(r) => out.push(r.clone()),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| rects(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut painted = Vec::new();
|
||||
shapes.iter().for_each(|c| rects(&c.shape, &mut painted));
|
||||
let near: Vec<_> = painted.iter().filter(|r| r.rect.expand(4.0).contains_rect(pane) && pane.expand(4.0).contains_rect(r.rect)).collect();
|
||||
let framed = near.iter().any(|r| r.stroke.width > 0.0 || r.fill.a() > 0);
|
||||
assert!(framed, "{boards} {view}: the items view at {pane:?} has a frame: {near:?}");
|
||||
assert!(clear.top() >= pane.bottom(), "{boards} {view}: Clear Selection {clear:?} is under the items {pane:?}");
|
||||
// One and a half tiles tall in the grid, five rows in the list, whatever the count of artboards.
|
||||
let least = if view == "grid" { 1.5 } else { 5.0 } * tile.height();
|
||||
assert!(pane.height() >= least, "{boards} {view}: the items view {pane:?} is at least {least} tall (an item is {tile:?})");
|
||||
let selected = |nodes: &[(egui::accesskit::NodeId, egui::accesskit::Node)]| {
|
||||
nodes.iter().find(|(_, n)| n.label() == Some("1 Artboard 1") && n.role() == Role::ListItem).and_then(|(_, n)| n.is_selected())
|
||||
};
|
||||
assert_eq!(selected(&nodes), Some(true), "{boards} {view}: the checked artboard is selected");
|
||||
let mut off = vec![true; boards];
|
||||
off[0] = false;
|
||||
set(&mut app, "boards", json!(off));
|
||||
let (_, nodes) = shown(&mut w, &mut app);
|
||||
assert_ne!(selected(&nodes), Some(true), "{boards} {view}: an artboard that is not checked is not selected");
|
||||
}
|
||||
}
|
||||
|
||||
/// With two artboards checked, the arrow keys move to a checked one and, a frame later, Space unchecks only that one,
|
||||
/// in the grid and in the list.
|
||||
#[test]
|
||||
fn space_on_a_checked_artboard_flips_only_its_own_check() {
|
||||
for (view, back) in [("grid", egui::Key::ArrowLeft), ("list", egui::Key::ArrowUp)] {
|
||||
let (mut app, _) = app(3, false);
|
||||
let mut w = Window::default();
|
||||
w.names(&mut app);
|
||||
open(&mut app);
|
||||
set(&mut app, "view", json!(view));
|
||||
set(&mut app, "boards", json!([true, true, false]));
|
||||
w.press(&mut app, "3 Artboard 3", Role::ListItem);
|
||||
assert_eq!(field(&app, "boards"), json!([true, true, false]), "{view}: a click on the third artboard leaves the checks");
|
||||
w.key(&mut app, back);
|
||||
w.run(&mut app, vec![]);
|
||||
w.key(&mut app, egui::Key::Space);
|
||||
assert_eq!(field(&app, "boards"), json!([true, false, false]), "{view}: Space unchecks only the second artboard");
|
||||
}
|
||||
}
|
||||
@@ -72,16 +72,6 @@ fn frame_texts(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<String> {
|
||||
|
||||
/// The texts the dialogs paint with where each is drawn and its font, once they have faded in.
|
||||
fn frame_runs(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<(String, egui::Rect, Option<egui::FontId>)> {
|
||||
fn walk(s: &egui::Shape, out: &mut Vec<(String, egui::Rect, Option<egui::FontId>)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => {
|
||||
let font = t.galley.job.sections.first().map(|section| section.format.font_id.clone());
|
||||
out.push((t.galley.text().to_string(), t.galley.rect.translate(t.pos.to_vec2()), font));
|
||||
}
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let dialogs = app.dialogs().expect("a window");
|
||||
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 1200.0));
|
||||
let mut texts = vec![];
|
||||
@@ -89,8 +79,13 @@ fn frame_runs(app: &VectorcraftApp, ctx: &egui::Context) -> Vec<(String, egui::R
|
||||
let raw = egui::RawInput { screen_rect: Some(screen), time: Some(f64::from(k) * 0.25), ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw, |ui| dialogs.with(|host| host.run(ui)));
|
||||
out.textures_delta.clear();
|
||||
texts.clear();
|
||||
out.shapes.iter().for_each(|c| walk(&c.shape, &mut texts));
|
||||
texts = crate::tests_labels::text_shapes(&out)
|
||||
.into_iter()
|
||||
.map(|(t, transform)| {
|
||||
let font = t.galley.job.sections.first().map(|section| section.format.font_id.clone());
|
||||
(t.galley.text().to_string(), transform * t.galley.rect.translate(t.pos.to_vec2()), font)
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
texts
|
||||
}
|
||||
|
||||
@@ -15,18 +15,10 @@ fn app_with(n: usize) -> VectorcraftApp {
|
||||
|
||||
/// One headless frame of the canvas panel's body (the tabs and the canvas or panes) on a
|
||||
/// 1200 × 800 window, then the floating document windows, which egui draws inside the window, run
|
||||
/// as the hosts run a frame → the shapes it drew, `Shape::Vec`s flattened.
|
||||
/// as the hosts run a frame → the shapes it drew, `Shape::Vec`s and retained paint chunks flattened.
|
||||
fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<Shape> {
|
||||
fn flat(s: Shape, out: &mut Vec<Shape>) {
|
||||
match s {
|
||||
Shape::Vec(v) => v.into_iter().for_each(|s| flat(s, out)),
|
||||
s => out.push(s),
|
||||
}
|
||||
}
|
||||
let out = run_frame(app, ctx, events);
|
||||
let mut shapes = vec![];
|
||||
out.shapes.into_iter().for_each(|c| flat(c.shape, &mut shapes));
|
||||
shapes
|
||||
crate::tests_labels::flat_painted_shapes(&out.shapes)
|
||||
}
|
||||
|
||||
/// One headless frame of the canvas panel's body and the floating document windows on a 1200 ×
|
||||
|
||||
@@ -132,11 +132,9 @@ mod tests {
|
||||
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| super::show(app, ui));
|
||||
out.textures_delta.clear();
|
||||
let mut texts = String::new();
|
||||
for shape in out.shapes {
|
||||
if let egui::epaint::Shape::Text(t) = shape.shape {
|
||||
texts.push_str(t.galley.text());
|
||||
texts.push('\n');
|
||||
}
|
||||
for (t, _) in crate::tests_labels::text_shapes(&out) {
|
||||
texts.push_str(t.galley.text());
|
||||
texts.push('\n');
|
||||
}
|
||||
texts
|
||||
}
|
||||
|
||||
@@ -288,8 +288,6 @@ pub struct VectorcraftApp {
|
||||
pub(crate) three_d: panels::three_d::Model,
|
||||
/// The open export option dialogs and what runs after each.
|
||||
pub(crate) export_dialogs: dialogs::export_host::ExportDialogs,
|
||||
/// The document and selection used by each open slice dialog.
|
||||
pub(crate) slice_dialogs: dialogs::slices::SliceDialogs,
|
||||
/// The drawing and loaded contents the open Package dialog saves and collects.
|
||||
pub(crate) package_document: Option<(u64, u64)>,
|
||||
/// Save for Web's renders and colour table.
|
||||
|
||||
@@ -738,7 +738,7 @@ fn run_ui_part6(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
// Tab: hide the panels, the toolbars and the Control bar, or show what the last Tab
|
||||
// hid; the window's shell applies it in its next pass.
|
||||
Some(ctx) => {
|
||||
let hidden = craft::ui::shell::chrome_state(&ctx, egui::ViewportId::ROOT).hidden;
|
||||
let hidden = crate::panel_docking::tab_hidden(app);
|
||||
request_chrome_toggle(&ctx, egui::ViewportId::ROOT, if hidden { ChromeToggle::ShowPanels } else { ChromeToggle::Panels });
|
||||
Ok(json!(hidden))
|
||||
}
|
||||
|
||||
@@ -262,6 +262,21 @@ fn help_f1_opens_discover_without_a_document() {
|
||||
assert!(crate::panel_docking::showing(&app.ui, "discover"));
|
||||
}
|
||||
|
||||
/// In Standard Screen Mode Tab hides the panels, the toolbars and the Control bar, and the next Tab
|
||||
/// shows them again.
|
||||
#[test]
|
||||
fn a_second_tab_shows_what_the_first_hid() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
|
||||
let ctx = crate::testing::ui_context();
|
||||
app.ui_ctx = Some(ctx.clone());
|
||||
assert_eq!(app.run("window.dock", json!({})).unwrap(), json!(false));
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
assert!(crate::panel_docking::tab_hidden(&app));
|
||||
assert_eq!(app.run("window.dock", json!({})).unwrap(), json!(true), "the second Tab shows what the first hid");
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
assert!(!crate::panel_docking::tab_hidden(&app));
|
||||
}
|
||||
|
||||
/// With the toolbars hidden by Tab, choosing a tool in Help, or a tool's link in a tutorial Help
|
||||
/// shows, marks nothing and the status bar says why.
|
||||
#[test]
|
||||
@@ -273,18 +288,10 @@ fn discover_says_why_a_tool_cannot_be_marked() {
|
||||
}
|
||||
fn texts(ctx: &egui::Context, app: &mut VectorcraftApp, events: Vec<egui::Event>) -> Vec<(String, egui::Rect)> {
|
||||
let out = pass(ctx, app, events);
|
||||
fn collect(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut texts = vec![];
|
||||
for c in &out.shapes {
|
||||
collect(&c.shape, &mut texts);
|
||||
}
|
||||
texts
|
||||
crate::tests_labels::text_shapes(&out)
|
||||
.into_iter()
|
||||
.map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect()))
|
||||
.collect()
|
||||
}
|
||||
fn click(ctx: &egui::Context, app: &mut VectorcraftApp, label: &str) {
|
||||
texts(ctx, app, vec![]);
|
||||
@@ -314,7 +321,7 @@ fn discover_says_why_a_tool_cannot_be_marked() {
|
||||
// Tab hides the toolbars in the shell's next pass.
|
||||
app.run("window.dock", json!({})).unwrap();
|
||||
app_frame(&mut app, &ctx, vec![]);
|
||||
assert!(craft::ui::shell::chrome_state(&ctx, egui::ViewportId::ROOT).hidden);
|
||||
assert!(crate::panel_docking::tab_hidden(&app));
|
||||
let reason = app.run("learn.locateTool", json!({"tool": "rectangle"})).unwrap()["reason"].as_str().unwrap().to_string();
|
||||
|
||||
let found = app.run("help.discover.search", json!({"query": "rectangle"})).unwrap();
|
||||
|
||||
@@ -522,11 +522,9 @@ fn progress(app: &mut VectorcraftApp, ctx: &egui::Context) -> String {
|
||||
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| crate::export_progress::show(app, ui));
|
||||
out.textures_delta.clear();
|
||||
let mut texts = String::new();
|
||||
for shape in out.shapes {
|
||||
if let egui::epaint::Shape::Text(t) = shape.shape {
|
||||
texts.push_str(t.galley.text());
|
||||
texts.push('\n');
|
||||
}
|
||||
for (t, _) in crate::tests_labels::text_shapes(&out) {
|
||||
texts.push_str(t.galley.text());
|
||||
texts.push('\n');
|
||||
}
|
||||
texts
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ fn tool_home(app: &VectorcraftApp, tool: &str) -> String {
|
||||
None => name.to_string(),
|
||||
};
|
||||
// Tab hides every toolbar with the panels, as the main window's shell left it.
|
||||
let tab_hidden = app.ui_ctx.as_ref().is_some_and(|ctx| craft::ui::shell::chrome_state(ctx, egui::ViewportId::ROOT).hidden);
|
||||
let tab_hidden = crate::panel_docking::tab_hidden(app);
|
||||
let toolbars_shown = app.ui.screen_mode < 3 && !tab_hidden;
|
||||
let main = crate::toolbar::slots(app).into_iter().map(|(_, s)| s).find(|s| s.contains(&tool));
|
||||
// A group torn off into a strip shows each of its tools on its own button.
|
||||
|
||||
@@ -226,20 +226,23 @@ fn settle(app: &mut VectorcraftApp) {
|
||||
/// last pass left it, and Presentation Mode is off? With no window yet nothing hides them.
|
||||
pub(crate) fn panels_shown(app: &VectorcraftApp) -> bool {
|
||||
let chrome = app.ui_ctx.as_ref().map(|ctx| chrome_state(ctx, egui::ViewportId::ROOT)).unwrap_or_default();
|
||||
!chrome.hidden && !chrome.panels_hidden && app.ui.screen_mode < 3
|
||||
!chrome.hidden && !chrome.chrome_hidden && !chrome.panels_hidden && app.ui.screen_mode < 3
|
||||
}
|
||||
|
||||
/// Whether Tab hides the main window's panels, toolbars and Control bar (Shift+Tab leaves the
|
||||
/// toolbars).
|
||||
pub(crate) fn tab_hidden(app: &VectorcraftApp) -> bool {
|
||||
app.ui_ctx.as_ref().is_some_and(|ctx| chrome_state(ctx, egui::ViewportId::ROOT).hidden)
|
||||
app.ui_ctx.as_ref().is_some_and(|ctx| {
|
||||
let chrome = chrome_state(ctx, egui::ViewportId::ROOT);
|
||||
chrome.hidden || chrome.chrome_hidden
|
||||
})
|
||||
}
|
||||
|
||||
/// Ends Tab and Shift+Tab hiding the panels in the main window; nothing while they show.
|
||||
pub(crate) fn show_panels(app: &VectorcraftApp) {
|
||||
let Some(ctx) = &app.ui_ctx else { return };
|
||||
let chrome = chrome_state(ctx, egui::ViewportId::ROOT);
|
||||
if chrome.hidden || chrome.panels_hidden {
|
||||
if chrome.hidden || chrome.chrome_hidden || chrome.panels_hidden {
|
||||
request_chrome_toggle(ctx, egui::ViewportId::ROOT, ChromeToggle::ShowPanels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,15 +113,10 @@ impl Host {
|
||||
};
|
||||
let mut full = ctx.run_ui(input, |ui| (viewport.viewport_ui_cb)(ui));
|
||||
full.textures_delta.clear();
|
||||
fn texts(s: &egui::Shape, out: &mut Vec<(String, Rect)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut shown = Vec::new();
|
||||
full.shapes.iter().for_each(|c| texts(&c.shape, &mut shown));
|
||||
let shown: Vec<(String, Rect)> = crate::tests_labels::text_shapes(&full)
|
||||
.into_iter()
|
||||
.map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect()))
|
||||
.collect();
|
||||
let nodes = full.platform_output.accesskit_update.as_ref().map_or_else(Vec::new, |update| {
|
||||
let rect = |b: egui::accesskit::Rect| Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32));
|
||||
update.nodes.iter().filter_map(|(_, node)| Some((node.label()?.to_string(), rect(node.bounds()?)))).collect()
|
||||
|
||||
@@ -1080,11 +1080,10 @@ fn footer_strip_shows_no_rows(h: &mut Harness, case: &str) {
|
||||
egui::Shape::Mesh(m) => m.vertices.iter().all(|v| v.color.a() == 0),
|
||||
_ => false,
|
||||
};
|
||||
let showing: Vec<Rect> = h
|
||||
.shapes
|
||||
.iter()
|
||||
.filter(|c| !transparent(&c.shape))
|
||||
.map(|c| (c.shape.visual_bounding_rect(), c.clip_rect))
|
||||
let showing: Vec<Rect> = crate::tests_labels::painted_shapes(&h.shapes)
|
||||
.into_iter()
|
||||
.filter(|(shape, ..)| !transparent(shape))
|
||||
.map(|(shape, transform, clip)| (transform * shape.visual_bounding_rect(), clip))
|
||||
.filter(|(bounds, clip)| {
|
||||
let seen = clip.intersect(*bounds).intersect(strip);
|
||||
bounds.height() < 60.0 && bounds.top() < footer.top() && seen.is_positive() && seen.height() > 0.5
|
||||
|
||||
@@ -614,6 +614,16 @@ pub(crate) fn panel_menu_states(app: &VectorcraftApp, states: &mut CommandStates
|
||||
crate::canvas::task_bar::menu_states(app, states);
|
||||
}
|
||||
|
||||
/// Names the panel menu rows `rows` in `states`, each by its English label shown in the UI language: a row the menu bar
|
||||
/// and the keymap do not list has no catalog label, and shows its command id without one. The state set for a row
|
||||
/// keeps its enabled and checked flags.
|
||||
pub(crate) fn name_rows<'a>(states: &mut CommandStates, rows: impl IntoIterator<Item = (CommandRef, &'a str)>) {
|
||||
for (command, label) in rows {
|
||||
let state = states.get(&command).cloned().unwrap_or_default();
|
||||
states.set(command, state.title(crate::i18n::t(label)));
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs panel menu command `id` when a panel runs it itself; `None` otherwise.
|
||||
pub(crate) fn run_menu_command(app: &mut VectorcraftApp, id: &str, params: &Value) -> Option<Result<Value, String>> {
|
||||
if id == "ui.libraryPanel.add" {
|
||||
@@ -1318,6 +1328,8 @@ mod tests_links;
|
||||
#[cfg(test)]
|
||||
mod tests_maskview;
|
||||
#[cfg(test)]
|
||||
mod tests_menu_names;
|
||||
#[cfg(test)]
|
||||
mod tests_panel_rows;
|
||||
#[cfg(test)]
|
||||
mod tests_panel_spacing;
|
||||
|
||||
@@ -145,17 +145,17 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
set(Row::Panel(C::InsertStop), recording || has);
|
||||
set(Row::Panel(C::InsertMenuItem), recording || has);
|
||||
set(Row::Panel(C::InsertPath), (recording || has) && f.path);
|
||||
set(Row::SelectObject, recording || has);
|
||||
set(Row::Options, has);
|
||||
set(Row::Panel(C::PlaybackOptions), true);
|
||||
set(Row::Panel(C::Save), f.current.is_some());
|
||||
set(Row::Panel(C::Load), can_load(app));
|
||||
set(Row::Panel(C::Replace), can_load(app) && f.idle);
|
||||
set(Row::Panel(C::ClearAll), f.idle && f.sets > 0);
|
||||
set(Row::Panel(C::Reset), f.idle);
|
||||
// The framework's labels differ from the panel's own words on these rows.
|
||||
let titled = |row: Row, title: &str, enabled: bool| (row.command(), CommandState::new().enabled(enabled).title(title.to_string()));
|
||||
// The framework's labels differ from the panel's own words on these rows, and the panel's own rows have none.
|
||||
let titled = |row: Row, title: &str, enabled: bool| (row.command(), CommandState::new().enabled(enabled).title(crate::i18n::t(title)));
|
||||
for (command, state) in [
|
||||
titled(Row::SelectObject, "Select Object…", recording || has),
|
||||
titled(Row::Options, "Action Options…", has),
|
||||
titled(Row::Panel(C::Play), "Play Current Selection", has || f.waiting),
|
||||
titled(Row::Panel(C::InsertPath), "Insert Select Path", (recording || has) && f.path),
|
||||
titled(Row::Panel(C::ClearAll), "Clear Actions", f.idle && f.sets > 0),
|
||||
|
||||
@@ -604,13 +604,14 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let hidden = part_hidden(app, HIDE_OPTIONS);
|
||||
let prefs = &app.session.prefs;
|
||||
states.set(CommandRef::new("ui.align.hideOptions"), CommandState::new().title(if hidden { tl!("Show Options") } else { tl!("Hide Options") }));
|
||||
states.set(CommandRef::new("ui.align.usePreviewBounds"), CommandState::new().checked(prefs.use_preview_bounds));
|
||||
states.set(CommandRef::new("ui.align.cancelKeyObject"), CommandState::new().enabled(align_to(app) == AlignTo::Key));
|
||||
states.set(CommandRef::new("ui.align.usePreviewBounds"), CommandState::new().checked(prefs.use_preview_bounds).title(tl!("Use Preview Bounds")));
|
||||
let cancel = CommandState::new().enabled(align_to(app) == AlignTo::Key).title(tl!("Cancel Key Object"));
|
||||
states.set(CommandRef::new("ui.align.cancelKeyObject"), cancel);
|
||||
// The key choice is named for what the key is: Align to Key Anchor while it is an anchor point.
|
||||
let key = CommandState::new().enabled(can_choose(app, AlignTo::Key)).checked(shown_align_to(app) == AlignTo::Key);
|
||||
states.set(CommandRef::new("align.toKeyObject"), key.title(align_to_icon_name(AlignTo::Key, key_is_anchor(app)).1));
|
||||
states.set(CommandRef::new("ui.align.glyphBoundsPoint"), CommandState::new().checked(prefs.align_glyph_bounds_point));
|
||||
states.set(CommandRef::new("ui.align.glyphBoundsArea"), CommandState::new().checked(prefs.align_glyph_bounds_area));
|
||||
states.set(CommandRef::new("ui.align.glyphBoundsPoint"), CommandState::new().checked(prefs.align_glyph_bounds_point).title(tl!("Point Text")));
|
||||
states.set(CommandRef::new("ui.align.glyphBoundsArea"), CommandState::new().checked(prefs.align_glyph_bounds_area).title(tl!("Area Text")));
|
||||
}
|
||||
|
||||
/// Runs the Align panel menu command `id`; `None` when `id` is not one of them. The glyph-bounds
|
||||
|
||||
@@ -44,7 +44,7 @@ use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::runtime::commands::{CommandRef, CommandState, CommandStates};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::sections::{FooterAction, FooterBar};
|
||||
use craft::ui::text::NumberOutput;
|
||||
use craft::ui::text::{NumberField, NumberOutput};
|
||||
use egui::{Rect, Ui, vec2};
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::{BlendMode, Paint};
|
||||
@@ -860,11 +860,9 @@ fn item_row<'r>(cx: &'r RowCx<'_>, key: RowKey, i: usize) -> ListRow<'r> {
|
||||
if let Some(st) = stroke_layer {
|
||||
let target = if new_art { WeightTarget::Shown } else { WeightTarget::Item(i) };
|
||||
let pass = cx.pass;
|
||||
row = row.trailing_field(stroke::weight_number(cx.app, Some(st.width)), move |out| {
|
||||
pass.borrow_mut().acts.push(Act::Weight(target, Box::new(out)))
|
||||
});
|
||||
row = row.trailing_field(row_weight(cx.app, Some(st.width)), move |out| pass.borrow_mut().acts.push(Act::Weight(target, Box::new(out))));
|
||||
} else {
|
||||
row = row.trailing_space(stroke::weight_number(cx.app, None));
|
||||
row = row.trailing_space(row_weight(cx.app, None));
|
||||
}
|
||||
let painted = if new_art { Painted::NewArt { fill } } else { Painted::Item(i) };
|
||||
let pass = cx.pass;
|
||||
@@ -892,6 +890,13 @@ fn paint_swatch(fill: bool, paint: &Paint) -> Swatch {
|
||||
.tooltip(tl!("Click to choose a swatch, Shift-click to mix a colour"))
|
||||
}
|
||||
|
||||
/// The weight field of a stroke row, or the room it takes in a fill row: the Stroke panel's field as a small control,
|
||||
/// as the row's swatch is, without the presets list (a step still stops at each preset), so the row's label shows
|
||||
/// whole in the narrowest group.
|
||||
fn row_weight(app: &VectorcraftApp, weight: Option<f64>) -> NumberField<'static> {
|
||||
stroke::steps_weight(app, weight).size(ControlSize::Sm)
|
||||
}
|
||||
|
||||
/// A stroke row's notes after the weight: its brush and "Dashed".
|
||||
fn stroke_notes(st: &vectorcraft_doc::StrokeLayer) -> Option<String> {
|
||||
let dashed = st.dash.as_ref().is_some_and(|d| d.is_dashed()).then_some(tl!("Dashed"));
|
||||
@@ -1898,8 +1903,8 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let enabled = |on: bool| CommandState::new().enabled(on);
|
||||
states.set("appearance.addFill", enabled(has));
|
||||
states.set("appearance.addStroke", enabled(has));
|
||||
states.set(DUPLICATE_ITEM, enabled(has && sel.editable()));
|
||||
states.set(REMOVE_ITEM, enabled(has && sel.deletable()));
|
||||
states.set(DUPLICATE_ITEM, enabled(has && sel.editable()).title(tl!("Duplicate Item")));
|
||||
states.set(REMOVE_ITEM, enabled(has && sel.deletable()).title(tl!("Remove Item")));
|
||||
states.set("appearance.clear", enabled(has));
|
||||
states.set("appearance.reduceToBasic", enabled(any_subject_needs_reduction(app)));
|
||||
states.set(new_art_basic(app), enabled(true).checked(app.session.prefs.new_art_basic));
|
||||
|
||||
@@ -677,6 +677,34 @@ fn an_appearance_row_held_across_file_revert_is_not_dropped_on_the_footer() {
|
||||
assert_eq!(items(&panel), before + 1, "a drag started after the revert still duplicates the row");
|
||||
}
|
||||
|
||||
/// A floating group at the narrowest panel width shows the "Stroke:" and "Fill:" links whole, as wide as a wide group
|
||||
/// shows them: the stroke weight beside them is a small field inside the panel, and the stroke and fill swatches still
|
||||
/// stand in one column.
|
||||
#[test]
|
||||
fn the_narrowest_group_shows_the_stroke_and_fill_labels_whole() {
|
||||
use crate::panel_docking::PANEL_MIN_WIDTH;
|
||||
use crate::tests::panel_harness::{Place, floated};
|
||||
let one = |shown: &crate::tests::panel_harness::Shown, name: &str, width: f32| {
|
||||
let rects = shown.rects(name);
|
||||
assert_eq!(rects.len(), 1, "one {name:?} at {width} pt: {rects:?}");
|
||||
rects[0]
|
||||
};
|
||||
let links = |width: f32| {
|
||||
let shown = floated(app_with_a_selected_rectangle(), "appearance", "en", Place::Floating(width), &["Stroke:", "Fill:"]);
|
||||
let [stroke, fill] = ["Stroke:", "Fill:"].map(|name| one(&shown, name, width).width());
|
||||
let [stroke_well, fill_well] = ["Stroke swatch", "Fill swatch"].map(|name| one(&shown, name, width).left());
|
||||
assert!((stroke_well - fill_well).abs() < 0.5, "the swatches stand at {stroke_well} and {fill_well} pt at {width} pt");
|
||||
let weight = one(&shown, "Weight", width);
|
||||
assert!(shown.body.contains_rect(weight), "the weight field {weight:?} stands inside the panel {:?} at {width} pt", shown.body);
|
||||
([stroke, fill], format!("stroke swatch at {stroke_well} pt, weight {weight:?}"))
|
||||
};
|
||||
let (wide, _) = links(400.0);
|
||||
let (narrow, row) = links(PANEL_MIN_WIDTH);
|
||||
for (at, name) in ["Stroke:", "Fill:"].iter().enumerate() {
|
||||
assert!(narrow[at] >= wide[at] - 0.5, "{name:?} is {} pt wide at {PANEL_MIN_WIDTH} pt and {} pt at 400 pt ({row})", narrow[at], wide[at]);
|
||||
}
|
||||
}
|
||||
|
||||
/// The panel's subject is the `Arc` the document holds for the selected object, a targeted group
|
||||
/// or a targeted layer, not a copy of it; nothing with nothing selected.
|
||||
#[test]
|
||||
|
||||
@@ -824,25 +824,46 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let facts = Facts::of(app);
|
||||
for panel_row in menu_rows(app) {
|
||||
let PanelRow::Command(command) = panel_row else { continue };
|
||||
let Some(f) = &facts else {
|
||||
states.set(command, CommandState::new().enabled(false));
|
||||
continue;
|
||||
let row = command.id.strip_prefix(PREFIX).unwrap_or_default();
|
||||
let state = match (&facts, row) {
|
||||
(None, _) => CommandState::new().enabled(false),
|
||||
(Some(f), "add" | "add3D") => CommandState::new().enabled(f.has_art),
|
||||
(Some(f), "selectAll") => CommandState::new().enabled(!f.all.is_empty()),
|
||||
(Some(f), "remove") => CommandState::new().enabled(!f.sel.is_empty()),
|
||||
(Some(f), "subfolders") => CommandState::new().checked(f.subfolders),
|
||||
(Some(f), "openLocation") => CommandState::new().checked(f.open_location),
|
||||
(Some(f), "applyPreset") => CommandState::new().checked(f.applied == command.params["name"].as_str().unwrap_or_default()),
|
||||
(Some(f), "saveChanges" | "deletePreset") => CommandState::new().enabled(f.saved),
|
||||
(Some(f), "exportPreset") => CommandState::new().enabled(f.known),
|
||||
_ => CommandState::new(),
|
||||
};
|
||||
let state = match command.id.strip_prefix(PREFIX).unwrap_or_default() {
|
||||
"add" | "add3D" => CommandState::new().enabled(f.has_art),
|
||||
"selectAll" => CommandState::new().enabled(!f.all.is_empty()),
|
||||
"remove" => CommandState::new().enabled(!f.sel.is_empty()),
|
||||
"subfolders" => CommandState::new().checked(f.subfolders),
|
||||
"openLocation" => CommandState::new().checked(f.open_location),
|
||||
"applyPreset" => {
|
||||
let name = command.params["name"].as_str().unwrap_or_default().to_string();
|
||||
CommandState::new().checked(f.applied == name).title(name)
|
||||
}
|
||||
"saveChanges" | "deletePreset" => CommandState::new().enabled(f.saved),
|
||||
"exportPreset" => CommandState::new().enabled(f.known),
|
||||
_ => continue,
|
||||
let title = match row {
|
||||
"applyPreset" => command.params["name"].as_str().unwrap_or_default().to_string(),
|
||||
"add" if command.params["multiple"] == true => tl!("Add Selected Artwork as Multiple Assets").to_string(),
|
||||
row => tl!(menu_label(row)).to_string(),
|
||||
};
|
||||
states.set(command, state);
|
||||
states.set(command, state.title(title));
|
||||
}
|
||||
}
|
||||
|
||||
/// The English label of the panel menu's row `row` (`ui.assetExport.<row>`); Add Selected Artwork as Multiple Assets
|
||||
/// and the presets' rows are named by [`menu_states`].
|
||||
fn menu_label(row: &str) -> &'static str {
|
||||
match row {
|
||||
"add" => "Add Selected Artwork as One Asset",
|
||||
"add3D" => "Export 3D Object",
|
||||
"selectAll" => "Select All Assets",
|
||||
"remove" => "Remove Selected Assets",
|
||||
"exportForScreens" => "Export for Screens…",
|
||||
"formatSettings" => "Format Settings…",
|
||||
"subfolders" => "Create Sub-folders",
|
||||
"openLocation" => "Open Location after Export",
|
||||
"savePresetAs" => "Save As Preset…",
|
||||
"saveChanges" => "Save Changes",
|
||||
"deletePreset" => "Delete Preset",
|
||||
"importPreset" => "Import Preset…",
|
||||
"exportPreset" => "Export Preset…",
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -767,6 +767,25 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
states.set(CommandRef::new(THUMBNAIL_VIEW), on(true).checked(!view.list));
|
||||
states.set(CommandRef::new(LIST_VIEW), on(true).checked(view.list));
|
||||
states.set(CommandRef::new(SAVE_LIBRARY), on(!list.is_empty()));
|
||||
let names = [
|
||||
(new_brush("calligraphic"), "New Calligraphic Brush"),
|
||||
(new_brush("bristle"), "New Bristle Brush"),
|
||||
(new_brush("art"), "New Art Brush from Selection"),
|
||||
(new_brush("scatter"), "New Scatter Brush from Selection"),
|
||||
(new_brush("pattern"), "New Pattern Brush from Selection"),
|
||||
(CommandRef::new(DUPLICATE), "Duplicate Brush"),
|
||||
(CommandRef::new(DELETE_BRUSH), "Delete Brush"),
|
||||
(CommandRef::new(SELECT_UNUSED), "Select All Unused"),
|
||||
(CommandRef::new(THUMBNAIL_VIEW), "Thumbnail View"),
|
||||
(CommandRef::new(LIST_VIEW), "List View"),
|
||||
(CommandRef::new(SAVE_LIBRARY), "Save Brush Library…"),
|
||||
];
|
||||
super::name_rows(states, names);
|
||||
for (ty, label) in KINDS {
|
||||
let title = crate::i18n::fmt(tl!("Show {kind} Brushes"), &[("kind", tl!(label))]);
|
||||
let state = states.get(&show_kind(ty)).cloned().unwrap_or_default();
|
||||
states.set(show_kind(ty), state.title(title));
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the panel menu's own row `id`; `None` for an id that is not one of them.
|
||||
|
||||
@@ -412,6 +412,7 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
for id in [SAVE, ADD_TO_SWATCHES, EDIT, DELETE] {
|
||||
states.set(CommandRef::new(id), CommandState::new().enabled(enabled(app, id)));
|
||||
}
|
||||
super::name_rows(states, [(CommandRef::new(SAVE), "Save Theme"), (CommandRef::new(ADD_TO_SWATCHES), "Add to Swatches")]);
|
||||
states.set(CommandRef::new(SHOW_FIND), CommandState::new().checked(app.ui.color_themes_panel.show_find));
|
||||
}
|
||||
|
||||
|
||||
@@ -285,17 +285,18 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let panel = &app.ui.css_properties_panel;
|
||||
let selection = app.session.active().map(|st| !st.selection.is_empty());
|
||||
let (has_doc, selected) = (selection.is_some(), selection == Some(true));
|
||||
states.set(CommandRef::new(COPY_SELECTED), CommandState::new().enabled(selected));
|
||||
states.set(CommandRef::new(EXPORT_SELECTED), CommandState::new().enabled(selected));
|
||||
states.set(CommandRef::new(EXPORT_ALL), CommandState::new().enabled(has_doc));
|
||||
states.set(CommandRef::new(GENERATE), CommandState::new().enabled(has_doc).checked(panel.all));
|
||||
states.set(CommandRef::new(COPY_SELECTED), CommandState::new().enabled(selected).title(tl!("Copy Selected Style")));
|
||||
states.set(CommandRef::new(EXPORT_SELECTED), CommandState::new().enabled(selected).title(tl!("Export Selected CSS…")));
|
||||
states.set(CommandRef::new(EXPORT_ALL), CommandState::new().enabled(has_doc).title(tl!("Export All…")));
|
||||
states.set(CommandRef::new(GENERATE), CommandState::new().enabled(has_doc).checked(panel.all).title(tl!("Generate CSS")));
|
||||
for units in CssUnits::ALL {
|
||||
states.set(units_ref(units), CommandState::new().checked(panel.options.units == units));
|
||||
states.set(units_ref(units), CommandState::new().checked(panel.options.units == units).title(units.name()));
|
||||
}
|
||||
let mut options = panel.options.clone();
|
||||
for name in FLAGS {
|
||||
let labels = [tl!("Absolute Position"), tl!("Width and Height"), tl!("Unnamed Objects"), tl!("Rasterize Unsupported Art")];
|
||||
for (name, label) in FLAGS.into_iter().zip(labels) {
|
||||
let on = flag_mut(&mut options, name).is_some_and(|on| *on);
|
||||
states.set(option_ref(name), CommandState::new().checked(on));
|
||||
states.set(option_ref(name), CommandState::new().checked(on).title(label));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -397,8 +397,10 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
|
||||
/// The states of the menu's rows: Refresh needs a document, Show Options is checked while the options show.
|
||||
pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
states.set(CommandRef::new(REFRESH), CommandState::new().enabled(app.session.active().is_some()));
|
||||
states.set(CommandRef::new(SHOW_OPTIONS), CommandState::new().checked(app.ui.flattener_preview.show_options));
|
||||
states.set(CommandRef::new(REFRESH), CommandState::new().enabled(app.session.active().is_some()).title(tl!("Refresh")));
|
||||
states.set(CommandRef::new(SHOW_OPTIONS), CommandState::new().checked(app.ui.flattener_preview.show_options).title(tl!("Show Options")));
|
||||
states.set(CommandRef::new(FIT_IN_WINDOW), CommandState::new().title(tl!("Fit in Window")));
|
||||
states.set(CommandRef::new(SAVE_PRESET), CommandState::new().title(tl!("Save Transparency Flattener Preset…")));
|
||||
}
|
||||
|
||||
/// Runs a menu row; `None` for an id that is not this panel's.
|
||||
|
||||
@@ -1395,6 +1395,7 @@ pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
/// The row titles of a category, which are the panel's words, with the check on the shown one. A
|
||||
/// form no face of the selection has a feature for is disabled ([`form_faces`]).
|
||||
pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
states.set(CommandRef::new("ui.glyphs.useTextFont"), CommandState::new().title(tl!("Use the Selected Text's Font")));
|
||||
let (_, _, face) = browsed_face(app);
|
||||
let cats = categories(face.as_deref());
|
||||
let current = current_category(app, &cats);
|
||||
|
||||
@@ -872,6 +872,19 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
for (v, _) in View::ALL {
|
||||
states.set(view_ref(v), CommandState::new().checked(app.ui.graphic_styles_view == v));
|
||||
}
|
||||
let names = [
|
||||
("new", "New Graphic Style…"),
|
||||
("duplicate", "Duplicate Graphic Style"),
|
||||
("merge", "Merge Graphic Styles"),
|
||||
("delete", "Delete Graphic Style"),
|
||||
("selectUnused", "Select All Unused"),
|
||||
("square", "Use Square for Previews"),
|
||||
("text", "Use Text for Previews"),
|
||||
("options", "Graphic Style Options…"),
|
||||
];
|
||||
let rows = names.into_iter().map(|(row, label)| (CommandRef::new(id(row)), label));
|
||||
let views = View::ALL.into_iter().map(|(v, label)| (view_ref(v), label));
|
||||
crate::panels::name_rows(states, rows.chain(views).chain([(override_ref(app), "Override Character Color")]));
|
||||
}
|
||||
|
||||
/// Run the panel-menu row `id` (an id under `ui.graphicStyles`).
|
||||
|
||||
@@ -1086,6 +1086,7 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let state = states.get(&command).cloned().unwrap_or_else(CommandState::new).enabled(enabled);
|
||||
states.set(command, state);
|
||||
}
|
||||
states.set(CommandRef::new("ui.imageTrace.reset"), CommandState::new().title(tl!("Reset to Default")));
|
||||
}
|
||||
|
||||
/// The panel's own menu commands.
|
||||
|
||||
@@ -860,7 +860,8 @@ fn create_strokes_traces_again_and_keeps_one_kind_on() {
|
||||
for s in ["Create:", "Fills", "Strokes", "Stroke"] {
|
||||
assert!(panel.shows(s), "{s}");
|
||||
}
|
||||
assert_eq!(panel.value("Stroke").as_deref().and_then(number), Some(10.0));
|
||||
// The dimmed row holds a slider and a number box under one name: read the slider.
|
||||
assert_eq!(panel.value_role("Stroke", craft::ui::contract::Role::SLIDER).as_deref().and_then(number), Some(10.0));
|
||||
// Fills alone can't be turned off.
|
||||
panel.click("Fills");
|
||||
assert_eq!(create(&panel), (Some(json!(true)), Some(json!(false))));
|
||||
|
||||
@@ -767,14 +767,12 @@ fn built_in_library_swatches_are_listed_in_the_ui_language() {
|
||||
let panel = shown(&app);
|
||||
app.run("ui.libraryPanel", json!({"panel": panel, "view": "smallList"})).unwrap();
|
||||
let draw = |app: &mut VectorcraftApp, ui: &mut Ui| show(app, ui, &panel);
|
||||
let mut texts = vec![];
|
||||
for _ in 0..2 {
|
||||
let out = draw_frame(&mut app, &ctx, &draw, vec![]);
|
||||
texts =
|
||||
out.shapes.iter().filter_map(|c| if let egui::Shape::Text(t) = &c.shape { Some(t.galley.text().to_string()) } else { None }).collect();
|
||||
}
|
||||
assert!(texts.iter().any(|t| t == "Argile") && texts.iter().any(|t| t == "Argile 1"), "{texts:?}");
|
||||
assert!(!texts.iter().any(|t| t == "Clay" || t == "Clay 1"), "{texts:?}");
|
||||
draw_frame(&mut app, &ctx, &draw, vec![]);
|
||||
let out = draw_frame(&mut app, &ctx, &draw, vec![]);
|
||||
let painted = crate::tests_labels::shapes_text(&out);
|
||||
let texts: Vec<_> = painted.lines().collect();
|
||||
assert!(texts.contains(&"Argile") && texts.contains(&"Argile 1"), "{texts:?}");
|
||||
assert!(!texts.contains(&"Clay") && !texts.contains(&"Clay 1"), "{texts:?}");
|
||||
let lib = SwatchLibraries::get(&app, "earth-tones").unwrap().1;
|
||||
// The browser's Find matches the shown name and the stored one.
|
||||
let rows = SwatchLibraries::rows(&lib, "earth-tones");
|
||||
|
||||
@@ -118,6 +118,12 @@ impl Cache {
|
||||
pub(super) fn nested_node(&self, id: u64) -> Option<&Arc<vectorcraft_doc::Node>> {
|
||||
self.nested.binary_search_by_key(&id, |(n, _)| *n).ok().and_then(|i| self.nested.get(i)).map(|(_, n)| n)
|
||||
}
|
||||
|
||||
/// The object of row `id` of `doc`, for its thumbnail: by the layer tree's index, or, for an
|
||||
/// object outside the layer tree, as [`cached`] collected it.
|
||||
pub(super) fn row_node(&self, doc: &vectorcraft_doc::Document, id: NodeId) -> Option<Arc<vectorcraft_doc::Node>> {
|
||||
super::layers::node_arc(doc, id).or_else(|| self.nested_node(id.0).cloned())
|
||||
}
|
||||
}
|
||||
|
||||
/// What a footer button, a row menu item or a panel menu row does to the selected rows.
|
||||
@@ -762,9 +768,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let rows: &[Value] = cache.list["links"].as_array().map_or(&[], Vec::as_slice);
|
||||
let by_id: HashMap<u64, &Value> = rows.iter().filter_map(|r| Some((r["id"].as_u64()?, r))).collect();
|
||||
let row_ids: Vec<u64> = rows.iter().filter_map(|r| r["id"].as_u64()).collect();
|
||||
// `lookup` gives the objects outside the layer tree.
|
||||
let thumbs = super::layers::link_thumbnails(ui.ctx());
|
||||
let nodes = super::layers::NodeThumbs::new(&doc, |id| cache.nested_node(id.0).cloned());
|
||||
let nodes = super::layers::NodeThumbs::new(&doc, |id| cache.row_node(&doc, id));
|
||||
let (thumbs, nodes) = (&thumbs, &nodes);
|
||||
let ppp = ui.ctx().pixels_per_point();
|
||||
|
||||
@@ -1049,14 +1054,14 @@ fn link_info(ui: &mut Ui, app: &VectorcraftApp, info: Option<(u64, &Value)>, uni
|
||||
reveal
|
||||
}
|
||||
|
||||
/// A command row with the state its panel-menu row shows.
|
||||
fn entry(app: &VectorcraftApp, f: &Facts, id: &str, params: Value, a: Act) -> (CommandRef, CommandState) {
|
||||
(CommandRef::with_params(id, params), CommandState::new().enabled(can(app, a, f, None)))
|
||||
/// A command row named `label` with the state its panel-menu row shows.
|
||||
fn entry(app: &VectorcraftApp, f: &Facts, id: &str, params: Value, a: Act, label: &str) -> (CommandRef, CommandState) {
|
||||
(CommandRef::with_params(id, params), CommandState::new().enabled(can(app, a, f, None)).title(tl!(label)))
|
||||
}
|
||||
|
||||
/// A command row that is always enabled and checked or not.
|
||||
fn option_entry(id: &str, params: Value, checked: bool) -> (CommandRef, CommandState) {
|
||||
(CommandRef::with_params(id, params), CommandState::new().enabled(true).checked(checked))
|
||||
/// A command row named `label` that is always enabled and checked or not.
|
||||
fn option_entry(id: &str, params: Value, checked: bool, label: &str) -> (CommandRef, CommandState) {
|
||||
(CommandRef::with_params(id, params), CommandState::new().enabled(true).checked(checked).title(tl!(label)))
|
||||
}
|
||||
|
||||
/// The panel menu's command rows with their states, in the groups the menu separates: the link
|
||||
@@ -1067,29 +1072,32 @@ fn groups(app: &VectorcraftApp) -> [Vec<(CommandRef, CommandState)>; 6] {
|
||||
let selected = selected_links(app);
|
||||
let f = Facts::of(&cache.list, &selected);
|
||||
let o = &app.ui.links.options;
|
||||
let e = |id: &str, params: Value, a: Act| entry(app, &f, id, params, a);
|
||||
let e = |id: &str, params: Value, a: Act, label: &str| entry(app, &f, id, params, a, label);
|
||||
[
|
||||
vec![
|
||||
e("ui.relinkDialog", json!({ "ids": f.all() }), Act::Relink),
|
||||
e("ui.links.relinkToFolder", Value::Null, Act::RelinkToFolder),
|
||||
e("ui.findLinksInFolder", json!({ "ids": f.linked() }), Act::FindInFolder),
|
||||
e("ui.links.goTo", Value::Null, Act::GoTo),
|
||||
e("ui.links.update", Value::Null, Act::Update),
|
||||
e("links.editOriginal", f.file_row(), Act::Edit),
|
||||
e("ui.relinkDialog", json!({ "ids": f.all() }), Act::Relink, "Relink…"),
|
||||
e("ui.links.relinkToFolder", Value::Null, Act::RelinkToFolder, "Relink to Folder…"),
|
||||
e("ui.findLinksInFolder", json!({ "ids": f.linked() }), Act::FindInFolder, "Find in Folder…"),
|
||||
e("ui.links.goTo", Value::Null, Act::GoTo, "Go To Link"),
|
||||
e("ui.links.update", Value::Null, Act::Update, "Update Link"),
|
||||
e("links.editOriginal", f.file_row(), Act::Edit, "Edit Original"),
|
||||
],
|
||||
vec![
|
||||
e("ui.links.embed", Value::Null, Act::Embed),
|
||||
e("ui.links.unembed", Value::Null, Act::Unembed),
|
||||
e("ui.placementOptionsDialog", json!({ "ids": f.all() }), Act::Placement),
|
||||
e("links.reveal", f.file_row(), Act::Reveal),
|
||||
e("ui.links.embed", Value::Null, Act::Embed, "Embed Image(s)"),
|
||||
e("ui.links.unembed", Value::Null, Act::Unembed, "Unembed…"),
|
||||
e("ui.placementOptionsDialog", json!({ "ids": f.all() }), Act::Placement, "Placement Options…"),
|
||||
e("links.reveal", f.file_row(), Act::Reveal, "Show in Folder"),
|
||||
],
|
||||
SHOW.iter().map(|(k, _)| option_entry("ui.links.show", json!({ "show": k }), o.show == *k)).collect(),
|
||||
SORT.iter().map(|(k, _)| option_entry("ui.links.sort", json!({ "sort": k }), o.sort == Some(*k))).collect(),
|
||||
vec![e("links.copyInfo", json!({ "ids": f.all() }), Act::CopyInfo)],
|
||||
SHOW.iter().map(|(k, label)| option_entry("ui.links.show", json!({ "show": k }), o.show == *k, label)).collect(),
|
||||
SORT.iter().map(|(k, label)| option_entry("ui.links.sort", json!({ "sort": k }), o.sort == Some(*k), label)).collect(),
|
||||
vec![e("links.copyInfo", json!({ "ids": f.all() }), Act::CopyInfo, "Copy Info")],
|
||||
THUMBS
|
||||
.iter()
|
||||
.map(|(k, size, _)| option_entry("ui.links.thumbnails", json!({ "size": k }), o.thumb == *size))
|
||||
.chain([option_entry("ui.links.linkInfo", Value::Null, o.info), option_entry("ui.links.dcs", Value::Null, o.dcs)])
|
||||
.map(|(k, size, label)| option_entry("ui.links.thumbnails", json!({ "size": k }), o.thumb == *size, label))
|
||||
.chain([
|
||||
option_entry("ui.links.linkInfo", Value::Null, o.info, "Show Link Info"),
|
||||
option_entry("ui.links.dcs", Value::Null, o.dcs, "Show DCS Transparency Interactions"),
|
||||
])
|
||||
.collect(),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let style = text_style(app);
|
||||
let has = style.is_some();
|
||||
states.set(CommandRef::new(RESET), CommandState::new().enabled(has));
|
||||
states.set(CommandRef::new(RESET), CommandState::new().enabled(has).title(tl!("Reset OpenType Features")));
|
||||
let sets = style.map(|(st, _)| set_entries(app, &st)).unwrap_or_default();
|
||||
for (set, flag, on) in &sets {
|
||||
if let Some(tag) = flag.tag() {
|
||||
@@ -872,7 +872,7 @@ mod tests {
|
||||
assert_eq!(text_style(&app).unwrap().0.features, ["smcp"]);
|
||||
app.session.execute("select.set", &json!({"ids": []})).unwrap();
|
||||
assert!(!menu_rows(&app).iter().any(|row| matches!(row, PanelRow::Submenu(..))), "the submenu is left out with no text selected");
|
||||
assert_eq!(state_of(&app, &CommandRef::new(RESET)), Some(CommandState::new().enabled(false)));
|
||||
assert_eq!(state_of(&app, &CommandRef::new(RESET)), Some(CommandState::new().enabled(false).title("Reset OpenType Features")));
|
||||
assert_eq!(run(&mut app, "ui.openType.nothing", &json!({})), None);
|
||||
}
|
||||
|
||||
|
||||
@@ -923,7 +923,7 @@ fn composers() -> [(&'static str, Composer); 4] {
|
||||
]
|
||||
}
|
||||
|
||||
/// The Paragraph panel menu's rows; the labels and chords come from the commands' catalogue entries.
|
||||
/// The Paragraph panel menu's rows; [`menu_states`] names them, and the chords come from the commands' catalogue entries.
|
||||
pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
let cmd = |r: CommandRef| PanelRow::Command(r);
|
||||
let mut rows = vec![
|
||||
@@ -965,34 +965,38 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
let has = style.is_some();
|
||||
let title = if app.ui.paragraph_hide_options { tl!("Show Options") } else { tl!("Hide Options") };
|
||||
states.set(show_ref(), CommandState::new().title(title));
|
||||
let mut put = |r: CommandRef, enabled: bool, checked: Option<bool>| states.set(r, state(enabled, checked));
|
||||
// Each row is named here: the rows take params the catalog's rows do not list. `title` is shown as given.
|
||||
let mut put = |r: CommandRef, enabled: bool, checked: Option<bool>, title: &str| states.set(r, state(enabled, checked).title(title));
|
||||
// Quotation marks, hyphens, full stops and commas at a line's ends hang outside the margin.
|
||||
put(toggle_ref("romanHangingPunctuation"), has, Some(style.as_ref().is_some_and(|(_, p)| p.roman_hanging)));
|
||||
put(CommandRef::new("ui.justification"), has, None);
|
||||
put(CommandRef::new("ui.hyphenation"), has, None);
|
||||
let hanging = Some(style.as_ref().is_some_and(|(_, p)| p.roman_hanging));
|
||||
put(toggle_ref("romanHangingPunctuation"), has, hanging, tl!("Roman Hanging Punctuation"));
|
||||
put(CommandRef::new("ui.justification"), has, None, tl!("Justification…"));
|
||||
put(CommandRef::new("ui.hyphenation"), has, None, tl!("Hyphenation…"));
|
||||
if app.session.prefs.show_east_asian_options {
|
||||
let top_to_top = style.as_ref().is_some_and(|(_, p)| p.leading_model == LeadingModel::EmBoxTop);
|
||||
put(set_ref("leadingModel", "emBoxTop"), has, Some(top_to_top));
|
||||
put(set_ref("leadingModel", "romanBaseline"), has, Some(has && !top_to_top));
|
||||
put(set_ref("leadingModel", "emBoxTop"), has, Some(top_to_top), tl!("Top-to-Top Leading"));
|
||||
put(set_ref("leadingModel", "romanBaseline"), has, Some(has && !top_to_top), tl!("Bottom-to-Bottom Leading"));
|
||||
let hang = style.as_ref().map(|(_, p)| p.burasagari);
|
||||
for (_, b, key) in burasagari_rows() {
|
||||
put(set_ref("burasagari", key), has, Some(hang == Some(b)));
|
||||
for (label, b, key) in burasagari_rows() {
|
||||
put(set_ref("burasagari", key), has, Some(hang == Some(b)), label);
|
||||
}
|
||||
put(toggle_ref("kurikaeshiMojiShori"), has, Some(shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true)));
|
||||
let repeat = Some(shared_para(app, |p| p.kurikaeshi_moji_shori) == Some(true));
|
||||
put(toggle_ref("kurikaeshiMojiShori"), has, repeat, tl!("Kurikaeshi Moji Shori"));
|
||||
let kinsoku_type = shared_para(app, |p| p.kinsoku_type);
|
||||
for (_, t, key) in kinsoku_types() {
|
||||
put(set_ref("kinsokuType", key), has, Some(kinsoku_type == Some(t)));
|
||||
for (label, t, key) in kinsoku_types() {
|
||||
put(set_ref("kinsokuType", key), has, Some(kinsoku_type == Some(t)), label);
|
||||
}
|
||||
// Inseparable pairs stay on one line; only with a kinsoku set.
|
||||
let (kinsoku_on, bunri) = bunri_kinshi_item(app);
|
||||
put(toggle_ref("bunriKinshi"), has && kinsoku_on, Some(bunri));
|
||||
put(toggle_ref("koreanLineBreakAnywhere"), has, Some(shared_para(app, |p| p.korean_line_break_anywhere) == Some(true)));
|
||||
put(toggle_ref("bunriKinshi"), has && kinsoku_on, Some(bunri), tl!("Bunri-Kinshi"));
|
||||
let anywhere = Some(shared_para(app, |p| p.korean_line_break_anywhere) == Some(true));
|
||||
put(toggle_ref("koreanLineBreakAnywhere"), has, anywhere, tl!("Korean Line Break Anywhere"));
|
||||
}
|
||||
let composer = shared_composer(app);
|
||||
for (_, c) in composers() {
|
||||
put(set_ref("composer", composer_id(c)), has, Some(composer == Some(c)));
|
||||
for (label, c) in composers() {
|
||||
put(set_ref("composer", composer_id(c)), has, Some(composer == Some(c)), label);
|
||||
}
|
||||
put(reset_ref(), has, None);
|
||||
put(reset_ref(), has, None, tl!("Reset Panel"));
|
||||
}
|
||||
|
||||
/// Runs a `ui.paragraph.*` command; `None` for any other id.
|
||||
|
||||
@@ -10,9 +10,11 @@ fn selected(app: &VectorcraftApp) -> Vec<Justify> {
|
||||
row.map(|r| r.0).into_iter().collect()
|
||||
}
|
||||
|
||||
/// Whether `states` holds `r` with exactly the state `state(enabled, checked)` makes.
|
||||
/// Whether `states` holds `r` with the enabled and checked flags `state(enabled, checked)` makes. The row's name is
|
||||
/// checked in `tests_menu_names`.
|
||||
fn has_state(states: &CommandStates, r: &CommandRef, enabled: bool, checked: Option<bool>) -> bool {
|
||||
format!("{:?}", states.get(r)) == format!("{:?}", Some(&state(enabled, checked)))
|
||||
let want = state(enabled, checked);
|
||||
states.get(r).is_some_and(|s| s.is_enabled() == want.is_enabled() && s.is_checked() == want.is_checked())
|
||||
}
|
||||
|
||||
fn editing_text(text: &str) -> (VectorcraftApp, Value) {
|
||||
|
||||
@@ -136,9 +136,12 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
Row::new().gap(Gap::Item).show(ui, |ui, _| {
|
||||
for ((icon, label, op), mode) in SHAPE_MODES.into_iter().zip(ShapeMode::ALL) {
|
||||
let glyph = ShapeModeGlyph { icon: IconId::new(icon), mixed };
|
||||
// The glyph paints the icon in its own inks, so it is used only for the question mark (mixed modes
|
||||
// keep the buttons on). Otherwise the button paints the set icon, dimmed while it is off.
|
||||
let spec = if mixed { IconSpec::glyph(&glyph) } else { IconSpec::svg(IconId::new(icon)) };
|
||||
let value = if mixed { Mixed::Mixed } else { Mixed::Same(shared == Some(mode)) };
|
||||
let out = ToggleButton::new(tl!(label).to_string(), Bind::given(value))
|
||||
.icon(IconSpec::glyph(&glyph))
|
||||
.icon(spec)
|
||||
.icon_only()
|
||||
.enabled(count >= 2)
|
||||
.tooltip(tip(label))
|
||||
@@ -187,7 +190,7 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
|
||||
/// The states of the panel's own menu commands; the others read the commands' own rules.
|
||||
pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
states.set(CommandRef::new("ui.pathfinder.trap"), CommandState::new().enabled(operands(app) >= 2));
|
||||
states.set(CommandRef::new("ui.pathfinder.trap"), CommandState::new().enabled(operands(app) >= 2).title(tl!("Trap…")));
|
||||
}
|
||||
|
||||
/// Runs the panel's own menu commands; `None` for any other id.
|
||||
|
||||
@@ -446,7 +446,7 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
|
||||
/// Show All Plates is available while the separations preview is on.
|
||||
pub(crate) fn menu_states(_app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
states.set(SHOW_ALL_PLATES, CommandState::new().enabled(proof::view().separations.is_some()));
|
||||
states.set(SHOW_ALL_PLATES, CommandState::new().enabled(proof::view().separations.is_some()).title(tl!("Show All Plates")));
|
||||
}
|
||||
|
||||
/// Runs the panel's own menu command `id`; `None` for any other id. Show All Plates turns the
|
||||
|
||||
@@ -301,10 +301,19 @@ static BLANK_WEIGHT_STOPS: [f64; 2] = [0.25, 0.5];
|
||||
/// 0 pt); Shift or Page steps the grid by ten.
|
||||
// PLAN: the sheet names `NumberField<'static, f64>`; `NumberField::length` takes `Option<f64>`.
|
||||
pub(crate) fn weight_number(app: &VectorcraftApp, weight: Option<f64>) -> NumberField<'static> {
|
||||
let field = steps_weight(app, weight);
|
||||
match weight_ladder(app) {
|
||||
Some(l) => field.presets(&l.rows),
|
||||
None => field,
|
||||
}
|
||||
}
|
||||
|
||||
/// [`weight_number`] without the presets list: a plain step still stops at each preset.
|
||||
pub(crate) fn steps_weight(app: &VectorcraftApp, weight: Option<f64>) -> NumberField<'static> {
|
||||
let unit = app.session.stroke_unit();
|
||||
let lengths =
|
||||
crate::fields::bare_points(LengthUnits::new(UnitKind::Points, shown_kind(unit), 72.0), app.session.prefs.numbers_without_units_are_points);
|
||||
let ladder = LADDERS.iter().find(|(u, _)| *u == unit).or_else(|| LADDERS.iter().find(|(u, _)| *u == Unit::Points)).map(|(_, l)| l);
|
||||
let ladder = weight_ladder(app);
|
||||
let field =
|
||||
NumberField::length(tl!("Weight"), Bind::given(weight), lengths).range(0.0..=1000.0).step_arrows(StepArrows::Leading).scrub_by_label();
|
||||
// The stepper steps the number the field shows; the ladders are in points.
|
||||
@@ -315,12 +324,18 @@ pub(crate) fn weight_number(app: &VectorcraftApp, weight: Option<f64>) -> Number
|
||||
match ladder {
|
||||
// A blank weight (the selected objects differ) steps in points from 0.25 pt, whatever the unit's ladder: up
|
||||
// gives 0.5 pt, down 0 pt (#5349).
|
||||
Some(l) if weight.is_none() => field.presets(&l.rows).stepper(in_points(&BLANK_WEIGHT_STOPS, true)),
|
||||
Some(l) => field.presets(&l.rows).stepper(in_points(&l.stops, false)),
|
||||
Some(_) if weight.is_none() => field.stepper(in_points(&BLANK_WEIGHT_STOPS, true)),
|
||||
Some(l) => field.stepper(in_points(&l.stops, false)),
|
||||
None => field,
|
||||
}
|
||||
}
|
||||
|
||||
/// The ladder of the stroke unit the session shows, or of points.
|
||||
fn weight_ladder(app: &VectorcraftApp) -> Option<&'static Ladder> {
|
||||
let unit = app.session.stroke_unit();
|
||||
LADDERS.iter().find(|(u, _)| *u == unit).or_else(|| LADDERS.iter().find(|(u, _)| *u == Unit::Points)).map(|(_, l)| l)
|
||||
}
|
||||
|
||||
/// Sends a weight edit of `out` to `target`: a scrub or slider drag is one undo step, a typed, stepped or picked
|
||||
/// value commits at once, and while the Type tool edits text the weight goes to the selected characters.
|
||||
pub(crate) fn apply_weight(app: &mut VectorcraftApp, out: &NumberOutput, target: WeightTarget) {
|
||||
|
||||
@@ -197,6 +197,27 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
for (v, _) in View::ALL {
|
||||
states.set(view_ref(v), CommandState::new().checked(v == app.ui.swatches_view));
|
||||
}
|
||||
let names = [
|
||||
("newSwatch", "New Swatch…"),
|
||||
("newColorGroup", "New Color Group…"),
|
||||
("duplicate", "Duplicate Swatch"),
|
||||
("merge", "Merge Swatches"),
|
||||
("delete", "Delete Swatch"),
|
||||
("editGroup", "Edit or Apply Color Group…"),
|
||||
("ungroup", "Ungroup Color Group"),
|
||||
("groupOptions", "Color Group Options…"),
|
||||
("selectUnused", "Select All Unused"),
|
||||
("addUsedColors", "Add Used Colors"),
|
||||
("addSelectedColors", "Add Selected Colors"),
|
||||
("sortByName", "Sort by Name"),
|
||||
("sortByKind", "Sort by Kind"),
|
||||
("showFind", "Show Find Field"),
|
||||
("showRecent", "Show Recent Colors"),
|
||||
("options", "Swatch Options…"),
|
||||
("spotColors", "Spot Colors…"),
|
||||
];
|
||||
let views = View::ALL.into_iter().map(|(v, label)| (view_ref(v), label));
|
||||
crate::panels::name_rows(states, names.into_iter().map(|(row, label)| (CommandRef::new(id(row)), label)).chain(views));
|
||||
}
|
||||
|
||||
/// Runs panel menu row `id` (`ui.swatches.<row>`); `None` for another panel's id.
|
||||
|
||||
@@ -774,39 +774,43 @@ fn menu_lines(app: &VectorcraftApp) -> Vec<MenuLine> {
|
||||
let picked = !marked(app).is_empty();
|
||||
let inst = instance_flags(app);
|
||||
let name = json!({ "name": sel });
|
||||
let row = |id: &str, params: Value, enabled: bool| MenuLine::Command(CommandRef::with_params(id, params), CommandState::new().enabled(enabled));
|
||||
// Each row is named here: several share a command (New Symbol… and Symbol Options…), and most take params that
|
||||
// the catalog's rows do not list.
|
||||
let row = |id: &str, params: Value, enabled: bool, label: &str| {
|
||||
MenuLine::Command(CommandRef::with_params(id, params), CommandState::new().enabled(enabled).title(tl!(label)))
|
||||
};
|
||||
let view = app.ui.symbols_view;
|
||||
let views = View::ALL.iter().map(|&(v, _)| {
|
||||
let views = View::ALL.iter().map(|&(v, label)| {
|
||||
let params = json!({ "panel": "symbols", "view": v });
|
||||
MenuLine::Command(CommandRef::with_params("ui.panelView", params), CommandState::new().checked(view == v))
|
||||
MenuLine::Command(CommandRef::with_params("ui.panelView", params), CommandState::new().checked(view == v).title(tl!(label)))
|
||||
});
|
||||
let mut lines = vec![
|
||||
// Shift on New Symbol… and Redefine Symbol keeps the selected art as ordinary art
|
||||
// ([`fired_params`]).
|
||||
row("ui.symbolOptions", json!({}), has_sel),
|
||||
row("symbol.update", name.clone(), has_sel && sel.is_some()),
|
||||
row("symbol.duplicate", name.clone(), sel.is_some()),
|
||||
row("ui.symbolOptions", json!({}), has_sel, "New Symbol…"),
|
||||
row("symbol.update", name.clone(), has_sel && sel.is_some(), "Redefine Symbol"),
|
||||
row("symbol.duplicate", name.clone(), sel.is_some(), "Duplicate Symbol"),
|
||||
// Asks first, as the panel's button does; the menu row has no Alt shortcut.
|
||||
row(ROW_DELETE, Value::Null, sel.is_some() || picked),
|
||||
row("ui.symbolOptions", json!({ "edit": true, "name": sel }), sel.is_some()),
|
||||
row(ROW_DELETE, Value::Null, sel.is_some() || picked, "Delete Symbol"),
|
||||
row("ui.symbolOptions", json!({ "edit": true, "name": sel }), sel.is_some(), "Symbol Options…"),
|
||||
// The selected instance's symbol, else the symbol selected in the panel.
|
||||
row("symbol.edit", if inst.any { json!({}) } else { name.clone() }, inst.any || sel.is_some()),
|
||||
row("symbol.place", name.clone(), sel.is_some()),
|
||||
row("symbol.replace", name.clone(), inst.any && sel.is_some()),
|
||||
row("symbol.breakLink", json!({}), inst.any),
|
||||
row("symbol.instance.reset", json!({}), inst.changed),
|
||||
row("symbol.instance.resetTransform", json!({}), inst.transformed),
|
||||
row("symbol.selectInstances", name, sel.is_some()),
|
||||
row("symbol.edit", if inst.any { json!({}) } else { name.clone() }, inst.any || sel.is_some(), "Edit Symbol"),
|
||||
row("symbol.place", name.clone(), sel.is_some(), "Place Symbol Instance"),
|
||||
row("symbol.replace", name.clone(), inst.any && sel.is_some(), "Replace Symbol"),
|
||||
row("symbol.breakLink", json!({}), inst.any, "Break Link to Symbol"),
|
||||
row("symbol.instance.reset", json!({}), inst.changed, "Reset Symbol Instance"),
|
||||
row("symbol.instance.resetTransform", json!({}), inst.transformed, "Reset Transformation"),
|
||||
row("symbol.selectInstances", name, sel.is_some(), "Select All Instances"),
|
||||
MenuLine::Separator,
|
||||
// Select All Unused (#4918): the symbols nothing places show selected, and Delete Symbol
|
||||
// deletes them all.
|
||||
row(ROW_SELECT_UNUSED, Value::Null, symbols > 0),
|
||||
row(ROW_SELECT_UNUSED, Value::Null, symbols > 0, "Select All Unused"),
|
||||
// The document's symbols in name order, as one undo step.
|
||||
row("symbol.sortByName", json!({}), symbols > 1),
|
||||
row("symbol.sortByName", json!({}), symbols > 1, "Sort by Name"),
|
||||
MenuLine::Separator,
|
||||
];
|
||||
lines.extend(views);
|
||||
lines.extend([MenuLine::Separator, MenuLine::Libraries, row(ROW_SAVE_LIBRARY, Value::Null, symbols > 0)]);
|
||||
lines.extend([MenuLine::Separator, MenuLine::Libraries, row(ROW_SAVE_LIBRARY, Value::Null, symbols > 0, "Save Symbol Library…")]);
|
||||
lines
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ fn checked_view(app: &VectorcraftApp) -> Vec<&'static str> {
|
||||
menu_states(app, &mut states);
|
||||
let checked = |view: &str| {
|
||||
let row = CommandRef::with_params("ui.panelView", json!({"panel": "symbols", "view": view}));
|
||||
states.get(&row) == Some(&CommandState::new().checked(true))
|
||||
states.get(&row).is_some_and(|s| s.is_enabled() && s.is_checked() == Some(true))
|
||||
};
|
||||
["thumbnail", "smallList", "largeList"].into_iter().filter(|&view| checked(view)).collect()
|
||||
}
|
||||
|
||||
@@ -840,8 +840,8 @@ pub(crate) fn menu_rows(_app: &VectorcraftApp) -> Vec<PanelRow> {
|
||||
|
||||
/// Enable or disable the panel menu's commands as [`can`] says.
|
||||
pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) {
|
||||
for id in COMMANDS {
|
||||
states.set(CommandRef::new(id), CommandState::new().enabled(can(app, id)));
|
||||
for (id, label) in COMMANDS.into_iter().zip([tl!("Clear All Tabs"), tl!("Delete Tab"), tl!("Repeat Tab")]) {
|
||||
states.set(CommandRef::new(id), CommandState::new().enabled(can(app, id)).title(label));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,18 +43,10 @@ pub(super) fn frame_raw(
|
||||
) -> Vec<(String, egui::Rect)> {
|
||||
let mut out = ctx.run_ui(raw, |ui| f(app, ui));
|
||||
out.textures_delta.clear();
|
||||
fn collect(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut texts = vec![];
|
||||
for c in &out.shapes {
|
||||
collect(&c.shape, &mut texts);
|
||||
}
|
||||
texts
|
||||
crate::tests_labels::text_shapes(&out)
|
||||
.into_iter()
|
||||
.map(|(t, transform)| (t.galley.text().to_string(), transform * t.visual_bounding_rect()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Click at `pos` over three frames of `f` (hover, press, release).
|
||||
|
||||
@@ -20,20 +20,11 @@ fn app() -> VectorcraftApp {
|
||||
|
||||
/// One frame of `draw` with `events`; the texts it painted.
|
||||
fn frame(ctx: &egui::Context, events: Vec<Event>, time: f64, mut draw: impl FnMut(&mut egui::Ui)) -> Vec<String> {
|
||||
fn texts(s: &egui::Shape, out: &mut Vec<String>) {
|
||||
match s {
|
||||
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let screen_rect = Some(Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0)));
|
||||
let input = egui::RawInput { events, time: Some(time), screen_rect, ..Default::default() };
|
||||
let mut out = ctx.run_ui(input, &mut draw);
|
||||
out.textures_delta.clear();
|
||||
let mut v = vec![];
|
||||
out.shapes.iter().for_each(|c| texts(&c.shape, &mut v));
|
||||
v
|
||||
crate::tests_labels::text_shapes(&out).into_iter().map(|(t, _)| t.galley.text().to_string()).collect()
|
||||
}
|
||||
|
||||
fn undo_len(app: &VectorcraftApp) -> usize {
|
||||
|
||||
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user