mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 16:59:56 +01:00
Merge origin/next
# Conflicts: # crates/ui-contract/src/contract/overlay/dismissal.rs
This commit is contained in:
commit
afaabe9e94
328 files changed
+7480
-920
No files matched your search
+15
-1
@@ -1,6 +1,8 @@
|
||||
# The Workspace gate's additions to .config/cargo-dev.toml (scripts/ci-workspace-tests.sh passes both). The gate runs
|
||||
# every test of these crates, and their tests spend nearly all their time in sample and pixel loops, which run several
|
||||
# times faster at opt-level 1; locally they stay at 0, so an edit to them rebuilds fast.
|
||||
# times faster at opt-level 1; locally they stay at 0, so an edit to them rebuilds fast. craft-pdf (R6 hash and AES-CBC
|
||||
# loops), craft-pkcs7 and craft-odf (PBKDF2 rounds, monomorphised in the crate) and craft-cms (CLUT builds) run their
|
||||
# own hot loops in tests, so they take part too.
|
||||
[profile.dev.package.craft-audio-dsp]
|
||||
opt-level = 1
|
||||
|
||||
@@ -15,3 +17,15 @@ opt-level = 1
|
||||
|
||||
[profile.dev.package.craft-imaging]
|
||||
opt-level = 1
|
||||
|
||||
[profile.dev.package.craft-pdf]
|
||||
opt-level = 1
|
||||
|
||||
[profile.dev.package.craft-pkcs7]
|
||||
opt-level = 1
|
||||
|
||||
[profile.dev.package.craft-odf]
|
||||
opt-level = 1
|
||||
|
||||
[profile.dev.package.craft-cms]
|
||||
opt-level = 1
|
||||
@@ -44,6 +44,7 @@ jobs:
|
||||
filter: ${{ steps.select.outputs.filter }}
|
||||
audit: ${{ steps.audit.outputs.audit }}
|
||||
profile: ${{ steps.audit.outputs.profile }}
|
||||
deps-profile: ${{ steps.audit.outputs.deps-profile }}
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@v2.22.4
|
||||
@@ -67,6 +68,10 @@ jobs:
|
||||
# passes (scripts/ci-workspace-tests.sh), which names the Workspace legs' cache entries:
|
||||
# rust-cache's key does not hash these files, and an entry built with other overrides would be
|
||||
# rebuilt in full on every run. Other events than a pull request check out only these files.
|
||||
# The macOS and Windows legs cache dependencies only, so `deps-profile` hashes only the
|
||||
# settings that reach a dependency: `[profile.dev]` and `[profile.dev.package."*"]`. Every
|
||||
# other override names a workspace crate (scripts/test-workspace-tests.py), so changing one
|
||||
# keeps those entries, and next's runs restore main's.
|
||||
- uses: actions/checkout@v7.0.1
|
||||
if: github.event_name != 'pull_request'
|
||||
with:
|
||||
@@ -83,6 +88,18 @@ jobs:
|
||||
run: |
|
||||
echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT"
|
||||
echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT"
|
||||
# An assignment, so a failure stops the step (`bash -e`) instead of naming every entry `v2-`.
|
||||
deps=$(python3 -I - <<'PY'
|
||||
import hashlib, json, tomllib
|
||||
kept = []
|
||||
for path in (".config/cargo-dev.toml", ".config/cargo-ci.toml"):
|
||||
with open(path, "rb") as file:
|
||||
dev = tomllib.load(file)["profile"]["dev"]
|
||||
kept.append([dev, dev.pop("package", {}).get("*", {})])
|
||||
print(hashlib.sha256(json.dumps(kept, sort_keys=True).encode()).hexdigest()[:12])
|
||||
PY
|
||||
)
|
||||
echo "deps-profile=$deps" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# The Linux leg keeps the compiled workspace crates between runs (`cache-workspace-crates`): each
|
||||
# main run saves a rolling cache entry of its own, every run restores the newest one, and Cargo
|
||||
@@ -150,7 +167,8 @@ jobs:
|
||||
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
|
||||
# A selection that reaches a replay-audit crate builds once in a `build` job, which writes
|
||||
# three nextest archives and then runs the doctests; three shard legs run them in parallel:
|
||||
# every selected test, the replay audit, and the default-feature crates. Any other selection
|
||||
# every selected test outside the replay audit's crates, those crates (run plainly, then with the
|
||||
# audit), and craft-image-codecs with default features. Any other selection
|
||||
# (and every macOS and Windows leg) builds and runs in one leg. scripts/ci-workspace-tests.sh
|
||||
# holds every step.
|
||||
test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}
|
||||
@@ -172,7 +190,8 @@ jobs:
|
||||
with:
|
||||
os: '["windows-latest","macos-latest"]'
|
||||
lint-cache: false
|
||||
cache-version: *cache-version
|
||||
# Named by the dependency settings alone (`deps-profile`), so next restores main's entries.
|
||||
cache-version: v2-${{ needs.platforms.outputs.deps-profile }}
|
||||
timeout-minutes: *timeout
|
||||
tools: *tools
|
||||
craft-fonts-ref: *craft-fonts
|
||||
|
||||
Generated
+23
-14
@@ -2301,6 +2301,7 @@ dependencies = [
|
||||
name = "craft-crw"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-testkit",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
@@ -2375,6 +2376,7 @@ dependencies = [
|
||||
"craft-geom",
|
||||
"craft-raw",
|
||||
"craft-render-parity",
|
||||
"craft-testkit",
|
||||
"proptest",
|
||||
"rayon",
|
||||
"serde",
|
||||
@@ -2533,6 +2535,7 @@ name = "craft-drawingml"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-testkit",
|
||||
"craft-xml",
|
||||
"kurbo",
|
||||
"log",
|
||||
@@ -2945,6 +2948,7 @@ dependencies = [
|
||||
name = "craft-heif"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-testkit",
|
||||
"heic-rs",
|
||||
"proptest",
|
||||
"rayon",
|
||||
@@ -3127,6 +3131,7 @@ dependencies = [
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-testkit",
|
||||
"jpeg-decoder",
|
||||
"jpeg-encoder 0.6.1",
|
||||
"rayon",
|
||||
@@ -3248,6 +3253,7 @@ dependencies = [
|
||||
name = "craft-material-graph"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-testkit",
|
||||
"libm",
|
||||
"rayon",
|
||||
]
|
||||
@@ -3404,6 +3410,7 @@ dependencies = [
|
||||
"chardetng",
|
||||
"chrono",
|
||||
"craft-codepage",
|
||||
"craft-testkit",
|
||||
"encoding_rs",
|
||||
"proptest",
|
||||
]
|
||||
@@ -3841,6 +3848,7 @@ name = "craft-ps"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-eps",
|
||||
"craft-testkit",
|
||||
"flate2",
|
||||
"kurbo",
|
||||
"miniz_oxide 0.8.9",
|
||||
@@ -4771,6 +4779,7 @@ dependencies = [
|
||||
name = "craft-xcf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-testkit",
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -5562,7 +5571,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"emath",
|
||||
@@ -5618,7 +5627,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -5653,7 +5662,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
@@ -5672,7 +5681,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-wgpu"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -5691,7 +5700,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"bytemuck",
|
||||
@@ -5711,7 +5720,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -5724,7 +5733,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_kittest"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"egui",
|
||||
@@ -5801,7 +5810,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
@@ -5874,7 +5883,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -5900,7 +5909,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint_default_fonts"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
|
||||
[[package]]
|
||||
name = "equator"
|
||||
@@ -15232,19 +15241,19 @@ dependencies = [
|
||||
[[patch.unused]]
|
||||
name = "egui_demo_lib"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_extras"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_inspection"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_system_font_provider"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec"
|
||||
+14
-14
@@ -316,20 +316,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" }
|
||||
linesweeper = { path = "vendor/linesweeper" }
|
||||
vello_common = { path = "vendor/vello_common" }
|
||||
vello_cpu = { path = "vendor/vello_cpu" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
|
||||
# symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid
|
||||
|
||||
@@ -291,6 +291,7 @@ mod tests {
|
||||
std::thread::scope(|scope| {
|
||||
for e in crate::testutil::sampled_effects() {
|
||||
scope.spawn(move || {
|
||||
let started = std::time::Instant::now();
|
||||
for setting in [0.0f32, 1.0] {
|
||||
let mut fx = (e.create)(SR, 2);
|
||||
for p in e.params {
|
||||
@@ -318,6 +319,9 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
if started.elapsed() > std::time::Duration::from_secs(1) {
|
||||
eprintln!("DIAG extreme settings: {} took {:?}", e.id, started.elapsed());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -418,21 +418,20 @@ mod tests {
|
||||
/// returns `MAX_RESAMPLE_BLOCK` frames.
|
||||
#[test]
|
||||
fn source_held_and_block_length_are_bounded() {
|
||||
let t0 = std::time::Instant::now();
|
||||
// At this ratio a pull holds about 42 output frames' worth of source, so 64 frames take two pulls; each output
|
||||
// frame pulls 1,536 source frames of 64 channels, so nightly runs a longer block.
|
||||
let frames = if craft_testkit::hostile::divisor() == 1 { 1_024 } else { 64 };
|
||||
let mut r = StreamResampler::new(1_536_000, 1_000);
|
||||
let mut widest = 0;
|
||||
let out = r.process(0, 1_024, |_, frames| {
|
||||
let out = r.process(0, frames, |_, frames| {
|
||||
widest = widest.max(frames);
|
||||
vec![vec![0.5; frames]; 64]
|
||||
});
|
||||
assert_eq!((out.len(), out[0].len()), (64, 1_024));
|
||||
assert_eq!((out.len(), out[0].len()), (64, frames));
|
||||
assert!(widest <= MAX_RESAMPLE_HELD / 64, "{widest}");
|
||||
assert!(r.held.iter().map(Vec::len).sum::<usize>() <= MAX_RESAMPLE_HELD);
|
||||
eprintln!("DIAG resample wide ratio {:?}", t0.elapsed());
|
||||
let t1 = std::time::Instant::now();
|
||||
let mut r = StreamResampler::new(48_000, 48_000);
|
||||
let out = r.process(0, usize::MAX, |_, frames| vec![vec![0.5; frames]]);
|
||||
eprintln!("DIAG resample oversized block {:?}", t1.elapsed());
|
||||
assert_eq!(out[0].len(), MAX_RESAMPLE_BLOCK);
|
||||
assert!(out[0].iter().all(|&x| x == 0.5));
|
||||
}
|
||||
|
||||
@@ -78,12 +78,14 @@ pub struct PressStart {
|
||||
pub time: f64,
|
||||
/// 1 for a single press, 2 for a double press, and so on.
|
||||
pub clicks: u32,
|
||||
/// The press went down on another target, which handed it to this one ([`PressMachine::take_over`]).
|
||||
pub handed: bool,
|
||||
}
|
||||
|
||||
impl PressStart {
|
||||
/// A press of `button` at `origin`.
|
||||
pub const fn new(origin: Pos2, button: PointerButton, time: f64, clicks: u32) -> Self {
|
||||
PressStart { origin, button, time, clicks }
|
||||
PressStart { origin, button, time, clicks, handed: false }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,8 +631,9 @@ impl<T: Copy> PressMachine<T> {
|
||||
}
|
||||
|
||||
/// Takes over a press whose button is down and went down elsewhere, as a drag of `target` from `start`: the next
|
||||
/// pass reports `DragStart`, and later ones the press's own `Drag`, `Release` or `Cancel` from their input. A
|
||||
/// press this machine holds already stays as it is.
|
||||
/// pass reports `DragStart`, and later ones the press's own `Drag`, `Release` or `Cancel` from their input, each
|
||||
/// with a start that says it was handed over ([`PressStart::handed`]). A press this machine holds already stays as
|
||||
/// it is.
|
||||
// PLAN: the sheet's Files table has no row for this file; the handover of a held press (decision q346) needs the
|
||||
// machine to open a press that did not begin on it, which only the machine can build.
|
||||
pub fn take_over(&mut self, target: T, sense: Sense, start: PressStart) {
|
||||
@@ -640,7 +643,7 @@ impl<T: Copy> PressMachine<T> {
|
||||
self.open = Some(Open {
|
||||
target,
|
||||
sense: sense - Sense::CLICK,
|
||||
start,
|
||||
start: PressStart { handed: true, ..start },
|
||||
dragging: true,
|
||||
abandoned: false,
|
||||
left: false,
|
||||
|
||||
@@ -18,7 +18,10 @@ fn input_over_the_size_limit_is_refused() {
|
||||
for format in Format::ALL {
|
||||
assert_eq!(parse(&big, format), Err(Error::TooLarge(MAX_INPUT)), "{format:?}");
|
||||
}
|
||||
assert!(parse(big.get(..MAX_INPUT).unwrap(), Format::Srt).is_ok());
|
||||
// Reading 64 MiB at the limit takes seconds: nightly only.
|
||||
if craft_testkit::hostile::divisor() == 1 {
|
||||
assert!(parse(big.get(..MAX_INPUT).unwrap(), Format::Srt).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
/// TTML is read without entity expansion: a document type with entities defines nothing.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/// The egui fork the library is built and tested with. Apps patch egui to exactly this.
|
||||
pub const GIT: &str = "https://github.com/storytold/egui.git";
|
||||
/// The commit of [`GIT`].
|
||||
pub const REV: &str = "a87d00caaec947ea781657c6ff410c9838016d18";
|
||||
pub const REV: &str = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec";
|
||||
|
||||
/// The packages the workspace patches to the fork (the `[patch.crates-io]` entries that name [`GIT`]).
|
||||
pub const PACKAGES: &[&str] = &[
|
||||
|
||||
@@ -15,6 +15,7 @@ workspace = true
|
||||
thiserror = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
# Pinned digests of the decoded CC0 sample files (tests/samples.rs); not a product dependency.
|
||||
|
||||
@@ -61,11 +61,13 @@ fn crw() -> Vec<u8> {
|
||||
#[test]
|
||||
fn every_truncation_and_single_byte_mutation_survives() {
|
||||
let good = crw();
|
||||
for n in 0..good.len() {
|
||||
// The gate runs every divisor-th position; nightly runs all.
|
||||
let step = craft_testkit::hostile::divisor();
|
||||
for n in (0..good.len()).step_by(step) {
|
||||
let _ = header(&good[..n], &Limits::default());
|
||||
let _ = decode(&good[..n], &Limits::default());
|
||||
}
|
||||
for i in 0..good.len() {
|
||||
for i in (0..good.len()).step_by(step) {
|
||||
let mut bad = good.clone();
|
||||
bad[i] ^= 0xa5;
|
||||
let _ = decode(&bad, &Limits::default());
|
||||
|
||||
@@ -24,4 +24,5 @@ rayon = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-render-parity = { workspace = true }
|
||||
craft-testkit = { workspace = true }
|
||||
proptest = { workspace = true }
|
||||
@@ -652,7 +652,7 @@ mod tests {
|
||||
apply(&mut px, n, n, 70.0, -60.0, SRGB);
|
||||
[px[(n / 8) * n + n / 8][0], px[(3 * n / 4) * n + 3 * n / 4][0]]
|
||||
};
|
||||
let (a, b) = (at(96), at(384));
|
||||
let (a, b) = (at(64), at(256));
|
||||
assert!((a[0] - b[0]).abs() < 0.02 && (a[1] - b[1]).abs() < 0.02, "{a:?} {b:?}");
|
||||
}
|
||||
}
|
||||
@@ -163,8 +163,13 @@ fn rebuilt_ramp_is_continuous_from_the_first_clip_to_the_last() {
|
||||
/// background surrounds it.
|
||||
#[test]
|
||||
fn thin_line_without_reliable_colour_is_continuous_where_it_clips() {
|
||||
for height in [32usize, 512, 1024] {
|
||||
for width in [1usize, 4, 16] {
|
||||
// The gate runs a one-row line in 32 rows and a four-row line in 512; nightly every pair, up to 1024 rows.
|
||||
let full = craft_testkit::hostile::divisor() == 1;
|
||||
for (h, height) in [32usize, 512, 1024].into_iter().enumerate() {
|
||||
for (w, width) in [1usize, 4, 16].into_iter().enumerate() {
|
||||
if !full && (w != h || h > 1) {
|
||||
continue;
|
||||
}
|
||||
let top = (height - width) / 2;
|
||||
let (row, first) = rebuilt_ramp(top..top + width, height);
|
||||
assert_continuous(&row, first, 0.002, &format!("{width} rows of {height}"));
|
||||
|
||||
@@ -103,8 +103,8 @@ fn reference_render_has_unit_variance_and_no_mean() {
|
||||
fn small_render_is_the_downscaled_reference() {
|
||||
for (size, rough) in [(0.0, 50.0), (25.0, 50.0), (100.0, 50.0), (25.0, 0.0), (25.0, 100.0)] {
|
||||
let t = tile_of(size, rough);
|
||||
for k in [2usize, 4, 8] {
|
||||
let n = 48;
|
||||
for k in [2usize, 8] {
|
||||
let n = 32;
|
||||
let full = patch(&t, REF_LONG, n * k, 0);
|
||||
let down: Vec<f32> = (0..n * n)
|
||||
.map(|q| {
|
||||
@@ -120,6 +120,7 @@ fn small_render_is_the_downscaled_reference() {
|
||||
.collect();
|
||||
let small = patch(&t, REF_LONG / k as f64, n, 0);
|
||||
let worst = down.iter().zip(&small).map(|(a, b)| (a - b).abs()).fold(0.0, f32::max);
|
||||
eprintln!("DIAG downscale size {size} roughness {rough} 1/{k}: worst {worst} (limit 2e-3)");
|
||||
assert!(worst < 2e-3, "size {size} roughness {rough} 1/{k}: differs by {worst}");
|
||||
}
|
||||
}
|
||||
@@ -129,7 +130,7 @@ fn small_render_is_the_downscaled_reference() {
|
||||
fn strength_matches_the_target_at_mid_grey() {
|
||||
for (a, s, r) in [(50.0, 25.0, 50.0), (25.0, 25.0, 50.0), (50.0, 0.0, 50.0), (50.0, 100.0, 50.0), (50.0, 25.0, 0.0)] {
|
||||
let g = CrystalGrain::new(&Grain { amount: a, size: s, roughness: r, seed: 3 }, REF_LONG).expect("grain");
|
||||
let n = 320;
|
||||
let n = 200;
|
||||
let lum: Vec<f32> = (0..n * n)
|
||||
.map(|k| {
|
||||
let (x, y) = ((k % n) as f32 + 0.5, (k / n) as f32 + 0.5);
|
||||
@@ -138,6 +139,7 @@ fn strength_matches_the_target_at_mid_grey() {
|
||||
})
|
||||
.collect();
|
||||
let want = strength_levels(a, s, r);
|
||||
eprintln!("DIAG strength {a}/{s}/{r}: deviation {:.4} (limit 0.06)", std(&lum) / want - 1.0);
|
||||
assert!((std(&lum) / want - 1.0).abs() < 0.06, "{a}/{s}/{r}: {} levels, want {want}", std(&lum));
|
||||
}
|
||||
}
|
||||
@@ -443,8 +445,10 @@ fn a_waiting_render_gets_the_tile_the_cache_evicted() {
|
||||
keep(&OWN, key, drawn.clone());
|
||||
// other renders' tiles push it out of the cache before the waiter wakes
|
||||
// (each its own tile: a waiter that took another key's would fail the check below)
|
||||
// (one tile of another seed under every key: a different `Arc` from the drawn one, drawn once)
|
||||
let other_tile = Arc::new(CrystalTile::new(look, seed + 1).expect("tile"));
|
||||
for other in 1..=CACHE as u32 {
|
||||
keep(&OWN, key_of(look, seed + other), Arc::new(CrystalTile::new(look, seed + other).expect("tile")));
|
||||
keep(&OWN, key_of(look, seed + other), other_tile.clone());
|
||||
}
|
||||
assert!(cached(&OWN, key).is_none(), "the tile is still cached");
|
||||
drop(marker);
|
||||
@@ -477,7 +481,8 @@ fn renders_that_miss_a_tile_together_draw_it_once() {
|
||||
static OWN: Cache = Mutex::new(Vec::new());
|
||||
const N: usize = 8;
|
||||
// the first render's draw waits for the other seven to miss the tile too
|
||||
const SEEDS: u32 = 5;
|
||||
// (each seed is a full trial, as the draw is held until the others wait, so a few are enough)
|
||||
const SEEDS: u32 = 2;
|
||||
HOLDS.lock().unwrap_or_else(PoisonError::into_inner).push((std::ptr::from_ref(&OWN) as usize, N - 1, SEEDS as usize));
|
||||
let look = CrystalLook::new(0.0, 50.0);
|
||||
for seed in 0x0d4a_1000..0x0d4a_1000 + SEEDS {
|
||||
@@ -502,7 +507,8 @@ fn renders_that_miss_a_tile_together_draw_it_once() {
|
||||
fn width_matches_lightroom_classic() {
|
||||
let lrc = [(0.0, 50.0, 0.5), (25.0, 50.0, 1.13), (100.0, 50.0, 3.38), (25.0, 0.0, 0.86), (25.0, 100.0, 1.54)];
|
||||
for (s, r, want) in lrc {
|
||||
let got = half_width(&patch(&tile_of(s, r), REF_LONG, 360, 0), 360);
|
||||
let got = half_width(&patch(&tile_of(s, r), REF_LONG, 256, 0), 256);
|
||||
eprintln!("DIAG width size {s} roughness {r}: {got:.3} want {want} (limit 10 percent)");
|
||||
assert!((got / want - 1.0).abs() < 0.1, "size {s} roughness {r}: width {got:.3}, want {want}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +552,9 @@ fn coloured_highlights_keep_their_brightness_at_the_edges() {
|
||||
let tubes = [([1.0f32, 0.15, 0.1], 3.5f32), ([1.0, 0.85, 0.15], 2.6), ([0.25, 1.0, 0.4], 2.0)];
|
||||
let scenes = suns.map(|(tint, level)| (tint, level, true)).into_iter().chain(tubes.map(|(tint, level)| (tint, level, false)));
|
||||
let lum = |p: [f32; 3]| 0.2126 * p[0] + 0.7152 * p[1] + 0.0722 * p[2];
|
||||
for (tint, level, sun) in scenes {
|
||||
// The gate develops every divisor-th (scene, layout) pair, a different layout per scene; nightly all of them.
|
||||
let divisor = craft_testkit::hostile::divisor();
|
||||
for (scene_index, (tint, level, sun)) in scenes.enumerate() {
|
||||
let scene_name = if sun { "sun" } else { "tube" };
|
||||
let scene = |x: f32, y: f32| {
|
||||
if sun {
|
||||
@@ -572,7 +574,10 @@ fn coloured_highlights_keep_their_brightness_at_the_edges() {
|
||||
})
|
||||
});
|
||||
let truth = |x: usize, y: usize| -> [f32; 3] { std::array::from_fn(|c| lights[c][y * w + x]) };
|
||||
for (name, cfa, method) in layouts() {
|
||||
for (layout_index, (name, cfa, method)) in layouts().into_iter().enumerate() {
|
||||
if !(scene_index + layout_index).is_multiple_of(divisor) {
|
||||
continue;
|
||||
}
|
||||
let raw = raw_of(w, h, &cfa, DAYLIGHT, truth);
|
||||
let (mut img, mask) = raw.develop_balanced_masked(method, DAYLIGHT, CLIP).unwrap();
|
||||
let mut by_value = img.clone();
|
||||
|
||||
@@ -117,7 +117,7 @@ fn saved(path: impl AsRef<Path>) -> Option<DialogResult<Answer>> {
|
||||
// `a_selected_folder_never_replaces_the_typed_save_name` and `a_removed_selected_file_keeps_its_exact_save_path`, with
|
||||
// `~` and "not found". The extension is the service's policy now, so the chooser answers the name as typed.
|
||||
#[trial]
|
||||
fn the_chooser_lists_and_accepts_like_a_file_panel() {
|
||||
fn a_typed_folder_is_entered_and_a_new_name_is_saved_as_typed() {
|
||||
// A typed folder is entered and its name used up; a new name is answered as typed.
|
||||
let mut save = Chooser::open(PickRequest::save("document").directory("/d"));
|
||||
save.type_name("drafts");
|
||||
@@ -126,7 +126,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() {
|
||||
save.type_name("chapter");
|
||||
save.click("Save");
|
||||
assert_eq!(save.answer(), saved("/d/drafts/chapter"), "a new name is saved to as typed");
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn a_listed_file_is_replaced_only_after_the_question() {
|
||||
// A listed file is replaced only after the question, asked once.
|
||||
let mut replace = Chooser::open(PickRequest::save("document").directory("/d/drafts"));
|
||||
replace.type_name("old.docx");
|
||||
@@ -134,7 +137,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() {
|
||||
assert_eq!(replace.answer(), None, "the chooser asks before replacing");
|
||||
replace.click("Replace");
|
||||
assert_eq!(replace.answer(), saved("/d/drafts/old.docx"));
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn a_selected_file_keeps_its_exact_name_for_open_and_for_the_save_question() {
|
||||
// A selected file keeps its exact name, leading space and all, for Open and for Save's question.
|
||||
let mut open = Chooser::open(PickRequest::open("document").directory("/d"));
|
||||
open.click(" report.docx");
|
||||
@@ -147,7 +153,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() {
|
||||
assert_eq!(save.answer(), None, "Save asks before replacing the selected file");
|
||||
save.click("Replace");
|
||||
assert_eq!(save.answer(), saved("/d/ report.docx"));
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn a_removed_selected_file_keeps_its_exact_save_path() {
|
||||
// A selected file removed meanwhile still names the exact path, and nothing is asked.
|
||||
let mut removed = Chooser::open(PickRequest::save("document").file_name("Draft.docx").directory("/d"));
|
||||
removed.click(" report.docx");
|
||||
@@ -155,7 +164,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() {
|
||||
removed.refocus();
|
||||
removed.click("Save");
|
||||
assert_eq!(removed.answer(), saved("/d/ report.docx"), "the removed selection keeps its path, not `report.docx`");
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn a_selected_folder_is_entered_and_never_becomes_the_save_name() {
|
||||
// A selected folder is entered and never becomes the save name; once it is gone, the typed name is saved to.
|
||||
let mut folder = Chooser::open(PickRequest::save("document").file_name("chapter.docx").directory("/d"));
|
||||
folder.click("Chapters");
|
||||
@@ -168,13 +180,19 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() {
|
||||
gone.refocus();
|
||||
gone.click("Save");
|
||||
assert_eq!(gone.answer(), saved("/d/chapter.docx"), "the removed folder is not saved over as `Chapters.docx`");
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn the_home_root_and_a_typed_path_elsewhere_open() {
|
||||
// `~` is the Home root; a typed path elsewhere is listed, then opened.
|
||||
let mut home = Chooser::open(PickRequest::open("document").directory("/d"));
|
||||
home.type_name("~/Letters/aunt.txt");
|
||||
home.click("Open");
|
||||
assert_eq!(home.answer(), picked("/home/u/Letters/aunt.txt"));
|
||||
}
|
||||
|
||||
#[trial]
|
||||
fn a_missing_name_on_open_is_refused_and_said() {
|
||||
// A missing name on Open is refused and said.
|
||||
let mut missing = Chooser::open(PickRequest::open("document").directory("/d"));
|
||||
missing.type_name("missing.docx");
|
||||
|
||||
@@ -16,8 +16,8 @@ use craft_behavior::{ColumnWidth, EditEvent, EditEvents, GestureId, IconId, Mixe
|
||||
use craft_ui::buttons::ToggleButton;
|
||||
use craft_ui::canvas::CanvasRulers;
|
||||
use craft_ui::contract::{
|
||||
Bind, BodyCx, Entry, FieldLayout, GlyphLabel, LabelKind, LabelPress, NoValue, Outcome, Props as _, Show as _, ShowContainer as _, SideLabel,
|
||||
Sizing,
|
||||
Bind, BodyCx, Bracket, Entry, FieldLayout, GlyphLabel, LabelKind, LabelPress, NoValue, Outcome, Props as _, Show as _, ShowContainer as _,
|
||||
SideLabel, Sizing,
|
||||
};
|
||||
use craft_ui::display::Divider;
|
||||
use craft_ui::form::{Field, FieldGroup};
|
||||
@@ -135,7 +135,8 @@ pub enum FieldArrangement {
|
||||
/// W, the link and H on the first row, then X and Y.
|
||||
#[default]
|
||||
SizeFirst,
|
||||
/// X and W on the first row, Y and H on the second, the link after them: Tab runs X, W, Y, H.
|
||||
/// X and W on the first row, Y and H on the second, the link beside them centred across the two rows: Tab runs X,
|
||||
/// W, Y, H.
|
||||
PositionFirst,
|
||||
}
|
||||
|
||||
@@ -224,7 +225,8 @@ impl Outcome for TransformFieldsOutput {
|
||||
/// - **Panel form** (the default): two field columns that fill the width, the link's column between them: W, the
|
||||
/// link and H on one row, X and Y on the next, the angle, then the H and V skews; the compact reference point, when
|
||||
/// shown, leads the first row. [`groups`](Self::groups) leaves out the rows of hidden groups. With
|
||||
/// [`FieldArrangement::PositionFirst`] the grid is X and W, then Y and H, with the link after them.
|
||||
/// [`FieldArrangement::PositionFirst`] the grid is X and W, then Y and H, with the link beside it, centred across
|
||||
/// the two rows.
|
||||
/// - **Bar form** ([`bar`](Self::bar)): the compact reference point, then captioned fields in Photoshop's order with a
|
||||
/// divider between the groups, the Δ toggle between X and Y, the interpolation select last.
|
||||
/// [`groups`](Self::groups) narrows the strip.
|
||||
@@ -437,10 +439,10 @@ struct Cells<'a> {
|
||||
const FIELD_COLUMNS: [ColumnWidth; 3] = [ColumnWidth::fill(1.0), ColumnWidth::Content, ColumnWidth::fill(1.0)];
|
||||
/// The panel form's columns with the reference point before them.
|
||||
const REFERENCE_COLUMNS: [ColumnWidth; 4] = [ColumnWidth::Content, ColumnWidth::fill(1.0), ColumnWidth::Content, ColumnWidth::fill(1.0)];
|
||||
/// The position-first panel form's columns: two fields, then the link's column.
|
||||
const POSITION_COLUMNS: [ColumnWidth; 3] = [ColumnWidth::fill(1.0), ColumnWidth::fill(1.0), ColumnWidth::Content];
|
||||
/// The position-first panel form's columns: two fields that share the width.
|
||||
const PAIR_COLUMNS: [ColumnWidth; 2] = [ColumnWidth::fill(1.0), ColumnWidth::fill(1.0)];
|
||||
/// The position-first panel form's columns with the reference point before them.
|
||||
const POSITION_REFERENCE_COLUMNS: [ColumnWidth; 4] = [ColumnWidth::Content, ColumnWidth::fill(1.0), ColumnWidth::fill(1.0), ColumnWidth::Content];
|
||||
const REFERENCE_PAIR_COLUMNS: [ColumnWidth; 3] = [ColumnWidth::Content, ColumnWidth::fill(1.0), ColumnWidth::fill(1.0)];
|
||||
|
||||
/// Which form the cells show in.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
@@ -690,43 +692,39 @@ impl Cells<'_> {
|
||||
});
|
||||
}
|
||||
|
||||
/// The position-first grid of [`rows`](Self::rows): X and W, Y and H with the link after them, the angle, then the
|
||||
/// skews; two field columns and the link's column, the reference point, when shown, in a column before them.
|
||||
/// The position-first form of [`rows`](Self::rows): X and W, then Y and H, in a grid beside the link, which stands
|
||||
/// centred across their two rows; the reference point, when shown, leads the grid's first row in a column of its
|
||||
/// own. The angle and the skews follow in a grid of their own.
|
||||
fn position_first(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>, pass: &mut Pass) {
|
||||
let groups = self.groups;
|
||||
let columns: &'static [ColumnWidth] = if groups.reference { &POSITION_REFERENCE_COLUMNS } else { &POSITION_COLUMNS };
|
||||
Grid::new(columns).id_salt("fields").fill_width().show(ui, |ui, _| {
|
||||
let mut first = true;
|
||||
let pair = [(groups.position, TransformField::X, TransformField::Y), (groups.size, TransformField::W, TransformField::H)];
|
||||
if groups.position || groups.size || groups.reference {
|
||||
self.lead(ui, cx, pass, &mut first);
|
||||
for (shown, top, _) in pair {
|
||||
self.field_or_empty(ui, cx, pass, shown, top);
|
||||
}
|
||||
if groups.position || groups.size || groups.reference {
|
||||
let columns: &'static [ColumnWidth] = if groups.reference { &REFERENCE_PAIR_COLUMNS } else { &PAIR_COLUMNS };
|
||||
Row::new().bracket(Bracket::Unlinked).fill_width().show(ui, |ui, _| {
|
||||
Grid::new(columns).id_salt("fields").fill_width().show(ui, |ui, _| {
|
||||
let mut first = true;
|
||||
let rows = if groups.position || groups.size { 2 } else { 1 };
|
||||
for row in [[TransformField::X, TransformField::W], [TransformField::Y, TransformField::H]].into_iter().take(rows) {
|
||||
self.lead(ui, cx, pass, &mut first);
|
||||
self.field_or_empty(ui, cx, pass, groups.position, row[0]);
|
||||
self.field_or_empty(ui, cx, pass, groups.size, row[1]);
|
||||
}
|
||||
});
|
||||
if groups.size {
|
||||
self.link(ui);
|
||||
} else {
|
||||
empty(ui);
|
||||
}
|
||||
}
|
||||
if groups.position || groups.size {
|
||||
self.lead(ui, cx, pass, &mut first);
|
||||
for (shown, _, bottom) in pair {
|
||||
self.field_or_empty(ui, cx, pass, shown, bottom);
|
||||
}
|
||||
empty(ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
if !(groups.angle || groups.skew) {
|
||||
return;
|
||||
}
|
||||
Grid::new(&PAIR_COLUMNS).id_salt("turns").fill_width().show(ui, |ui, _| {
|
||||
if groups.angle {
|
||||
self.lead(ui, cx, pass, &mut first);
|
||||
self.field(ui, cx, pass, TransformField::Angle, Form::Panel);
|
||||
empty(ui);
|
||||
empty(ui);
|
||||
}
|
||||
if groups.skew {
|
||||
self.lead(ui, cx, pass, &mut first);
|
||||
self.field(ui, cx, pass, TransformField::SkewH, Form::Panel);
|
||||
self.field(ui, cx, pass, TransformField::SkewV, Form::Panel);
|
||||
empty(ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use craft_behavior::geometry::quad::BoxState;
|
||||
use craft_behavior::kurbo::{Point, Rect, Size};
|
||||
use craft_behavior::{EditEvent, Mixed, RulerUnits};
|
||||
use craft_draw::ui::transform::{SizeUnit, TransformField, TransformFields, TransformGroups, TransformRow, TransformSource};
|
||||
use craft_draw::ui::transform::{FieldArrangement, SizeUnit, TransformField, TransformFields, TransformGroups, TransformRow, TransformSource};
|
||||
use craft_ui::canvas::{CanvasRulers, RulerText};
|
||||
use craft_ui::contract::Bind;
|
||||
use craft_ui::runtime::env::UnitKind;
|
||||
@@ -286,3 +286,44 @@ fn a_start_box_that_moves_with_a_scrub_keeps_the_scrub_running() {
|
||||
assert!(events.iter().any(|event| matches!(event, EditEvent::Commit { .. })), "the release committed it: {events:?}");
|
||||
assert!(row.state.quad[0].distance(row.state.quad[1]) > START.width(), "the scrub widened the box: {row:?}");
|
||||
}
|
||||
|
||||
/// The position-first panel form stands the reference point before the X and W, Y and H rows and the link after them
|
||||
/// centred across the rows, both clear of every field, in a wide room, a narrow one and a host sized from its content.
|
||||
#[trial]
|
||||
fn the_position_first_link_stands_between_the_width_and_height_rows() {
|
||||
use craft_ui::contract::ShowContainer as _;
|
||||
for (width, content) in [(260.0, false), (400.0, false), (400.0, true)] {
|
||||
let mut row = TransformRow::new(BoxState::from_rect(START), 0.0);
|
||||
let mut linked = true;
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let mut show = |ui: &mut egui::Ui| {
|
||||
TransformFields::new("Transform", Bind::bound(&mut row), START, Bind::bound(&mut linked))
|
||||
.arrangement(FieldArrangement::PositionFirst)
|
||||
.show(ui)
|
||||
};
|
||||
if content {
|
||||
craft_ui::layout_components::Stack::new().show(ui, |ui, _| show(ui));
|
||||
} else {
|
||||
show(ui);
|
||||
}
|
||||
});
|
||||
fixture.room(egui::vec2(width, 400.0)).settle();
|
||||
let rect = |label: &str| fixture.by_label(label).unwrap_or_else(|| panic!("the fields show {label}")).rect;
|
||||
let link = rect("Maintain aspect ratio");
|
||||
let reference = rect("Reference point");
|
||||
let fields = ["X position", "Width", "Y position", "Height"].map(rect);
|
||||
let dump = format!("in {width} (content: {content}): reference {reference:?}, link {link:?}, fields {fields:?}");
|
||||
assert!(
|
||||
fields.iter().all(|field| !field.intersects(link) && !field.intersects(reference)),
|
||||
"no field overlaps the link or the point: {dump}"
|
||||
);
|
||||
let [x, w, _, h] = fields;
|
||||
assert!(
|
||||
reference.right() <= x.left() && w.right() <= link.left() && link.right() <= width,
|
||||
"point, fields, link in order, inside the room: {dump}"
|
||||
);
|
||||
assert!(h.top() >= w.bottom(), "H is under W: {dump}");
|
||||
let middle = (w.top() + h.bottom()) / 2.0;
|
||||
assert!((link.center().y - middle).abs() <= 1.0, "the link is centred across the two rows: {dump}");
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,5 @@ log = "0.4"
|
||||
serde = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
@@ -342,30 +342,42 @@ impl Table {
|
||||
}
|
||||
/// Whether [`Table::normalize`] would drop rows or columns to fit [`MAX_CELLS`].
|
||||
pub fn over_cap(&self) -> bool {
|
||||
let n = self.cols.len();
|
||||
n > MAX_CELLS || self.rows.len() > (MAX_CELLS / n.max(1)).max(1)
|
||||
self.over(MAX_CELLS)
|
||||
}
|
||||
/// What [`Table::normalize`] would leave of this table, cloning only the rows and cells that
|
||||
/// survive (an oversized table is not copied whole first).
|
||||
pub fn normalized(&self) -> Table {
|
||||
let n = self.cols.len().min(MAX_CELLS);
|
||||
let keep = (MAX_CELLS / n.max(1)).max(1);
|
||||
let rows = self.rows.iter().take(keep).map(|r| Row { height: r.height, cells: r.cells.iter().take(n).cloned().collect() }).collect();
|
||||
let mut t = Table { cols: self.cols[..n].to_vec(), rows, background: self.background.clone(), style: self.style.clone(), ..*self };
|
||||
t.normalize();
|
||||
if self.over_cap() {
|
||||
t.clip_spans();
|
||||
}
|
||||
t
|
||||
self.normalized_within(MAX_CELLS)
|
||||
}
|
||||
/// Make every row have exactly `cols.len()` cells (repair after loading). A grid over
|
||||
/// [`MAX_CELLS`] loses its last rows (and columns) first, so a file naming many rows and many
|
||||
/// columns but few cells cannot make this allocate their product.
|
||||
pub fn normalize(&mut self) {
|
||||
let truncated = self.over_cap();
|
||||
self.cols.truncate(MAX_CELLS);
|
||||
self.normalize_within(MAX_CELLS);
|
||||
}
|
||||
/// [`Table::over_cap`] for a cap of `max` cells.
|
||||
fn over(&self, max: usize) -> bool {
|
||||
let n = self.cols.len();
|
||||
self.rows.truncate((MAX_CELLS / n.max(1)).max(1));
|
||||
n > max || self.rows.len() > (max / n.max(1)).max(1)
|
||||
}
|
||||
/// [`Table::normalized`] for a cap of `max` cells.
|
||||
fn normalized_within(&self, max: usize) -> Table {
|
||||
let n = self.cols.len().min(max);
|
||||
let keep = (max / n.max(1)).max(1);
|
||||
let rows = self.rows.iter().take(keep).map(|r| Row { height: r.height, cells: r.cells.iter().take(n).cloned().collect() }).collect();
|
||||
let mut t = Table { cols: self.cols[..n].to_vec(), rows, background: self.background.clone(), style: self.style.clone(), ..*self };
|
||||
t.normalize_within(max);
|
||||
if self.over(max) {
|
||||
t.clip_spans();
|
||||
}
|
||||
t
|
||||
}
|
||||
/// [`Table::normalize`] for a cap of `max` cells.
|
||||
fn normalize_within(&mut self, max: usize) {
|
||||
let truncated = self.over(max);
|
||||
self.cols.truncate(max);
|
||||
let n = self.cols.len();
|
||||
self.rows.truncate((max / n.max(1)).max(1));
|
||||
for r in &mut self.rows {
|
||||
r.cells.resize_with(n, || Cell::new(""));
|
||||
for c in &mut r.cells {
|
||||
@@ -741,22 +753,27 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn normalize_caps_a_sparse_grid_at_max_cells() {
|
||||
let mut t = Table { cols: vec![10.0; 1000], rows: vec![Row::default(); 1000], ..Default::default() };
|
||||
t.normalize();
|
||||
assert_eq!(t.cols.len(), 1000);
|
||||
assert_eq!(t.rows.len(), MAX_CELLS / 1000);
|
||||
assert!(t.rows.iter().all(|r| r.cells.len() == 1000));
|
||||
let mut t = Table { cols: vec![1.0; MAX_CELLS + 5], rows: vec![Row::default(); 3], ..Default::default() };
|
||||
t.normalize();
|
||||
assert_eq!((t.cols.len(), t.rows.len()), (MAX_CELLS, 1));
|
||||
let wide = Table {
|
||||
cols: vec![10.0; 1000],
|
||||
rows: vec![Row { height: 1.0, cells: vec![Cell::new("x"); 1100] }; MAX_CELLS / 1000 + 1],
|
||||
..Default::default()
|
||||
};
|
||||
let mut n = wide.clone();
|
||||
n.normalize();
|
||||
assert_eq!(wide.normalized(), n);
|
||||
// At a cap 100 times smaller; nightly also at MAX_CELLS.
|
||||
let full = craft_testkit::hostile::divisor() == 1;
|
||||
for max in [MAX_CELLS / 100].into_iter().chain(full.then_some(MAX_CELLS)) {
|
||||
let cols = max / 100;
|
||||
let mut t = Table { cols: vec![10.0; cols], rows: vec![Row::default(); 1000], ..Default::default() };
|
||||
t.normalize_within(max);
|
||||
assert_eq!(t.cols.len(), cols);
|
||||
assert_eq!(t.rows.len(), max / cols);
|
||||
assert!(t.rows.iter().all(|r| r.cells.len() == cols));
|
||||
let mut t = Table { cols: vec![1.0; max + 5], rows: vec![Row::default(); 3], ..Default::default() };
|
||||
t.normalize_within(max);
|
||||
assert_eq!((t.cols.len(), t.rows.len()), (max, 1));
|
||||
let wide = Table {
|
||||
cols: vec![10.0; cols],
|
||||
rows: vec![Row { height: 1.0, cells: vec![Cell::new("x"); cols + cols / 10] }; max / cols + 1],
|
||||
..Default::default()
|
||||
};
|
||||
let mut n = wide.clone();
|
||||
n.normalize_within(max);
|
||||
assert_eq!(wide.normalized_within(max), n);
|
||||
}
|
||||
let mut t = Table::new(4, 4, 400.0, 30.0);
|
||||
t.normalize();
|
||||
assert_eq!((t.n_rows(), t.n_cols()), (4, 4));
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::sync::{Condvar, Mutex};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use craft_font_catalog::Catalog;
|
||||
pub use craft_font_store::preview::PreviewStore;
|
||||
pub use craft_font_store::PreviewStore;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use craft_font_store::{Cancel, Client, Face, FontStore, Network, PINNED_INDEX, verify_font};
|
||||
pub use craft_font_store::{LegalText, PREVIEW_SERVICE_ENV, PreviewServiceSource, UserSource};
|
||||
|
||||
@@ -281,7 +281,11 @@ impl Installer for FakeStore {
|
||||
}
|
||||
|
||||
fn set_preview_service(&self, url: Option<&str>) -> Result<(), StoreError> {
|
||||
// The address check is the native store's; the browser has no preview service to reach.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let url = url.map(craft_font_store::check_preview_service).transpose().map_err(err)?;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let url = url.map(str::to_owned);
|
||||
*self.preview_service.lock().map_err(err)? = url;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
mod index;
|
||||
mod pin;
|
||||
mod service;
|
||||
mod source;
|
||||
mod sources;
|
||||
mod verify;
|
||||
@@ -42,6 +43,7 @@ pub use index::{
|
||||
MAX_FILE_BYTES, MAX_INDEX_BYTES, MAX_LICENSE_BYTES, Sample, Script, SourceProblem, Unavailable, parse_style,
|
||||
};
|
||||
pub use pin::{IndexPin, PINNED_INDEX};
|
||||
pub use service::{LegalText, PREVIEW_SERVICE_ENV, PreviewServiceSource, PreviewStore};
|
||||
pub use sources::{SourceEntry, SourcesFile};
|
||||
pub use verify::{VerifyError, is_font, sha256_hex, verify_font};
|
||||
|
||||
@@ -67,10 +69,7 @@ pub use language_packs::{
|
||||
MAX_PACK_INDEX_BYTES, MAX_PACK_UNPACKED_BYTES, PackEntry, PackIndex, PackIndexPin, language_pack_index_overridden,
|
||||
};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use store::{
|
||||
Caller, Error, FontStore, InstalledFamily, InstalledFile, LegalText, Network, PREVIEW_SERVICE_ENV, PreviewServiceSource, Problem, Progress,
|
||||
check_preview_service,
|
||||
};
|
||||
pub use store::{Caller, Error, FontStore, InstalledFamily, InstalledFile, Network, Problem, Progress, check_preview_service};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -246,31 +246,7 @@ pub struct Preview {
|
||||
pub font: Result<Vec<u8>, PreviewError>,
|
||||
}
|
||||
|
||||
/// What [`Previews`] reads from the font store: the service and the user's setting on each request, the client and
|
||||
/// the cache folder when the pool is made. The font manager's `Installer` builds on it.
|
||||
pub trait PreviewStore: Send + Sync {
|
||||
/// The preview service's base URL, if one is set: [`PREVIEW_SERVICE_ENV`](crate::PREVIEW_SERVICE_ENV), else the
|
||||
/// font store's `preview_service` setting, else the host's default. Installs try it as a mirror first.
|
||||
fn preview_service(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// The store's HTTP client, if it has one. [`Previews`] fetches with it, so a preview service that installs
|
||||
/// found unreachable is skipped by previews too, and the reverse.
|
||||
fn http_client(&self) -> Option<Client> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Whether previews may be fetched from the preview service: the user's setting, on by default.
|
||||
fn previews_enabled(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// The folder [`Previews`] caches preview subsets in; none keeps them only for as long as the caller holds them.
|
||||
fn preview_cache(&self) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
}
|
||||
pub use crate::service::PreviewStore;
|
||||
|
||||
/// How the pool downloads: the store's [`Client`], or a stand-in in tests.
|
||||
pub trait Fetch: Send + Sync {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//! What the font store and the preview service's client share with the font manager on every target: which legal
|
||||
//! text to read, where the preview service comes from, and what the preview pool reads from a store. The store and
|
||||
//! the client themselves are native only.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Which of a family's legal texts [`FontStore::legal_text`](crate::FontStore::legal_text) reads.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum LegalText {
|
||||
/// The licence file (`OFL.txt`, `LICENSE.txt`).
|
||||
License,
|
||||
/// An Apache family's `NOTICE` file.
|
||||
Notice,
|
||||
}
|
||||
|
||||
/// The environment variable that sets the preview service's base URL; it beats the saved setting.
|
||||
pub const PREVIEW_SERVICE_ENV: &str = "CRAFT_FONT_PREVIEW_URL";
|
||||
|
||||
/// Where the preview service in effect comes from.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PreviewServiceSource {
|
||||
/// [`PREVIEW_SERVICE_ENV`]; the setting can't change it.
|
||||
Env,
|
||||
/// The `preview_service` setting in `settings.json`.
|
||||
Saved,
|
||||
/// The host's default, [`FontStore::with_default_preview_service`](crate::FontStore::with_default_preview_service).
|
||||
Default,
|
||||
/// There is no service.
|
||||
None,
|
||||
}
|
||||
|
||||
/// What [`Previews`](crate::preview::Previews) reads from the font store: the service and the user's setting on each request, the client and
|
||||
/// the cache folder when the pool is made. The font manager's `Installer` builds on it.
|
||||
pub trait PreviewStore: Send + Sync {
|
||||
/// The preview service's base URL, if one is set: [`PREVIEW_SERVICE_ENV`](crate::PREVIEW_SERVICE_ENV), else the
|
||||
/// font store's `preview_service` setting, else the host's default. Installs try it as a mirror first.
|
||||
fn preview_service(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// The store's HTTP client, if it has one. [`Previews`](crate::preview::Previews) fetches with it, so a preview service that installs
|
||||
/// found unreachable is skipped by previews too, and the reverse.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn http_client(&self) -> Option<crate::Client> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Whether previews may be fetched from the preview service: the user's setting, on by default.
|
||||
fn previews_enabled(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// The folder [`Previews`](crate::preview::Previews) caches preview subsets in; none keeps them only for as long as the caller holds them.
|
||||
fn preview_cache(&self) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ use crate::index::{
|
||||
Face, Family, FontFile, GOOGLE_FONTS, Index, IndexError, LicenseFile, MAX_INDEX_BYTES, MAX_LICENSE_BYTES, SourceProblem, Unavailable,
|
||||
};
|
||||
use crate::pin::IndexPin;
|
||||
use crate::service::{LegalText, PREVIEW_SERVICE_ENV, PreviewServiceSource};
|
||||
use crate::source::{is_source_url, safe_dir, safe_file_name, slug};
|
||||
use crate::sources::{MAX_SOURCES_BYTES, SourceEntry, SourcesFile};
|
||||
use crate::verify::{VerifyError, is_font, sha256_hex, verify_font};
|
||||
@@ -237,15 +238,6 @@ pub struct Problem {
|
||||
pub error: Option<VerifyError>,
|
||||
}
|
||||
|
||||
/// Which of a family's legal texts [`FontStore::legal_text`] reads.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum LegalText {
|
||||
/// The licence file (`OFL.txt`, `LICENSE.txt`).
|
||||
License,
|
||||
/// An Apache family's `NOTICE` file.
|
||||
Notice,
|
||||
}
|
||||
|
||||
/// A licence or NOTICE file's size and sha256, when the index has them. A format 1.0 index has
|
||||
/// neither for the licence: the size cap is then the only check.
|
||||
fn check_license(file: Option<&LicenseFile>, bytes: &[u8]) -> Result<(), VerifyError> {
|
||||
@@ -690,22 +682,6 @@ pub(crate) fn read_limited(path: &Path, max: u64) -> Option<Vec<u8>> {
|
||||
std::fs::read(path).ok()
|
||||
}
|
||||
|
||||
/// The environment variable that sets the preview service's base URL; it beats the saved setting.
|
||||
pub const PREVIEW_SERVICE_ENV: &str = "CRAFT_FONT_PREVIEW_URL";
|
||||
|
||||
/// Where the preview service in effect comes from.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum PreviewServiceSource {
|
||||
/// [`PREVIEW_SERVICE_ENV`]; the setting can't change it.
|
||||
Env,
|
||||
/// The `preview_service` setting in `settings.json`.
|
||||
Saved,
|
||||
/// The host's default, [`FontStore::with_default_preview_service`].
|
||||
Default,
|
||||
/// There is no service.
|
||||
None,
|
||||
}
|
||||
|
||||
/// The environment value when set and not empty, else the setting; an unusable value counts as
|
||||
/// unset.
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -20,6 +20,7 @@ heic-rs = { version = "=0.1.4", default-features = false, features = ["std", "pa
|
||||
rayon = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
proptest = { workspace = true }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -186,7 +186,9 @@ fn grid_tiles_are_held_to_the_pixel_budget_together() {
|
||||
fn truncated_and_corrupted_files_are_errors_not_panics() {
|
||||
let bytes = build(&Spec { props: vec![FULL_601, Prop::Irot(1)], thumbnail: Some(&grey), ..Spec::new(64, 64, &grey) });
|
||||
let full = decode(&bytes, &Options::default()).unwrap();
|
||||
for cut in (0..bytes.len()).step_by(7) {
|
||||
// The gate runs a divisor's fraction of the cuts and flips; nightly runs all.
|
||||
let divisor = craft_testkit::hostile::divisor();
|
||||
for cut in (0..bytes.len()).step_by(7 * divisor) {
|
||||
let b = &bytes[..cut];
|
||||
// Cut inside the photo: an error. Cut in the trailing thumbnail: the whole photo.
|
||||
if let (Ok(_), Ok(d)) = (probe(b), decode(b, &Options::default())) {
|
||||
@@ -197,7 +199,7 @@ fn truncated_and_corrupted_files_are_errors_not_panics() {
|
||||
}
|
||||
// Flip bits all over the file: any outcome but a panic.
|
||||
let mut state = 0x2545_f491_u32;
|
||||
for _ in 0..400 {
|
||||
for _ in 0..400 / divisor {
|
||||
let mut b = bytes.clone();
|
||||
for _ in 0..3 {
|
||||
state ^= state << 13;
|
||||
|
||||
@@ -2324,6 +2324,9 @@ mod streamed_tests {
|
||||
/// gives, at 8 and 16 bits, with a profile, resolution, text and XMP.
|
||||
#[test]
|
||||
fn streamed_rows_match_the_whole_image_encoder() {
|
||||
// The gate runs every divisor-th (image, level, bands) case, nightly all twelve.
|
||||
let divisor = craft_media_testkit::hostile::divisor();
|
||||
let mut case = 0usize;
|
||||
for (layout, sample, ch, bytes, w, h) in
|
||||
[(ChannelLayout::Rgba, SampleType::U8, 4usize, 1usize, 1024u32, 1025u32), (ChannelLayout::Rgb, SampleType::U16, 3, 2, 1024, 700)]
|
||||
{
|
||||
@@ -2339,9 +2342,20 @@ mod streamed_tests {
|
||||
.with_meta(meta);
|
||||
for level in [PngCompression::Fast, PngCompression::Default] {
|
||||
let opts = EncodeOptions { png_compression: level, ..Default::default() };
|
||||
let one_band = [h];
|
||||
let cases: Vec<&[u32]> = [&[1u32, 77, 300][..], &[256, 256, 256], &one_band]
|
||||
.into_iter()
|
||||
.filter(|_| {
|
||||
case += 1;
|
||||
(case - 1).is_multiple_of(divisor)
|
||||
})
|
||||
.collect();
|
||||
if cases.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let whole = crate::encode(&img, Format::Png, &opts).unwrap();
|
||||
let (head, zlib, _) = split(&whole);
|
||||
for heights in [&[1u32, 77, 300][..], &[256, 256, 256], &[h]] {
|
||||
for heights in cases {
|
||||
let png = streamed(&img, heights, &opts);
|
||||
let (h2, z2, _) = split(&png);
|
||||
assert!(h2 == head, "{layout:?} {level:?} {heights:?}: header chunks differ");
|
||||
|
||||
@@ -99,9 +99,12 @@ fn byte_overwrites_in_header_never_panic() {
|
||||
let step = craft_media_testkit::hostile::divisor();
|
||||
for (k, (f, bytes)) in samples().into_iter().enumerate() {
|
||||
for i in (0..bytes.len().min(64)).filter(|i| (i + k) % step == 0) {
|
||||
for v in [0x00, 0x7F, 0xFF] {
|
||||
// nightly writes every value to each byte; the gate one per byte, rotating, so the sampled bytes together see all
|
||||
let values = [0x00, 0x7F, 0xFF];
|
||||
let one = [values[(i / step) % 3]];
|
||||
for v in if step == 1 { &values[..] } else { &one[..] } {
|
||||
let mut b = bytes.clone();
|
||||
b[i] = v;
|
||||
b[i] = *v;
|
||||
no_panic(f, &b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,24 +340,28 @@ fn blank_g4(h: u32) -> Vec<u8> {
|
||||
fn a_blank_fax_page_wider_than_4096_px_passes_the_bomb_guard() {
|
||||
// A blank page codes each row in one bit, so a row wider than 4096 pixels is past 4096:1: it
|
||||
// must open, with or without the metadata and other pages that used to raise the bound. The
|
||||
// page has enough rows to hold more than the guard's fixed 1 MiB of slack.
|
||||
for (w, h) in [(20_000u32, 800u32)] {
|
||||
let mut d = Dir { entries: base(w, h, 1, 1, 0), chunks: vec![blank_g4(h)], tiled: false }.tag(278, LONG, &[u64::from(h)]);
|
||||
d.entries.retain(|e| e.0 != 259);
|
||||
let d = d.tag(259, SHORT, &[4]);
|
||||
let pages: Vec<Dir> = (0..2).map(|_| d.clone()).collect();
|
||||
for (what, bytes) in
|
||||
[("one page", build(true, false, std::slice::from_ref(&d), &[0]).bytes), ("two pages", build(true, false, &pages, &[0, 1]).bytes)]
|
||||
{
|
||||
let img = decode(&bytes).unwrap_or_else(|e| panic!("{w}x{h} {what}: {e}"));
|
||||
assert_eq!(img.dimensions(), (w, h), "{what}");
|
||||
assert!(img.data().iter().all(|&v| v == 255), "{w}x{h} {what}: not white");
|
||||
}
|
||||
}
|
||||
let mut d = Dir { entries: base(20_000, 800, 1, 1, 0), chunks: vec![blank_g4(800)], tiled: false }.tag(278, LONG, &[800]);
|
||||
// page has enough rows to hold more than the guard's fixed 1 MiB of slack: (w - 4096) * h / 8
|
||||
// bytes past 4096:1, so a wider page needs fewer pixels. The gate decodes the one-page file;
|
||||
// nightly also the two-page file and the banded decode.
|
||||
let full = craft_media_testkit::hostile::divisor() == 1;
|
||||
let (w, h) = (60_000u32, 160u32);
|
||||
let mut d = Dir { entries: base(w, h, 1, 1, 0), chunks: vec![blank_g4(h)], tiled: false }.tag(278, LONG, &[u64::from(h)]);
|
||||
d.entries.retain(|e| e.0 != 259);
|
||||
let bytes = build(true, false, &[d.tag(259, SHORT, &[4])], &[0]).bytes;
|
||||
assert!(banded(&bytes, None, &Limits::banded(), true).unwrap().data() == decode(&bytes).unwrap().data());
|
||||
let d = d.tag(259, SHORT, &[4]);
|
||||
let one_page = build(true, false, std::slice::from_ref(&d), &[0]).bytes;
|
||||
let mut files = vec![("one page", one_page.clone())];
|
||||
if full {
|
||||
let pages: Vec<Dir> = (0..2).map(|_| d.clone()).collect();
|
||||
files.push(("two pages", build(true, false, &pages, &[0, 1]).bytes));
|
||||
}
|
||||
for (what, bytes) in files {
|
||||
let img = decode(&bytes).unwrap_or_else(|e| panic!("{w}x{h} {what}: {e}"));
|
||||
assert_eq!(img.dimensions(), (w, h), "{what}");
|
||||
assert!(img.data().iter().all(|&v| v == 255), "{w}x{h} {what}: not white");
|
||||
}
|
||||
if full {
|
||||
assert!(banded(&one_page, None, &Limits::banded(), true).unwrap().data() == decode(&one_page).unwrap().data());
|
||||
}
|
||||
// Still a bound: 100 bytes of Group 4 can't hold that page (4096:1 for Group 3, which is not decoded).
|
||||
for compression in [4, 3] {
|
||||
let mut d = Dir { entries: base(7016, 4961, 1, 1, 0), chunks: vec![vec![0x80; 100]], tiled: false }.tag(278, LONG, &[4961]);
|
||||
|
||||
@@ -840,7 +840,11 @@ fn zoo_decodes_and_never_panics_when_cut_or_corrupted() {
|
||||
poke(&f[..cut]);
|
||||
}
|
||||
for i in (0..f.len()).filter(|i| (i + k) % step == 0) {
|
||||
for flip in [0xffu8, 0x80, 0x01] {
|
||||
// nightly flips each byte three ways; the gate one way per byte, rotating, so the sampled bytes together see all
|
||||
let flips = [0xffu8, 0x80, 0x01];
|
||||
let one = [flips[(i / step) % 3]];
|
||||
for flip in if step == 1 { &flips[..] } else { &one[..] } {
|
||||
let flip = *flip;
|
||||
let mut g = f.clone();
|
||||
g[i] ^= flip;
|
||||
poke(&g);
|
||||
|
||||
@@ -16,6 +16,7 @@ thiserror = { workspace = true }
|
||||
rayon = { workspace = true, optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
# Reference encoder and baseline decoder for the comparison tests.
|
||||
jpeg-encoder = "0.6"
|
||||
zune-jpeg = "0.5"
|
||||
|
||||
@@ -42,12 +42,19 @@ fn compare(src: &[u8], w: usize, h: usize, ch: usize, q: u8, sub: ChromaSubsampl
|
||||
|
||||
#[test]
|
||||
fn all_sampling_and_channels_match_retained_tokens_byte_for_byte() {
|
||||
// The gate compares every divisor-th case, so every size, channel count, subsampling and quality still runs;
|
||||
// nightly compares them all.
|
||||
let divisor = craft_testkit::hostile::divisor();
|
||||
let mut case = 0usize;
|
||||
for (w, h) in [(1, 1), (7, 9), (17, 31), (33, 65), (17, 1025)] {
|
||||
for ch in [1, 3, 4] {
|
||||
let src = noise(w * h * ch);
|
||||
for sub in [ChromaSubsampling::S444, ChromaSubsampling::S422, ChromaSubsampling::S420] {
|
||||
for q in [0, 1, 25, 50, 90, 100, 255] {
|
||||
compare(&src, w, h, ch, q, sub, &[]);
|
||||
case += 1;
|
||||
if case.is_multiple_of(divisor) {
|
||||
compare(&src, w, h, ch, q, sub, &[]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,6 +821,19 @@ impl Outcome for LayerFilterOutput {
|
||||
}
|
||||
}
|
||||
|
||||
/// How wide the Objects filter's search field stands in the filter bar. An app sets it once at its root
|
||||
/// (`RootEnv::values`); the default is `Natural`.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, craft_ui::runtime::env::EnvValue, craft_ui::contract::MemoProps)]
|
||||
#[env(style)]
|
||||
#[non_exhaustive]
|
||||
pub enum ObjectsSearch {
|
||||
/// The field's own width, with the Filter button right after it.
|
||||
#[default]
|
||||
Natural,
|
||||
/// The field fills the row, with the Filter button at the end edge: VectorCraft's Layers panel.
|
||||
Fill,
|
||||
}
|
||||
|
||||
/// Whether the Objects filter's popover is open: the bar's memory, so it stays open across passes until a
|
||||
/// click outside or Escape closes it.
|
||||
#[derive(Clone, Default)]
|
||||
@@ -859,7 +872,10 @@ impl<'a> LayerFilterBar<'a> {
|
||||
}
|
||||
let words = Env::of(ui).words::<LayerFilterWords>();
|
||||
let mut edit = None;
|
||||
let row = Row::new().show(ui, |ui, cx| {
|
||||
// A filling search field needs a row as wide as the bar to fill.
|
||||
let fill = Env::of(ui).get::<ObjectsSearch>() == ObjectsSearch::Fill;
|
||||
let row = if fill { Row::new().fill_width() } else { Row::new() };
|
||||
let row = row.show(ui, |ui, cx| {
|
||||
let select_name = std::mem::replace(&mut cx.memory::<FindName>().select, focus_name);
|
||||
let Some(Mixed::Same(current)) = filter.reborrow().read(cx) else { return };
|
||||
let stored = current;
|
||||
@@ -948,9 +964,12 @@ impl<'a> LayerFilterBar<'a> {
|
||||
// The selected layers pick the artboards; Group lists every group.
|
||||
FilterBy::Artboard | FilterBy::Group => {}
|
||||
FilterBy::Objects => {
|
||||
let typed = TextField::search(words.search_layers.clone(), Bind::given(current.name.clone()))
|
||||
.placeholder(words.search_all.clone())
|
||||
.show(ui);
|
||||
let mut field =
|
||||
TextField::search(words.search_layers.clone(), Bind::given(current.name.clone())).placeholder(words.search_all.clone());
|
||||
if fill {
|
||||
field = field.sizing(Sizing::FillWidth);
|
||||
}
|
||||
let typed = field.show(ui);
|
||||
if let Some(text) = typed.value() {
|
||||
next.name.clone_from(text);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
//! Stories of `LayerFilterBar`: each filter type in one card, with the count of a document's layers it lets through.
|
||||
|
||||
use super::{EffectKind, FilterBy, FilterKind, FilterObject, FilterState, LayerAttribute, LayerFilter, LayerFilterBar, SmartKind};
|
||||
use super::{EffectKind, FilterBy, FilterKind, FilterObject, FilterState, LayerAttribute, LayerFilter, LayerFilterBar, ObjectsSearch, SmartKind};
|
||||
use crate::ui::mock::FakeLayers;
|
||||
use crate::ui::tree::LayerTree as _;
|
||||
use craft_theme::LabelColor;
|
||||
use craft_ui::runtime::env::with_env;
|
||||
use craft_ui::testing::{Drive, Fixture, StoryData, StoryOutput, ValueAt, story};
|
||||
use egui::Ui;
|
||||
|
||||
@@ -103,3 +104,17 @@ fn layer_filter_objects(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
);
|
||||
show(ui, filter, filter_at)
|
||||
}
|
||||
|
||||
/// The Objects filter in an app whose search field fills the bar (`ObjectsSearch::Fill`, VectorCraft's Layers panel):
|
||||
/// the Filter button at the end edge.
|
||||
#[story(LayerFilterBar<'static>, covers = [], drive = Drive::Never, group = "Types", title = "Filter by Objects, filling search")]
|
||||
fn layer_filter_objects_fill(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let (filter, filter_at) = data.value_at("filter", LayerFilter { by: FilterBy::Objects, ..LayerFilter::default() });
|
||||
with_env(
|
||||
ui,
|
||||
|overrides| {
|
||||
overrides.values.set(ObjectsSearch::Fill);
|
||||
},
|
||||
|ui| show(ui, filter, filter_at),
|
||||
)
|
||||
}
|
||||
@@ -338,3 +338,23 @@ fn a_filter_the_bar_applies_deselects_what_it_hides() {
|
||||
fixture.idle(2);
|
||||
assert!(selects(&seen).is_empty(), "a layer selected later, while the filter hides it, stays selected");
|
||||
}
|
||||
|
||||
/// Where the Objects filter's Filter button ends under `search`.
|
||||
fn filter_button_end(search: craft_layers::ui::filter::ObjectsSearch) -> f32 {
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let mut filter = LayerFilter::default();
|
||||
filter.by = FilterBy::Objects;
|
||||
let _ = craft_layers::ui::filter::LayerFilterBar::new(Bind::bound(&mut filter)).filter_types([FilterBy::Objects]).show(ui);
|
||||
});
|
||||
fixture.root_value(search).room(ONE_PANEL).settle();
|
||||
fixture.by_label("Filter").expect("the Objects filter shows its Filter button").rect.right()
|
||||
}
|
||||
|
||||
/// An app whose Objects search fills the bar (`ObjectsSearch::Fill`, VectorCraft's Layers panel) gets its Filter
|
||||
/// button further toward the end edge than the field's own width leaves it.
|
||||
#[trial]
|
||||
fn a_filling_objects_search_puts_the_filter_button_at_the_end() {
|
||||
use craft_layers::ui::filter::ObjectsSearch;
|
||||
let (natural, fill) = (filter_button_end(ObjectsSearch::Natural), filter_button_end(ObjectsSearch::Fill));
|
||||
assert!(fill > natural, "the Filter button ends at {fill} under Fill, {natural} under Natural");
|
||||
}
|
||||
@@ -15,3 +15,6 @@ workspace = true
|
||||
libm = "0.2.16"
|
||||
# Data-parallel loops (MIT OR Apache-2.0).
|
||||
rayon = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
@@ -5459,6 +5459,38 @@ mod grey_tests {
|
||||
pub(super) static GREY_RUNS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
/// A sample of a sweep of `total` cases: all of them when `craft_testkit::hostile::divisor()` is 1 (nightly), at the
|
||||
/// gate every `per_div * divisor - 1`-th (an odd stride, so every axis of a nested loop varies).
|
||||
struct Sweep {
|
||||
stride: usize,
|
||||
total: usize,
|
||||
seen: usize,
|
||||
visited: usize,
|
||||
}
|
||||
|
||||
impl Sweep {
|
||||
fn new(total: usize, per_div: usize) -> Sweep {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let div = craft_testkit::hostile::divisor();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let div = 1;
|
||||
Sweep { stride: if div == 1 { 1 } else { per_div * div - 1 }, total, seen: 0, visited: 0 }
|
||||
}
|
||||
|
||||
/// Whether the next case of the sweep is in the sample.
|
||||
fn take(&mut self) -> bool {
|
||||
let take = self.seen.is_multiple_of(self.stride);
|
||||
self.seen += 1;
|
||||
self.visited += usize::from(take);
|
||||
take
|
||||
}
|
||||
|
||||
/// What `full` grey runs over all the cases comes to over the cases visited.
|
||||
fn share(&self, full: usize) -> usize {
|
||||
full * self.visited / self.total
|
||||
}
|
||||
}
|
||||
|
||||
fn bits(outs: &BTreeMap<String, Tex>) -> Vec<(String, Vec<u32>)> {
|
||||
outs.iter().map(|(k, t)| (k.clone(), t.px.iter().flat_map(|p| p.map(f32::to_bits)).collect())).collect()
|
||||
}
|
||||
@@ -5532,6 +5564,7 @@ mod grey_tests {
|
||||
"m00=-1 m01=0 m10=0 m11=1",
|
||||
];
|
||||
let bgs = ["", "bg_r=0.5 bg_g=0.5 bg_b=0.5 bg_a=1", "bg_r=0.2 bg_g=0.3 bg_b=0.2 bg_a=1", "bg_a=0.5"];
|
||||
let mut sweep = Sweep::new(2 * mats.len() * bgs.len() * 3 * 4 * 4, 16);
|
||||
let n = greys(|| {
|
||||
for compiled in [false, true] {
|
||||
for m in mats {
|
||||
@@ -5544,6 +5577,9 @@ mod grey_tests {
|
||||
(" osize_log2_x=4 osize_log2_y=5", " ofmt=5"),
|
||||
(" osize_log2_x=6 osize_log2_y=6", " ofmt=6 offset_x=0.13 offset_y=-0.3"),
|
||||
] {
|
||||
if !sweep.take() {
|
||||
continue;
|
||||
}
|
||||
let body = format!("node 10 transform_matrix in=@2 {m} {bg} {tiles} {filt}{osz}{fmt}\noutput out 10\n");
|
||||
same(&body, 32, compiled);
|
||||
}
|
||||
@@ -5553,7 +5589,7 @@ mod grey_tests {
|
||||
}
|
||||
}
|
||||
});
|
||||
assert!(n > 300, "{n} grey runs");
|
||||
assert!(n > sweep.share(300), "{n} grey runs in {} of {} cases", sweep.visited, sweep.total);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -5663,6 +5699,7 @@ mod grey_tests {
|
||||
|
||||
#[test]
|
||||
fn blend_grey_is_rgba() {
|
||||
let mut sweep = Sweep::new(2 * 26 * 5 * 10, 16);
|
||||
let n = greys(|| {
|
||||
for compiled in [false, true] {
|
||||
for mode in (0..=21).chain(32..=35) {
|
||||
@@ -5679,6 +5716,9 @@ mod grey_tests {
|
||||
("0.6", " ofmt=1 tile_x=0.25"),
|
||||
("0.6", " ofmt=7"),
|
||||
] {
|
||||
if !sweep.take() {
|
||||
continue;
|
||||
}
|
||||
let body = format!("node 10 blend fg=@1 bg=@2 mode={mode} alpha_mode={am} opacity={op}{extra}\noutput out 10\n");
|
||||
same(&body, 24, compiled);
|
||||
}
|
||||
@@ -5686,7 +5726,7 @@ mod grey_tests {
|
||||
}
|
||||
}
|
||||
});
|
||||
assert!(n > 300, "{n} grey runs");
|
||||
assert!(n > sweep.share(300), "{n} grey runs in {} of {} cases", sweep.visited, sweep.total);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -8,6 +8,12 @@ use std::fmt::Write;
|
||||
/// The stack of a thread spawned without asking for one (Rust's default), and of rayon's workers.
|
||||
const NORMAL_STACK: usize = 2 << 20;
|
||||
|
||||
/// Stacks too small for a walk that recurses once per node: a frame takes at least tens of bytes (an unoptimised one about
|
||||
/// a kilobyte), so the chains below overflow them if the evaluator recurses, and the chain length needs no more work than
|
||||
/// that.
|
||||
const SMALL_STACK: usize = 128 << 10;
|
||||
const MEDIUM_STACK: usize = 512 << 10;
|
||||
|
||||
/// The stack a function as deep as allowed is run with: the normal one in an optimised build (measured: 2040 nodes in a
|
||||
/// row take under 1 MB); an unoptimised build's frames are about fifteen times larger.
|
||||
const FUNCTION_STACK: usize = if cfg!(debug_assertions) { 32 << 20 } else { NORMAL_STACK };
|
||||
@@ -51,22 +57,22 @@ fn nested(levels: u32) -> String {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_chain_of_a_hundred_thousand_nodes_evaluates_on_a_normal_stack() {
|
||||
let g = Graph::parse(&image_chain(100_000)).expect("parses");
|
||||
fn a_long_chain_evaluates_on_a_small_stack() {
|
||||
let g = Graph::parse(&image_chain(10_000)).expect("parses");
|
||||
let shallow = Graph::parse(&image_chain(2)).expect("parses");
|
||||
let (deep, two) =
|
||||
on_stack(NORMAL_STACK, move || (g.evaluate(None).map_err(|e| e.to_string()), shallow.evaluate(None).map_err(|e| e.to_string())));
|
||||
on_stack(MEDIUM_STACK, move || (g.evaluate(None).map_err(|e| e.to_string()), shallow.evaluate(None).map_err(|e| e.to_string())));
|
||||
let (deep, two) = (deep.expect("evaluates"), two.expect("evaluates"));
|
||||
// an even number of inverts is the gradient again, as two are
|
||||
assert_eq!(deep["o"].px, two["o"].px);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_node_of_a_long_chain_gets_a_thumbnail_on_a_normal_stack() {
|
||||
let g = Graph::parse(&image_chain(20_000)).expect("parses");
|
||||
let all = on_stack(NORMAL_STACK, move || g.evaluate_all(16, &[20_000]));
|
||||
fn every_node_of_a_long_chain_gets_a_thumbnail_on_a_small_stack() {
|
||||
let g = Graph::parse(&image_chain(300)).expect("parses");
|
||||
let all = on_stack(SMALL_STACK, move || g.evaluate_all(16, &[300]));
|
||||
assert!(all.errors.is_empty(), "{:?}", all.errors.iter().next());
|
||||
assert_eq!(all.thumbs.len(), 20_001);
|
||||
assert_eq!(all.thumbs.len(), 301);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -38,13 +38,14 @@ fn in_pool<R: Send>(threads: usize, f: impl FnOnce() -> R + Send) -> R {
|
||||
|
||||
#[test]
|
||||
fn one_thread_and_eight_render_the_same_bytes() {
|
||||
let graphs = demo_graphs();
|
||||
assert!(graphs.len() > 100, "only {} demo graphs", graphs.len());
|
||||
let all = demo_graphs();
|
||||
assert!(all.len() > 100, "only {} demo graphs", all.len());
|
||||
let graphs = crate::sampled(all, 0);
|
||||
let one = in_pool(1, || graphs.iter().map(|(_, g)| render(g)).collect::<Vec<_>>());
|
||||
let eight = in_pool(8, || graphs.iter().map(|(_, g)| render(g)).collect::<Vec<_>>());
|
||||
let differ: Vec<&str> = graphs.iter().zip(one.iter().zip(&eight)).filter(|(_, (a, b))| a != b).map(|((k, _), _)| *k).collect();
|
||||
assert!(differ.is_empty(), "these kinds render differently on 1 and 8 threads: {differ:?}");
|
||||
assert!(one.iter().filter(|r| r.is_ok()).count() > 100, "most demo graphs must render");
|
||||
assert!(one.iter().filter(|r| r.is_ok()).count() * 10 > graphs.len() * 8, "most demo graphs must render");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -52,7 +53,7 @@ fn cached_and_uncached_evaluations_give_the_same_bytes() {
|
||||
let cache = Arc::new(NodeCache::new(256));
|
||||
let mut differ = Vec::new();
|
||||
let mut not_reused = Vec::new();
|
||||
for (kind, g) in demo_graphs() {
|
||||
for (kind, g) in crate::sampled(demo_graphs(), 0) {
|
||||
let keep: Vec<u32> = g.nodes.keys().copied().collect();
|
||||
let fresh = g.evaluate_all(SIDE, &keep);
|
||||
let first = g.evaluate_all_cached(&EvalContext::default(), SIDE, &keep, &cache, None, &mut |_| {});
|
||||
|
||||
@@ -53,11 +53,15 @@ fn a_fix_in_one_operation_leaves_most_kinds_alone() {
|
||||
files.iter().for_each(|f| println!(" {}", f.name));
|
||||
}
|
||||
assert!(files.len() > 20, "{} of {} files reachable", files.len(), all.len());
|
||||
let started = std::time::Instant::now();
|
||||
let tree = SourceTree::scan(&files, DISPATCHERS);
|
||||
eprintln!("DIAG kind_versions first scan {:?}", started.elapsed());
|
||||
let kinds: Vec<String> = tree.kinds().map(str::to_string).collect();
|
||||
assert!(kinds.len() > 100, "the kinds were found: {}", kinds.len());
|
||||
let versions = |t: &SourceTree| kinds.iter().map(|k| t.kind_version(k, SHARED).unwrap()).collect::<Vec<_>>();
|
||||
let started = std::time::Instant::now();
|
||||
let before = versions(&tree);
|
||||
eprintln!("DIAG kind_versions first versions {:?}", started.elapsed());
|
||||
let distinct: std::collections::BTreeSet<_> = before.iter().collect();
|
||||
if std::env::var_os("TC_VERSIONS_DUMP").is_some() {
|
||||
for k in &kinds {
|
||||
@@ -72,24 +76,38 @@ fn a_fix_in_one_operation_leaves_most_kinds_alone() {
|
||||
}
|
||||
assert!(distinct.len() > kinds.len() / 2, "{} distinct versions of {} kinds", distinct.len(), kinds.len());
|
||||
|
||||
let changed_by = |file: &str, from: &str, to: &str| {
|
||||
let changed_by_all = |edits: &[(&str, &str, &str)]| {
|
||||
let edited: Vec<SourceFile> = files
|
||||
.iter()
|
||||
.map(|f| {
|
||||
let text = if f.name == file { f.text.replacen(from, to, 1) } else { f.text.clone() };
|
||||
assert!(f.name != file || text != f.text, "{from} is in {file}");
|
||||
let mut text = f.text.clone();
|
||||
for (file, from, to) in edits.iter().filter(|e| e.0 == f.name) {
|
||||
let next = text.replacen(from, to, 1);
|
||||
assert!(next != text, "{from} is in {file}");
|
||||
text = next;
|
||||
}
|
||||
SourceFile { text, ..f.clone() }
|
||||
})
|
||||
.collect();
|
||||
let after = versions(&SourceTree::scan(&edited, DISPATCHERS));
|
||||
let started = std::time::Instant::now();
|
||||
let scanned = SourceTree::scan(&edited, DISPATCHERS);
|
||||
let scan = started.elapsed();
|
||||
let after = versions(&scanned);
|
||||
eprintln!(
|
||||
"DIAG kind_versions edit of {:?}: scan {scan:?}, versions {:?}",
|
||||
edits.iter().map(|e| e.0).collect::<Vec<_>>(),
|
||||
started.elapsed() - scan
|
||||
);
|
||||
kinds.iter().zip(before.iter().zip(&after)).filter(|(_, (a, b))| a != b).map(|(k, _)| k.clone()).collect::<Vec<String>>()
|
||||
};
|
||||
let changed_by = |file: &str, from: &str, to: &str| changed_by_all(&[(file, from, to)]);
|
||||
|
||||
let added = changed_by("src/compiled_ops.rs", "pub fn compute(kind: &str", "fn __added_helper() -> u8 { 1 }\npub fn compute(kind: &str");
|
||||
assert_eq!(added, Vec::<String>::new(), "an added function nothing uses changes nothing");
|
||||
|
||||
let comment = changed_by("src/atomic.rs", "\"levels_mid\" => {", "\"levels_mid\" => { // a comment\n");
|
||||
assert_eq!(comment, Vec::<String>::new(), "a comment changes nothing");
|
||||
// an added function nothing uses, and a comment: both change nothing (edits in two files, one pass)
|
||||
let unchanged = changed_by_all(&[
|
||||
("src/compiled_ops.rs", "pub fn compute(kind: &str", "fn __added_helper() -> u8 { 1 }\npub fn compute(kind: &str"),
|
||||
("src/atomic.rs", "\"levels_mid\" => {", "\"levels_mid\" => { // a comment\n"),
|
||||
]);
|
||||
assert_eq!(unchanged, Vec::<String>::new(), "an unused added function and a comment change nothing");
|
||||
|
||||
// a fix inside one node's arm
|
||||
let arm = changed_by("src/atomic.rs", "\"levels_mid\" => {", "\"levels_mid\" => { let _fixed = 1;");
|
||||
|
||||
@@ -14,3 +14,21 @@ mod kind_versions;
|
||||
mod nodes;
|
||||
mod seam;
|
||||
mod vector;
|
||||
|
||||
/// The gate's share of a sweep over `items`: every `craft_testkit::hostile::divisor()`-th one from `offset` (all of them
|
||||
/// nightly, where the divisor is 1), so tests sweeping the same list with different offsets together reach more of it.
|
||||
fn sampled<T>(items: impl IntoIterator<Item = T>, offset: usize) -> Vec<T> {
|
||||
let div = divisor();
|
||||
items.into_iter().enumerate().filter(|(i, _)| (i + offset).is_multiple_of(div)).map(|(_, t)| t).collect()
|
||||
}
|
||||
|
||||
fn divisor() -> usize {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
craft_testkit::hostile::divisor()
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
1
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@ fn node_parameters_survive_extreme_values() {
|
||||
use craft_material_graph::graph::{SPECS, demo_graph_for};
|
||||
let mut problems = Vec::new();
|
||||
let mut ran = 0usize;
|
||||
for sp in SPECS {
|
||||
for sp in crate::sampled(SPECS, 0) {
|
||||
let Some(text) = demo_graph_for(sp.kind) else { continue };
|
||||
let doc = sp.doc.split_once(':').map(|x| x.1).unwrap_or("");
|
||||
let names: Vec<String> = doc
|
||||
@@ -338,7 +338,7 @@ fn node_parameters_survive_extreme_values() {
|
||||
}
|
||||
problems.sort();
|
||||
problems.dedup();
|
||||
assert!(ran > 500, "only {ran} parameter cases ran");
|
||||
assert!(ran > 500 / crate::divisor(), "only {ran} parameter cases ran");
|
||||
assert!(problems.is_empty(), "{} parameter problems:\n{}", problems.len(), problems.join("\n"));
|
||||
}
|
||||
|
||||
@@ -446,17 +446,17 @@ fn large_sizes_are_accepted() {
|
||||
fn a_cancelled_evaluation_stops_early() {
|
||||
use craft_material_graph::context::{Cancel, EvalContext};
|
||||
let mut g = Graph::parse(EXAMPLE).unwrap();
|
||||
g.size = 1024;
|
||||
g.size = 256;
|
||||
let keep: Vec<u32> = g.output_nodes().iter().map(|o| o.2).collect();
|
||||
let job = EvalContext::with_cancel(Cancel::new());
|
||||
let t0 = std::time::Instant::now();
|
||||
let full = g.evaluate_all_in(&job, 1024, &keep);
|
||||
let full = g.evaluate_all_in(&job, 256, &keep);
|
||||
let full_time = t0.elapsed();
|
||||
assert!(!full.kept.is_empty(), "a current job must deliver its outputs");
|
||||
// a newer job exists: the old one is cancelled from the start
|
||||
job.cancel.cancel();
|
||||
let t1 = std::time::Instant::now();
|
||||
let r = g.evaluate_all_in(&job, 1024, &keep);
|
||||
let r = g.evaluate_all_in(&job, 256, &keep);
|
||||
assert!(r.kept.is_empty(), "a cancelled run must not deliver outputs");
|
||||
assert!(
|
||||
t1.elapsed() < full_time / 4 + std::time::Duration::from_millis(50),
|
||||
|
||||
@@ -18,7 +18,7 @@ fn seam(t: &Tex) -> (f32, f32) {
|
||||
#[test]
|
||||
fn every_node_is_seamless() {
|
||||
let mut bad = Vec::new();
|
||||
for sp in SPECS {
|
||||
for sp in crate::sampled(SPECS, 0) {
|
||||
let Some(text) = demo_graph_for(sp.kind) else { continue };
|
||||
let g = Graph::parse(&text).unwrap();
|
||||
let out = match g.evaluate(Some(seam_size())) {
|
||||
@@ -83,7 +83,7 @@ fn filters_commute_with_wrapped_shifts() {
|
||||
"quantize",
|
||||
];
|
||||
let mut bad = Vec::new();
|
||||
for c in filters {
|
||||
for c in crate::sampled(filters.iter(), 0) {
|
||||
let kind = c.split(' ').next().unwrap();
|
||||
let mut line = format!("node 1 {c}");
|
||||
// (the nodes that read no `in` are given their inputs in the line)
|
||||
@@ -144,7 +144,7 @@ fn filters_commute_with_wrapped_shifts() {
|
||||
fn every_node_is_seamless_when_not_square() {
|
||||
let mut bad = Vec::new();
|
||||
for (wide, name) in [(true, "2:1"), (false, "1:2")] {
|
||||
for sp in SPECS {
|
||||
for sp in crate::sampled(SPECS, 4) {
|
||||
let Some(text) = demo_graph_for(sp.kind) else { continue };
|
||||
let mut g = Graph::parse(&text).unwrap();
|
||||
let s = g.size;
|
||||
|
||||
@@ -159,13 +159,15 @@ fn extreme(f: &mut [u8], at: usize, len: usize, r: &mut Rng) {
|
||||
fn extreme_metadata_index_and_partition_fields_never_panic() {
|
||||
let mut r = Rng(0x00C0_FFEE_1234_5678);
|
||||
let mut opened = 0;
|
||||
// The gate damages each base the hostile divisor's fraction of the rounds; nightly all 600.
|
||||
let rounds = 600 / craft_media_testkit::hostile::divisor();
|
||||
for base in bases() {
|
||||
assert!(exercise(&base), "the unchanged file opens");
|
||||
// local sets (header metadata, index table segments) and partition packs
|
||||
let sets: Vec<(usize, usize, usize)> =
|
||||
klvs(&base).into_iter().filter(|&(k, _, len)| len > 0 && base[k + 4] == 0x02 && matches!(base[k + 5], 0x53 | 0x05)).collect();
|
||||
assert!(sets.len() > 10, "{} packets to damage", sets.len());
|
||||
for round in 0..600 {
|
||||
for round in 0..rounds {
|
||||
let mut f = base.clone();
|
||||
for _ in 0..1 + round % 3 {
|
||||
let (k, v, len) = sets[r.below(sets.len())];
|
||||
@@ -184,7 +186,7 @@ fn extreme_metadata_index_and_partition_fields_never_panic() {
|
||||
opened += usize::from(exercise(&f));
|
||||
}
|
||||
}
|
||||
assert!(opened > 1200, "most damaged files still open and are read: {opened}");
|
||||
assert!(opened > 2 * rounds, "most damaged files still open and are read: {opened} of {rounds} rounds a base");
|
||||
}
|
||||
|
||||
/// KLV lengths that lie (longer than the file, the largest BER lengths, zero) and keys that stop
|
||||
|
||||
@@ -44,15 +44,15 @@ fn review_rig() -> Rig {
|
||||
rig
|
||||
}
|
||||
|
||||
/// Only the lines in view are drawn: the review of 2,000 entries holds a few include boxes, not 2,000.
|
||||
/// Only the lines in view are drawn: a review of several hundred entries holds a few include boxes, not one per entry.
|
||||
#[trial]
|
||||
fn a_large_review_draws_only_the_rows_in_view() {
|
||||
let commands: Vec<String> = (0..2000).map(|i| command(&format!("Entry {i}"), "Cmd+K")).collect();
|
||||
let commands: Vec<String> = (0..400).map(|i| command(&format!("Entry {i}"), "Cmd+K")).collect();
|
||||
let mut rig = Rig::new(keymap(Platform::Mac), options(), None);
|
||||
rig.review(set(&commands), ImportOptions::default());
|
||||
let drawn = rig.names_with(Role::CHECK_BOX, "").len();
|
||||
assert!(drawn > 0, "the lines in view carry include boxes");
|
||||
assert!(drawn < 100, "{drawn} include boxes drawn for 2,000 entries");
|
||||
assert!(drawn < 100, "{drawn} include boxes drawn for 400 entries");
|
||||
}
|
||||
|
||||
/// Start, include and a picked target re-plan the import; a pick and No equivalent reach the app.
|
||||
|
||||
@@ -512,10 +512,10 @@ mod tests {
|
||||
assert_eq!(found.descs[0].attrs.len(), n + 2, "every attribute is read");
|
||||
took
|
||||
};
|
||||
let (n, small_packet, large_packet) = (50_000, packet(50_000), packet(200_000));
|
||||
let (n, small_packet, large_packet) = (20_000, packet(20_000), packet(80_000));
|
||||
// interleaved, so a burst of load slows both sizes rather than one; the fastest run of each counts
|
||||
let (mut small, mut large) = (std::time::Duration::MAX, std::time::Duration::MAX);
|
||||
for _ in 0..5 {
|
||||
for _ in 0..3 {
|
||||
small = small.min(run(&small_packet, n));
|
||||
large = large.min(run(&large_packet, 4 * n));
|
||||
}
|
||||
|
||||
@@ -117,12 +117,20 @@ fn names_instruments_and_lyrics() {
|
||||
assert_eq!((read.smf.tracks.len(), read.instruments), (2, vec!["Sax".to_string(), String::new()]));
|
||||
}
|
||||
|
||||
/// Three bytes a note-on under running status: more events than are read. Built once for the tests that need it.
|
||||
fn event_flood_body() -> &'static [u8] {
|
||||
static BODY: std::sync::OnceLock<Vec<u8>> = std::sync::OnceLock::new();
|
||||
BODY.get_or_init(|| {
|
||||
let mut body = vec![0x00, 0x90, 60, 100];
|
||||
body.extend((0..MAX_EVENTS + 1).flat_map(|i| [0x00, (i % 128) as u8, 1]));
|
||||
body
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_file_of_any_size_is_read_into_a_bounded_number_of_events_and_warnings() {
|
||||
// Three bytes a note-on under running status: more events than are read.
|
||||
let mut body = vec![0x00, 0x90, 60, 100];
|
||||
body.extend((0..MAX_EVENTS + 1000).flat_map(|i| [0x00, (i % 128) as u8, 1]));
|
||||
let LenientRead { smf, warnings, over_limit, .. } = read_smf_lenient(&file(1, 96, &[&body])).unwrap();
|
||||
let body = event_flood_body();
|
||||
let LenientRead { smf, warnings, over_limit, .. } = read_smf_lenient(&file(1, 96, &[body])).unwrap();
|
||||
assert_eq!(smf.tracks[0].sequence.notes.len(), MAX_EVENTS);
|
||||
assert!(warnings.iter().any(|w| w.contains("more events")), "{warnings:?}");
|
||||
assert!(over_limit, "the event limit left events out");
|
||||
@@ -140,10 +148,9 @@ fn a_file_of_any_size_is_read_into_a_bounded_number_of_events_and_warnings() {
|
||||
fn a_limit_reached_after_the_warnings_are_full_is_still_reported() {
|
||||
// MAX_WARNINGS damaged tracks fill the warnings; the track after them holds more events than are
|
||||
// read, so its warning is dropped, and over_limit is what says the file was cut.
|
||||
let mut body = vec![0x00, 0x90, 60, 100];
|
||||
body.extend((0..MAX_EVENTS + 1000).flat_map(|i| [0x00, (i % 128) as u8, 1]));
|
||||
let body = event_flood_body();
|
||||
let mut tracks = vec![&[0x00, 60][..]; MAX_WARNINGS];
|
||||
tracks.push(&body);
|
||||
tracks.push(body);
|
||||
let LenientRead { warnings, over_limit, .. } = read_smf_lenient(&file(1, 96, &tracks)).unwrap();
|
||||
assert_eq!(warnings.len(), MAX_WARNINGS);
|
||||
assert!(!warnings.iter().any(|w| w.contains("more events")), "the test needs the limit's warning dropped: {warnings:?}");
|
||||
|
||||
@@ -24,4 +24,5 @@ chardetng = { version = "1", optional = true }
|
||||
detect = ["dep:chardetng"]
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
proptest = { workspace = true }
|
||||
@@ -145,7 +145,8 @@ fn mutations_read() {
|
||||
};
|
||||
const INTERESTING: &[u8] = b"\0\r\n\t \"\\()<>;:=?-_%*'/@,.\x7f\x80\xff";
|
||||
for original in [sample(), archive()] {
|
||||
for round in 0..4000u32 {
|
||||
// The gate runs a divisor's fraction of the rounds; nightly runs all.
|
||||
for round in 0..4000 / craft_testkit::hostile::divisor() as u32 {
|
||||
let mut bytes = original.clone();
|
||||
for _ in 0..=(round % 4) {
|
||||
let at = (next() as usize) % bytes.len().max(1);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use pgp::crypto::hash::HashAlgorithm;
|
||||
|
||||
use crate::fixtures::*;
|
||||
use crate::{CantCheck, Checked, Coverage, Fingerprint, KeyRing, MAX_MESSAGE, NotVerified, Outcome, verify};
|
||||
use crate::{CantCheck, Checked, Coverage, Fingerprint, KeyRing, MAX_MESSAGE, NotVerified, Outcome, verify, verify_within};
|
||||
|
||||
const ALICE: &str = "Alice <alice@example.org>";
|
||||
|
||||
@@ -120,17 +120,21 @@ fn an_armour_header_other_than_hash_or_an_unescaped_dash_line_is_unreadable() {
|
||||
|
||||
#[test]
|
||||
fn a_signed_message_too_large_to_check_says_so() {
|
||||
let mut big = signed_message(&secret(ALICE, Make::default()), HashAlgorithm::Sha256);
|
||||
big.resize(MAX_MESSAGE + 1, b'a');
|
||||
let checked = verify(&big, ALICE, &KeyRing::new(), LATER, yes).unwrap();
|
||||
assert!(matches!(checked.outcome, Outcome::CantCheck { why: CantCheck::TooLarge, .. }));
|
||||
// Inline-signed, the block found anywhere in it.
|
||||
let mut big = plain(ALICE, "7bit", &"a".repeat(1 << 20));
|
||||
big.extend_from_slice(b"\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\n");
|
||||
big.resize(MAX_MESSAGE + 1, b'a');
|
||||
assert!(verify(&big, ALICE, &KeyRing::new(), LATER, yes).is_some());
|
||||
// Not signed at all: nothing to say.
|
||||
let mut big = plain(ALICE, "7bit", "Just text.\r\n");
|
||||
big.resize(MAX_MESSAGE + 1, b'a');
|
||||
assert_eq!(verify(&big, ALICE, &KeyRing::new(), LATER, yes), None);
|
||||
// At a 64 KiB limit; nightly also at MAX_MESSAGE.
|
||||
let full = craft_testkit::hostile::divisor() == 1;
|
||||
for max in [64 << 10].into_iter().chain(full.then_some(MAX_MESSAGE)) {
|
||||
let mut big = signed_message(&secret(ALICE, Make::default()), HashAlgorithm::Sha256);
|
||||
big.resize(max + 1, b'a');
|
||||
let checked = verify_within(&big, max, ALICE, &KeyRing::new(), LATER, yes).unwrap();
|
||||
assert!(matches!(checked.outcome, Outcome::CantCheck { why: CantCheck::TooLarge, .. }));
|
||||
// Inline-signed, the block found anywhere in it.
|
||||
let mut big = plain(ALICE, "7bit", &"a".repeat(max / 2));
|
||||
big.extend_from_slice(b"\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\n");
|
||||
big.resize(max + 1, b'a');
|
||||
assert!(verify_within(&big, max, ALICE, &KeyRing::new(), LATER, yes).is_some());
|
||||
// Not signed at all: nothing to say.
|
||||
let mut big = plain(ALICE, "7bit", "Just text.\r\n");
|
||||
big.resize(max + 1, b'a');
|
||||
assert_eq!(verify_within(&big, max, ALICE, &KeyRing::new(), LATER, yes), None);
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,19 @@ pub(crate) fn guard<T>(f: impl FnOnce() -> T) -> Option<T> {
|
||||
/// [`Outcome::Verified`] only when the signature covers all of it ([`Coverage::whole`]); one
|
||||
/// that covers part of it is at best [`Outcome::Valid`] with [`NotVerified::partly_signed`].
|
||||
pub fn verify(original: &[u8], from: &str, keys: &KeyRing, now: u64, verified: impl Fn(&Fingerprint, &str) -> bool) -> Option<Checked> {
|
||||
if original.len() > MAX_MESSAGE {
|
||||
verify_within(original, MAX_MESSAGE, from, keys, now, verified)
|
||||
}
|
||||
|
||||
/// [`verify`] for messages of at most `max` bytes.
|
||||
fn verify_within(
|
||||
original: &[u8],
|
||||
max: usize,
|
||||
from: &str,
|
||||
keys: &KeyRing,
|
||||
now: u64,
|
||||
verified: impl Fn(&Fingerprint, &str) -> bool,
|
||||
) -> Option<Checked> {
|
||||
if original.len() > max {
|
||||
return looks_signed(original).then(|| Checked { outcome: Outcome::cant(CantCheck::TooLarge), coverage: Coverage::default() });
|
||||
}
|
||||
let cx = check::Context {
|
||||
|
||||
@@ -512,7 +512,8 @@ fn a_page_gap_change_keeps_the_scroll_offset() {
|
||||
#[trial]
|
||||
fn the_pictures_a_view_holds_stay_bounded_as_it_scrolls_through_many_pages() {
|
||||
let budget = TextureStoreOptions::pages().budget.max_entries;
|
||||
let count = 2 * budget;
|
||||
// Past the budget by half again: the store has to evict for the bound to be tested.
|
||||
let count = budget + budget / 2;
|
||||
let state = Rc::new(RefCell::new(state_with(|s| {
|
||||
s.continuous = true;
|
||||
s.fit = Fit::None;
|
||||
@@ -539,6 +540,7 @@ fn the_pictures_a_view_holds_stay_bounded_as_it_scrolls_through_many_pages() {
|
||||
assert!(drawn > 0, "the view drew pages");
|
||||
// The pages of the last two passes, in view and one row either side, are never evicted.
|
||||
let bound = budget + 2 * (drawn + 2);
|
||||
eprintln!("DIAG pictures_bounded: budget {budget}, count {count}, held {held}, drawn {drawn}");
|
||||
assert!(held > 0 && held <= bound, "{held} pictures held over {count} pages scrolled through, at most {bound} expected");
|
||||
}
|
||||
|
||||
|
||||
@@ -120,10 +120,10 @@ fn open_aes256() -> &'static SecurityHandler {
|
||||
HANDLER.get_or_init(|| make(Algorithm::Aes256, "", "owner"))
|
||||
}
|
||||
|
||||
/// Cases for the expensive properties (each draws fresh AES-256 files): the gate's fraction of
|
||||
/// `full` (the hostile-input divisor), at least `floor`; nightly runs `full`.
|
||||
fn cases(full: u32, floor: u32) -> ProptestConfig {
|
||||
ProptestConfig::with_cases((full / craft_testkit::hostile::divisor() as u32).max(floor))
|
||||
/// Cases for the expensive properties (each case creates a file and runs a password hash per
|
||||
/// password it tries): `gate` cases at the gate, `full` nightly (hostile-input divisor 1).
|
||||
fn cases(full: u32, gate: u32) -> ProptestConfig {
|
||||
ProptestConfig::with_cases(if craft_testkit::hostile::divisor() == 1 { full } else { gate })
|
||||
}
|
||||
|
||||
proptest! {
|
||||
@@ -280,7 +280,7 @@ proptest! {
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#![proptest_config(cases(256, 12))]
|
||||
#![proptest_config(cases(256, 3))]
|
||||
/// A file created for `user` and `owner` opens for exactly the passwords whose effective bytes
|
||||
/// equal one of theirs, and reports the role that match earned — owner first, since viewers try
|
||||
/// `/O` before `/U`. Everything else is `WrongPassword`: never an opening, and no panic on odd
|
||||
@@ -414,7 +414,7 @@ proptest! {
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#![proptest_config(cases(256, 12))]
|
||||
#![proptest_config(cases(256, 5))]
|
||||
/// `/Perms` certifies the permission bits and `/EncryptMetadata`: decrypted with the file key it
|
||||
/// must hold `/P` little-endian, four set bytes, 'T' or 'F', and the `adb` sentinel (Algorithm 10).
|
||||
/// Nothing else in this crate reads it — `cos` writes it out and no code takes it back apart — so
|
||||
|
||||
@@ -29,13 +29,13 @@ fn a_flood_of_long_lines_ends_the_command() {
|
||||
// 600 lines of 60 KB are more than the 32 MB one command may bring. The gate sends lines that
|
||||
// are not parsed (the cap counts the text read); nightly sends the lines of a real listing.
|
||||
let full = craft_testkit::hostile::divisor() == 1;
|
||||
let server =
|
||||
flood(600, |n| if full { format!("* {n} FETCH (UID {} FLAGS ({pad}))\r\n", n + 1) } else { format!("* OK {pad}\r\n") }) + "A0001 OK done\r\n";
|
||||
let ok_lines = format!("* OK {pad}\r\n").repeat(600);
|
||||
let server = if full { flood(600, |n| format!("* {n} FETCH (UID {} FLAGS ({pad}))\r\n", n + 1)) } else { ok_lines.clone() } + "A0001 OK done\r\n";
|
||||
let mut s = Script::new(server);
|
||||
let err = opened(&mut s, 1000, 2000).uid_fetch_flags("1:*").unwrap_err();
|
||||
assert!(matches!(err, ProtoError::Protocol(ref m) if m.to_string().contains("too much")), "{err:?}");
|
||||
// The same in a list.
|
||||
let server = flood(600, |n| if full { format!("* LIST () \"/\" \"{n}{pad}\"\r\n") } else { format!("* OK {pad}\r\n") }) + "A0001 OK done\r\n";
|
||||
let server = if full { flood(600, |n| format!("* LIST () \"/\" \"{n}{pad}\"\r\n")) } else { ok_lines } + "A0001 OK done\r\n";
|
||||
let mut s = Script::new(server);
|
||||
assert!(matches!(opened(&mut s, 0, 0).list(), Err(ProtoError::Protocol(_))));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ skrifa = { workspace = true, optional = true }
|
||||
kurbo = { workspace = true, optional = true }
|
||||
flate2 = { version = "1.1.10", default-features = false, features = ["rust_backend"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
|
||||
[[example]]
|
||||
name = "eps2pdf"
|
||||
required-features = ["read"]
|
||||
@@ -602,9 +602,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn numbers_match_base_formatter() {
|
||||
let mut integer_path = 0usize;
|
||||
// The gate walks every `divisor()`-th value (offset by `places` so the places differ); nightly walks all.
|
||||
let step = craft_testkit::hostile::divisor();
|
||||
let (mut integer_path, mut visited) = (0usize, 0usize);
|
||||
let samples = number_samples();
|
||||
for places in 0..=12 {
|
||||
for v in number_samples() {
|
||||
for v in samples.iter().copied().skip(places as usize % step).step_by(step) {
|
||||
visited += 1;
|
||||
let mut expected = String::from("x ");
|
||||
base_push_num_places(&mut expected, v, places);
|
||||
let mut got = String::from("x ");
|
||||
@@ -616,7 +620,8 @@ mod tests {
|
||||
}
|
||||
}
|
||||
// The comparison covers the integer path, not only the fallback.
|
||||
assert!(integer_path > 200_000, "{integer_path} values took the integer path");
|
||||
eprintln!("DIAG numbers_match_base_formatter: visited {visited}, integer path {integer_path}");
|
||||
assert!(integer_path * 20 > visited, "{integer_path} of {visited} values took the integer path");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -781,7 +781,8 @@ mod tests {
|
||||
#[test]
|
||||
fn a_mesh_that_makes_every_triangle_cover_the_output_is_refused() {
|
||||
// A 48×48 custom mesh whose patch corners scatter over the four corners of the
|
||||
// content, so most of the 4608 triangles span the whole 2048² output.
|
||||
// content, so most of the 4608 triangles span the whole output (the work budget grows with
|
||||
// the output's pixels, so the size only sets how much is filled before it runs out).
|
||||
let (cols, rows) = (48usize, 48usize);
|
||||
let stride = cols * 3 + 1;
|
||||
let mut mesh = vec![[0.0, 0.0]; stride * (rows * 3 + 1)];
|
||||
@@ -794,9 +795,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
let warp = crate::smart::Warp { style: "warpCustom".into(), bounds: [0.0, 0.0, 16.0, 16.0], cols, rows, mesh, ..Default::default() };
|
||||
let s = so([[0.0, 0.0], [2048.0, 0.0], [2048.0, 2048.0], [0.0, 2048.0]], Some(warp));
|
||||
let s = so([[0.0, 0.0], [512.0, 0.0], [512.0, 512.0], [0.0, 512.0]], Some(warp));
|
||||
let content = FloatImage { width: 16, height: 16, data: vec![[1.0, 0.0, 0.0, 1.0]; 256] };
|
||||
assert!(s.render_placed(&content, 1.0, Some((2048, 2048))).is_none());
|
||||
assert!(s.render_placed(&content, 1.0, Some((512, 512))).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+17
-11
@@ -987,10 +987,12 @@ mod tests {
|
||||
/// D70 and D70s get best-guess frames (the D40 shares the D50 / D70 / D70s data size but not their frame).
|
||||
#[test]
|
||||
fn measured_older_dx_bodies_image_area() {
|
||||
let decode_as = |model: &str, (w, h): (usize, usize)| {
|
||||
let nef = nef_model_in(ByteOrder::Big, model, 1, 12, vec![vec![0x10; w * h * 2]], w as u32, h as u32, h as u32, None);
|
||||
crate::decode(&nef).unwrap()
|
||||
let nef_as = |model: &str, (w, h): (usize, usize)| {
|
||||
nef_model_in(ByteOrder::Big, model, 1, 12, vec![vec![0x10; w * h * 2]], w as u32, h as u32, h as u32, None)
|
||||
};
|
||||
// The headers decide the frame (`probe_info` equals the decoded image's info); one body decodes in full.
|
||||
let crop_of = |model: &str, size: (usize, usize)| crate::probe_info(&nef_as(model, size)).unwrap().crop;
|
||||
assert_eq!(crate::decode(&nef_as("NIKON D200", (3904, 2616))).unwrap().crop, Rect::new(16, 12, 3872, 2592));
|
||||
for (model, size, crop) in [
|
||||
("NIKON D200", (3904, 2616), Rect::new(16, 12, 3872, 2592)),
|
||||
("NIKON D80", (3904, 2616), Rect::new(14, 9, 3872, 2592)),
|
||||
@@ -1003,10 +1005,10 @@ mod tests {
|
||||
("NIKON D70", (3040, 2014), Rect::new(15, 7, 3008, 2000)),
|
||||
("NIKON D70s", (3040, 2014), Rect::new(15, 7, 3008, 2000)),
|
||||
] {
|
||||
assert_eq!(decode_as(model, size).crop, crop, "{model}");
|
||||
assert_eq!(crop_of(model, size), crop, "{model}");
|
||||
}
|
||||
// the V1's area on the V2's data size: no entry, the whole data
|
||||
assert_eq!(decode_as("NIKON 1 V1", (4620, 3084)).crop, Rect::new(0, 0, 4620, 3084));
|
||||
assert_eq!(crop_of("NIKON 1 V1", (4620, 3084)), Rect::new(0, 0, 4620, 3084));
|
||||
}
|
||||
|
||||
/// Every measured entry is a crop inside its data, once per model, data size and depth, with a white level (if
|
||||
@@ -1028,21 +1030,25 @@ mod tests {
|
||||
/// image areas (full frame and 1.3x crop), so renders came out larger and Lightroom crops landed off.
|
||||
#[test]
|
||||
fn measured_d7100_image_area() {
|
||||
let decode_as = |model: &str, (w, h): (usize, usize)| {
|
||||
let nef_as = |model: &str, (w, h): (usize, usize)| {
|
||||
let mut nef = nef(1, 14, vec![vec![0x10; w * h * 2]], w as u32, h as u32, h as u32);
|
||||
// the fixture's model is "NIKON TEST" plus its NUL: 11 bytes to overwrite
|
||||
let at = nef.windows(11).position(|b| b == b"NIKON TEST\0").unwrap();
|
||||
let name = format!("{model:\0<11}");
|
||||
nef[at..at + 11].copy_from_slice(name.as_bytes());
|
||||
crate::decode(&nef).unwrap()
|
||||
nef
|
||||
};
|
||||
// The headers decide the frame (`probe_info` equals the decoded image's info); the white level needs the
|
||||
// samples, so the full-frame area decodes in full.
|
||||
let d7100 = crate::decode(&nef_as("NIKON D7100", (6036, 4020))).unwrap();
|
||||
assert_eq!(d7100.crop, Rect::new(18, 10, 6000, 4000));
|
||||
assert_ne!(d7100.white, vec![15520.0]);
|
||||
for (size, crop) in [((6036, 4020), Rect::new(18, 10, 6000, 4000)), ((4812, 3212), Rect::new(6, 6, 4800, 3200))] {
|
||||
let d7100 = decode_as("NIKON D7100", size);
|
||||
let d7100 = crate::probe_info(&nef_as("NIKON D7100", size)).unwrap();
|
||||
assert_eq!(d7100.crop, crop);
|
||||
assert_eq!((d7100.crop.width, d7100.crop.height), (crop.width, crop.height));
|
||||
assert_ne!(d7100.white, vec![15520.0]);
|
||||
assert_eq!(d7100.info().developed_size(), (crop.width, crop.height));
|
||||
assert_eq!(decode_as("NIKON D7200", size).crop, Rect::new(0, 0, size.0, size.1));
|
||||
assert_eq!(d7100.developed_size(), (crop.width, crop.height));
|
||||
assert_eq!(crate::probe_info(&nef_as("NIKON D7200", size)).unwrap().crop, Rect::new(0, 0, size.0, size.1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,12 @@ fn value(c: u8) -> Option<u32> {
|
||||
/// Decodes padded (or unpadded) standard base64. `None` for malformed input or a result larger
|
||||
/// than [`MAX_DECODED_BYTES`].
|
||||
pub fn decode(text: &str) -> Option<Vec<u8>> {
|
||||
if text.bytes().filter(|c| !c.is_ascii_whitespace()).count() > MAX_DECODED_BYTES.div_ceil(3).saturating_mul(4) {
|
||||
decode_capped(text, MAX_DECODED_BYTES)
|
||||
}
|
||||
|
||||
/// [`decode`] with the output capped at `max` bytes.
|
||||
fn decode_capped(text: &str, max: usize) -> Option<Vec<u8>> {
|
||||
if text.bytes().filter(|c| !c.is_ascii_whitespace()).count() > max.div_ceil(3).saturating_mul(4) {
|
||||
return None;
|
||||
}
|
||||
let syms: Vec<u8> = text.bytes().filter(|c| !c.is_ascii_whitespace()).collect();
|
||||
@@ -46,7 +51,7 @@ pub fn decode(text: &str) -> Option<Vec<u8>> {
|
||||
return None;
|
||||
}
|
||||
let decoded_len = body.len() / 4 * 3 + body.len() % 4 * 3 / 4;
|
||||
if decoded_len > MAX_DECODED_BYTES {
|
||||
if decoded_len > max {
|
||||
return None;
|
||||
}
|
||||
let mut out = Vec::with_capacity(decoded_len);
|
||||
@@ -99,19 +104,17 @@ mod tests {
|
||||
encoded
|
||||
}
|
||||
|
||||
// Build valid base64 directly instead of encoding a 64 MiB allocation on every case.
|
||||
// This keeps the same decoded-size boundary checks while making the workspace gate much
|
||||
// faster and using less temporary memory.
|
||||
let exact = encoded_zero_bytes(MAX_DECODED_BYTES);
|
||||
assert_eq!(decode(&exact).map(|bytes| bytes.len()), Some(MAX_DECODED_BYTES), "padded boundary");
|
||||
let too_large = encoded_zero_bytes(MAX_DECODED_BYTES + 1);
|
||||
assert!(decode(&too_large).is_none(), "padded over boundary");
|
||||
// Each case decodes tens of MiB: the gate runs the two above, nightly the rest.
|
||||
if craft_testkit::hostile::divisor() > 1 {
|
||||
return;
|
||||
// The boundary at a cap of every remainder mod 3; nightly also at the real 64 MiB cap.
|
||||
let full = craft_testkit::hostile::divisor() == 1;
|
||||
let caps = [97, 98, 99].into_iter().chain(full.then_some(MAX_DECODED_BYTES));
|
||||
for max in caps {
|
||||
let exact = encoded_zero_bytes(max);
|
||||
assert_eq!(decode_capped(&exact, max).map(|bytes| bytes.len()), Some(max), "padded boundary at {max}");
|
||||
let too_large = encoded_zero_bytes(max + 1);
|
||||
assert!(decode_capped(&too_large, max).is_none(), "padded over boundary at {max}");
|
||||
assert_eq!(decode_capped(exact.trim_end_matches('='), max).map(|bytes| bytes.len()), Some(max), "unpadded boundary at {max}");
|
||||
let spaced = format!("{}\n {}", &too_large[..8], &too_large[8..]);
|
||||
assert!(decode_capped(&spaced, max).is_none(), "whitespace over boundary at {max}");
|
||||
}
|
||||
assert_eq!(decode(exact.trim_end_matches('=')).map(|bytes| bytes.len()), Some(MAX_DECODED_BYTES), "unpadded boundary");
|
||||
let spaced = format!("{}\n {}", &too_large[..8], &too_large[8..]);
|
||||
assert!(decode(&spaced).is_none(), "whitespace over boundary");
|
||||
}
|
||||
}
|
||||
@@ -434,6 +434,10 @@ mod tests {
|
||||
self.0 += 1;
|
||||
}
|
||||
}
|
||||
// The largest page, 2^28 pixels, takes seconds to encode and decode: nightly only.
|
||||
if craft_testkit::hostile::divisor() > 1 {
|
||||
return;
|
||||
}
|
||||
// One black pixel, so a page that came back blank wouldn't pass.
|
||||
let mut largest = vec![0xFF; 2_048 * 16_384];
|
||||
largest[0] = 0x7F;
|
||||
|
||||
@@ -518,7 +518,10 @@ mod tests {
|
||||
// decoder, which has the same one and can refuse it first.
|
||||
let large = |rows| decode_jbig2(&page_of(&data, 16_384, rows), None, 16_384, rows, usize::MAX);
|
||||
assert!(matches!(large(16_385), Err(CodecError::Unsupported(_) | CodecError::Corrupt { .. })), "{:?}", large(16_385));
|
||||
assert!(large(16_384).is_ok(), "{:?}", large(16_384).map(|page| page.len()));
|
||||
// Decoding the 2^28-pixel page takes seconds: nightly only.
|
||||
if craft_testkit::hostile::divisor() == 1 {
|
||||
assert!(large(16_384).is_ok(), "{:?}", large(16_384).map(|page| page.len()));
|
||||
}
|
||||
|
||||
// An extension segment (ISO/IEC 14492 7.4.14), which a decoder skips: its 11-byte header
|
||||
// gives the length of the data after it.
|
||||
|
||||
@@ -398,6 +398,11 @@ fn symbols(page: &mut Page) -> Option<()> {
|
||||
/// here, and the page's own dictionary holds only the others (none, when it has none), as
|
||||
/// [`encode_shared`] writes them; `None` too for a page that places none of the shared ones.
|
||||
fn plan(page: &Page, columns: u32, rows: u32, copies: u32, log_strips: Option<u32>, shared: Option<&Shared>) -> Option<Vec<u8>> {
|
||||
plan_within(page, columns, rows, copies, log_strips, shared, MAX_CODED_SYMBOLS)
|
||||
}
|
||||
|
||||
/// [`plan`] coding at most `max` symbols.
|
||||
fn plan_within(page: &Page, columns: u32, rows: u32, copies: u32, log_strips: Option<u32>, shared: Option<&Shared>, max: usize) -> Option<Vec<u8>> {
|
||||
let symbol = |s: u32| page.symbols.get(s as usize);
|
||||
let global = |s: u32| shared.and_then(|g| g.ids.get(s as usize).copied().flatten());
|
||||
let globals = shared.map_or(0, |g| g.count);
|
||||
@@ -405,7 +410,7 @@ fn plan(page: &Page, columns: u32, rows: u32, copies: u32, log_strips: Option<u3
|
||||
let mut kept: Vec<u32> =
|
||||
(0..page.symbols.len() as u32).filter(|s| global(*s).is_none() && symbol(*s).is_some_and(|s| s.uses >= copies)).collect();
|
||||
let count = usize::try_from(globals).ok()?.checked_add(kept.len())?;
|
||||
if !(2..=MAX_CODED_SYMBOLS).contains(&count) {
|
||||
if !(2..=max).contains(&count) {
|
||||
return None;
|
||||
}
|
||||
kept.sort_by_key(|s| symbol(*s).map(|s| (s.height, s.width)));
|
||||
@@ -934,18 +939,26 @@ mod tests {
|
||||
}
|
||||
(samples(&picture), columns as u32, rows as u32)
|
||||
};
|
||||
// At a cap of 300 symbols, then (nightly: each picture is tens of thousands of marks coded and decoded) at
|
||||
// MAX_CODED_SYMBOLS and past it through `encode_jbig2`.
|
||||
let max = 300;
|
||||
let (data, columns, rows) = codes(max, 0);
|
||||
let at_cap = page(&data, columns).unwrap();
|
||||
assert_eq!(decode(&plan_within(&at_cap, columns, rows, 1, None, None, max).unwrap()), unpack(&data, columns, rows));
|
||||
// One more distinct mark, each once: neither plan is made.
|
||||
let (data, columns, rows) = codes(max + 1, 0);
|
||||
let past = page(&data, columns).unwrap();
|
||||
assert!(plan_within(&past, columns, rows, 1, None, None, max).is_none() && plan_within(&past, columns, rows, 2, None, None, max).is_none());
|
||||
if craft_testkit::hostile::divisor() > 1 {
|
||||
return;
|
||||
}
|
||||
let (data, columns, rows) = codes(MAX_CODED_SYMBOLS, 0);
|
||||
let at_cap = page(&data, columns).unwrap();
|
||||
assert_eq!(decode(&plan(&at_cap, columns, rows, 1, None, None).unwrap()), unpack(&data, columns, rows));
|
||||
// One more distinct mark, each once: neither plan is made.
|
||||
let (data, columns, rows) = codes(MAX_CODED_SYMBOLS + 1, 0);
|
||||
let past = page(&data, columns).unwrap();
|
||||
assert!(plan(&past, columns, rows, 1, None, None).is_none() && plan(&past, columns, rows, 2, None, None).is_none());
|
||||
assert_eq!(encode_jbig2(&data, columns, rows).unwrap(), encode_jbig2_generic(&data, columns, rows).unwrap());
|
||||
// Each picture below is another 65,536 marks coded and decoded: nightly only.
|
||||
if craft_testkit::hostile::divisor() > 1 {
|
||||
return;
|
||||
}
|
||||
// With two of them repeated, the second plan codes those two.
|
||||
let (data, columns, rows) = codes(MAX_CODED_SYMBOLS + 1, 200);
|
||||
let past = page(&data, columns).unwrap();
|
||||
@@ -1245,6 +1258,10 @@ mod tests {
|
||||
/// in. Ten marks of the first image are in two images after it, with 464 first seen there.
|
||||
#[test]
|
||||
fn past_the_marks_a_group_holds_later_ones_arent_shared() {
|
||||
// 66,000 marks coded in four images: nightly only.
|
||||
if craft_testkit::hostile::divisor() > 1 {
|
||||
return;
|
||||
}
|
||||
let (a, b) = (samples(&combs(0..40_000)), samples(&combs(40_000..65_536)));
|
||||
let late = combs((0..10).chain(65_536..66_000).collect::<Vec<_>>().into_iter());
|
||||
let (rows, late) = (late.len() as u32, samples(&late));
|
||||
@@ -1263,6 +1280,10 @@ mod tests {
|
||||
/// or a generic region, whichever is smaller).
|
||||
#[test]
|
||||
fn past_the_shared_limit_the_most_widely_held_marks_are_shared() {
|
||||
// 50,000 marks coded in three images: nightly only.
|
||||
if craft_testkit::hostile::divisor() > 1 {
|
||||
return;
|
||||
}
|
||||
let (both, first) = (combs(0..20_000), combs(0..10_000));
|
||||
let rows = both.len();
|
||||
let first: Bitmap = first.iter().cloned().chain(std::iter::repeat_n(vec![0u8; 120 * 36], rows - first.len())).collect();
|
||||
|
||||
@@ -487,7 +487,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn a_repeated_large_entity_is_too_large_and_a_namespace_entity_is_not() {
|
||||
let big = "x".repeat(1 << 20);
|
||||
// (the limit is passed in: the same arithmetic as `MAX_ENTITY_EXPANSION` over entities 256 times smaller, which
|
||||
// only expand to 16 references' worth, so the strings the test builds and scans stay small)
|
||||
let big = "x".repeat(1 << 16);
|
||||
let expansion_too_large = |svg: &str| entities_expand_past(svg, 16 << 16);
|
||||
let refs = "&a;".repeat(20);
|
||||
let bomb = format!("<!DOCTYPE svg [<!ENTITY a \"{big}\">]><svg xmlns=\"http://www.w3.org/2000/svg\" id=\"{refs}\"/>");
|
||||
assert!(expansion_too_large(&bomb));
|
||||
@@ -500,6 +503,7 @@ mod tests {
|
||||
let ampersands = format!("<!DOCTYPE svg [<!ENTITY a \"x\">]><svg id=\"{}\"/>", "&".repeat(1 << 20));
|
||||
let start = std::time::Instant::now();
|
||||
assert!(!expansion_too_large(&ersands));
|
||||
eprintln!("DIAG svg ampersand run read in {:?}", start.elapsed());
|
||||
// A quadratic read would take hours; the bound is loose for a loaded machine.
|
||||
assert!(start.elapsed() < std::time::Duration::from_secs(120), "{:?}", start.elapsed());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"tab_large": 38.0,
|
||||
"title": 38.0
|
||||
},
|
||||
"button": 30.0,
|
||||
"checker": 4.0,
|
||||
"control": {
|
||||
"md": 30.0,
|
||||
@@ -70,6 +71,11 @@
|
||||
"short": 120.0,
|
||||
"track": 144.0
|
||||
},
|
||||
"page": {
|
||||
"action": 30.0,
|
||||
"column": 820.0,
|
||||
"margin": 50.0
|
||||
},
|
||||
"pane": {
|
||||
"least": 50.0
|
||||
},
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"tab_large": 32.0,
|
||||
"title": 32.0
|
||||
},
|
||||
"button": 24.0,
|
||||
"checker": 4.0,
|
||||
"control": {
|
||||
"md": 24.0,
|
||||
@@ -70,6 +71,11 @@
|
||||
"short": 96.0,
|
||||
"track": 128.0
|
||||
},
|
||||
"page": {
|
||||
"action": 24.0,
|
||||
"column": 820.0,
|
||||
"margin": 40.0
|
||||
},
|
||||
"pane": {
|
||||
"least": 40.0
|
||||
},
|
||||
|
||||
@@ -33,6 +33,10 @@ pub struct AppSizes {
|
||||
pub text_steps: TextSizeSteps,
|
||||
}
|
||||
|
||||
/// Base values that follow another's override when an app sets none of their own: a push button stands a control high
|
||||
/// in an app that changes the control's height alone.
|
||||
const FOLLOWS: [(&str, &str); 1] = [("size.button", "size.control.md")];
|
||||
|
||||
/// The base paths an app may override: sizes, spacing, corner radii, strokes and type sizes, not the
|
||||
/// edge or fonts.
|
||||
pub(crate) fn base_path(path: &str) -> bool {
|
||||
@@ -80,6 +84,12 @@ impl AppSizes {
|
||||
self.all.is_empty() && self.compact.is_empty() && self.comfortable.is_empty()
|
||||
}
|
||||
|
||||
/// The override of base value `path` (with no `base.` prefix) in `merged`: its own, else the one of the value it
|
||||
/// follows when it has none.
|
||||
pub(crate) fn override_of<'m>(merged: &'m SizeMap, path: &str) -> Option<&'m SizeValue> {
|
||||
merged.get(path).or_else(|| FOLLOWS.iter().find(|(own, _)| *own == path).and_then(|(_, of)| merged.get(*of)))
|
||||
}
|
||||
|
||||
/// The overrides for `size`: `all`, with the set's own map over it.
|
||||
pub(crate) fn merged(&self, size: Size) -> SizeMap {
|
||||
let own = match size {
|
||||
@@ -98,7 +108,7 @@ impl AppSizes {
|
||||
return;
|
||||
}
|
||||
for Leaf { path, slot, .. } in leaves(base) {
|
||||
let Some(value) = path.strip_prefix("base.").and_then(|p| merged.get(p)) else { continue };
|
||||
let Some(value) = path.strip_prefix("base.").and_then(|p| Self::override_of(&merged, p)) else { continue };
|
||||
let SizeValue::Number(n) = value;
|
||||
if let Slot::Num(x) | Slot::Length(x) = slot {
|
||||
*x = *n;
|
||||
|
||||
@@ -20,3 +20,20 @@ fn written_sizes_parse_back_to_the_same_overrides() {
|
||||
assert_eq!(AppSizes::parse(text.as_bytes()).unwrap(), original);
|
||||
assert_eq!(AppSizes::default().to_json(), "{}\n");
|
||||
}
|
||||
|
||||
/// An app that sets only the control height keeps its push buttons a control high; one that sets the button height
|
||||
/// gets that height.
|
||||
#[test]
|
||||
fn a_push_button_follows_the_control_height_unless_the_app_sets_its_own() {
|
||||
let base = crate::sizes::builtin(Size::Compact).base;
|
||||
let applied = |v: &Value| {
|
||||
let mut preset = base;
|
||||
sizes(v).apply_base(Size::Compact, &mut preset);
|
||||
preset.size
|
||||
};
|
||||
let follows = applied(&json!({ "all": { "size.control.md": 40 } }));
|
||||
assert!(follows.control.md > base.size.button, "the override raises the control height");
|
||||
assert_eq!(follows.button, follows.control.md, "the button follows the control height");
|
||||
let own = applied(&json!({ "all": { "size.control.md": 40, "size.button": 30 } }));
|
||||
assert!(own.button < own.control.md, "the app's own button height wins");
|
||||
}
|
||||
@@ -7,8 +7,8 @@ use std::fmt::Write as _;
|
||||
|
||||
use crate::{
|
||||
BarSizes, ColorToken, ControlSizes, DialogSizes, DockColumnSizes, Easing, Edge, Elevation, ElevationTokens, FloatSizes, FontSlot, Gaps,
|
||||
GripShape, HandleSizes, HitSizes, IconSizes, Insets, KnobShape, LengthSizes, Motion, MotionTokens, Pads, PaneSizes, PlotSizes, RadiusSet,
|
||||
RailSizes, RampSizes, Rgba, RowSizes, ShapeTokens, SizeTokens, SpaceTokens, StrokeTokens, ThumbSamples, ThumbSizes, Tokens, TypeStyle,
|
||||
GripShape, HandleSizes, HitSizes, IconSizes, Insets, KnobShape, LengthSizes, Motion, MotionTokens, Pads, PageSizes, PaneSizes, PlotSizes,
|
||||
RadiusSet, RailSizes, RampSizes, Rgba, RowSizes, ShapeTokens, SizeTokens, SpaceTokens, StrokeTokens, ThumbSamples, ThumbSizes, Tokens, TypeStyle,
|
||||
TypeTokens, WellShape, WindowSizes,
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ fn edge(e: Edge) -> String {
|
||||
}
|
||||
|
||||
fn shape_lines(out: &mut Lines, shape: &ShapeTokens) {
|
||||
let ShapeTokens { radius, edge: e, knob, wells, grip } = shape;
|
||||
let ShapeTokens { radius, edge: e, knob, wells, grip, locator } = shape;
|
||||
let RadiusSet { sm, control, surface, window, panel, button, pill } = radius;
|
||||
for (k, v) in [("sm", sm), ("control", control), ("surface", surface), ("window", window), ("panel", panel), ("button", button), ("pill", pill)] {
|
||||
out.line(&format!("shape.radius.{k}"), len(*v));
|
||||
@@ -81,6 +81,8 @@ fn shape_lines(out: &mut Lines, shape: &ShapeTokens) {
|
||||
for (k, v) in [("length", length), ("width", width), ("gap", gap)] {
|
||||
out.line(&format!("shape.grip.{k}"), len(*v));
|
||||
}
|
||||
out.line("shape.locator.cell", len(locator.cell));
|
||||
out.line("shape.locator.square", len(locator.square));
|
||||
}
|
||||
|
||||
fn stroke_lines(out: &mut Lines, stroke: &StrokeTokens) {
|
||||
@@ -120,6 +122,7 @@ fn space_lines(out: &mut Lines, space: &SpaceTokens) {
|
||||
fn size_lines(out: &mut Lines, size: &SizeTokens) {
|
||||
let SizeTokens {
|
||||
control,
|
||||
button,
|
||||
icon,
|
||||
rail,
|
||||
bar,
|
||||
@@ -140,10 +143,12 @@ fn size_lines(out: &mut Lines, size: &SizeTokens) {
|
||||
pane,
|
||||
dock,
|
||||
dialog,
|
||||
page,
|
||||
} = size;
|
||||
let ControlSizes { sm, md } = control;
|
||||
out.line("size.control.sm", len(*sm));
|
||||
out.line("size.control.md", len(*md));
|
||||
out.line("size.button", len(*button));
|
||||
let IconSizes { sm, md, lg, glyph_sm, glyph_md } = icon;
|
||||
out.line("size.icon.sm", len(*sm));
|
||||
out.line("size.icon.md", len(*md));
|
||||
@@ -211,6 +216,10 @@ fn size_lines(out: &mut Lines, size: &SizeTokens) {
|
||||
out.line("size.dialog.wrap", len(*wrap));
|
||||
out.line("size.dialog.button", len(*button));
|
||||
out.line("size.dialog.side_button", len(*side_button));
|
||||
let PageSizes { column, margin, action } = page;
|
||||
out.line("size.page.column", len(*column));
|
||||
out.line("size.page.margin", len(*margin));
|
||||
out.line("size.page.action", len(*action));
|
||||
}
|
||||
|
||||
fn slot(s: FontSlot) -> &'static str {
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::format::FormatErrors;
|
||||
use crate::id::{AppId, IconPackId};
|
||||
use crate::ramp::Mode;
|
||||
use crate::theme::{
|
||||
AppOverrides, ContrastIntent, EdgeSeed, GripSeed, ModePins, Pins, RadiusOffset, SeedOverrides, Seeds, ShapeSeed, ThemeDef, Variants,
|
||||
AppOverrides, ContrastIntent, EdgeSeed, GripSeed, LocatorSeed, ModePins, Pins, RadiusOffset, SeedOverrides, Seeds, ShapeSeed, ThemeDef, Variants,
|
||||
};
|
||||
use crate::tokens::{ColorToken, KnobShape, RadiusSet, WellShape};
|
||||
|
||||
@@ -140,6 +140,8 @@ pub enum ShapeValue {
|
||||
Wells(Option<WellShape>),
|
||||
/// [`ShapeSeed::grip`].
|
||||
Grip(Option<GripSeed>),
|
||||
/// [`ShapeSeed::locator`].
|
||||
Locator(Option<LocatorSeed>),
|
||||
}
|
||||
|
||||
/// Which field of the shape a [`ShapeValue`] holds.
|
||||
@@ -159,10 +161,12 @@ pub enum ShapeField {
|
||||
Wells,
|
||||
/// [`ShapeSeed::grip`].
|
||||
Grip,
|
||||
/// [`ShapeSeed::locator`].
|
||||
Locator,
|
||||
}
|
||||
|
||||
impl ShapeField {
|
||||
const ALL: [ShapeField; 7] = [
|
||||
const ALL: [ShapeField; 8] = [
|
||||
ShapeField::Radius,
|
||||
ShapeField::RadiusOffset,
|
||||
ShapeField::ButtonRadius,
|
||||
@@ -170,6 +174,7 @@ impl ShapeField {
|
||||
ShapeField::Knob,
|
||||
ShapeField::Wells,
|
||||
ShapeField::Grip,
|
||||
ShapeField::Locator,
|
||||
];
|
||||
|
||||
fn get(self, s: &ShapeSeed) -> ShapeValue {
|
||||
@@ -181,6 +186,7 @@ impl ShapeField {
|
||||
ShapeField::Knob => ShapeValue::Knob(s.knob),
|
||||
ShapeField::Wells => ShapeValue::Wells(s.wells),
|
||||
ShapeField::Grip => ShapeValue::Grip(s.grip),
|
||||
ShapeField::Locator => ShapeValue::Locator(s.locator),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,6 +201,7 @@ impl ShapeValue {
|
||||
ShapeValue::Knob(_) => ShapeField::Knob,
|
||||
ShapeValue::Wells(_) => ShapeField::Wells,
|
||||
ShapeValue::Grip(_) => ShapeField::Grip,
|
||||
ShapeValue::Locator(_) => ShapeField::Locator,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,11 +214,13 @@ impl ShapeValue {
|
||||
ShapeValue::Knob(v) => s.knob = v,
|
||||
ShapeValue::Wells(v) => s.wells = v,
|
||||
ShapeValue::Grip(v) => s.grip = v,
|
||||
ShapeValue::Locator(v) => s.locator = v,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const NO_SHAPE: ShapeSeed = ShapeSeed { radius: None, radius_offset: None, button_radius: None, edge: None, knob: None, wells: None, grip: None };
|
||||
const NO_SHAPE: ShapeSeed =
|
||||
ShapeSeed { radius: None, radius_offset: None, button_radius: None, edge: None, knob: None, wells: None, grip: None, locator: None };
|
||||
|
||||
/// A theme's name, variants, contrast intent or icon pack.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
||||
@@ -257,7 +257,7 @@ fn size_origins(resolved: &Resolved, size: Size, app: &AppSizes) -> Vec<SizeOrig
|
||||
_ => continue,
|
||||
};
|
||||
// A theme's own corner radii win over the app's, so an override that did not take is the set's.
|
||||
let set_by_app = merged.get(path).is_some_and(|o| !path.starts_with("radius.") || *o == value);
|
||||
let set_by_app = AppSizes::override_of(&merged, path).is_some_and(|o| !path.starts_with("radius.") || *o == value);
|
||||
let layer = if set_by_app { SizeLayer::App } else { SizeLayer::SizeSet };
|
||||
out.push(SizeOrigin { path: path.to_owned(), layer, value, range: (leaf.lo, leaf.hi) });
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ const KNOB: &str = "\"round\" or \"tab\"";
|
||||
const WELLS: &str = "\"square\" or \"round\"";
|
||||
/// What `shape.grip.mark` takes.
|
||||
const GRIP_MARK: &str = "\"ticks\", \"dots\" or \"bar\"";
|
||||
/// What the numbers of `shape.grip` take.
|
||||
const GRIP_NUMBER: &str = "a number";
|
||||
/// What the numbers of `shape.grip` and `shape.locator` take.
|
||||
const SHAPE_NUMBER: &str = "a number";
|
||||
/// What `icon_pack` takes.
|
||||
const ICON_PACK: &str = "an icon pack id: 2 to 64 of a-z, 0-9, '.', '_' or '-', starting with a-z or 0-9";
|
||||
const EDGE: &str = "\"flat\" or {\"bevel\": {\"width\": n}} with n above 0";
|
||||
|
||||
@@ -5,13 +5,14 @@ use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
use super::{
|
||||
EDGE, ErrorKind, FormatError, FormatErrors, GRIP_MARK, GRIP_NUMBER, ICON_PACK, KNOB, LENGTH, MAX_THEME_BYTES, OFFSET, SCHEMA, SCHEMA_VERSION,
|
||||
EDGE, ErrorKind, FormatError, FormatErrors, GRIP_MARK, ICON_PACK, KNOB, LENGTH, MAX_THEME_BYTES, OFFSET, SCHEMA, SCHEMA_VERSION, SHAPE_NUMBER,
|
||||
ThemeFile, WELLS,
|
||||
};
|
||||
use crate::color::Rgba;
|
||||
use crate::scale::Radius;
|
||||
use crate::theme::{
|
||||
AppOverrides, ContrastIntent, EdgeSeed, GripSeed, ModePins, ModeSeeds, Pins, RadiusOffset, SeedOverrides, Seeds, ShapeSeed, ThemeDef, Variants,
|
||||
AppOverrides, ContrastIntent, EdgeSeed, GripSeed, LocatorSeed, ModePins, ModeSeeds, Pins, RadiusOffset, SeedOverrides, Seeds, ShapeSeed,
|
||||
ThemeDef, Variants,
|
||||
};
|
||||
use crate::tokens::{ColorToken, GripMark, KnobShape, RadiusSet, Status, WellShape};
|
||||
use crate::{AppId, IconPackId, ThemeId};
|
||||
@@ -271,8 +272,13 @@ impl Parser {
|
||||
Some(g) => p.at("grip", |p| p.grip(g)).map(Some),
|
||||
None => Some(None),
|
||||
};
|
||||
let locator = match p.optional_object(shape, "locator") {
|
||||
Some(l) => p.at("locator", |p| p.locator(l)).map(Some),
|
||||
None => Some(None),
|
||||
};
|
||||
Some(Some(ShapeSeed {
|
||||
grip: grip?,
|
||||
locator: locator?,
|
||||
radius: radius?,
|
||||
radius_offset: radius_offset?,
|
||||
button_radius: button_radius?,
|
||||
@@ -324,29 +330,38 @@ impl Parser {
|
||||
None
|
||||
}
|
||||
});
|
||||
let number = |p: &mut Self, key: &str, min: f32, max: f32, whole: bool| -> Option<Option<f32>> {
|
||||
p.at(key, |p| match g.get(key) {
|
||||
None | Some(Value::Null) => Some(None),
|
||||
Some(v) => match v.as_f64().filter(|x| x.is_finite() && (!whole || x.fract() == 0.0)) {
|
||||
Some(x) if (f64::from(min)..=f64::from(max)).contains(&x) => Some(Some(x as f32)),
|
||||
Some(_) => {
|
||||
p.fail(ErrorKind::OutOfRange { min, max });
|
||||
None
|
||||
}
|
||||
None => {
|
||||
p.fail(ErrorKind::BadValue { expected: GRIP_NUMBER });
|
||||
None
|
||||
}
|
||||
},
|
||||
})
|
||||
};
|
||||
let count = number(self, "count", 1.0, 32.0, true);
|
||||
let length = number(self, "length", 0.5, 32.0, false);
|
||||
let width = number(self, "width", 0.5, 8.0, false);
|
||||
let gap = number(self, "gap", 0.5, 16.0, false);
|
||||
let count = self.optional_number(g, "count", (1.0, 32.0), true);
|
||||
let length = self.optional_number(g, "length", (0.5, 32.0), false);
|
||||
let width = self.optional_number(g, "width", (0.5, 8.0), false);
|
||||
let gap = self.optional_number(g, "gap", (0.5, 16.0), false);
|
||||
Some(GripSeed { mark: mark?, count: count?.map(|c| c as u16), length: length?, width: width?, gap: gap? })
|
||||
}
|
||||
|
||||
/// `shape.locator`: the reference point's squares. Each value is optional.
|
||||
fn locator(&mut self, l: &Map<String, Value>) -> Option<LocatorSeed> {
|
||||
let cell = self.optional_number(l, "cell", (1.0, 32.0), false);
|
||||
let square = self.optional_number(l, "square", (1.0, 16.0), false);
|
||||
Some(LocatorSeed { cell: cell?, square: square? })
|
||||
}
|
||||
|
||||
/// The optional number at `key` of `map`, in `range` and, when `whole`, a whole number.
|
||||
fn optional_number(&mut self, map: &Map<String, Value>, key: &str, (min, max): (f32, f32), whole: bool) -> Option<Option<f32>> {
|
||||
self.at(key, |p| match map.get(key) {
|
||||
None | Some(Value::Null) => Some(None),
|
||||
Some(v) => match v.as_f64().filter(|x| x.is_finite() && (!whole || x.fract() == 0.0)) {
|
||||
Some(x) if (f64::from(min)..=f64::from(max)).contains(&x) => Some(Some(x as f32)),
|
||||
Some(_) => {
|
||||
p.fail(ErrorKind::OutOfRange { min, max });
|
||||
None
|
||||
}
|
||||
None => {
|
||||
p.fail(ErrorKind::BadValue { expected: SHAPE_NUMBER });
|
||||
None
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/// A signed length in logical pixels.
|
||||
fn offset(&mut self, v: &Value) -> Option<f32> {
|
||||
let out = v.as_f64().filter(|x| x.is_finite()).map(|x| x as f32);
|
||||
|
||||
@@ -4,7 +4,7 @@ use serde_json::{Map, Number, Value};
|
||||
|
||||
use super::{FormatErrors, SCHEMA, SCHEMA_VERSION, ThemeFile};
|
||||
use crate::scale::Radius;
|
||||
use crate::theme::{AppOverrides, ContrastIntent, EdgeSeed, GripSeed, ModePins, ModeSeeds, Pins, ShapeSeed, ThemeDef, Variants};
|
||||
use crate::theme::{AppOverrides, ContrastIntent, EdgeSeed, GripSeed, LocatorSeed, ModePins, ModeSeeds, Pins, ShapeSeed, ThemeDef, Variants};
|
||||
use crate::tokens::{KnobShape, WellShape};
|
||||
|
||||
/// Top-level keys in the order a file lists them; other keys follow, sorted.
|
||||
@@ -167,6 +167,19 @@ fn update_shape(shape: &mut Map<String, Value>, s: &ShapeSeed) {
|
||||
shape.insert("grip".to_owned(), Value::Object(obj));
|
||||
}
|
||||
}
|
||||
match s.locator {
|
||||
None => {
|
||||
shape.remove("locator");
|
||||
}
|
||||
Some(l) => {
|
||||
let mut obj = match shape.remove("locator") {
|
||||
Some(Value::Object(m)) => m,
|
||||
_ => Map::new(),
|
||||
};
|
||||
locator(&mut obj, &l);
|
||||
shape.insert("locator".to_owned(), Value::Object(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates the `shape.grip` object `out` to the values the theme sets: a set value is written, an unset one removed.
|
||||
@@ -187,13 +200,23 @@ fn grip(out: &mut Map<String, Value>, g: &GripSeed) {
|
||||
out.remove("count");
|
||||
}
|
||||
}
|
||||
for (key, v) in [("length", g.length), ("width", g.width), ("gap", g.gap)] {
|
||||
numbers(out, &[("length", g.length), ("width", g.width), ("gap", g.gap)]);
|
||||
}
|
||||
|
||||
/// Updates the `shape.locator` object `out` to the values the theme sets: a set value is written, an unset one removed.
|
||||
fn locator(out: &mut Map<String, Value>, l: &LocatorSeed) {
|
||||
numbers(out, &[("cell", l.cell), ("square", l.square)]);
|
||||
}
|
||||
|
||||
/// Writes each set number of `values` into `out` and removes each unset one.
|
||||
fn numbers(out: &mut Map<String, Value>, values: &[(&str, Option<f32>)]) {
|
||||
for (key, v) in values {
|
||||
match v.and_then(|v| Number::from_f64(f64::from(v))) {
|
||||
Some(n) => {
|
||||
out.insert(key.to_owned(), Value::Number(n));
|
||||
out.insert((*key).to_owned(), Value::Number(n));
|
||||
}
|
||||
None => {
|
||||
out.remove(key);
|
||||
out.remove(*key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,6 +186,32 @@ fn reference_cycles_are_errors() {
|
||||
assert_eq!(e.len(), 1, "{e:?}");
|
||||
}
|
||||
|
||||
/// `shape.locator` sets the reference point's squares: left out, a value is the Size preset's handle size; set, the
|
||||
/// tokens take it and the file writes it back; a value of the wrong kind or out of range is an error at its key.
|
||||
#[test]
|
||||
fn the_locator_shape_is_read_resolved_written_and_checked() {
|
||||
let appearance = super::semantic_tests::app(Mode::Dark, Contrast::Standard);
|
||||
let plain = crate::resolve(&parse_value(&full()).unwrap().theme, appearance, None).tokens;
|
||||
let handle = plain.size.handle;
|
||||
assert_eq!((plain.shape.locator.cell, plain.shape.locator.square), (handle.md, handle.sm), "no locator: the preset's handles");
|
||||
|
||||
let mut v = full();
|
||||
v["shape"]["locator"] = json!({ "square": 5 });
|
||||
let file = parse_value(&v).unwrap();
|
||||
let locator = crate::resolve(&file.theme, appearance, None).tokens.shape.locator;
|
||||
assert_eq!((locator.cell, locator.square), (handle.md, 5.0), "a set value over the preset's");
|
||||
let written: Value = serde_json::from_str(&format::write(&file).unwrap()).unwrap();
|
||||
assert_eq!(written.pointer("/shape/locator/square"), Some(&json!(5.0)));
|
||||
assert_eq!(written.pointer("/shape/locator/cell"), None, "an unset value is not written");
|
||||
|
||||
for (key, bad) in [("cell", json!(0)), ("cell", json!(33)), ("square", json!("small")), ("square", json!(17))] {
|
||||
let mut v = full();
|
||||
v["shape"]["locator"] = json!({ key: bad });
|
||||
let found = errors(&v);
|
||||
assert!(found.iter().any(|e| e.contains(&format!("shape.locator.{key}"))), "{key} = {bad}: {found:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// photocraft#16426: `shape.grip` sets the dock grips' marks. Each value is optional and keeps the default's when
|
||||
/// left out; the theme's tokens take them, the file writes them back, and a value of the wrong kind or out of range
|
||||
/// is an error at its key.
|
||||
|
||||
@@ -91,16 +91,16 @@ pub use selection::{
|
||||
};
|
||||
pub use stateful::{FlagMask, Flags, Mix, Resolve, StateMix, Stateful};
|
||||
pub use theme::{
|
||||
AppOverrides, Appearance, Contrast, ContrastIntent, EdgeSeed, GripSeed, InterfaceFont, ModePins, ModeSeeds, PinLayer, Pins, RadiusOffset,
|
||||
SeedOverrides, Seeds, ShapeSeed, Size, TextSize, TextSizeSteps, ThemeDef, Variants,
|
||||
AppOverrides, Appearance, Contrast, ContrastIntent, EdgeSeed, GripSeed, InterfaceFont, LocatorSeed, ModePins, ModeSeeds, PinLayer, Pins,
|
||||
RadiusOffset, SeedOverrides, Seeds, ShapeSeed, Size, TextSize, TextSizeSteps, ThemeDef, Variants,
|
||||
};
|
||||
pub use token_group::{GroupValues, TokenGroup};
|
||||
pub use tokens::{
|
||||
AccentColors, BarSizes, CaptionColors, ColorToken, ColorTokens, ControlSizes, DataColors, DialogSizes, DockColumnSizes, Edge, EdgeColors,
|
||||
ElevationTokens, FloatSizes, FontSlot, Gaps, GripMark, GripShape, HandleSizes, HitSizes, IconSizes, Insets, KnobShape, LengthSizes, LetterCase,
|
||||
LineColors, Motion, MotionTokens, OverlayColors, Pads, PaneSizes, PlotSizes, RadiusSet, RailSizes, RampSizes, RowSizes, ShapeTokens, SizeTokens,
|
||||
SpaceTokens, StateColors, Status, StatusColors, StatusKind, StrokeTokens, SurfaceColors, TextColors, ThumbSamples, ThumbSizes, Tokens, TypeRole,
|
||||
TypeStyle, TypeTokens, WellShape, WindowSizes,
|
||||
LineColors, LocatorShape, Motion, MotionTokens, OverlayColors, Pads, PageSizes, PaneSizes, PlotSizes, RadiusSet, RailSizes, RampSizes, RowSizes,
|
||||
ShapeTokens, SizeTokens, SpaceTokens, StateColors, Status, StatusColors, StatusKind, StrokeTokens, SurfaceColors, TextColors, ThumbSamples,
|
||||
ThumbSizes, Tokens, TypeRole, TypeStyle, TypeTokens, WellShape, WindowSizes,
|
||||
};
|
||||
pub use values::ColorSource;
|
||||
pub use variant::{CustomVariant, Emphasis, RadiusStep, Variant, VariantLook};
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::ramp::Mode;
|
||||
use super::scale::{Easing, Elevation};
|
||||
use super::sizes;
|
||||
use super::theme::{Appearance, Contrast, ContrastIntent, PinLayer, Pins, ThemeDef};
|
||||
use super::tokens::{ColorToken, Edge, ElevationTokens, GripShape, Motion, MotionTokens, RadiusSet, ShapeTokens, SizeTokens, Tokens};
|
||||
use super::tokens::{ColorToken, Edge, ElevationTokens, GripShape, LocatorShape, Motion, MotionTokens, RadiusSet, ShapeTokens, SizeTokens, Tokens};
|
||||
use super::values;
|
||||
use crate::AppId;
|
||||
|
||||
@@ -207,6 +207,10 @@ fn resolve_concrete(theme: &ThemeDef, appearance: Appearance, app: Option<&AppId
|
||||
knob: seed.and_then(|s| s.knob).unwrap_or_default(),
|
||||
wells: seed.and_then(|s| s.wells).unwrap_or_default(),
|
||||
grip: seed.and_then(|s| s.grip).map_or(GripShape::DEFAULT, |g| g.shape()),
|
||||
locator: {
|
||||
let own = seed.and_then(|s| s.locator).unwrap_or_default();
|
||||
LocatorShape { cell: own.cell.unwrap_or(preset.size.handle.md), square: own.square.unwrap_or(preset.size.handle.sm) }
|
||||
},
|
||||
};
|
||||
let text_factor = sizes.text_steps.factor(appearance.text_size);
|
||||
let typography = preset.typography.scaled(text_factor, values::TYPE_ROUNDING);
|
||||
|
||||
@@ -93,6 +93,7 @@ pub(crate) fn leaves(b: &mut Preset) -> Vec<Leaf<'_>> {
|
||||
leaves! { out;
|
||||
"base.size.control.sm" Num 16.0..=48.0 => s.control.sm;
|
||||
"base.size.control.md" Num 16.0..=48.0 => s.control.md;
|
||||
"base.size.button" Num 16.0..=48.0 => s.button;
|
||||
"base.size.icon.sm" Num 10.0..=32.0 => s.icon.sm;
|
||||
"base.size.icon.md" Num 10.0..=32.0 => s.icon.md;
|
||||
"base.size.icon.lg" Num 10.0..=32.0 => s.icon.lg;
|
||||
@@ -145,6 +146,9 @@ pub(crate) fn leaves(b: &mut Preset) -> Vec<Leaf<'_>> {
|
||||
"base.size.dialog.wrap" Num 120.0..=1024.0 => s.dialog.wrap;
|
||||
"base.size.dialog.button" Num 24.0..=240.0 => s.dialog.button;
|
||||
"base.size.dialog.side_button" Num 24.0..=240.0 => s.dialog.side_button;
|
||||
"base.size.page.column" Num 240.0..=2048.0 => s.page.column;
|
||||
"base.size.page.margin" Num 0.0..=240.0 => s.page.margin;
|
||||
"base.size.page.action" Num 16.0..=96.0 => s.page.action;
|
||||
}
|
||||
let sp = &mut b.space;
|
||||
leaves! { out;
|
||||
|
||||
@@ -242,6 +242,18 @@ pub struct ShapeSeed {
|
||||
pub wells: Option<WellShape>,
|
||||
/// The dock grips' marks; each value left unset keeps [`GripShape::DEFAULT`]'s.
|
||||
pub grip: Option<GripSeed>,
|
||||
/// The reference point's squares; each value left unset is the Size preset's handle size.
|
||||
pub locator: Option<LocatorSeed>,
|
||||
}
|
||||
|
||||
/// A theme's reference point squares ([`LocatorShape`](crate::LocatorShape)): each `None` takes the Size preset's value, `size.handle.md`
|
||||
/// for the step and `size.handle.sm` for the square.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub struct LocatorSeed {
|
||||
/// The step from one square's centre to the next, in points.
|
||||
pub cell: Option<f32>,
|
||||
/// A square's side, in points.
|
||||
pub square: Option<f32>,
|
||||
}
|
||||
|
||||
/// A theme's grip marks: each `None` keeps [`GripShape::DEFAULT`]'s value.
|
||||
|
||||
@@ -55,6 +55,8 @@ pub struct SurfaceColors {
|
||||
/// The dots or grid an app may draw on the canvas outside the document. Equal to `canvas` (no
|
||||
/// pattern) unless the theme sets it.
|
||||
pub canvas_pattern: Rgba,
|
||||
/// A full-window page with no document open (a start page); follows `canvas` unless pinned.
|
||||
pub page: Rgba,
|
||||
/// Panels, bars and rails.
|
||||
pub panel: Rgba,
|
||||
/// Window chrome: title bars, toolbars, option bars, rulers and scrollbar tracks; follows
|
||||
@@ -322,6 +324,7 @@ impl ColorTokens {
|
||||
background: c,
|
||||
canvas: c,
|
||||
canvas_pattern: c,
|
||||
page: c,
|
||||
panel: c,
|
||||
chrome: c,
|
||||
raised: c,
|
||||
@@ -436,6 +439,8 @@ color_tokens! {
|
||||
SurfaceCanvas = "surface.canvas" => surface.canvas;
|
||||
/// `surface.canvas_pattern`
|
||||
SurfaceCanvasPattern = "surface.canvas_pattern" => surface.canvas_pattern;
|
||||
/// `surface.page`
|
||||
SurfacePage = "surface.page" => surface.page;
|
||||
/// `surface.panel`
|
||||
SurfacePanel = "surface.panel" => surface.panel;
|
||||
/// `surface.chrome`
|
||||
@@ -657,14 +662,15 @@ impl ColorToken {
|
||||
/// (`surface.*` except `scrim` and `shadow`); those must be opaque.
|
||||
pub const fn is_opaque_surface(self) -> bool {
|
||||
use ColorToken::{
|
||||
SurfaceBackground, SurfaceCanvas, SurfaceCanvasPattern, SurfaceChrome, SurfaceInverse, SurfaceKnob, SurfacePanel, SurfaceRaised,
|
||||
SurfaceSunken,
|
||||
SurfaceBackground, SurfaceCanvas, SurfaceCanvasPattern, SurfaceChrome, SurfaceInverse, SurfaceKnob, SurfacePage, SurfacePanel,
|
||||
SurfaceRaised, SurfaceSunken,
|
||||
};
|
||||
matches!(
|
||||
self,
|
||||
SurfaceBackground
|
||||
| SurfaceCanvas
|
||||
| SurfaceCanvasPattern
|
||||
| SurfacePage
|
||||
| SurfaceChrome
|
||||
| SurfacePanel
|
||||
| SurfaceRaised
|
||||
|
||||
@@ -123,7 +123,17 @@ impl Default for GripShape {
|
||||
}
|
||||
}
|
||||
|
||||
/// Corner radii, edge style, knob shape, well shape and grip marks.
|
||||
/// The squares of a reference point picker's square look: the step from one square's centre to the next and a
|
||||
/// square's side, in points. The picker is two steps and a square wide.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub struct LocatorShape {
|
||||
/// The step from one square's centre to the next.
|
||||
pub cell: f32,
|
||||
/// A square's side.
|
||||
pub square: f32,
|
||||
}
|
||||
|
||||
/// Corner radii, edge style, knob shape, well shape, grip marks and the reference point's squares.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct ShapeTokens {
|
||||
/// Corner radii.
|
||||
@@ -136,6 +146,8 @@ pub struct ShapeTokens {
|
||||
pub wells: WellShape,
|
||||
/// The marks of the dock grips.
|
||||
pub grip: GripShape,
|
||||
/// The squares of a reference point picker's square look.
|
||||
pub locator: LocatorShape,
|
||||
}
|
||||
|
||||
/// Gaps between neighbouring elements, in logical pixels.
|
||||
@@ -254,6 +266,9 @@ pub struct BarSizes {
|
||||
pub struct SizeTokens {
|
||||
/// Control heights.
|
||||
pub control: ControlSizes,
|
||||
/// The height of a standard push button, a text button's face (a small one stands `control.sm` high). An app that
|
||||
/// sets `size.control.md` and not this keeps its buttons a control high.
|
||||
pub button: f32,
|
||||
/// Icon sizes.
|
||||
pub icon: IconSizes,
|
||||
/// Tool rail.
|
||||
@@ -295,6 +310,19 @@ pub struct SizeTokens {
|
||||
pub dock: DockColumnSizes,
|
||||
/// Dialogs: their content width and their buttons.
|
||||
pub dialog: DialogSizes,
|
||||
/// Full-window pages.
|
||||
pub page: PageSizes,
|
||||
}
|
||||
|
||||
/// The sizes of a full-window page (a start page), in logical pixels.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub struct PageSizes {
|
||||
/// The widest a page's centred column of content grows; a narrower room keeps the page's margin at each side.
|
||||
pub column: f32,
|
||||
/// The room above and below a page's centred column.
|
||||
pub margin: f32,
|
||||
/// The height of a page's call to action (`ControlPlace::CallToAction`).
|
||||
pub action: f32,
|
||||
}
|
||||
|
||||
/// The sizes of the panes of a dock's split, in logical pixels.
|
||||
|
||||
@@ -197,6 +197,7 @@ pub(super) fn source(token: ColorToken, mode: Mode) -> ColorSource {
|
||||
T::SurfaceBackground => Anchored(pick(2, 3)),
|
||||
T::SurfaceCanvas => Same(T::SurfaceBackground),
|
||||
T::SurfaceCanvasPattern => Same(T::SurfaceCanvas),
|
||||
T::SurfacePage => Same(T::SurfaceCanvas),
|
||||
T::SurfacePanel => Neutral(panel_step(mode)),
|
||||
T::SurfaceChrome => Same(T::SurfacePanel),
|
||||
T::SurfaceRaised => Anchored(pick(4, 1)),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #222226ff
|
||||
surface.canvas = #1d1d20ff
|
||||
surface.canvas_pattern = #1d1d20ff
|
||||
surface.page = #1d1d20ff
|
||||
surface.panel = #36363aff
|
||||
surface.chrome = #2e2e32ff
|
||||
surface.raised = #404044ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #222226ff
|
||||
surface.canvas = #1d1d20ff
|
||||
surface.canvas_pattern = #1d1d20ff
|
||||
surface.page = #1d1d20ff
|
||||
surface.panel = #36363aff
|
||||
surface.chrome = #2e2e32ff
|
||||
surface.raised = #404044ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #222226ff
|
||||
surface.canvas = #1d1d20ff
|
||||
surface.canvas_pattern = #1d1d20ff
|
||||
surface.page = #1d1d20ff
|
||||
surface.panel = #36363aff
|
||||
surface.chrome = #2e2e32ff
|
||||
surface.raised = #39393eff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #222226ff
|
||||
surface.canvas = #1d1d20ff
|
||||
surface.canvas_pattern = #1d1d20ff
|
||||
surface.page = #1d1d20ff
|
||||
surface.panel = #36363aff
|
||||
surface.chrome = #2e2e32ff
|
||||
surface.raised = #39393eff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #ebebedff
|
||||
surface.canvas = #dededfff
|
||||
surface.canvas_pattern = #dededfff
|
||||
surface.page = #dededfff
|
||||
surface.panel = #ffffffff
|
||||
surface.chrome = #ffffffff
|
||||
surface.raised = #ffffffff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #ebebedff
|
||||
surface.canvas = #dededfff
|
||||
surface.canvas_pattern = #dededfff
|
||||
surface.page = #dededfff
|
||||
surface.panel = #ffffffff
|
||||
surface.chrome = #ffffffff
|
||||
surface.raised = #ffffffff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #ebebedff
|
||||
surface.canvas = #dededfff
|
||||
surface.canvas_pattern = #dededfff
|
||||
surface.page = #dededfff
|
||||
surface.panel = #ffffffff
|
||||
surface.chrome = #ffffffff
|
||||
surface.raised = #ffffffff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #ebebedff
|
||||
surface.canvas = #dededfff
|
||||
surface.canvas_pattern = #dededfff
|
||||
surface.page = #dededfff
|
||||
surface.panel = #ffffffff
|
||||
surface.chrome = #ffffffff
|
||||
surface.raised = #ffffffff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #424242ff
|
||||
surface.canvas = #282828ff
|
||||
surface.canvas_pattern = #282828ff
|
||||
surface.page = #282828ff
|
||||
surface.panel = #535353ff
|
||||
surface.chrome = #535353ff
|
||||
surface.raised = #595959ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #424242ff
|
||||
surface.canvas = #282828ff
|
||||
surface.canvas_pattern = #282828ff
|
||||
surface.page = #282828ff
|
||||
surface.panel = #535353ff
|
||||
surface.chrome = #535353ff
|
||||
surface.raised = #595959ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #424242ff
|
||||
surface.canvas = #282828ff
|
||||
surface.canvas_pattern = #282828ff
|
||||
surface.page = #282828ff
|
||||
surface.panel = #535353ff
|
||||
surface.chrome = #535353ff
|
||||
surface.raised = #5c5c5cff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #424242ff
|
||||
surface.canvas = #282828ff
|
||||
surface.canvas_pattern = #282828ff
|
||||
surface.page = #282828ff
|
||||
surface.panel = #535353ff
|
||||
surface.chrome = #535353ff
|
||||
surface.raised = #5c5c5cff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #e2e2e2ff
|
||||
surface.canvas = #d6d6d6ff
|
||||
surface.canvas_pattern = #d6d6d6ff
|
||||
surface.page = #d6d6d6ff
|
||||
surface.panel = #f0f0f0ff
|
||||
surface.chrome = #f0f0f0ff
|
||||
surface.raised = #f6f6f6ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #e2e2e2ff
|
||||
surface.canvas = #d6d6d6ff
|
||||
surface.canvas_pattern = #d6d6d6ff
|
||||
surface.page = #d6d6d6ff
|
||||
surface.panel = #f0f0f0ff
|
||||
surface.chrome = #f0f0f0ff
|
||||
surface.raised = #f6f6f6ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #e2e2e2ff
|
||||
surface.canvas = #d6d6d6ff
|
||||
surface.canvas_pattern = #d6d6d6ff
|
||||
surface.page = #d6d6d6ff
|
||||
surface.panel = #f0f0f0ff
|
||||
surface.chrome = #f0f0f0ff
|
||||
surface.raised = #f6f6f6ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 3
|
||||
space.gap.inline = 6
|
||||
space.gap.row = 6
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 28
|
||||
space.inset.page_gap = 14
|
||||
size.control.sm = 24
|
||||
size.control.md = 30
|
||||
size.button = 30
|
||||
size.icon.sm = 14
|
||||
size.icon.md = 18
|
||||
size.icon.lg = 22
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 50
|
||||
size.page.action = 30
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
surface.background = #e2e2e2ff
|
||||
surface.canvas = #d6d6d6ff
|
||||
surface.canvas_pattern = #d6d6d6ff
|
||||
surface.page = #d6d6d6ff
|
||||
surface.panel = #f0f0f0ff
|
||||
surface.chrome = #f0f0f0ff
|
||||
surface.raised = #f6f6f6ff
|
||||
@@ -124,6 +125,8 @@ shape.grip.count = 11
|
||||
shape.grip.length = 5
|
||||
shape.grip.width = 1
|
||||
shape.grip.gap = 1
|
||||
shape.locator.cell = 8
|
||||
shape.locator.square = 6
|
||||
space.gap.tight = 2
|
||||
space.gap.inline = 4
|
||||
space.gap.row = 4
|
||||
@@ -143,6 +146,7 @@ space.inset.page_margin = 24
|
||||
space.inset.page_gap = 12
|
||||
size.control.sm = 20
|
||||
size.control.md = 24
|
||||
size.button = 24
|
||||
size.icon.sm = 12
|
||||
size.icon.md = 16
|
||||
size.icon.lg = 20
|
||||
@@ -195,6 +199,9 @@ size.dialog.least = 380
|
||||
size.dialog.wrap = 440
|
||||
size.dialog.button = 84
|
||||
size.dialog.side_button = 96
|
||||
size.page.column = 820
|
||||
size.page.margin = 40
|
||||
size.page.action = 24
|
||||
stroke.thin = 1
|
||||
stroke.medium = 1.5
|
||||
stroke.thick = 2
|
||||
|
||||
Loaded 100 of 328 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user