mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 07:24:56 -10:00
Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d5521b3f9 | ||
|
|
cbf011b74f | ||
|
|
37bec45aeb | ||
|
|
b9716478a0 | ||
|
|
1996d64dc7 | ||
|
|
7039bc061e | ||
|
|
526c7b850c | ||
|
|
2774595caf | ||
|
|
8d6fc2a8ea | ||
|
|
0798f0f6d2 | ||
|
|
f1136abfd4 | ||
|
|
085833d1a6 | ||
|
|
1bfddeefd6 | ||
|
|
4dfc9d3596 | ||
|
|
a66a8abf4b | ||
|
|
f32f31a57a | ||
|
|
4914c9c51a | ||
|
|
d1c52db648 | ||
|
|
0f915cfbb3 | ||
|
|
a4ed8f0031 | ||
|
|
243372dd5a | ||
|
|
91d87bd6ab | ||
|
|
772e9161b7 | ||
|
|
8c97698080 | ||
|
|
3ade7e31ff | ||
|
|
76039460d4 | ||
|
|
1f1cab1b21 | ||
|
|
6713e4ff5b | ||
|
|
7710ff64d7 | ||
|
|
b4d07595ca | ||
|
|
6b30e415e6 |
No files matched your search
@@ -31,13 +31,12 @@ let
|
||||
}).buildRustPackage
|
||||
(finalAttrs: {
|
||||
pname = "rustc_codegen_spirv";
|
||||
version = "0.10.0-alpha.1";
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://github.com/Rust-GPU/rust-gpu";
|
||||
rev = "2fff75a21a1909945ac85f5818843dd9960004d7";
|
||||
sha256 = "sha256-clUt4jUh4D9EmoXZFgur1RrMYob4X5jti2e2hvBnAx8=";
|
||||
version = "0.10.0";
|
||||
src = pkgs.fetchCrate {
|
||||
inherit (finalAttrs) pname version;
|
||||
sha256 = "sha256-QluNI2TdJI0j2CBOeAbB9DfOv+8LqzWk7siZyT1WWLU=";
|
||||
};
|
||||
cargoHash = "sha256-9dGb+RDYpJKaIhkMPkZAx1M1VGE3gMfCD2T84i1VtV8=";
|
||||
cargoHash = "sha256-vvviUccnip+j60Ml1vqLNJ49KyEF40VLUoV1TMALHMs=";
|
||||
cargoBuildFlags = [
|
||||
"-p"
|
||||
"rustc_codegen_spirv"
|
||||
|
||||
Generated
+114
-56
@@ -317,7 +317,7 @@ name = "blending-nodes"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphic-types",
|
||||
"node-macro",
|
||||
"serde",
|
||||
@@ -359,7 +359,7 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"graphic-types",
|
||||
"half",
|
||||
@@ -377,7 +377,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"serde",
|
||||
]
|
||||
@@ -471,8 +471,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cargo-gpu-install"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/Rust-GPU/rust-gpu.git?rev=2fff75a21a1909945ac85f5818843dd9960004d7#2fff75a21a1909945ac85f5818843dd9960004d7"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "668b4bd1b59810c4f907eeb36bb0f0a450c824219b2e599b9b8ef2b3ae056e94"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_metadata 0.21.0",
|
||||
@@ -829,6 +830,15 @@ version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
|
||||
|
||||
[[package]]
|
||||
name = "control-protocol"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"glam 0.33.12",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.12.0"
|
||||
@@ -903,7 +913,7 @@ dependencies = [
|
||||
"color",
|
||||
"ctor",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"image",
|
||||
"kurbo",
|
||||
@@ -1170,6 +1180,13 @@ version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
|
||||
|
||||
[[package]]
|
||||
name = "diffrast"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"glam 0.33.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@@ -1385,7 +1402,7 @@ name = "dyn-any"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"dyn-any-derive",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"reqwest",
|
||||
]
|
||||
|
||||
@@ -1960,9 +1977,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glam"
|
||||
version = "0.33.10"
|
||||
version = "0.33.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "928452f9c953e142b2f0973e4bd5f34445fcaa8069556ea97a3c9d34d15a4cf8"
|
||||
checksum = "37bfe73dc8ec21f54d181e5a60554327ec3f1c600c455a75ccbfc65d2106a6c4"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"libm",
|
||||
@@ -2038,7 +2055,7 @@ dependencies = [
|
||||
"core-types",
|
||||
"criterion",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graph-craft",
|
||||
"graphene-animation",
|
||||
"graphene-application-io",
|
||||
@@ -2072,7 +2089,7 @@ name = "graphene-animation"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"kurbo",
|
||||
"serde",
|
||||
@@ -2085,7 +2102,7 @@ dependencies = [
|
||||
"blake3",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"graphene-resource",
|
||||
"log",
|
||||
@@ -2102,7 +2119,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-application-io",
|
||||
"log",
|
||||
"serde",
|
||||
@@ -2140,7 +2157,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-animation",
|
||||
"graphene-hash",
|
||||
"graphic-types",
|
||||
@@ -2156,7 +2173,7 @@ dependencies = [
|
||||
name = "graphene-hash"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash-derive",
|
||||
]
|
||||
|
||||
@@ -2191,7 +2208,7 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graph-craft",
|
||||
"graphene-application-io",
|
||||
"graphene-canvas-utils",
|
||||
@@ -2212,6 +2229,7 @@ dependencies = [
|
||||
"transform-nodes",
|
||||
"vector-nodes",
|
||||
"vector-types",
|
||||
"vectorize-nodes",
|
||||
"vello",
|
||||
"vello_encoding",
|
||||
"wasm-bindgen",
|
||||
@@ -2228,7 +2246,7 @@ dependencies = [
|
||||
"brush-types",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphic-types",
|
||||
"node-macro",
|
||||
"rand",
|
||||
@@ -2244,7 +2262,7 @@ dependencies = [
|
||||
"brush-types",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"node-macro",
|
||||
"raster-types",
|
||||
@@ -2265,7 +2283,7 @@ dependencies = [
|
||||
"dirs",
|
||||
"fd-lock",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphite-desktop-ui",
|
||||
"graphite-desktop-wrapper",
|
||||
"interprocess",
|
||||
@@ -2392,7 +2410,7 @@ dependencies = [
|
||||
"dyn-any",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graph-craft",
|
||||
"graphene-hash",
|
||||
"graphene-std",
|
||||
@@ -2412,6 +2430,7 @@ dependencies = [
|
||||
"serde_bytes",
|
||||
"serde_json",
|
||||
"simplecss",
|
||||
"snapping",
|
||||
"spin",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
@@ -2426,15 +2445,6 @@ dependencies = [
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphite-editor-control-protocol"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"glam 0.33.10",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphite-proc-macros"
|
||||
version = "0.0.0"
|
||||
@@ -3010,7 +3020,7 @@ dependencies = [
|
||||
"criterion",
|
||||
"dyn-any",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graph-craft",
|
||||
"graphene-animation",
|
||||
"graphene-core",
|
||||
@@ -3451,7 +3461,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-core",
|
||||
"graphic-types",
|
||||
"log",
|
||||
@@ -3664,7 +3674,7 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"half",
|
||||
"log",
|
||||
@@ -4106,7 +4116,7 @@ name = "path-bool-nodes"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphic-types",
|
||||
"linesweeper",
|
||||
"log",
|
||||
@@ -4425,7 +4435,7 @@ dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graph-craft",
|
||||
"graphene-std",
|
||||
"interpreted-executor",
|
||||
@@ -4647,7 +4657,7 @@ dependencies = [
|
||||
"dyn-any",
|
||||
"fastnoise-lite",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-core",
|
||||
"graphene-hash",
|
||||
"graphene-resource",
|
||||
@@ -4695,7 +4705,7 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"image",
|
||||
"node-macro",
|
||||
@@ -4883,7 +4893,7 @@ dependencies = [
|
||||
"brush-types",
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"graphene-resource",
|
||||
"graphic-types",
|
||||
@@ -4906,7 +4916,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-core",
|
||||
"graphic-types",
|
||||
"kurbo",
|
||||
@@ -5066,8 +5076,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_codegen_spirv-types"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/Rust-GPU/rust-gpu.git?rev=2fff75a21a1909945ac85f5818843dd9960004d7#2fff75a21a1909945ac85f5818843dd9960004d7"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d703f5624720c5b6012f4b88d6e6766f43ed50d80144eaffd6791c3270754cdc"
|
||||
dependencies = [
|
||||
"rspirv",
|
||||
"semver",
|
||||
@@ -5617,6 +5628,15 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snapping"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"glam 0.33.12",
|
||||
"kurbo",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.0"
|
||||
@@ -5659,8 +5679,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "spirv-builder"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/Rust-GPU/rust-gpu.git?rev=2fff75a21a1909945ac85f5818843dd9960004d7#2fff75a21a1909945ac85f5818843dd9960004d7"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57fa119866f0311546e5309b18770b72141c25d185452c11a812be2c7b9d84e9"
|
||||
dependencies = [
|
||||
"cargo_metadata 0.21.0",
|
||||
"log",
|
||||
@@ -5675,15 +5696,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "spirv-std"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/Rust-GPU/rust-gpu.git?rev=2fff75a21a1909945ac85f5818843dd9960004d7#2fff75a21a1909945ac85f5818843dd9960004d7"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d98471765e294d4dd6289350e3633b5c5ba57bb382c3287d83e69ee737179e0"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytemuck",
|
||||
"glam 0.30.10",
|
||||
"glam 0.31.1",
|
||||
"glam 0.32.1",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"libm",
|
||||
"num-traits",
|
||||
"spirv-std-macros",
|
||||
@@ -5692,8 +5714,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "spirv-std-macros"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/Rust-GPU/rust-gpu.git?rev=2fff75a21a1909945ac85f5818843dd9960004d7#2fff75a21a1909945ac85f5818843dd9960004d7"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13a6a0d063d4dd003e43818135b7aa4a30c41c48b5d0efe2cac02220448d4f19"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5703,8 +5726,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "spirv-std-types"
|
||||
version = "0.10.0-alpha.1"
|
||||
source = "git+https://github.com/Rust-GPU/rust-gpu.git?rev=2fff75a21a1909945ac85f5818843dd9960004d7#2fff75a21a1909945ac85f5818843dd9960004d7"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "655632248eaaa205cea4656bc73c8285cbd8109fc784010b24ea6bd0bab79ac1"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
@@ -5926,7 +5950,7 @@ dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"fancy-regex",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"graphene-resource",
|
||||
"ipsum",
|
||||
@@ -6264,6 +6288,13 @@ version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
|
||||
|
||||
[[package]]
|
||||
name = "tracer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"glam 0.33.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.41"
|
||||
@@ -6331,7 +6362,7 @@ name = "transform-nodes"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphic-types",
|
||||
"node-macro",
|
||||
"rand",
|
||||
@@ -6585,7 +6616,7 @@ dependencies = [
|
||||
"delaunator",
|
||||
"dyn-any",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-core",
|
||||
"graphene-hash",
|
||||
"graphic-types",
|
||||
@@ -6613,7 +6644,7 @@ dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"fixedbitset",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"kurbo",
|
||||
"log",
|
||||
@@ -6630,6 +6661,24 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vectorize-nodes"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"futures",
|
||||
"glam 0.33.12",
|
||||
"graphene-hash",
|
||||
"graphic-types",
|
||||
"kurbo",
|
||||
"log",
|
||||
"node-macro",
|
||||
"raster-types",
|
||||
"vector-types",
|
||||
"vtrace",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vello"
|
||||
version = "0.10.0"
|
||||
@@ -6681,6 +6730,15 @@ version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "vtrace"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"diffrast",
|
||||
"glam 0.33.12",
|
||||
"tracer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
@@ -6911,9 +6969,9 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"clap",
|
||||
"control-protocol",
|
||||
"getrandom 0.3.3",
|
||||
"glam 0.33.10",
|
||||
"graphite-editor-control-protocol",
|
||||
"glam 0.33.12",
|
||||
"image",
|
||||
"interprocess",
|
||||
"serde",
|
||||
@@ -7076,7 +7134,7 @@ dependencies = [
|
||||
"core-types",
|
||||
"dyn-any",
|
||||
"futures",
|
||||
"glam 0.33.10",
|
||||
"glam 0.33.12",
|
||||
"graphene-application-io",
|
||||
"node-macro",
|
||||
"raster-types",
|
||||
|
||||
+9
-5
@@ -12,12 +12,13 @@ members = [
|
||||
"document/graph-storage",
|
||||
"document/container",
|
||||
"editor",
|
||||
"editor/control-protocol",
|
||||
"frontend/wrapper",
|
||||
"libraries/dyn-any",
|
||||
"libraries/math-parser",
|
||||
"libraries/ipsum",
|
||||
"libraries/snapping",
|
||||
"libraries/wgpu-sync",
|
||||
"libraries/control-protocol",
|
||||
"node-graph/libraries/graphene-hash",
|
||||
"node-graph/libraries/*",
|
||||
"node-graph/nodes/*",
|
||||
@@ -44,6 +45,7 @@ default-members = [
|
||||
"libraries/dyn-any",
|
||||
"libraries/math-parser",
|
||||
"libraries/ipsum",
|
||||
"libraries/snapping",
|
||||
"node-graph/graph-craft",
|
||||
"node-graph/interpreted-executor",
|
||||
"node-graph/node-macro",
|
||||
@@ -95,6 +97,8 @@ text-nodes = { path = "node-graph/nodes/text" }
|
||||
transform-nodes = { path = "node-graph/nodes/transform" }
|
||||
vector-nodes = { path = "node-graph/nodes/vector" }
|
||||
repeat-nodes = { path = "node-graph/nodes/repeat" }
|
||||
vectorize-nodes = { path = "node-graph/nodes/vectorize" }
|
||||
vtrace = { path = "../vtrace/vtrace" }
|
||||
math-nodes = { path = "node-graph/nodes/math" }
|
||||
path-bool-nodes = { path = "node-graph/nodes/path-bool" }
|
||||
graph-craft = { path = "node-graph/graph-craft" }
|
||||
@@ -109,9 +113,10 @@ wgpu-executor = { path = "node-graph/libraries/wgpu-executor" }
|
||||
wgpu-sync = { path = "libraries/wgpu-sync" }
|
||||
graphite-proc-macros = { path = "proc-macros" }
|
||||
graphite-editor = { path = "editor" }
|
||||
graphite-editor-control-protocol = { path = "editor/control-protocol" }
|
||||
control-protocol = { path = "libraries/control-protocol" }
|
||||
graphene-canvas-utils = { path = "node-graph/libraries/canvas-utils" }
|
||||
ipsum = { path = "libraries/ipsum" }
|
||||
snapping = { path = "libraries/snapping" }
|
||||
|
||||
# Workspace dependencies
|
||||
rustc-hash = "2.0"
|
||||
@@ -246,9 +251,8 @@ spin = "0.10"
|
||||
clap = "4.5"
|
||||
|
||||
# Ensure these are kept in sync with .nix/deps/rust-gpu.nix
|
||||
# Git commit required for glam=0.33 support (TODO: use release when new version is published. Last publish was Apr 17)
|
||||
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu.git", rev = "2fff75a21a1909945ac85f5818843dd9960004d7", features = ["bytemuck"] }
|
||||
cargo-gpu-install = { git = "https://github.com/Rust-GPU/rust-gpu.git", rev = "2fff75a21a1909945ac85f5818843dd9960004d7", default-features = false }
|
||||
spirv-std = { version = "0.10.0", features = ["bytemuck"] }
|
||||
cargo-gpu-install = { version = "0.10.0", default-features = false }
|
||||
|
||||
qrcodegen = "1.8"
|
||||
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
|
||||
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":3143874172491239000,"output_index":0}}],"nodes":[[26023588519449590,{"inputs":[{"Node":{"node_id":4002029424845293600,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.94750905,"green":0.5567761,"blue":0.06654528,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.94750905,"green":0.5567761,"blue":0.06654528,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true},{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[0.0,-92.53735521402166,92.53735521402166,0.0,9.606221358397944,-69.72678572415595]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[213744308682803360,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::graphic::Graphic"}}}},"exposed":true}},{"Node":{"node_id":10463288500489480000,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[366962978353611840,{"inputs":[{"Node":{"node_id":8366826746721323000,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Union"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[799182088624980700,{"inputs":[{"Node":{"node_id":7386572856931342000,"output_index":0}},{"Value":{"tagged_value":{"Number":100.0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"math_nodes::DivideNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1250460246919467000,{"inputs":[{"Node":{"node_id":4742778578215475000,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Union"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplicationLine truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":3143874172491239000,"output_index":0}}],"nodes":[[26023588519449590,{"inputs":[{"Node":{"node_id":4002029424845293600,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.94750905,"green":0.5567761,"blue":0.06654528,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.94750905,"green":0.5567761,"blue":0.06654528,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true},{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[0.0,-92.53735521402166,92.53735521402166,0.0,9.606221358397944,-69.72678572415595]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[213744308682803360,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::graphic::Graphic"}}}},"exposed":true}},{"Node":{"node_id":10463288500489480000,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[366962978353611840,{"inputs":[{"Node":{"node_id":8366826746721323000,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Union"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[799182088624980700,{"inputs":[{"Node":{"node_id":7386572856931342000,"output_index":0}},{"Value":{"tagged_value":{"Number":100.0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"math_nodes::DivideNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1250460246919467000,{"inputs":[{"Node":{"node_id":4742778578215475000,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Union"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplicationLine truncated
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":15709488322180832347,"output_index":0}}],"nodes":[[57904581517036791,{"inputs":[{"Node":{"node_id":9393309733761233513,"output_index":0}},{"Node":{"node_id":15300421479077882117,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[70804263053697201,{"inputs":[{"Node":{"node_id":13942787566051910019,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[3.410605131648481e-13,3.410605131648481e-13]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1268.999999999999,634.9999999999992]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64"}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[194878846429432339,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4],"remove":[],"delta":[[1,[671.7691453623979,420.00000000000006]],[2,[559.8076211353317,450.0000000000001]],[3,[410.5255888325765,410.0]],[4,[522.4871130596428,380.00000000000006]]]},"segments":{"add":[1,2,3,4],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4]],"end_point":[[1,2],[2,3]Line truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":15709488322180832347,"output_index":0}}],"nodes":[[57904581517036791,{"inputs":[{"Node":{"node_id":9393309733761233513,"output_index":0}},{"Node":{"node_id":15300421479077882117,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[70804263053697201,{"inputs":[{"Node":{"node_id":13942787566051910019,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[3.410605131648481e-13,3.410605131648481e-13]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1268.999999999999,634.9999999999992]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[194878846429432339,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4],"remove":[],"delta":[[1,[671.7691453623979,420.00000000000006]],[2,[559.8076211353317,450.0000000000001]],[3,[410.5255888325765,410.0]],[4,[522.4871130596428,380.00000000000006]]]},"segments":{"add":[1,2,3,4],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4]],"end_point":[[1,2],[2,3],[3,4],[4,1]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]]],"handle_end":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]]]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplicLine truncated
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":12241147352993594415,"output_index":0}}],"nodes":[[80924370013313595,{"inputs":[{"Node":{"node_id":6029481207635803402,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.06469504,"green":0.0,"blue":0.0755814,"alpha":1.0,"linear":true},{"red":0.016644126,"green":0.13212071,"blue":0.62523156,"alpha":1.0,"linear":true},{"red":1.0,"green":0.8708812,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.30054384,"green":0.8468733,"blue":0.8468733,"alpha":0.01,"linear":true}],"position":[0.0,0.12704918032786883,0.5,1.0],"midpoint":[0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3606681156406984991,{"inputs":[{"Node":{"node_id":6323350524796370485,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":0.04631017,"green":0.0,"blue":0.0076861563,"alpha":1.0,"linear":true},{"red":0.83939683,"green":0.7249875,"blue":0.27055356,"alpha":1.0,"linear":true},{"red":0.025397457,"green":0.3485102,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.01102731,"green":0.09231063,"blue":0.09231063,"alpha":1.0,"linear":true}],"position":[0.0,0.3237704918032787,0.5655737704918032,0.8155737704918032,1.0],"midpoint":[0.5,0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4388711862172196665,{"inputs":[],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::MandelbrotNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[6029481207635803402,{"inputs":[{"Node":{"node_id":4388711862172196665,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1000.0,1000.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64"}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[6323350524796370485,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"Integer":0},"exposed":false}},{"Value":{"tagged_value":{"Number":35.0},"exposed":false}},{"Value":{"tagged_value":{"NoiseType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"DomainWarpType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"Number":100.0},"exposed":false}},{"Value":{"tagged_value":{"FractalType":"PingPong"},"exposed":false}},{"Value":{"tagged_value":{"Integer":3},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"Number":0.5},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed"Line truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":12241147352993594415,"output_index":0}}],"nodes":[[80924370013313595,{"inputs":[{"Node":{"node_id":6029481207635803402,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.06469504,"green":0.0,"blue":0.0755814,"alpha":1.0,"linear":true},{"red":0.016644126,"green":0.13212071,"blue":0.62523156,"alpha":1.0,"linear":true},{"red":1.0,"green":0.8708812,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.30054384,"green":0.8468733,"blue":0.8468733,"alpha":0.01,"linear":true}],"position":[0.0,0.12704918032786883,0.5,1.0],"midpoint":[0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3606681156406984991,{"inputs":[{"Node":{"node_id":6323350524796370485,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":0.04631017,"green":0.0,"blue":0.0076861563,"alpha":1.0,"linear":true},{"red":0.83939683,"green":0.7249875,"blue":0.27055356,"alpha":1.0,"linear":true},{"red":0.025397457,"green":0.3485102,"blue":0.3485102,"alpha":1.0,"linear":true},{"red":0.01102731,"green":0.09231063,"blue":0.09231063,"alpha":1.0,"linear":true}],"position":[0.0,0.3237704918032787,0.5655737704918032,0.8155737704918032,1.0],"midpoint":[0.5,0.5,0.5,0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::adjustments::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4388711862172196665,{"inputs":[],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::MandelbrotNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[6029481207635803402,{"inputs":[{"Node":{"node_id":4388711862172196665,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1000.0,1000.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[6323350524796370485,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"Integer":0},"exposed":false}},{"Value":{"tagged_value":{"Number":35.0},"exposed":false}},{"Value":{"tagged_value":{"NoiseType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"DomainWarpType":"OpenSimplex2"},"exposed":false}},{"Value":{"tagged_value":{"Number":100.0},"exposed":false}},{"Value":{"tagged_value":{"FractalType":"PingPong"},"exposed":false}},{"Value":{"tagged_value":{"Integer":3},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"Number":0.5},"exposed":false}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"Number":2.0},"exposed":false}},{"Value":{"tagged_value":{"CellularDistanceFunction":"Hybrid"},"exposed":false}},{"Value":{"tagged_value":{"CellularReturnType":"CellValue"},"exposed":false}},{"Value":{"tagged_value":{"Number":1.0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"raster_nodes::std_nodes::NoisePatternNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[6565638614909771142,{"inputs":[{"Node":{"node_id":7624113397561636853,"output_index":0}},{"Node":{"node_id":80924370013313595,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"GeLine truncated
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":392274448837115448,"output_index":0}}],"nodes":[[57390435731316553,{"inputs":[{"Node":{"node_id":8460565235419043665,"output_index":0}},{"Node":{"node_id":13838011362258067867,"output_index":0}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64"}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2"}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[140396870212231820,{"inputs":[{"Node":{"node_id":18095952297474762348,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Intersect"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[294265135510952894,{"inputs":[{"Node":{"node_id":11264395591110193456,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.83076996,"green":0.32314324,"blue":0.027320892,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.6938719,"green":0.048171822,"blue":0.028426038,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[20.0,0.0,0.0,20.0,-10.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[392274448837115448,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::artboard::Artboard"}}}},"exposed":true}},{"Node":{"node_id":6787585796949551500,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1536.0,768.0]},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.8549927,"green":0.71569365,"blue":0.48514998,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"Generic":"T"}]},"import_index":1}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":2}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":3}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":4}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":5}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::artboard::CreateArtboardNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<allocLine truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":392274448837115448,"output_index":0}}],"nodes":[[57390435731316553,{"inputs":[{"Node":{"node_id":8460565235419043665,"output_index":0}},{"Node":{"node_id":13838011362258067867,"output_index":0}},{"Value":{"tagged_value":{"Number":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"transform_nodes::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[140396870212231820,{"inputs":[{"Node":{"node_id":18095952297474762348,"output_index":0}},{"Value":{"tagged_value":{"BooleanOperation":"Intersect"},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"path_bool_nodes::BooleanOperationNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[294265135510952894,{"inputs":[{"Node":{"node_id":11264395591110193456,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.83076996,"green":0.32314324,"blue":0.027320892,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.6938719,"green":0.048171822,"blue":0.028426038,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[20.0,0.0,0.0,20.0,-10.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[392274448837115448,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::artboard::Artboard"}}}},"exposed":true}},{"Node":{"node_id":6787585796949551500,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1536.0,768.0]},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.8549927,"green":0.71569365,"blue":0.48514998,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"Generic":"T"}]},"import_index":1}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":2}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":3}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":4}},{"Import":{"import_type":{"Item":{"Concrete":{"name":"graph_craft::document::value::TaggedValue"}}},"import_index":5}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::artboard::CreateArtboardNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":1,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Import":{"import_type":{"Fn":[{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},{"List":{"Concrete":{"nameLine truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":4445985685181725042,"output_index":0}}],"nodes":[[239716716021064150,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::graphic::Graphic"}}}},"exposed":true}},{"Node":{"node_id":7711570794020903773,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1801066723091712434,{"inputs":[{"Value":{"tagged_value":"None","exposed":true}},{"Value":{"tagged_value":{"Color":{"red":0.036889445,"green":0.038204364,"blue":0.043735027,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Number":1744.31393592},"exposed":false}},{"Value":{"tagged_value":{"Number":63.0},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":2288754089236120499,"output_index":0}}],"nodes":[[640915213983348287,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Number":4000.0},"exposed":false}},{"Value":{"tagged_value":{"Number":500.0},"exposed":false}},{"Value":{"tagged_value":{"BoxCorners":[0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"vector_nodes::generator_nodes::RectangleNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1791308547102433540,{"inputs":[{"Node":{"node_id":640915213983348287,"output_index":0}},{"Import":{"import_type":{"Generic":"T"},"import_index":1}},{"Value":{"tagged_value":{"Color":{"red":0.9911022,"green":0.6514057,"blue":0.39157256,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[1.0,0.0,0.0,1.0,0.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2288754089236120499,{"inputs":[{"Node":{"node_id":1415828794531Line truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":4445985685181725042,"output_index":0}}],"nodes":[[239716716021064150,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"List":{"Concrete":{"name":"graphic_types::graphic::Graphic"}}}},"exposed":true}},{"Node":{"node_id":7711570794020903773,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1801066723091712434,{"inputs":[{"Value":{"tagged_value":"None","exposed":true}},{"Value":{"tagged_value":{"Color":{"red":0.036889445,"green":0.038204364,"blue":0.043735027,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Number":1744.31393592},"exposed":false}},{"Value":{"tagged_value":{"Number":63.0},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":2288754089236120499,"output_index":0}}],"nodes":[[640915213983348287,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"Number":4000.0},"exposed":false}},{"Value":{"tagged_value":{"Number":500.0},"exposed":false}},{"Value":{"tagged_value":{"BoxCorners":[0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"vector_nodes::generator_nodes::RectangleNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1791308547102433540,{"inputs":[{"Node":{"node_id":640915213983348287,"output_index":0}},{"Import":{"import_type":{"Generic":"T"},"import_index":1}},{"Value":{"tagged_value":{"Color":{"red":0.9911022,"green":0.6514057,"blue":0.39157256,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[1.0,0.0,0.0,1.0,0.0,0.0]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2288754089236120499,{"inputs":[{"Node":{"node_id":1415828794531Line truncated
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":14972365039974885000,"output_index":0}}],"nodes":[[169695252050218443,{"inputs":[{"Node":{"node_id":13907401402762847509,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.75,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.7734375,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Radial"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[31.55635094002563,-2.7755575615628914e-17,2.7755575615628914e-17,31.55635094002563,-0.225779263556106,34.981204988590605]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[183562335973647870,{"inputs":[{"Node":{"node_id":4248875763694880300,"output_index":0}},{"Node":{"node_id":2181148486404191200,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[655907162126315400,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8,9,10,11],"remove":[],"delta":[[1,[416.0,270.9999999999999]],[2,[587.0,291.9999999999999]],[3,[373.0,372.9999999999999]],[4,[484.0,446.9999999999999]],[5,[639.0,438.9999999999999]],[6,[495.0,533.9999999999999]],[7,[304.0,611.9999999999999]],[8,[475.0,671.9999999999999]],[9,[750.0,703.9999999999999]],[10,[455.0,824.9999999999999]],[11,[186.0,824.9999999999999]]]},"segments":{"add":[1,2,3,4,5,6,7,8,9,10],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]],[5,[0.0,0.0]],[6,[0.0,0.0]],[7,[0.0,0.0]],[8,[0.0,0.0]],[9,[0.0,0.0]],[10,[0.0,0.0]]],"handle_end":Line truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":14972365039974885000,"output_index":0}}],"nodes":[[169695252050218443,{"inputs":[{"Node":{"node_id":13907401402762847509,"output_index":0}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.75,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.7734375,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":0.01,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Radial"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[31.55635094002563,-2.7755575615628914e-17,2.7755575615628914e-17,31.55635094002563,-0.225779263556106,34.981204988590605]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[183562335973647870,{"inputs":[{"Node":{"node_id":4248875763694880300,"output_index":0}},{"Node":{"node_id":2181148486404191200,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[655907162126315400,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8,9,10,11],"remove":[],"delta":[[1,[416.0,270.9999999999999]],[2,[587.0,291.9999999999999]],[3,[373.0,372.9999999999999]],[4,[484.0,446.9999999999999]],[5,[639.0,438.9999999999999]],[6,[495.0,533.9999999999999]],[7,[304.0,611.9999999999999]],[8,[475.0,671.9999999999999]],[9,[750.0,703.9999999999999]],[10,[455.0,824.9999999999999]],[11,[186.0,824.9999999999999]]]},"segments":{"add":[1,2,3,4,5,6,7,8,9,10],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11]],"handle_primary":[[1,[0.0,0.0]],[2,[0.0,0.0]],[3,[0.0,0.0]],[4,[0.0,0.0]],[5,[0.0,0.0]],[6,[0.0,0.0]],[7,[0.0,0.0]],[8,[0.0,0.0]],[9,[0.0,0.0]],[10,[0.0,0.0]]],"handle_end":Line truncated
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":2394762731964337494,"output_index":0}}],"nodes":[[1378578509112405,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5],"remove":[],"delta":[[1,[602.6886145404666,50.91906721536352]],[2,[599.5281207133061,50.3923182441701]],[3,[590.4855967078191,66.80932784636488]],[4,[594.6410608139003,75.57872275567746]],[5,[593.3924706599604,60.59564090839812]]]},"segments":{"add":[1,2,3,4,5],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,1]],"handle_primary":[[1,[0.0,0.0]],[2,[-1.843621399176982,0.5267489711934203]],[3,[1.9314128943758533,7.3257125438195345]],[4,[0.0,0.0]],[5,[1.248590153939972,-3.9798811156835896]]],"handle_end":[[1,[1.843621399176982,-0.5267489711934203]],[2,[-2.7532629181224593,-10.4429315732828]],[3,[0.0,0.0]],[4,[-1.704168058538812,5.432035686592322]],[5,[-4.379820149367788,0.9754610577655498]]]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[172538270105470471,{"inputs":[{"Node":{"node_id":9276497172451351253,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[2.170365521878466,0.0,0.0,2.170365521878466,604.9565968314213,108.54930650815425]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[314278016428495768,{"inputs":[{"Node":{"node_id":6282972142629473139,"output_index":0}},{"Node":{"node_id":5020096817747898028,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpLine truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":2394762731964337494,"output_index":0}}],"nodes":[[1378578509112405,{"inputs":[{"Value":{"tagged_value":{"TypeDefault":{"Item":{"Concrete":{"name":"vector_types::vector::vector_types::Vector"}}}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5],"remove":[],"delta":[[1,[602.6886145404666,50.91906721536352]],[2,[599.5281207133061,50.3923182441701]],[3,[590.4855967078191,66.80932784636488]],[4,[594.6410608139003,75.57872275567746]],[5,[593.3924706599604,60.59564090839812]]]},"segments":{"add":[1,2,3,4,5],"remove":[],"start_point":[[1,1],[2,2],[3,3],[4,4],[5,5]],"end_point":[[1,2],[2,3],[3,4],[4,5],[5,1]],"handle_primary":[[1,[0.0,0.0]],[2,[-1.843621399176982,0.5267489711934203]],[3,[1.9314128943758533,7.3257125438195345]],[4,[0.0,0.0]],[5,[1.248590153939972,-3.9798811156835896]]],"handle_end":[[1,[1.843621399176982,-0.5267489711934203]],[2,[-2.7532629181224593,-10.4429315732828]],[3,[0.0,0.0]],[4,[-1.704168058538812,5.432035686592322]],[5,[-4.379820149367788,0.9754610577655498]]]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"vector_types::vector::vector_modification::VectorModification"}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"vector_nodes::vector_modification_nodes::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[172538270105470471,{"inputs":[{"Node":{"node_id":9276497172451351253,"output_index":0}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"red":0.78353786,"green":0.6038274,"blue":0.33245158,"alpha":1.0,"linear":true}},"exposed":false}},{"Value":{"tagged_value":{"GradientRamp":{"stops":{"color":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0,"linear":true},{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0,"linear":true}],"position":[0.0,1.0],"midpoint":[0.5,0.5]},"gradient_space":"RgbGamma"}},"exposed":false}},{"Value":{"tagged_value":{"GradientForm":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[2.170365521878466,0.0,0.0,2.170365521878466,604.9565968314213,108.54930650815425]},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[314278016428495768,{"inputs":[{"Node":{"node_id":6282972142629473139,"output_index":0}},{"Node":{"node_id":5020096817747898028,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpLine truncated
|
||||
Generated
+1
-1
@@ -1 +1 @@
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":16815500381887058038,"output_index":0}}],"nodes":[[74,{"inputs":[{"Node":{"node_id":75,"output_index":0}},{"Node":{"node_id":81,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[75,{"inputs":[{"Node":{"node_id":76,"output_index":0}},{"Node":{"node_id":161,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_Line truncated
|
||||
{"network_interface":{"network":{"exports":[{"Node":{"node_id":16815500381887058038,"output_index":0}}],"nodes":[[74,{"inputs":[{"Node":{"node_id":75,"output_index":0}},{"Node":{"node_id":81,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[75,{"inputs":[{"Node":{"node_id":76,"output_index":0}},{"Node":{"node_id":161,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":5,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::AsGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::IntoGroupNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::PathOfSubgraphNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Value":{"tagged_value":{"String":"editor:layer_path"},"exposed":false}},{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::WriteAttributeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<core_types::context::OwnedContextImpl>>"}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[5,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":4,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphic_nodes::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_Line truncated
|
||||
@@ -151,6 +151,9 @@ impl<L: Layout> Gdd<L> {
|
||||
last_broadcast_rev: self.session.last_broadcast_rev(),
|
||||
redo_stack: self.session.redo_stack().to_vec(),
|
||||
next_node_counter: self.session.next_node_counter(),
|
||||
last_hot_sequence: self.session.last_hot_sequence(),
|
||||
retired_marks: self.session.retired_marks().clone(),
|
||||
clock_counter: self.session.clock_counter(),
|
||||
view_settings: self.view_settings.clone(),
|
||||
network_view_settings: self.network_view_settings.clone(),
|
||||
};
|
||||
|
||||
@@ -161,6 +161,10 @@ impl<L: Layout> Gdd<L> {
|
||||
session.publish_up_to(rev);
|
||||
}
|
||||
|
||||
session.restore_hot_sequence(session_state.last_hot_sequence);
|
||||
session.restore_clock_counter(session_state.clock_counter);
|
||||
// Before the hot log replays, so a retired op in it is dropped rather than staged again.
|
||||
session.absorb_retired_marks(&session_state.retired_marks);
|
||||
replay_hot_log(&working, &layout, codecs.hot_log, &mut session).await?;
|
||||
|
||||
Ok(Self {
|
||||
|
||||
@@ -176,6 +176,8 @@ impl<L: Layout> Gdd<L> {
|
||||
pub fn annotate_delta(&mut self, rev: Rev, key: &str, value: Value) -> Result<(), Error> {
|
||||
if self.session.annotate_delta(rev, key, value) {
|
||||
self.rewrite_history()?;
|
||||
// The annotation ticked the clock, which a reopen must not hand out again.
|
||||
self.persist_session_state()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -199,6 +201,9 @@ impl<L: Layout> Gdd<L> {
|
||||
last_broadcast_rev: self.session.last_broadcast_rev(),
|
||||
redo_stack: self.session.redo_stack().to_vec(),
|
||||
next_node_counter: self.session.next_node_counter(),
|
||||
last_hot_sequence: self.session.last_hot_sequence(),
|
||||
retired_marks: self.session.retired_marks().clone(),
|
||||
clock_counter: self.session.clock_counter(),
|
||||
view_settings: self.view_settings.clone(),
|
||||
network_view_settings: self.network_view_settings.clone(),
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! Lives in `session.json`. Rewritten on retirement.
|
||||
|
||||
use document_graph_storage::{NetworkId, PeerId, Rev, UserId, Value};
|
||||
use document_graph_storage::{HotSequence, NetworkId, PeerId, RetiredMarks, Rev, UserId, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -34,6 +34,9 @@ pub struct SessionState {
|
||||
/// collide on minted IDs.
|
||||
#[serde(default)]
|
||||
pub next_node_counter: u64,
|
||||
/// The last hot op sequence this peer authored, so a reopen never reuses one.
|
||||
#[serde(default)]
|
||||
pub last_hot_sequence: HotSequence,
|
||||
/// Per-peer view settings (PTZ, rulers, overlays, snapping, panel collapse). Local to the viewer,
|
||||
/// so kept out of the CRDT/history. Editor owns the keys/values (opaque `ui::doc::*` blobs).
|
||||
#[serde(default)]
|
||||
@@ -42,4 +45,10 @@ pub struct SessionState {
|
||||
/// Per-peer like [`view_settings`](Self::view_settings); opaque `ui::nav::*` / `ui::previewing` blobs.
|
||||
#[serde(default)]
|
||||
pub network_view_settings: BTreeMap<NetworkId, BTreeMap<String, Value>>,
|
||||
/// The retired hot op marks, so a late copy re-sent after a reopen is dropped rather than retired again.
|
||||
#[serde(default)]
|
||||
pub retired_marks: RetiredMarks,
|
||||
/// The Lamport counter, so a reopen never mints a spent stamp.
|
||||
#[serde(default)]
|
||||
pub clock_counter: u64,
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
use document_container::AnyContainer;
|
||||
use document_container::backends::memory::MemoryBackend;
|
||||
use document_format::{Codec, Error, GddV1, GddV1Layout, Layout, Manifest, io, manifest};
|
||||
use document_graph_storage::{HotOp, Network, NetworkId, PeerId, ROOT_NETWORK, RegistryDelta, TimeStamp};
|
||||
use document_graph_storage::{HotOp, HotSequence, Network, NetworkId, PeerId, ROOT_NETWORK, RegistryDelta, TimeStamp};
|
||||
|
||||
fn empty_container() -> AnyContainer {
|
||||
AnyContainer::Memory(MemoryBackend::new())
|
||||
@@ -122,6 +122,7 @@ fn apply_hot_op_persists_to_hot_log_and_survives_reopen() {
|
||||
network: Network::default(),
|
||||
},
|
||||
timestamp: TimeStamp { counter: 1, peer: PeerId(5) },
|
||||
sequence: HotSequence(1),
|
||||
};
|
||||
gdd.apply_hot_op(hot_op).unwrap_or_else(|error| panic!("apply_hot_op failed: {error:?}"));
|
||||
|
||||
@@ -146,6 +147,7 @@ fn retire_moves_eligible_hot_ops_to_history_and_keeps_rest() {
|
||||
network: Network::default(),
|
||||
},
|
||||
timestamp: TimeStamp { counter: 1, peer: PeerId(5) },
|
||||
sequence: HotSequence(1),
|
||||
};
|
||||
let late = HotOp {
|
||||
op: RegistryDelta::AddNetwork {
|
||||
@@ -153,6 +155,7 @@ fn retire_moves_eligible_hot_ops_to_history_and_keeps_rest() {
|
||||
network: Network::default(),
|
||||
},
|
||||
timestamp: TimeStamp { counter: 10, peer: PeerId(5) },
|
||||
sequence: HotSequence(2),
|
||||
};
|
||||
gdd.apply_hot_op(early).unwrap();
|
||||
gdd.apply_hot_op(late).unwrap();
|
||||
@@ -190,6 +193,7 @@ fn last_broadcast_rev_persists_across_reopen() {
|
||||
network: Network::default(),
|
||||
},
|
||||
timestamp: TimeStamp { counter: 1, peer: PeerId(5) },
|
||||
sequence: HotSequence(1),
|
||||
};
|
||||
gdd.apply_hot_op(op).unwrap();
|
||||
let retired = gdd.retire(TimeStamp { counter: 1, peer: PeerId(5) }).unwrap_or_else(|error| panic!("retire failed: {error:?}"));
|
||||
@@ -627,6 +631,7 @@ fn persist_path_writes_at_manifest_declared_codec_paths() {
|
||||
network: Network::default(),
|
||||
},
|
||||
timestamp: TimeStamp { counter: 1, peer: PeerId(5) },
|
||||
sequence: HotSequence(1),
|
||||
};
|
||||
gdd.apply_hot_op(hot_op).unwrap_or_else(|error| panic!("apply_hot_op failed: {error:?}"));
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ fn restaging_the_whole_document_after_a_batch_stages_nothing() {
|
||||
/// `registry.bin` is the retired snapshot the hot log replays onto, so an op still hot at save time must stay out of it.
|
||||
#[test]
|
||||
fn a_reopen_keeps_unretired_hot_ops_out_of_the_retired_snapshot() {
|
||||
use document_graph_storage::{AttributeDelta, HotOp, RegistryDelta, TimeStamp, Value};
|
||||
use document_graph_storage::{AttributeDelta, HotOp, HotSequence, RegistryDelta, TimeStamp, Value};
|
||||
let set = |value: u32, counter: u64| HotOp {
|
||||
op: RegistryDelta::ChangeDocumentAttribute {
|
||||
delta: AttributeDelta {
|
||||
@@ -53,6 +53,7 @@ fn a_reopen_keeps_unretired_hot_ops_out_of_the_retired_snapshot() {
|
||||
},
|
||||
},
|
||||
timestamp: TimeStamp { counter, peer: PeerId(22) },
|
||||
sequence: HotSequence(counter),
|
||||
};
|
||||
futures::executor::block_on(async {
|
||||
let mut gdd = GddV1::create_in(AnyContainer::Memory(MemoryBackend::new()), GddV1Layout, PeerId(22), 1, "ed".into(), "std".into()).unwrap();
|
||||
@@ -67,3 +68,39 @@ fn a_reopen_keeps_unretired_hot_ops_out_of_the_retired_snapshot() {
|
||||
assert_eq!(reopened.session().hot_log().len(), 1);
|
||||
});
|
||||
}
|
||||
|
||||
/// A reused sequence would let a peer's retired marks drop the new op.
|
||||
#[test]
|
||||
fn a_reopen_continues_the_hot_op_sequence() {
|
||||
use document_graph_storage::{AttributeDelta, RegistryDelta, Value};
|
||||
let set = |value: u32| RegistryDelta::ChangeDocumentAttribute {
|
||||
delta: AttributeDelta {
|
||||
key: "k".into(),
|
||||
value: Some(Value::from(serde_json::json!(value))),
|
||||
},
|
||||
};
|
||||
fn stage(gdd: &mut GddV1, op: RegistryDelta) -> u64 {
|
||||
gdd.stage_constructed_ops(vec![op], &Default::default(), &HashMapResourceStorage::new()).unwrap();
|
||||
gdd.session().hot_log().last().unwrap().sequence.0
|
||||
}
|
||||
futures::executor::block_on(async {
|
||||
let mut gdd = GddV1::create_in(AnyContainer::Memory(MemoryBackend::new()), GddV1Layout, PeerId(23), 1, "ed".into(), "std".into()).unwrap();
|
||||
stage(&mut gdd, set(1));
|
||||
let up_to = gdd.session().hot_log().last().unwrap().timestamp;
|
||||
gdd.retire(up_to).unwrap();
|
||||
let last = stage(&mut gdd, set(2));
|
||||
|
||||
let (working, layout) = gdd.into_storage();
|
||||
let mut reopened = GddV1::open_in(working, layout).await.unwrap();
|
||||
assert_eq!(stage(&mut reopened, set(3)), last + 1);
|
||||
|
||||
let up_to = reopened.session().hot_log().last().unwrap().timestamp;
|
||||
reopened.retire(up_to).unwrap();
|
||||
let last = reopened.session().last_hot_sequence().0;
|
||||
let clock = reopened.session().clock_counter();
|
||||
let (working, layout) = reopened.into_storage();
|
||||
let mut reopened = GddV1::open_in(working, layout).await.unwrap();
|
||||
assert_eq!(reopened.session().clock_counter(), clock, "the clock carries over");
|
||||
assert_eq!(stage(&mut reopened, set(4)), last + 1);
|
||||
});
|
||||
}
|
||||
@@ -25,6 +25,7 @@ pub mod node {
|
||||
pub const LOCKED: &str = "ui::locked";
|
||||
pub const PINNED: &str = "ui::pinned";
|
||||
pub const OUTPUT_NAMES: &str = "ui::output_names";
|
||||
pub const OUTPUT_DESCRIPTIONS: &str = "ui::output_descriptions";
|
||||
pub const REFERENCE: &str = "ui::reference"; // TODO: Remove?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::hash::Hash;
|
||||
|
||||
use crate::{
|
||||
Attributes, CrdtError, Delta, ExportSlot, History, HotOp, Implementation, InputSlot, LamportClock, MAX_EXPORT_SLOTS, MAX_INPUT_SLOTS, Network, NetworkId, Node, NodeId, NodeInput, PeerId,
|
||||
PeerRegistration, Registry, RegistryDelta, ResourceEntry, ResourceId, Rev, SourceValue, TimeStamp, Tombstone, UserId, Value, reverse_attribute_delta,
|
||||
Attributes, CrdtError, Delta, ExportSlot, History, HotOp, HotSequence, Implementation, InputSlot, LamportClock, MAX_EXPORT_SLOTS, MAX_INPUT_SLOTS, Network, NetworkId, Node, NodeId, NodeInput,
|
||||
PeerId, PeerRegistration, Registry, RegistryDelta, ResourceEntry, ResourceId, RetiredMarks, Rev, SourceValue, TimeStamp, Tombstone, UserId, Value, reverse_attribute_delta,
|
||||
};
|
||||
use std::borrow::Cow;
|
||||
|
||||
@@ -15,6 +15,10 @@ pub struct Document {
|
||||
/// Live broadcast stream, applied to the `working_registry` on receive, GC'd at retirement.
|
||||
/// Persisted for crash recovery so in-flight unretired work survives editor restarts.
|
||||
pub(crate) hot_log: Vec<HotOp>,
|
||||
/// The stamps of the hot log's ops, so a re-announced op is recognised without a scan.
|
||||
pub(crate) hot_timestamps: HashSet<TimeStamp>,
|
||||
/// Which hot ops are retired into history, so a late copy is dropped.
|
||||
pub(crate) retired: RetiredMarks,
|
||||
/// The registry as of the last retirement, with no un-retired hot ops applied. Retirement computes
|
||||
/// each delta's `reverse` against this (so LWW reverses capture the true pre-op value, not the
|
||||
/// hot-polluted working state) and advances it. It equals the working registry whenever the hot log is
|
||||
@@ -36,6 +40,8 @@ pub struct Document {
|
||||
/// peer is calling; collision avoidance comes from hashing `(self.peer, counter)`, so two peers
|
||||
/// reading the same counter still produce distinct IDs.
|
||||
pub(crate) next_node_counter: u64,
|
||||
/// Counts this peer's own hot ops, so each carries its position in a gap-free run. See [`HotOp::sequence`].
|
||||
pub(crate) last_hot_sequence: HotSequence,
|
||||
}
|
||||
|
||||
impl Document {
|
||||
@@ -45,6 +51,8 @@ impl Document {
|
||||
retired_snapshot: Registry::default(),
|
||||
history: History::new(),
|
||||
hot_log: Vec::new(),
|
||||
hot_timestamps: HashSet::new(),
|
||||
retired: RetiredMarks::default(),
|
||||
head: None,
|
||||
redo_stack: Vec::new(),
|
||||
clock: LamportClock::new(peer),
|
||||
@@ -52,6 +60,7 @@ impl Document {
|
||||
user,
|
||||
last_broadcast_rev: None,
|
||||
next_node_counter: 0,
|
||||
last_hot_sequence: HotSequence::NONE,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,20 +89,69 @@ impl Document {
|
||||
self.apply_op_with(target, delta.kind, delta.timestamp, ApplyMode::Force)
|
||||
}
|
||||
|
||||
/// Stage a local op onto the working registry and the hot log.
|
||||
/// Stage a local op onto the working registry and the hot log, skipping the retired check so local work is never dropped.
|
||||
pub(crate) fn stage_hot_op(&mut self, hot_op: HotOp, mode: ApplyMode) -> Result<(), CrdtError> {
|
||||
self.apply_op_with(RegistryTarget::Working, hot_op.op.clone(), hot_op.timestamp, mode)?;
|
||||
self.hot_timestamps.insert(hot_op.timestamp);
|
||||
self.hot_log.push(hot_op);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Replay a persisted or received hot op. One already reflected in the registry changes nothing.
|
||||
/// Replay a persisted or received hot op. One already retired or held changes nothing.
|
||||
pub fn replay_hot_op(&mut self, hot_op: HotOp) -> Result<(), CrdtError> {
|
||||
// Seeing an op is enough to know what it implies, whether or not it applies: its stamp, and for one of our own a
|
||||
// spent sequence, should the persisted counter lag.
|
||||
self.clock.observe(hot_op.timestamp);
|
||||
if hot_op.timestamp.peer == self.peer {
|
||||
self.last_hot_sequence = self.last_hot_sequence.max(hot_op.sequence);
|
||||
}
|
||||
if self.retired.covers(hot_op.id()) {
|
||||
return Ok(());
|
||||
}
|
||||
if self.hot_timestamps.contains(&hot_op.timestamp) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.apply_op_idempotent(hot_op.op.clone(), hot_op.timestamp)?;
|
||||
self.hot_timestamps.insert(hot_op.timestamp);
|
||||
self.hot_log.push(hot_op);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Take on a peer's marks as well as this peer's. Returns whether a hot op was dropped.
|
||||
pub(crate) fn absorb_retired_marks(&mut self, remote: &RetiredMarks) -> bool {
|
||||
self.retired.absorb(remote);
|
||||
self.drop_retired_hot_ops()
|
||||
}
|
||||
|
||||
/// Bring the stamp index back in line after the hot log was filtered as a whole.
|
||||
pub(crate) fn resync_hot_timestamps(&mut self) {
|
||||
self.hot_timestamps = self.hot_log.iter().map(|hot_op| hot_op.timestamp).collect();
|
||||
}
|
||||
|
||||
/// Re-derive working as the snapshot plus every hot op, for a change that cannot apply in place. O(registry), so rare.
|
||||
pub(crate) fn rebuild_working(&mut self) {
|
||||
self.working_registry = self.retired_snapshot.clone();
|
||||
for hot_op in std::mem::take(&mut self.hot_log) {
|
||||
// No op fails on a referent, and one failing otherwise must not be lost.
|
||||
let _ = self.apply_op_idempotent(hot_op.op.clone(), hot_op.timestamp);
|
||||
self.hot_log.push(hot_op);
|
||||
}
|
||||
}
|
||||
|
||||
/// Drop retired hot ops and re-derive working without them: their effect returns with their deltas.
|
||||
fn drop_retired_hot_ops(&mut self) -> bool {
|
||||
let before = self.hot_log.len();
|
||||
let retired = &self.retired;
|
||||
self.hot_log.retain(|hot_op| !retired.covers(hot_op.id()));
|
||||
let dropped = self.hot_log.len() != before;
|
||||
if dropped {
|
||||
self.resync_hot_timestamps();
|
||||
self.rebuild_working();
|
||||
}
|
||||
dropped
|
||||
}
|
||||
|
||||
/// Apply a retired commit and record it in history.
|
||||
pub fn apply_delta(&mut self, delta: Delta) -> Result<(), CrdtError> {
|
||||
for parent in delta.all_parents() {
|
||||
|
||||
@@ -549,6 +549,13 @@ fn write_ui_attributes<M: NodeMetadataSource + ?Sized>(
|
||||
.map_err(map_serialization_error(node::ui::OUTPUT_NAMES))?;
|
||||
}
|
||||
|
||||
let output_descriptions = metadata.output_descriptions(metadata_path, runtime_node_id);
|
||||
if output_descriptions.iter().any(|description| !description.is_empty()) {
|
||||
attributes
|
||||
.set_serialized(node::ui::OUTPUT_DESCRIPTIONS, &output_descriptions, timestamp)
|
||||
.map_err(map_serialization_error(node::ui::OUTPUT_DESCRIPTIONS))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ pub struct NodeMetadataEntry {
|
||||
/// returns an error if this length does not match the node's input count.
|
||||
pub input_metadata: Vec<InputMetadataEntry>,
|
||||
pub output_names: Vec<String>,
|
||||
pub output_descriptions: Vec<String>,
|
||||
}
|
||||
|
||||
/// Per-network metadata. Separate from `NodeMetadataEntry` since these are
|
||||
@@ -79,6 +80,10 @@ pub trait NodeMetadataSource {
|
||||
fn output_names(&self, _network_path: &[RuntimeNodeId], _local_id: RuntimeNodeId) -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
/// Indexed like `output_names`, where a missing or empty entry is no description. Stored as one `ui::output_descriptions` attribute.
|
||||
fn output_descriptions(&self, _network_path: &[RuntimeNodeId], _local_id: RuntimeNodeId) -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn input_name(&self, _network_path: &[RuntimeNodeId], _local_id: RuntimeNodeId, _input_index: usize) -> Option<&str> {
|
||||
None
|
||||
|
||||
@@ -146,6 +146,7 @@ impl Session {
|
||||
/// `PeerId → UserId` mapping is established (and, under causal delivery, observed by other peers)
|
||||
/// before any of its edits. A no-op batch doesn't register, since registration rides a real edit.
|
||||
pub(crate) fn stage_ops(&mut self, ops: impl IntoIterator<Item = RegistryDelta>) -> Result<Vec<HotOp>, CrdtError> {
|
||||
// A batch is staged whole or not at all.
|
||||
let mut pending: Vec<RegistryDelta> = ops.into_iter().collect();
|
||||
if pending.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
@@ -156,13 +157,32 @@ impl Session {
|
||||
pending.insert(0, RegistryDelta::RegisterPeer { peer, user });
|
||||
}
|
||||
|
||||
// A reused sequence would fall under the retired marks, so a batch running past the end is refused.
|
||||
if self.document.last_hot_sequence.0.checked_add(pending.len() as u64).is_none() {
|
||||
return Err(CrdtError::SequencesExhausted);
|
||||
}
|
||||
|
||||
let sequence_before = self.document.last_hot_sequence;
|
||||
let mut staged = Vec::with_capacity(pending.len());
|
||||
for op in pending {
|
||||
let sequence = HotSequence(self.document.last_hot_sequence.0 + 1);
|
||||
let hot_op = HotOp {
|
||||
op,
|
||||
timestamp: self.document.clock.tick(),
|
||||
sequence,
|
||||
};
|
||||
self.document.stage_hot_op(hot_op.clone(), ApplyMode::Strict)?;
|
||||
if let Err(error) = self.document.stage_hot_op(hot_op.clone(), ApplyMode::Strict) {
|
||||
// The run continues where it was, so no sequence goes unused.
|
||||
self.document.last_hot_sequence = sequence_before;
|
||||
if !staged.is_empty() {
|
||||
let taken: HashSet<HotOpId> = staged.iter().map(HotOp::id).collect();
|
||||
self.document.hot_log.retain(|hot_op| !taken.contains(&hot_op.id()));
|
||||
self.document.resync_hot_timestamps();
|
||||
self.document.rebuild_working();
|
||||
}
|
||||
return Err(error);
|
||||
}
|
||||
self.document.last_hot_sequence = sequence;
|
||||
staged.push(hot_op);
|
||||
}
|
||||
Ok(staged)
|
||||
@@ -262,6 +282,16 @@ impl Session {
|
||||
Ok(session)
|
||||
}
|
||||
|
||||
/// Which hot ops are done with, for a peer catching up and for persisting. See [`RetiredMarks`].
|
||||
pub fn retired_marks(&self) -> &RetiredMarks {
|
||||
&self.document.retired
|
||||
}
|
||||
|
||||
/// Take on a peer's marks, or this peer's persisted ones, dropping the hot ops they cover.
|
||||
pub fn absorb_retired_marks(&mut self, remote: &RetiredMarks) {
|
||||
self.document.absorb_retired_marks(remote);
|
||||
}
|
||||
|
||||
/// Replay a persisted hot op. Idempotent on structural ops, suitable for crash recovery
|
||||
/// where the registry may already reflect the op's effect from a prior retired snapshot.
|
||||
pub fn replay_hot_op(&mut self, hot_op: HotOp) -> Result<(), CrdtError> {
|
||||
@@ -314,14 +344,30 @@ impl Session {
|
||||
self.document.history.len()
|
||||
}
|
||||
|
||||
/// Promote every hot op stamped at or before `up_to` into retired deltas in hot-log order, each keeping its authored
|
||||
/// stamp.
|
||||
pub fn retire(&mut self, up_to: TimeStamp) -> Result<Vec<Rev>, CrdtError> {
|
||||
let (drained, kept): (Vec<HotOp>, Vec<HotOp>) = self.document.hot_log.drain(..).partition(|hot_op| hot_op.timestamp <= up_to);
|
||||
/// The hot ops stamped at or before `up_to`, which [`retire`](Self::retire) drains.
|
||||
pub fn hot_ops_up_to(&self, up_to: TimeStamp) -> Vec<HotOpId> {
|
||||
self.document.hot_log.iter().filter(|hot_op| hot_op.timestamp <= up_to).map(HotOp::id).collect()
|
||||
}
|
||||
|
||||
/// Promote the given hot ops into retired deltas in hot-log order, each keeping its authored stamp.
|
||||
///
|
||||
/// One retired delta per hot op.
|
||||
pub fn retire_hot_ops(&mut self, ids: &[HotOpId]) -> Result<Vec<Rev>, CrdtError> {
|
||||
let wanted: HashSet<HotOpId> = ids.iter().copied().collect();
|
||||
let (drained, kept): (Vec<HotOp>, Vec<HotOp>) = self.document.hot_log.drain(..).partition(|hot_op| wanted.contains(&hot_op.id()));
|
||||
self.document.hot_log = kept;
|
||||
self.document.resync_hot_timestamps();
|
||||
self.document.retired.extend(drained.iter().map(HotOp::id));
|
||||
|
||||
let ops = drained.into_iter().map(|hot_op| (hot_op.op, Some(hot_op.timestamp)));
|
||||
self.commit_ops_authored_at(ops, true)
|
||||
}
|
||||
|
||||
/// Promote every hot op stamped at or before `up_to`, whatever its author.
|
||||
pub fn retire(&mut self, up_to: TimeStamp) -> Result<Vec<Rev>, CrdtError> {
|
||||
let ids = self.hot_ops_up_to(up_to);
|
||||
self.retire_hot_ops(&ids)
|
||||
}
|
||||
/// Mark a retired delta as the end of a user interaction, so the undo cursor treats it as a checkpoint.
|
||||
/// Called once per interaction by the editor-facing commit path (not by resource/internal commits).
|
||||
pub fn mark_interaction_end(&mut self, rev: Rev) {
|
||||
@@ -549,6 +595,26 @@ impl Session {
|
||||
pub fn next_node_counter(&self) -> u64 {
|
||||
self.document.next_node_counter
|
||||
}
|
||||
|
||||
/// The last hot op sequence this peer authored, carried across a reload so none is spent twice.
|
||||
pub fn last_hot_sequence(&self) -> HotSequence {
|
||||
self.document.last_hot_sequence
|
||||
}
|
||||
|
||||
/// The Lamport counter, persisted so a reopen never mints a spent stamp, even one nothing carries any more.
|
||||
pub fn clock_counter(&self) -> u64 {
|
||||
self.document.clock.counter
|
||||
}
|
||||
|
||||
/// Continue the Lamport clock after a load. Raises only, like observing an op.
|
||||
pub fn restore_clock_counter(&mut self, counter: u64) {
|
||||
self.document.clock.counter = self.document.clock.counter.max(counter);
|
||||
}
|
||||
|
||||
/// Restore the hot op sequence after a load. Raises only, as replaying the hot log may already have.
|
||||
pub fn restore_hot_sequence(&mut self, sequence: HotSequence) {
|
||||
self.document.last_hot_sequence = self.document.last_hot_sequence.max(sequence);
|
||||
}
|
||||
}
|
||||
|
||||
/// Errors from `Session::commit_from_runtime`.
|
||||
@@ -574,10 +640,120 @@ impl Default for Session {
|
||||
pub struct HotOp {
|
||||
pub op: RegistryDelta,
|
||||
pub timestamp: TimeStamp,
|
||||
/// Position in its author's run. See [`HotSequence`].
|
||||
pub sequence: HotSequence,
|
||||
}
|
||||
|
||||
impl HotOp {
|
||||
/// Identifies the op in the retired marks, which track a contiguous prefix per author.
|
||||
pub fn id(&self) -> HotOpId {
|
||||
HotOpId {
|
||||
peer: self.timestamp.peer,
|
||||
sequence: self.sequence,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Position in one author's run of hot ops, counting from 1 with no gaps. Kept apart from the Lamport
|
||||
/// counter, which skips on observing a higher remote timestamp and so cannot bound a contiguous prefix.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct HotSequence(pub u64);
|
||||
|
||||
impl HotSequence {
|
||||
/// Before this author has written anything, covering no op.
|
||||
pub const NONE: Self = Self(0);
|
||||
|
||||
/// The position after this one, for adjacency. Saturates: a run ending at the last position has no successor.
|
||||
pub fn next(self) -> Self {
|
||||
Self(self.0.saturating_add(1))
|
||||
}
|
||||
}
|
||||
|
||||
/// One hot op's author and position in its run, as the retired marks name it.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
pub struct HotOpId {
|
||||
pub peer: PeerId,
|
||||
pub sequence: HotSequence,
|
||||
}
|
||||
|
||||
/// Which hot ops are retired: each author's gap-free prefix, plus runs past it while ops are in flight. Persisted, so
|
||||
/// a late copy of a retired op is dropped.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct RetiredMarks {
|
||||
pub retired_up_to: HashMap<PeerId, HotSequence>,
|
||||
/// retired ops past their author's prefix, as inclusive runs, one per gap in flight.
|
||||
pub retired_runs: HashMap<PeerId, Vec<(HotSequence, HotSequence)>>,
|
||||
}
|
||||
|
||||
/// Sort and coalesce runs, joining any that touch or abut.
|
||||
fn coalesce(runs: &mut Vec<(HotSequence, HotSequence)>) {
|
||||
runs.sort_unstable();
|
||||
runs.dedup_by(|(start, end), (_, last_end)| {
|
||||
let joins = *start <= last_end.next();
|
||||
if joins {
|
||||
*last_end = (*last_end).max(*end);
|
||||
}
|
||||
joins
|
||||
});
|
||||
}
|
||||
|
||||
impl RetiredMarks {
|
||||
/// Whether history already holds this hot op.
|
||||
pub fn covers(&self, id: HotOpId) -> bool {
|
||||
self.retired_up_to.get(&id.peer).is_some_and(|&through| id.sequence <= through)
|
||||
|| self
|
||||
.retired_runs
|
||||
.get(&id.peer)
|
||||
.is_some_and(|runs| runs.iter().any(|&(start, end)| (start..=end).contains(&id.sequence)))
|
||||
}
|
||||
|
||||
/// Take on `remote`'s coverage as well as this one's.
|
||||
pub(crate) fn absorb(&mut self, remote: &Self) {
|
||||
for (&peer, &remote_through) in &remote.retired_up_to {
|
||||
let through = self.retired_up_to.entry(peer).or_default();
|
||||
*through = (*through).max(remote_through);
|
||||
}
|
||||
for (&peer, runs) in &remote.retired_runs {
|
||||
self.retired_runs.entry(peer).or_default().extend(runs.iter().copied());
|
||||
}
|
||||
self.compact();
|
||||
}
|
||||
|
||||
/// Record newly retired ops.
|
||||
pub fn extend(&mut self, retired: impl IntoIterator<Item = HotOpId>) {
|
||||
for id in retired {
|
||||
self.retired_runs.entry(id.peer).or_default().push((id.sequence, id.sequence));
|
||||
}
|
||||
self.compact();
|
||||
}
|
||||
|
||||
/// Fold runs that continue their author's prefix into `retired_up_to`, leaving only those past a gap.
|
||||
fn compact(&mut self) {
|
||||
for (&peer, runs) in &mut self.retired_runs {
|
||||
coalesce(runs);
|
||||
let mut through = self.retired_up_to.get(&peer).copied().unwrap_or(HotSequence::NONE);
|
||||
let joined = runs.iter().take_while(|&&(start, end)| {
|
||||
let joins = start <= through.next();
|
||||
if joins {
|
||||
through = through.max(end);
|
||||
}
|
||||
joins
|
||||
});
|
||||
let joined = joined.count();
|
||||
runs.drain(..joined);
|
||||
if through != HotSequence::NONE {
|
||||
self.retired_up_to.insert(peer, through);
|
||||
}
|
||||
}
|
||||
self.retired_runs.retain(|_, runs| !runs.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum CrdtError {
|
||||
#[error("This peer has authored every hot op sequence there is")]
|
||||
SequencesExhausted,
|
||||
#[error("Target node {0} does not exist")]
|
||||
TargetNodeDoesNotExist(NodeId),
|
||||
#[error("Network {0} does not exist")]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{AttributeDelta, CrdtError, Implementation, Network, NetworkId, Node, NodeId, NodeInput, PeerId, RegistryDelta, Session, UserId, Value};
|
||||
use crate::{AttributeDelta, CrdtError, HotOpId, Implementation, Network, NetworkId, Node, NodeId, NodeInput, PeerId, RegistryDelta, Session, UserId, Value};
|
||||
|
||||
fn set_attribute(key: &str, value: u32) -> RegistryDelta {
|
||||
RegistryDelta::ChangeDocumentAttribute {
|
||||
@@ -24,10 +24,12 @@ fn retirement_takes_the_ops_under_the_cutoff_in_any_applied_order() {
|
||||
let hot = |op, counter, peer| crate::HotOp {
|
||||
op,
|
||||
timestamp: crate::TimeStamp { counter, peer: PeerId(peer) },
|
||||
sequence: crate::HotSequence(1),
|
||||
};
|
||||
let (late, own) = (hot(add_network(9), 50, 2), hot(set_attribute("x", 1), 20, 3));
|
||||
host.replay_hot_op(late.clone()).expect("the late-stamped op lands first");
|
||||
host.replay_hot_op(own.clone()).expect("the earlier-stamped op lands second");
|
||||
assert_eq!(host.hot_ops_up_to(own.timestamp).len(), 1, "only the op under the cutoff retires");
|
||||
|
||||
host.retire(own.timestamp).expect("retire");
|
||||
assert_eq!(host.hot_log().len(), 1, "the later-stamped op stays hot");
|
||||
@@ -45,7 +47,8 @@ fn newest_peer_registration_wins_in_any_order() {
|
||||
// Registration rides the staging path, so the steps go through the hot log and retire.
|
||||
fn stage_and_retire(session: &mut Session, op: RegistryDelta) {
|
||||
let hot = session.stage_ops([op]).expect("stage");
|
||||
session.retire(hot.last().expect("staged").timestamp).expect("retire");
|
||||
let ids: Vec<crate::HotOpId> = hot.iter().map(crate::HotOp::id).collect();
|
||||
session.retire_hot_ops(&ids).expect("retire");
|
||||
}
|
||||
let mut device = Session::with_identity(PeerId(1), UserId(10));
|
||||
stage_and_retire(&mut device, set_attribute("first", 1));
|
||||
@@ -66,6 +69,33 @@ fn newest_peer_registration_wins_in_any_order() {
|
||||
assert_eq!(other.user_of(PeerId(3)), None, "a peer never registered has no user");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_batch_past_the_last_sequence_is_refused_whole() {
|
||||
let mut session = Session::with_peer(PeerId(1));
|
||||
session.restore_hot_sequence(crate::HotSequence(u64::MAX - 1));
|
||||
assert!(matches!(session.stage_ops([set_attribute("k", 1)]), Err(crate::CrdtError::SequencesExhausted)));
|
||||
assert!(session.hot_log().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_reopened_session_drops_a_late_copy_of_a_retired_op() {
|
||||
let op = crate::HotOp {
|
||||
op: set_attribute("k", 1),
|
||||
timestamp: crate::TimeStamp { counter: 3, peer: PeerId(2) },
|
||||
sequence: crate::HotSequence(1),
|
||||
};
|
||||
let mut host = Session::with_peer(PeerId(1));
|
||||
host.replay_hot_op(op.clone()).unwrap();
|
||||
host.retire(op.timestamp).unwrap();
|
||||
|
||||
let mut reopened = Session::load(PeerId(1), UserId(1), host.retired_registry().clone(), host.cloned_deltas(), host.head_rev(), Vec::new(), 0);
|
||||
reopened.absorb_retired_marks(host.retired_marks());
|
||||
reopened.replay_hot_op(op.clone()).unwrap();
|
||||
assert!(reopened.hot_log().is_empty());
|
||||
assert!(reopened.retire(op.timestamp).unwrap().is_empty());
|
||||
assert_eq!(reopened.history_len(), host.history_len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_refused_local_op_leaves_the_working_registry_unchanged() {
|
||||
let mut s = Session::with_peer(PeerId(1));
|
||||
@@ -88,3 +118,61 @@ fn a_refused_local_op_leaves_the_working_registry_unchanged() {
|
||||
assert!(matches!(refused, Err(CrdtError::TargetNodeDoesNotExist(_))));
|
||||
assert_eq!(s.registry(), &before, "the refused op's write to node 1 stayed in the working registry");
|
||||
}
|
||||
|
||||
/// The caller only gets the error, so ops left staged would never be persisted or sent.
|
||||
#[test]
|
||||
fn a_refused_batch_stages_nothing() {
|
||||
let mut s = Session::with_peer(PeerId(1));
|
||||
s.stage_ops([RegistryDelta::AddNetwork {
|
||||
id: NetworkId(1),
|
||||
network: Network::default(),
|
||||
}])
|
||||
.unwrap();
|
||||
let hot_before = s.hot_log().len();
|
||||
let refused = s.stage_ops([
|
||||
set_attribute("lands", 1),
|
||||
RegistryDelta::ChangeNodeInput {
|
||||
id: NodeId(404),
|
||||
index: 0,
|
||||
new_input: NodeInput::Value {
|
||||
value: Value::from(serde_json::json!(1)),
|
||||
exposed: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
assert!(refused.is_err());
|
||||
assert_eq!(s.hot_log().len(), hot_before, "a refused batch stages nothing");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn retired_marks_round_trip_through_json() {
|
||||
let mut marks = crate::RetiredMarks::default();
|
||||
let id = |peer: u64, sequence: u64| HotOpId {
|
||||
peer: PeerId(peer),
|
||||
sequence: crate::HotSequence(sequence),
|
||||
};
|
||||
marks.extend([id(1, 1), id(1, 2), id(1, 5), id(u64::MAX, 3)]);
|
||||
let json = serde_json::to_string(&marks).unwrap();
|
||||
assert_eq!(serde_json::from_str::<crate::RetiredMarks>(&json).unwrap(), marks);
|
||||
}
|
||||
|
||||
/// A late copy of one of this peer's own ops that is already retired still raises the sequence and the clock, so the
|
||||
/// next op this peer stages takes a fresh sequence and a later stamp.
|
||||
#[test]
|
||||
fn a_retired_late_copy_still_advances_the_sequence_and_the_clock() {
|
||||
let mut session = Session::with_peer(PeerId(1));
|
||||
let own = crate::HotOp {
|
||||
op: set_attribute("k", 1),
|
||||
timestamp: crate::TimeStamp { counter: 50, peer: PeerId(1) },
|
||||
sequence: crate::HotSequence(7),
|
||||
};
|
||||
let mut marks = crate::RetiredMarks::default();
|
||||
marks.extend([own.id()]);
|
||||
session.absorb_retired_marks(&marks);
|
||||
session.replay_hot_op(own.clone()).expect("a retired copy is dropped");
|
||||
|
||||
let staged = session.stage_ops([set_attribute("k", 2)]).expect("stage");
|
||||
let next = staged.last().expect("staged");
|
||||
assert!(next.sequence > own.sequence, "a fresh sequence");
|
||||
assert!(next.timestamp > own.timestamp, "a later stamp");
|
||||
}
|
||||
@@ -40,6 +40,7 @@ fn apply_hot_op_advances_clock_past_observed_timestamp() {
|
||||
let hot_op = HotOp {
|
||||
op: remove_node_op(NodeId(99)),
|
||||
timestamp: observed,
|
||||
sequence: crate::HotSequence(1),
|
||||
};
|
||||
|
||||
document
|
||||
@@ -901,8 +902,66 @@ fn change_node_attribute(id: NodeId, key: &str, value: serde_json::Value) -> Reg
|
||||
RegistryDelta::ChangeNodeAttribute { id, delta }
|
||||
}
|
||||
|
||||
fn hot_op(op: RegistryDelta, counter: u64, peer: u64) -> HotOp {
|
||||
HotOp { op, timestamp: ts(counter, peer) }
|
||||
fn hot_op(op: RegistryDelta, counter: u64, peer: u64, sequence: u64) -> HotOp {
|
||||
let sequence = crate::HotSequence(sequence);
|
||||
HotOp {
|
||||
op,
|
||||
timestamp: ts(counter, peer),
|
||||
sequence,
|
||||
}
|
||||
}
|
||||
|
||||
/// An op past a gap is covered without the gap, a filled gap joins the prefix, and absorbing is a union.
|
||||
#[test]
|
||||
fn retired_marks_keep_a_prefix_and_runs_past_gaps() {
|
||||
let author = PeerId(1);
|
||||
let id = |sequence: u64| crate::HotOpId {
|
||||
peer: author,
|
||||
sequence: crate::HotSequence(sequence),
|
||||
};
|
||||
let marks_of = |batches: &[&[u64]]| {
|
||||
let mut marks = crate::RetiredMarks::default();
|
||||
batches.iter().for_each(|batch| marks.extend(batch.iter().map(|&sequence| id(sequence))));
|
||||
marks
|
||||
};
|
||||
let after_a_lost_op: Vec<u64> = (2..=20).collect();
|
||||
let one_by_one: Vec<&[u64]> = after_a_lost_op.chunks(1).collect();
|
||||
|
||||
/// Batches extended in order, batches of a peer's marks absorbed, expected prefix, expected runs past it.
|
||||
type Case<'a> = (&'a [&'a [u64]], &'a [&'a [u64]], u64, Option<usize>);
|
||||
let cases: [Case; 5] = [
|
||||
(&[&[1, 2]], &[], 2, None),
|
||||
(&[&[1, 2], &[4]], &[], 2, Some(1)),
|
||||
(&[&[1, 2], &[4], &[3]], &[], 4, None),
|
||||
(one_by_one.as_slice(), &[], 0, Some(1)),
|
||||
(&[&[1, 4]], &[&[1, 2, 3, 5]], 5, None),
|
||||
];
|
||||
for (batches, absorbed, prefix, runs) in cases {
|
||||
let mut marks = marks_of(batches);
|
||||
marks.absorb(&marks_of(absorbed));
|
||||
let up_to = marks.retired_up_to.get(&author).copied().unwrap_or(crate::HotSequence::NONE);
|
||||
assert_eq!(up_to, crate::HotSequence(prefix), "{batches:?}");
|
||||
assert_eq!(marks.retired_runs.get(&author).map(Vec::len), runs, "{batches:?}");
|
||||
for sequence in 1..=21 {
|
||||
let retired = batches.iter().chain(absorbed).any(|batch| batch.contains(&sequence));
|
||||
assert_eq!(marks.covers(id(sequence)), retired, "{batches:?}: sequence {sequence}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A retirer that never received an author's earlier op still retires the later one, past the author's prefix.
|
||||
#[test]
|
||||
fn retiring_over_a_gap_lands_beyond_the_prefix() {
|
||||
let mut host = Session::with_peer(PeerId(1));
|
||||
// Sequence 1 was lost with the link that carried it.
|
||||
let second = hot_op(set_document_attribute("late", 1), 9, 2, 2);
|
||||
host.replay_hot_op(second.clone()).expect("apply");
|
||||
host.retire(second.timestamp).expect("retire");
|
||||
|
||||
let marks = host.retired_marks();
|
||||
assert_eq!(marks.retired_up_to.get(&PeerId(2)).copied().unwrap_or(crate::HotSequence::NONE), crate::HotSequence::NONE);
|
||||
assert_eq!(marks.retired_runs.get(&PeerId(2)).map(Vec::len), Some(1));
|
||||
assert!(marks.covers(second.id()));
|
||||
}
|
||||
|
||||
/// So the snapshot and a replay keep the LWW winner the live view did, whether the straggler retires with it or after.
|
||||
@@ -910,12 +969,12 @@ fn hot_op(op: RegistryDelta, counter: u64, peer: u64) -> HotOp {
|
||||
fn retirement_preserves_the_live_lww_winner() {
|
||||
for straggler_retires_alone in [false, true] {
|
||||
let mut host = Session::with_peer(PeerId(1));
|
||||
let winner = hot_op(set_document_attribute("k", 1), 10, 2);
|
||||
let winner = hot_op(set_document_attribute("k", 1), 10, 2, 1);
|
||||
host.replay_hot_op(winner.clone()).expect("apply winner");
|
||||
if straggler_retires_alone {
|
||||
host.retire(winner.timestamp).expect("retire winner");
|
||||
}
|
||||
host.replay_hot_op(hot_op(set_document_attribute("k", 2), 5, 3)).expect("apply straggler");
|
||||
host.replay_hot_op(hot_op(set_document_attribute("k", 2), 5, 3, 1)).expect("apply straggler");
|
||||
host.retire(winner.timestamp).expect("retire");
|
||||
|
||||
let value = |registry: &crate::Registry| registry.attributes.get("k").map(|attribute| attribute.value.clone());
|
||||
|
||||
@@ -255,6 +255,7 @@ fn extract_ui_metadata(node: &crate::Node, storage_id: NodeId, network_path: &[R
|
||||
let locked = node.attributes.get_or(node::ui::LOCKED, false);
|
||||
let pinned = node.attributes.get_or(node::ui::PINNED, false);
|
||||
let output_names: Vec<String> = node.attributes.get_or_default(node::ui::OUTPUT_NAMES);
|
||||
let output_descriptions: Vec<String> = node.attributes.get_or_default(node::ui::OUTPUT_DESCRIPTIONS);
|
||||
|
||||
let input_metadata: Vec<InputMetadataEntry> = node.inputs.iter().map(|slot| &slot.attributes).map(extract_input_metadata).collect();
|
||||
|
||||
@@ -269,6 +270,7 @@ fn extract_ui_metadata(node: &crate::Node, storage_id: NodeId, network_path: &[R
|
||||
pinned,
|
||||
input_metadata,
|
||||
output_names,
|
||||
output_descriptions,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ interpreted-executor = { workspace = true }
|
||||
graphene-std = { workspace = true } # NOTE: `core-types` should not be added here because `graphene-std` re-exports its contents
|
||||
preprocessor = { workspace = true }
|
||||
math-parser = { workspace = true }
|
||||
snapping = { workspace = true }
|
||||
|
||||
# Workspace dependencies
|
||||
js-sys = { workspace = true }
|
||||
|
||||
@@ -37,19 +37,11 @@ pub const VIEWPORT_ZOOM_TO_FIT_PADDING_SCALE_FACTOR: f64 = 0.95;
|
||||
|
||||
pub const DRAG_BEYOND_VIEWPORT_MAX_OVEREXTENSION_PIXELS: f64 = 50.;
|
||||
pub const DRAG_BEYOND_VIEWPORT_SPEED_FACTOR: f64 = 20.;
|
||||
/// How long a dragged wire must stay beyond the node graph's edge before auto-panning begins, so passing over to another panel doesn't pan.
|
||||
pub const WIRE_DRAG_AUTO_PAN_DELAY_MILLISECONDS: u64 = 400;
|
||||
/// How long a dragged wire must rest over a node before the node reveals its hidden inputs the wire could connect to.
|
||||
pub const WIRE_DRAG_NODE_EXPAND_DELAY_MILLISECONDS: u64 = 250;
|
||||
|
||||
// SNAPPING POINT
|
||||
pub const SNAP_POINT_TOLERANCE: f64 = 5.;
|
||||
/// These are layers whose bounding boxes are used for alignment.
|
||||
pub const MAX_ALIGNMENT_CANDIDATES: usize = 100;
|
||||
/// These are layers that are used for the layer snapper.
|
||||
pub const MAX_SNAP_CANDIDATES: usize = 10;
|
||||
/// These are points (anchors and bounding box corners etc.) in the layer snapper.
|
||||
pub const MAX_LAYER_SNAP_POINTS: usize = 100;
|
||||
|
||||
pub const DRAG_THRESHOLD: f64 = 1.;
|
||||
|
||||
@@ -194,6 +186,12 @@ pub const DOUBLE_CLICK_MILLISECONDS: u64 = 500;
|
||||
/// Maximum duration of the whole double-tap gesture, measured from the first tap's key-down to the second tap's key-up.
|
||||
pub const DOUBLE_TAP_MILLISECONDS: u64 = 1000;
|
||||
|
||||
// FONTS
|
||||
/// How long a font catalog request may go unanswered before another can be sent.
|
||||
pub const FONT_CATALOG_REQUEST_TIMEOUT_MILLISECONDS: u64 = 60_000;
|
||||
/// How long to wait after a failed font catalog request before sending another.
|
||||
pub const FONT_CATALOG_RETRY_DELAY_MILLISECONDS: u64 = 10_000;
|
||||
|
||||
// UI
|
||||
pub const UI_SCALE_DEFAULT: f64 = 1.;
|
||||
pub const UI_SCALE_MIN: f64 = 0.5;
|
||||
|
||||
@@ -57,9 +57,8 @@ impl DispatcherMessageHandlers {
|
||||
}
|
||||
}
|
||||
|
||||
/// For optimization, these are messages guaranteed to be redundant when repeated.
|
||||
/// The last occurrence of the message in the message queue is sufficient to ensure correct behavior.
|
||||
/// In addition, these messages do not change any state in the backend (aside from caches).
|
||||
/// For optimization, these messages are deferred to the end of the outermost queue, where equal copies are dropped.
|
||||
/// Each must only refresh a cache, a layout, the frontend, or a render from the current state, so one run at the end matches running every copy.
|
||||
const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::DocumentStructureChanged)),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
|
||||
@@ -68,16 +67,25 @@ const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
|
||||
NodeGraphMessageDiscriminant::UpdateLayerPanel,
|
||||
))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(NodeGraphMessageDiscriminant::SendWires))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
|
||||
NodeGraphMessageDiscriminant::UpdateVisibleNodes,
|
||||
))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
|
||||
NodeGraphMessageDiscriminant::SendSelectedNodes,
|
||||
))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
|
||||
NodeGraphMessageDiscriminant::UpdateGraphBarRight,
|
||||
))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::SubmitActiveGraphRender),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::SubmitEyedropperPreviewRender),
|
||||
MessageDiscriminant::MenuBar(MenuBarMessageDiscriminant::SendLayout),
|
||||
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateUIScale),
|
||||
];
|
||||
/// Since we don't need to update the frontend multiple times per frame,
|
||||
/// we have a set of messages which we will buffer until the next frame is requested.
|
||||
const FRONTEND_UPDATE_MESSAGES: &[MessageDiscriminant] = &[
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
|
||||
PropertiesPanelMessageDiscriminant::Refresh,
|
||||
))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Inspector(InspectorMessageDiscriminant::Refresh))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::UpdateDocumentWidgets),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderRulers)),
|
||||
@@ -88,6 +96,7 @@ const DEBUG_MESSAGE_BLOCK_LIST: &[MessageDiscriminant] = &[
|
||||
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(EventMessageDiscriminant::AnimationFrame)),
|
||||
MessageDiscriminant::Animation(AnimationMessageDiscriminant::IncrementFrameCounter),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::AutoSaveAllDocuments),
|
||||
MessageDiscriminant::Tool(ToolMessageDiscriminant::SnappingTick),
|
||||
];
|
||||
// TODO: Find a way to combine these with the list above. We use strings for now since these are the standard variant names used by multiple messages. But having these also type-checked would be best.
|
||||
const DEBUG_MESSAGE_ENDING_BLOCK_LIST: &[&str] = &["PointerMove", "PointerOutsideViewport", "Overlays", "Draw", "CurrentTime", "Time"];
|
||||
@@ -278,7 +287,7 @@ impl Dispatcher {
|
||||
let layout = &self.message_handlers.portfolio_message_handler.workspace.panel_layout;
|
||||
menu_bar_message_handler.data_panel_open = layout.is_panel_present(PanelType::Data);
|
||||
menu_bar_message_handler.layers_panel_open = layout.is_panel_present(PanelType::Layers);
|
||||
menu_bar_message_handler.properties_panel_open = layout.is_panel_present(PanelType::Properties);
|
||||
menu_bar_message_handler.inspector_open = layout.is_panel_present(PanelType::Inspector);
|
||||
menu_bar_message_handler.message_logging_verbosity = self.message_handlers.debug_message_handler.message_logging_verbosity;
|
||||
menu_bar_message_handler.reset_node_definitions_on_open = self.message_handlers.portfolio_message_handler.reset_node_definitions_on_open;
|
||||
menu_bar_message_handler.show_storage_preferences = self.message_handlers.preferences_message_handler.show_storage_preferences;
|
||||
@@ -344,11 +353,13 @@ impl Dispatcher {
|
||||
Message::Tool(message) => {
|
||||
let Some(document_id) = self.message_handlers.portfolio_message_handler.active_document_id() else {
|
||||
warn!("Called ToolMessage without an active document.\nGot {message:?}");
|
||||
return;
|
||||
self.cleanup_queues(false);
|
||||
continue;
|
||||
};
|
||||
let Some(document) = self.message_handlers.portfolio_message_handler.documents.get_mut(&document_id) else {
|
||||
warn!("Called ToolMessage with an invalid active document.\nGot {message:?}");
|
||||
return;
|
||||
self.cleanup_queues(false);
|
||||
continue;
|
||||
};
|
||||
|
||||
let context = ToolMessageContext {
|
||||
@@ -457,6 +468,33 @@ mod test {
|
||||
use crate::messages::portfolio::ingest::utility_types::IngestAction;
|
||||
pub use crate::test_utils::test_prelude::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn switching_documents_and_tools_does_not_add_event_listeners() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
let first_document = editor.portfolio_message_handler().active_document_id().unwrap();
|
||||
editor.new_document().await;
|
||||
let second_document = editor.portfolio_message_handler().active_document_id().unwrap();
|
||||
editor.select_tool(ToolType::Select).await;
|
||||
|
||||
let listener_count = |editor: &EditorTestUtils| editor.editor.dispatcher.message_handlers.broadcast_message_handler.listener_count();
|
||||
let initial_listener_count = listener_count(&editor);
|
||||
|
||||
for _ in 0..3 {
|
||||
for document_id in [first_document, second_document] {
|
||||
editor.handle_message(PortfolioMessage::SelectDocument { document_id }).await;
|
||||
}
|
||||
editor.select_tool(ToolType::Path).await;
|
||||
editor.select_tool(ToolType::Select).await;
|
||||
|
||||
// Last, since a document switch would restore anything the graph's opening and closing drop
|
||||
editor.handle_message(DocumentMessage::GraphViewOverlayToggle).await;
|
||||
editor.handle_message(DocumentMessage::GraphViewOverlayToggle).await;
|
||||
}
|
||||
|
||||
assert_eq!(listener_count(&editor), initial_listener_count);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
/// This test will fail when you make changes to the underlying serialization format for a document.
|
||||
async fn check_if_demo_art_opens() {
|
||||
|
||||
@@ -14,7 +14,13 @@ impl MessageHandler<BroadcastMessage, ()> for BroadcastMessageHandler {
|
||||
BroadcastMessage::TriggerEvent(message) => self.event.process_message(message, responses, EventMessageContext { listeners: &mut self.listeners }),
|
||||
|
||||
// Messages
|
||||
BroadcastMessage::SubscribeEvent { on, send } => self.listeners.entry(on).or_default().push(*send),
|
||||
BroadcastMessage::SubscribeEvent { on, send } => {
|
||||
// Skip an existing listener, since some are subscribed again on every document switch
|
||||
let listeners = self.listeners.entry(on).or_default();
|
||||
if !listeners.contains(&send) {
|
||||
listeners.push(*send);
|
||||
}
|
||||
}
|
||||
BroadcastMessage::UnsubscribeEvent { on, send } => self.listeners.entry(on).or_default().retain(|msg| *msg != *send),
|
||||
}
|
||||
}
|
||||
@@ -23,3 +29,10 @@ impl MessageHandler<BroadcastMessage, ()> for BroadcastMessageHandler {
|
||||
actions!(EventMessageDiscriminant;)
|
||||
}
|
||||
}
|
||||
|
||||
impl BroadcastMessageHandler {
|
||||
#[cfg(test)]
|
||||
pub fn listener_count(&self) -> usize {
|
||||
self.listeners.values().map(Vec::len).sum()
|
||||
}
|
||||
}
|
||||
@@ -827,7 +827,6 @@ fn rgb_input(channel: RgbChannel, value: Option<f64>, tooltip_label: &'static st
|
||||
.disabled(disabled)
|
||||
.min(0.)
|
||||
.max(255.)
|
||||
.min_width(1)
|
||||
.display_decimal_places(0)
|
||||
.tooltip_label(tooltip_label)
|
||||
.tooltip_description("Integers 0–255.")
|
||||
@@ -841,7 +840,6 @@ fn hsv_input(channel: HsvChannel, value: Option<f64>, max: f64, unit: &'static s
|
||||
.disabled(disabled)
|
||||
.min(0.)
|
||||
.max(max)
|
||||
.min_width(1)
|
||||
.unit(unit)
|
||||
.display_decimal_places(1)
|
||||
.tooltip_label(tooltip_label)
|
||||
|
||||
@@ -123,13 +123,16 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
||||
.collect();
|
||||
|
||||
let export_type = vec![
|
||||
TextLabel::new("File Type").table_align(true).min_width(100).widget_instance(),
|
||||
TextLabel::new("File Type").table_align(true).sizing(WidgetSizing::fixed(100)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
DropdownInput::new(entries).selected_index(selected_index.map(|index| index as u32)).min_width(200).widget_instance(),
|
||||
DropdownInput::new(entries)
|
||||
.selected_index(selected_index.map(|index| index as u32))
|
||||
.sizing(WidgetSizing::default().min_width(200))
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let resolution = vec![
|
||||
TextLabel::new("Scale Factor").table_align(true).min_width(100).widget_instance(),
|
||||
TextLabel::new("Scale Factor").table_align(true).sizing(WidgetSizing::fixed(100)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(self.scale_factor))
|
||||
.unit("")
|
||||
@@ -138,7 +141,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
||||
.increment_step(0.5)
|
||||
.disabled(self.file_type == FileType::Svg)
|
||||
.on_update(|number_input: &NumberInput| ExportDialogMessage::ScaleFactor { factor: number_input.value.unwrap() }.into())
|
||||
.min_width(200)
|
||||
.sizing(WidgetSizing::default().min_width(200))
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
@@ -177,7 +180,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
|
||||
}
|
||||
|
||||
let export_area = vec![
|
||||
TextLabel::new("Bounds").table_align(true).min_width(100).widget_instance(),
|
||||
TextLabel::new("Bounds").table_align(true).sizing(WidgetSizing::fixed(100)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
DropdownInput::new(entries).selected_index(Some(index as u32)).widget_instance(),
|
||||
];
|
||||
|
||||
+11
-6
@@ -84,17 +84,22 @@ impl DialogLayoutHolder for NewDocumentDialogMessageHandler {
|
||||
impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
fn layout(&self) -> Layout {
|
||||
let name = vec![
|
||||
TextLabel::new("Name").table_align(true).min_width(90).widget_instance(),
|
||||
TextLabel::new("Name").table_align(true).sizing(WidgetSizing::fixed(90)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
TextInput::new(&self.name)
|
||||
.on_update(|text_input: &TextInput| NewDocumentDialogMessage::Name { name: text_input.value.clone() }.into())
|
||||
.min_width(204) // Matches the 100px of both NumberInputs below + the 4px of the Unrelated-type separator
|
||||
// Matches the 100px of both NumberInputs below plus the 4px of the Related-type separator between them
|
||||
.sizing(WidgetSizing::default().min_width(204))
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let infinite = vec![
|
||||
TextLabel::new("Infinite Canvas").table_align(true).min_width(90).for_checkbox(checkbox_id).widget_instance(),
|
||||
TextLabel::new("Infinite Canvas")
|
||||
.table_align(true)
|
||||
.sizing(WidgetSizing::fixed(90))
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(self.infinite)
|
||||
.on_update(|checkbox_input: &CheckboxInput| NewDocumentDialogMessage::Infinite { infinite: checkbox_input.checked }.into())
|
||||
@@ -103,7 +108,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
];
|
||||
|
||||
let scale = vec![
|
||||
TextLabel::new("Dimensions").table_align(true).min_width(90).widget_instance(),
|
||||
TextLabel::new("Dimensions").table_align(true).sizing(WidgetSizing::fixed(90)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(self.dimensions.x as f64))
|
||||
.label("W")
|
||||
@@ -112,7 +117,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
.is_integer(true)
|
||||
.disabled(self.infinite)
|
||||
.min_width(100)
|
||||
.sizing(WidgetSizing::default().min_width(100))
|
||||
.on_update(|number_input: &NumberInput| NewDocumentDialogMessage::DimensionsX { width: number_input.value.unwrap() }.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
@@ -123,7 +128,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
.is_integer(true)
|
||||
.disabled(self.infinite)
|
||||
.min_width(100)
|
||||
.sizing(WidgetSizing::default().min_width(100))
|
||||
.on_update(|number_input: &NumberInput| NewDocumentDialogMessage::DimensionsY { height: number_input.value.unwrap() }.into())
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
@@ -177,6 +177,7 @@ impl PreferencesDialogMessageHandler {
|
||||
}),
|
||||
])
|
||||
.selected_index(Some(preferences.selection_mode as u32))
|
||||
.sizing(WidgetSizing::default().shrink(false))
|
||||
.widget_instance();
|
||||
let selection_mode = vec![
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
@@ -266,6 +267,7 @@ impl PreferencesDialogMessageHandler {
|
||||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
|
||||
])
|
||||
.selected_index(Some(preferences.graph_wire_style as u32))
|
||||
.sizing(WidgetSizing::default().shrink(false))
|
||||
.widget_instance();
|
||||
let graph_wire_style = vec![
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
|
||||
@@ -51,7 +51,13 @@ impl LayoutHolder for DemoArtworkDialog {
|
||||
|
||||
let buttons = chunk
|
||||
.iter()
|
||||
.map(|(name, _, filename)| TextButton::new(*name).min_width(256).flush(true).on_update(|_| make_dialog(name, filename)).widget_instance())
|
||||
.map(|(name, _, filename)| {
|
||||
TextButton::new(*name)
|
||||
.sizing(WidgetSizing::default().min_width(256))
|
||||
.flush(true)
|
||||
.on_update(|_| make_dialog(name, filename))
|
||||
.widget_instance()
|
||||
})
|
||||
.collect();
|
||||
|
||||
vec![LayoutGroup::row(images), LayoutGroup::row(buttons), LayoutGroup::row(vec![])]
|
||||
|
||||
@@ -105,10 +105,10 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
entry!(KeyDown(Minus); action_dispatch=TransformLayerMessage::TypeNegate),
|
||||
entry!(KeyDown(Comma); action_dispatch=TransformLayerMessage::TypeDecimalPoint),
|
||||
entry!(KeyDown(Period); action_dispatch=TransformLayerMessage::TypeDecimalPoint),
|
||||
entry!(PointerMove; refresh_keys=[Control, Shift], action_dispatch=TransformLayerMessage::PointerMove { slow_key: Shift, increments_key: Control }),
|
||||
entry!(PointerMove; refresh_keys=[Control, Shift, Alt, KeyQ, KeyW], action_dispatch=TransformLayerMessage::PointerMove { slow_key: Shift, increments_key: Control }),
|
||||
//
|
||||
// SelectToolMessage
|
||||
entry!(PointerMove; refresh_keys=[Control, Alt, Shift], action_dispatch=SelectToolMessage::PointerMove { modifier_keys: SelectToolPointerKeys { axis_align: Shift, snap_angle: Shift, center: Alt, duplicate: Alt } }),
|
||||
entry!(PointerMove; refresh_keys=[Control, Alt, Shift, KeyQ, KeyW], action_dispatch=SelectToolMessage::PointerMove { modifier_keys: SelectToolPointerKeys { axis_align: Shift, snap_angle: Shift, center: Alt, duplicate: Alt } }),
|
||||
entry!(KeyDown(MouseLeft); action_dispatch=SelectToolMessage::DragStart { extend_selection: Shift, remove_from_selection: Alt, select_deepest: Accel, lasso_select: Control, skew: Control }),
|
||||
entry!(KeyUp(MouseLeft); action_dispatch=SelectToolMessage::DragStop { remove_from_selection: Alt }),
|
||||
entry!(KeyDown(Enter); action_dispatch=SelectToolMessage::Enter),
|
||||
@@ -118,7 +118,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
//
|
||||
// ArtboardToolMessage
|
||||
entry!(KeyDown(MouseLeft); action_dispatch=ArtboardToolMessage::PointerDown),
|
||||
entry!(PointerMove; refresh_keys=[Shift, Alt], action_dispatch=ArtboardToolMessage::PointerMove { constrain_axis_or_aspect: Shift, center: Alt }),
|
||||
entry!(PointerMove; refresh_keys=[Shift, Alt, KeyQ, KeyW], action_dispatch=ArtboardToolMessage::PointerMove { constrain_axis_or_aspect: Shift, center: Alt }),
|
||||
entry!(KeyUp(MouseLeft); action_dispatch=ArtboardToolMessage::PointerUp),
|
||||
entry!(KeyDown(Delete); action_dispatch=ArtboardToolMessage::DeleteSelected),
|
||||
entry!(KeyDown(Backspace); action_dispatch=ArtboardToolMessage::DeleteSelected),
|
||||
@@ -166,7 +166,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
entry!(KeyDown(Escape); action_dispatch=EyedropperToolMessage::Abort),
|
||||
//
|
||||
// TextToolMessage
|
||||
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=TextToolMessage::PointerMove { center: Alt, lock_ratio: Shift }),
|
||||
entry!(PointerMove; refresh_keys=[Alt, Shift, KeyQ, KeyW], action_dispatch=TextToolMessage::PointerMove { center: Alt, lock_ratio: Shift }),
|
||||
entry!(KeyDown(MouseLeft); action_dispatch=TextToolMessage::DragStart),
|
||||
entry!(KeyUp(MouseLeft); action_dispatch=TextToolMessage::DragStop),
|
||||
entry!(KeyDown(MouseRight); action_dispatch=TextToolMessage::Abort),
|
||||
@@ -176,7 +176,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
// GradientToolMessage
|
||||
entry!(DoubleClick(MouseButton::Left); action_dispatch=GradientToolMessage::DoubleClick),
|
||||
entry!(KeyDown(MouseLeft); action_dispatch=GradientToolMessage::PointerDown),
|
||||
entry!(PointerMove; refresh_keys=[Shift, Control], action_dispatch=GradientToolMessage::PointerMove { constrain_axis: Shift, lock_angle: Control }),
|
||||
entry!(PointerMove; refresh_keys=[Shift, Control, KeyQ, KeyW], action_dispatch=GradientToolMessage::PointerMove { constrain_axis: Shift, lock_angle: Control }),
|
||||
entry!(KeyUp(MouseLeft); action_dispatch=GradientToolMessage::PointerUp),
|
||||
entry!(KeyDown(Delete); action_dispatch=GradientToolMessage::DeleteStop),
|
||||
entry!(KeyDown(Backspace); action_dispatch=GradientToolMessage::DeleteStop),
|
||||
@@ -190,7 +190,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
entry!(KeyDown(Escape); action_dispatch=ShapeToolMessage::Abort),
|
||||
entry!(KeyDown(BracketLeft); action_dispatch=ShapeToolMessage::DecreaseSides),
|
||||
entry!(KeyDown(BracketRight); action_dispatch=ShapeToolMessage::IncreaseSides),
|
||||
entry!(PointerMove; refresh_keys=[Alt, Shift, Control], action_dispatch=ShapeToolMessage::PointerMove { modifier: [Alt, Shift, Control] }),
|
||||
entry!(PointerMove; refresh_keys=[Alt, Shift, Control, KeyQ, KeyW], action_dispatch=ShapeToolMessage::PointerMove { modifier: [Alt, Shift, Control] }),
|
||||
entry!(KeyDown(ArrowUp); modifiers=[Shift, ArrowLeft], action_dispatch=ShapeToolMessage::NudgeSelectedLayers { delta_x: -BIG_NUDGE_AMOUNT, delta_y: -BIG_NUDGE_AMOUNT, resize: Alt, resize_opposite: Control }),
|
||||
entry!(KeyDown(ArrowUp); modifiers=[Shift, ArrowRight], action_dispatch=ShapeToolMessage::NudgeSelectedLayers { delta_x: BIG_NUDGE_AMOUNT, delta_y: -BIG_NUDGE_AMOUNT, resize: Alt, resize_opposite: Control }),
|
||||
entry!(KeyDown(ArrowUp); modifiers=[Shift], action_dispatch=ShapeToolMessage::NudgeSelectedLayers { delta_x: 0., delta_y: -BIG_NUDGE_AMOUNT, resize: Alt, resize_opposite: Control }),
|
||||
@@ -233,7 +233,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
entry!(KeyDown(KeyG); action_dispatch=PathToolMessage::GRS { key: KeyG }),
|
||||
entry!(KeyDown(KeyR); action_dispatch=PathToolMessage::GRS { key: KeyR }),
|
||||
entry!(KeyDown(KeyS); action_dispatch=PathToolMessage::GRS { key: KeyS }),
|
||||
entry!(PointerMove; refresh_keys=[KeyC, Space, Control, Shift, Alt], action_dispatch=PathToolMessage::PointerMove { toggle_colinear: KeyC, equidistant: Alt, move_anchor_with_handles: Space, snap_angle: Shift, lock_angle: Control, delete_segment: Alt, break_colinear_molding: Alt, segment_editing_modifier: Control }),
|
||||
entry!(PointerMove; refresh_keys=[KeyC, Space, Control, Shift, Alt, KeyQ, KeyW], action_dispatch=PathToolMessage::PointerMove { toggle_colinear: KeyC, equidistant: Alt, move_anchor_with_handles: Space, snap_angle: Shift, lock_angle: Control, delete_segment: Alt, break_colinear_molding: Alt, segment_editing_modifier: Control }),
|
||||
entry!(KeyDown(Delete); action_dispatch=PathToolMessage::Delete),
|
||||
entry!(KeyDown(KeyA); modifiers=[Accel], action_dispatch=PathToolMessage::SelectAll),
|
||||
entry!(KeyDown(KeyA); modifiers=[Accel, Shift], canonical, action_dispatch=PathToolMessage::DeselectAllSelected),
|
||||
@@ -269,7 +269,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
entry!(KeyDown(KeyJ); modifiers=[Accel], action_dispatch=ToolMessage::Path(PathToolMessage::ClosePath)),
|
||||
//
|
||||
// PenToolMessage
|
||||
entry!(PointerMove; refresh_keys=[Control, Alt, Shift, KeyC], action_dispatch=PenToolMessage::PointerMove { snap_angle: Shift, break_handle: Alt, lock_angle: Control, colinear: KeyC, move_anchor_with_handles: Space }),
|
||||
entry!(PointerMove; refresh_keys=[Control, Alt, Shift, KeyC, KeyQ, KeyW], action_dispatch=PenToolMessage::PointerMove { snap_angle: Shift, break_handle: Alt, lock_angle: Control, colinear: KeyC, move_anchor_with_handles: Space }),
|
||||
entry!(KeyDownNoRepeat(Tab); action_dispatch=PenToolMessage::SwapHandles),
|
||||
entry!(KeyDown(MouseLeft); action_dispatch=PenToolMessage::DragStart { append_to_selected: Shift }),
|
||||
entry!(KeyUp(MouseLeft); action_dispatch=PenToolMessage::DragStop),
|
||||
@@ -290,7 +290,7 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
|
||||
entry!(KeyDown(Escape); action_dispatch=FreehandToolMessage::Abort),
|
||||
//
|
||||
// SplineToolMessage
|
||||
entry!(PointerMove; action_dispatch=SplineToolMessage::PointerMove),
|
||||
entry!(PointerMove; refresh_keys=[KeyQ, KeyW], action_dispatch=SplineToolMessage::PointerMove),
|
||||
entry!(KeyDown(MouseLeft); action_dispatch=SplineToolMessage::DragStart { append_to_selected: Shift }),
|
||||
entry!(KeyUp(MouseLeft); action_dispatch=SplineToolMessage::DragStop),
|
||||
entry!(KeyDown(MouseRight); action_dispatch=SplineToolMessage::Confirm),
|
||||
|
||||
@@ -165,7 +165,7 @@ impl LayoutMessageHandler {
|
||||
}
|
||||
}
|
||||
// A section contains more LayoutGroups which we add to the stack.
|
||||
LayoutGroup::Section(WidgetSection { layout, .. }) => {
|
||||
LayoutGroup::NodeSection(NodeSection { layout, .. }) => {
|
||||
stack.extend(layout.0.iter().enumerate().map(|(index, val)| ([widget_path.as_slice(), &[index]].concat(), val)));
|
||||
}
|
||||
LayoutGroup::Table(WidgetTable { rows, .. }) => {
|
||||
@@ -435,6 +435,14 @@ impl LayoutMessageHandler {
|
||||
_ => {}
|
||||
},
|
||||
},
|
||||
Widget::ParameterChainToggle(parameter_chain_toggle) => {
|
||||
let callback_message = match action {
|
||||
WidgetValueAction::Commit => (parameter_chain_toggle.on_commit.callback)(&()),
|
||||
WidgetValueAction::Update => (parameter_chain_toggle.on_update.callback)(parameter_chain_toggle),
|
||||
};
|
||||
|
||||
responses.add(callback_message);
|
||||
}
|
||||
Widget::ParameterExposeButton(parameter_expose_button) => {
|
||||
let callback_message = match action {
|
||||
WidgetValueAction::Commit => (parameter_expose_button.on_commit.callback)(&()),
|
||||
|
||||
@@ -70,8 +70,8 @@ define_layout_target!(
|
||||
MenuBar,
|
||||
/// Bar at the top of the node graph containing the location and the "Preview" and "Hide" buttons.
|
||||
NodeGraphControlBar,
|
||||
/// The body of the Properties panel containing many collapsable sections.
|
||||
PropertiesPanel,
|
||||
/// The body of the Inspector containing many collapsable sections.
|
||||
Inspector,
|
||||
/// The contextual input key/mouse combination shortcuts shown in the status bar at the bottom of the window.
|
||||
StatusBarHints,
|
||||
/// The version information shown in the status bar at the bottom right of the window.
|
||||
@@ -295,7 +295,7 @@ impl<'a> Iterator for WidgetIter<'a> {
|
||||
self.table.extend(rows.iter().flatten().flatten().rev());
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Section(WidgetSection { layout, .. })) => {
|
||||
Some(LayoutGroup::NodeSection(NodeSection { layout, .. })) => {
|
||||
for layout_row in &layout.0 {
|
||||
self.stack.push(layout_row);
|
||||
}
|
||||
@@ -347,7 +347,7 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
||||
self.table.extend(rows.iter_mut().flatten().flatten().rev());
|
||||
self.next()
|
||||
}
|
||||
Some(LayoutGroup::Section(WidgetSection { layout, .. })) => {
|
||||
Some(LayoutGroup::NodeSection(NodeSection { layout, .. })) => {
|
||||
for layout_row in &mut layout.0 {
|
||||
self.stack.push(layout_row);
|
||||
}
|
||||
@@ -364,7 +364,7 @@ pub enum LayoutGroup {
|
||||
Column(WidgetColumn),
|
||||
Row(WidgetRow),
|
||||
Table(WidgetTable),
|
||||
Section(WidgetSection),
|
||||
NodeSection(NodeSection),
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
@@ -390,7 +390,7 @@ pub struct WidgetTable {
|
||||
pub unstyled: bool,
|
||||
}
|
||||
|
||||
/// A wire drawn between Properties panel sections, styled like the graph's wire carrying the same data.
|
||||
/// A wire drawn between Inspector sections, styled like the graph's wire carrying the same data.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct SectionWire {
|
||||
@@ -401,11 +401,11 @@ pub struct SectionWire {
|
||||
pub is_list: bool,
|
||||
}
|
||||
|
||||
/// A collapsible Properties panel section for a single node: a header with its name and pin, delete, and visibility controls, above its input parameter widgets.
|
||||
/// A collapsible Inspector section for a single node: a header with its name and pin, delete, and visibility controls, above its input parameter widgets.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetSection {
|
||||
/// The node's name shown in the section header: its given alias with the implementation name in parentheses, or just the implementation name.
|
||||
pub struct NodeSection {
|
||||
/// The node's name shown in the section header: its implementation name, followed in parentheses by its given alias if it has one.
|
||||
pub name: String,
|
||||
/// The node definition's icon, shown before the name in the section header (none when it has no icon).
|
||||
pub icon: Option<IconName>,
|
||||
@@ -413,21 +413,24 @@ pub struct WidgetSection {
|
||||
pub description: String,
|
||||
/// Whether the node is visible rather than hidden (shown as the eye icon).
|
||||
pub visible: bool,
|
||||
/// Whether the node is pinned, keeping its section shown in the Properties panel when nothing is selected (shown as the pin icon).
|
||||
/// Whether the node is pinned, keeping its section shown in the Inspector when nothing is selected (shown as the pin icon).
|
||||
pub pinned: bool,
|
||||
/// Whether this section can be dragged to reorder it within its layer's chain of nodes (true for a layer chain's nodes, but not its terminal layer node).
|
||||
pub draggable: bool,
|
||||
/// For a selected layer's own section, the wire drawn up into its chain input from its chain's sections below (none when it has no chain).
|
||||
/// For a section showing the chain feeding one of its inputs, the wire drawn up into that input from the chain's sections within it (none when it shows no chain).
|
||||
#[serde(rename = "chainWire")]
|
||||
pub chain_wire: Option<SectionWire>,
|
||||
/// For a section in a selected layer's chain, the wire drawn up to the section above, which its node's output feeds.
|
||||
/// For a section in the chain feeding another section's input, the wire drawn up to the section above, which its node's output feeds.
|
||||
#[serde(rename = "outputWire")]
|
||||
pub output_wire: Option<SectionWire>,
|
||||
/// Whether this section only refers to its node with a row like the Data panel's, in place of its header and parameters (for the layer whose stack feeds the bottom of a chain).
|
||||
#[serde(rename = "nodeReference")]
|
||||
pub node_reference: bool,
|
||||
/// Whether this section is expanded to show its contents, as opposed to being collapsed down to just its header.
|
||||
pub expanded: bool,
|
||||
/// The ID of the node whose properties this section displays.
|
||||
/// The ID of the node whose Inspector section this is.
|
||||
pub id: u64,
|
||||
/// The node's properties content, rendered as the section's body when expanded.
|
||||
/// The node's Inspector content, rendered as the section's body when expanded, followed by the sections of any chain it shows (those with an `output_wire`).
|
||||
pub layout: Layout,
|
||||
}
|
||||
|
||||
@@ -464,7 +467,7 @@ impl LayoutGroup {
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn section(name: impl Into<String>, icon: Option<IconName>, description: impl Into<String>, visible: bool, pinned: bool, expanded: bool, id: u64, layout: Layout) -> Self {
|
||||
Self::Section(WidgetSection {
|
||||
Self::NodeSection(NodeSection {
|
||||
name: name.into(),
|
||||
icon,
|
||||
description: description.into(),
|
||||
@@ -473,6 +476,7 @@ impl LayoutGroup {
|
||||
draggable: false,
|
||||
chain_wire: None,
|
||||
output_wire: None,
|
||||
node_reference: false,
|
||||
expanded,
|
||||
id,
|
||||
layout,
|
||||
@@ -498,6 +502,7 @@ impl LayoutGroup {
|
||||
Widget::ImageLabel(x) => &mut x.tooltip_description,
|
||||
Widget::MathExpressionInput(x) => &mut x.tooltip_description,
|
||||
Widget::NumberInput(x) => &mut x.tooltip_description,
|
||||
Widget::ParameterChainToggle(x) => &mut x.tooltip_description,
|
||||
Widget::PopoverButton(x) => &mut x.tooltip_description,
|
||||
Widget::TextAreaInput(x) => &mut x.tooltip_description,
|
||||
Widget::TextButton(x) => &mut x.tooltip_description,
|
||||
@@ -567,7 +572,7 @@ impl Diffable for LayoutGroup {
|
||||
}
|
||||
}
|
||||
(
|
||||
Self::Section(WidgetSection {
|
||||
Self::NodeSection(NodeSection {
|
||||
name: current_name,
|
||||
icon: current_icon,
|
||||
description: current_description,
|
||||
@@ -576,11 +581,12 @@ impl Diffable for LayoutGroup {
|
||||
draggable: current_draggable,
|
||||
chain_wire: current_chain_wire,
|
||||
output_wire: current_output_wire,
|
||||
node_reference: current_node_reference,
|
||||
expanded: current_expanded,
|
||||
id: current_id,
|
||||
layout: current_layout,
|
||||
}),
|
||||
Self::Section(WidgetSection {
|
||||
Self::NodeSection(NodeSection {
|
||||
name: new_name,
|
||||
icon: new_icon,
|
||||
description: new_description,
|
||||
@@ -589,6 +595,7 @@ impl Diffable for LayoutGroup {
|
||||
draggable: new_draggable,
|
||||
chain_wire: new_chain_wire,
|
||||
output_wire: new_output_wire,
|
||||
node_reference: new_node_reference,
|
||||
expanded: new_expanded,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
@@ -605,6 +612,7 @@ impl Diffable for LayoutGroup {
|
||||
|| *current_draggable != new_draggable
|
||||
|| *current_chain_wire != new_chain_wire
|
||||
|| *current_output_wire != new_output_wire
|
||||
|| *current_node_reference != new_node_reference
|
||||
|| *current_expanded != new_expanded
|
||||
|| *current_id != new_id
|
||||
{
|
||||
@@ -617,12 +625,13 @@ impl Diffable for LayoutGroup {
|
||||
*current_draggable = new_draggable;
|
||||
*current_chain_wire = new_chain_wire;
|
||||
*current_output_wire = new_output_wire;
|
||||
*current_node_reference = new_node_reference;
|
||||
*current_expanded = new_expanded;
|
||||
*current_id = new_id;
|
||||
current_layout.clone_from(&new_layout);
|
||||
|
||||
// Push an update layout group to the diff
|
||||
let new_value = Self::Section(WidgetSection {
|
||||
let new_value = Self::NodeSection(NodeSection {
|
||||
name: new_name,
|
||||
icon: new_icon,
|
||||
description: new_description,
|
||||
@@ -631,6 +640,7 @@ impl Diffable for LayoutGroup {
|
||||
draggable: new_draggable,
|
||||
chain_wire: new_chain_wire,
|
||||
output_wire: new_output_wire,
|
||||
node_reference: new_node_reference,
|
||||
expanded: new_expanded,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
@@ -681,7 +691,7 @@ impl Diffable for LayoutGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::Section(WidgetSection { layout, .. }) => {
|
||||
Self::NodeSection(NodeSection { layout, .. }) => {
|
||||
layout.collect_checkbox_ids(layout_target, widget_path, checkbox_map);
|
||||
}
|
||||
}
|
||||
@@ -711,7 +721,7 @@ impl Diffable for LayoutGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::Section(WidgetSection { layout, .. }) => {
|
||||
Self::NodeSection(NodeSection { layout, .. }) => {
|
||||
layout.replace_widget_ids(layout_target, widget_path, checkbox_map);
|
||||
}
|
||||
}
|
||||
@@ -877,6 +887,7 @@ pub enum Widget {
|
||||
ShortcutLabel(ShortcutLabel),
|
||||
NodeCatalog(NodeCatalog),
|
||||
NumberInput(NumberInput),
|
||||
ParameterChainToggle(ParameterChainToggle),
|
||||
ParameterExposeButton(ParameterExposeButton),
|
||||
ReferencePointInput(ReferencePointInput),
|
||||
PopoverButton(PopoverButton),
|
||||
@@ -891,12 +902,78 @@ pub enum Widget {
|
||||
WorkingColorsInput(WorkingColorsInput),
|
||||
}
|
||||
|
||||
/// How a widget claims width within its row, borrowing the model of flexbox. Parts left unset follow the defaults of the layout it appears in.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WidgetSizing {
|
||||
/// The width in pixels before growing or shrinking.
|
||||
pub basis: Option<u32>,
|
||||
/// Whether it widens into spare room in its row.
|
||||
pub grow: Option<bool>,
|
||||
/// Whether it narrows below its starting width when its row runs out of room.
|
||||
pub shrink: Option<bool>,
|
||||
/// The narrowest it can be, in pixels.
|
||||
pub min_width: Option<u32>,
|
||||
/// The widest it can be, in pixels.
|
||||
pub max_width: Option<u32>,
|
||||
}
|
||||
|
||||
impl WidgetSizing {
|
||||
/// Exactly this many pixels wide, neither growing nor shrinking.
|
||||
pub const fn fixed(width: u32) -> Self {
|
||||
Self {
|
||||
basis: Some(width),
|
||||
grow: Some(false),
|
||||
shrink: Some(false),
|
||||
min_width: Some(width),
|
||||
max_width: Some(width),
|
||||
}
|
||||
}
|
||||
|
||||
/// As wide as its content, neither growing nor shrinking.
|
||||
pub const fn hug() -> Self {
|
||||
Self {
|
||||
basis: None,
|
||||
grow: Some(false),
|
||||
shrink: Some(false),
|
||||
min_width: None,
|
||||
max_width: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn basis(mut self, width: u32) -> Self {
|
||||
self.basis = Some(width);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn grow(mut self, grow: bool) -> Self {
|
||||
self.grow = Some(grow);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn shrink(mut self, shrink: bool) -> Self {
|
||||
self.shrink = Some(shrink);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn min_width(mut self, width: u32) -> Self {
|
||||
self.min_width = Some(width);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn max_width(mut self, width: u32) -> Self {
|
||||
self.max_width = Some(width);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// A single change to part of the UI, containing the location of the change and the new value.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetDiff {
|
||||
/// A path to the change
|
||||
/// e.g. [0, 1, 2] in the Properties panel is the first section, second row and third widget.
|
||||
/// e.g. [0, 1, 2] in the Inspector is the first section, second row and third widget.
|
||||
/// An empty path [] shows that the entire panel has changed and is sent when the UI is first created.
|
||||
#[serde(rename = "widgetPath")]
|
||||
pub widget_path: Vec<usize>,
|
||||
@@ -930,6 +1007,7 @@ impl DiffUpdate {
|
||||
Widget::DropdownInput(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::IconButton(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::NumberInput(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::ParameterChainToggle(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::ParameterExposeButton(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::PopoverButton(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
Widget::TextButton(widget) => widget.tooltip_shortcut.as_mut(),
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
|
||||
use crate::messages::tool::tool_messages::tool_prelude::WidgetCallback;
|
||||
use derivative::*;
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_std::color::SRGBA8;
|
||||
use graphene_std::vector::style::FillChoice;
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
@@ -113,15 +112,6 @@ pub struct ParameterExposeButton {
|
||||
pub exposed: bool,
|
||||
#[serde(rename = "dataType")]
|
||||
pub data_type: FrontendGraphDataType,
|
||||
/// The node whose input this connector represents, so it can be dragged to and from as a wire endpoint.
|
||||
#[serde(rename = "nodeId")]
|
||||
pub node_id: NodeId,
|
||||
/// A `u32` so it reaches the frontend as a number rather than a bigint.
|
||||
#[serde(rename = "inputIndex")]
|
||||
pub input_index: u32,
|
||||
/// Whether the wire currently being dragged in the graph can be dropped onto this connector.
|
||||
#[serde(rename = "wireDropTarget")]
|
||||
pub wire_drop_target: bool,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
@@ -140,6 +130,33 @@ pub struct ParameterExposeButton {
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
/// A parameter's name, for an input fed by a chain of nodes, that shows or hides that chain's sections within its node's Inspector section.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
pub struct ParameterChainToggle {
|
||||
// Content
|
||||
#[widget_builder(constructor)]
|
||||
pub name: String,
|
||||
pub expanded: bool,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
pub tooltip_label: String,
|
||||
#[serde(rename = "tooltipDescription")]
|
||||
pub tooltip_description: String,
|
||||
#[serde(rename = "tooltipShortcut")]
|
||||
pub tooltip_shortcut: Option<ActionShortcut>,
|
||||
|
||||
// Callbacks
|
||||
#[serde(skip)]
|
||||
#[derivative(Debug = "ignore", PartialEq = "ignore")]
|
||||
pub on_update: WidgetCallback<ParameterChainToggle>,
|
||||
#[serde(skip)]
|
||||
#[derivative(Debug = "ignore", PartialEq = "ignore")]
|
||||
pub on_commit: WidgetCallback<()>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Default, WidgetBuilder)]
|
||||
#[derivative(Debug, PartialEq)]
|
||||
@@ -164,10 +181,7 @@ pub struct TextButton {
|
||||
pub emphasized: bool,
|
||||
pub flush: bool,
|
||||
pub narrow: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
pub sizing: WidgetSizing,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
@@ -234,14 +248,9 @@ pub struct ColorInput {
|
||||
pub disabled: bool,
|
||||
pub mixed: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
#[serde(rename = "maxWidth")]
|
||||
pub max_width: u32,
|
||||
|
||||
// Styling
|
||||
pub narrow: bool,
|
||||
pub sizing: WidgetSizing,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
|
||||
@@ -77,23 +77,19 @@ pub struct DropdownInput {
|
||||
|
||||
// Styling
|
||||
pub narrow: bool,
|
||||
pub sizing: WidgetSizing,
|
||||
// Sized to the selected entry, rather than the widest, so its width changes with the selection
|
||||
#[serde(rename = "sizedToSelection")]
|
||||
pub sized_to_selection: bool,
|
||||
|
||||
// Behavior
|
||||
#[serde(rename = "virtualScrolling")]
|
||||
pub virtual_scrolling: bool,
|
||||
#[derivative(Default(value = "true"))]
|
||||
pub interactive: bool,
|
||||
// Set along with the `on_file_drop` callback
|
||||
#[serde(rename = "takesFileDrop")]
|
||||
#[widget_builder(skip)]
|
||||
pub takes_file_drop: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
#[serde(rename = "maxWidth")]
|
||||
pub max_width: u32,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
pub tooltip_label: String,
|
||||
@@ -222,6 +218,7 @@ pub struct NumberInput {
|
||||
|
||||
// Styling
|
||||
pub narrow: bool,
|
||||
pub sizing: WidgetSizing,
|
||||
|
||||
// Behavior
|
||||
pub mode: NumberInputMode,
|
||||
@@ -248,12 +245,6 @@ pub struct NumberInput {
|
||||
#[derivative(Default(value = "true"))]
|
||||
pub unit_is_hidden_when_editing: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
#[serde(rename = "maxWidth")]
|
||||
pub max_width: u32,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
pub tooltip_label: String,
|
||||
@@ -367,10 +358,7 @@ pub struct RadioInput {
|
||||
|
||||
// Styling
|
||||
pub narrow: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
pub sizing: WidgetSizing,
|
||||
//
|
||||
// Callbacks exists on the `RadioEntryData` children, not this parent `RadioInput`
|
||||
}
|
||||
@@ -481,12 +469,7 @@ pub struct TextInput {
|
||||
// Styling
|
||||
pub narrow: bool,
|
||||
pub centered: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
#[serde(rename = "maxWidth")]
|
||||
pub max_width: u32,
|
||||
pub sizing: WidgetSizing,
|
||||
|
||||
// Tooltips
|
||||
#[serde(rename = "tooltipLabel")]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::input_widgets::CheckboxId;
|
||||
use crate::messages::layout::utility_types::layout_widget::WidgetSizing;
|
||||
use crate::messages::{frontend::IconName, input_mapper::utility_types::misc::ActionShortcut};
|
||||
use derivative::*;
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
@@ -70,12 +71,7 @@ pub struct TextLabel {
|
||||
pub center_align: bool,
|
||||
#[serde(rename = "tableAlign")]
|
||||
pub table_align: bool,
|
||||
|
||||
// Sizing
|
||||
#[serde(rename = "minWidth")]
|
||||
pub min_width: u32,
|
||||
#[serde(rename = "maxWidth")]
|
||||
pub max_width: u32,
|
||||
pub sizing: WidgetSizing,
|
||||
#[serde(rename = "minWidthCharacters")]
|
||||
pub min_width_characters: u32,
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ pub struct MenuBarMessageHandler {
|
||||
pub make_path_editable_is_allowed: bool,
|
||||
pub data_panel_open: bool,
|
||||
pub layers_panel_open: bool,
|
||||
pub properties_panel_open: bool,
|
||||
pub inspector_open: bool,
|
||||
pub focus_document: bool,
|
||||
}
|
||||
|
||||
@@ -669,11 +669,11 @@ impl LayoutHolder for MenuBarMessageHandler {
|
||||
.on_commit(|_| WorkspaceMessage::ResetWorkspaceLayout.into()),
|
||||
],
|
||||
vec![
|
||||
MenuListEntry::new("Properties")
|
||||
.label("Properties")
|
||||
.icon(if self.properties_panel_open { "CheckboxChecked" } else { "CheckboxUnchecked" })
|
||||
.tooltip_shortcut(action_shortcut!(WorkspaceMessageDiscriminant::TogglePropertiesPanelOpen))
|
||||
.on_commit(|_| WorkspaceMessage::TogglePropertiesPanelOpen.into())
|
||||
MenuListEntry::new("Inspector")
|
||||
.label("Inspector")
|
||||
.icon(if self.inspector_open { "CheckboxChecked" } else { "CheckboxUnchecked" })
|
||||
.tooltip_shortcut(action_shortcut!(WorkspaceMessageDiscriminant::ToggleInspectorOpen))
|
||||
.on_commit(|_| WorkspaceMessage::ToggleInspectorOpen.into())
|
||||
.disabled(self.focus_document),
|
||||
MenuListEntry::new("Layers")
|
||||
.label("Layers")
|
||||
|
||||
@@ -127,32 +127,13 @@ impl DataPanelMessageHandler {
|
||||
|
||||
let mut widgets = Vec::new();
|
||||
|
||||
// Selected layer/node name
|
||||
// The selected layer or node, by its icon and name
|
||||
if let Some((node_id, parent_path)) = self.introspected_node_path.split_last() {
|
||||
let node_id = *node_id;
|
||||
let is_layer = network_interface.is_layer(&node_id, parent_path);
|
||||
let parent_path_owned = parent_path.to_vec();
|
||||
|
||||
widgets.extend([
|
||||
if is_layer {
|
||||
IconLabel::new("Layer").tooltip_description("Name of the selected layer.").widget_instance()
|
||||
} else {
|
||||
IconLabel::new("Node").tooltip_description("Name of the selected node.").widget_instance()
|
||||
},
|
||||
IconLabel::new(network_interface.node_icon(node_id, parent_path)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextInput::new(network_interface.display_name(&node_id, parent_path))
|
||||
.tooltip_description(if is_layer { "Name of the selected layer." } else { "Name of the selected node." })
|
||||
.on_update(move |text_input| {
|
||||
NodeGraphMessage::SetDisplayName {
|
||||
node_id,
|
||||
network_path: parent_path_owned.clone(),
|
||||
alias: text_input.value.clone(),
|
||||
skip_adding_history_step: false,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.max_width(200)
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextLabel::new(network_interface.display_name(node_id, parent_path)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
]);
|
||||
}
|
||||
@@ -406,7 +387,7 @@ impl<T: TableItemLayout> TableItemLayout for Item<T> {
|
||||
let target = PathStep::Attribute { row: 0, key: key.clone() };
|
||||
let cell = self.attributes().get_any(key).and_then(|any| dispatch_value_widgets(any, target, data)).unwrap_or_else(|| {
|
||||
let text = self.attributes().display_value(key, display_value_override).unwrap_or_else(|| "-".to_string());
|
||||
vec![TextLabel::new(text).narrow(true).widget_instance()]
|
||||
vec![text_preview_label(text)]
|
||||
});
|
||||
values.push(cell);
|
||||
}
|
||||
@@ -470,7 +451,7 @@ impl<T: TableItemLayout> TableItemLayout for List<T> {
|
||||
let target = PathStep::Attribute { row: index, key: key.clone() };
|
||||
let cell = self.attribute_any(key, index).and_then(|any| dispatch_value_widgets(any, target, data)).unwrap_or_else(|| {
|
||||
let text = self.attribute_display_value(key, index, display_value_override).unwrap_or_else(|| "-".to_string());
|
||||
vec![TextLabel::new(text).narrow(true).widget_instance()]
|
||||
vec![text_preview_label(text)]
|
||||
});
|
||||
values.push(cell);
|
||||
}
|
||||
@@ -938,6 +919,14 @@ fn string_preview(value: &str) -> String {
|
||||
first_line.chars().take(MAX_CHARACTERS - 1).chain(['…']).collect()
|
||||
}
|
||||
|
||||
/// Shows text in a table cell as a string preview, with the full text as its tooltip when the preview cuts it short.
|
||||
fn text_preview_label(text: String) -> WidgetInstance {
|
||||
let preview = string_preview(&text);
|
||||
let tooltip = if preview == text { String::new() } else { text };
|
||||
|
||||
TextLabel::new(preview).narrow(true).tooltip_label(tooltip).widget_instance()
|
||||
}
|
||||
|
||||
impl TableItemLayout for DVec2 {
|
||||
fn type_name() -> &'static str {
|
||||
"Vec2"
|
||||
@@ -1086,6 +1075,35 @@ fn node_id_display_label(node_id: NodeId, network_interface: &NodeNetworkInterfa
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to a node, as a button with its icon and name that selects it with the message from `select`.
|
||||
pub fn node_reference_button(
|
||||
node_id: NodeId,
|
||||
network_interface: &NodeNetworkInterface,
|
||||
network_path: &[NodeId],
|
||||
selection_network_path: &[NodeId],
|
||||
select: impl Fn() -> Message + Send + Sync + 'static,
|
||||
) -> WidgetInstance {
|
||||
let is_layer = network_interface.is_layer(&node_id, network_path);
|
||||
let icon = network_interface.node_icon(&node_id, network_path);
|
||||
let name = network_interface.display_name(&node_id, network_path);
|
||||
let in_open_network = network_path == selection_network_path;
|
||||
let already_selected = network_interface.selected_nodes_in_nested_network(network_path).is_some_and(|selected| selected.0 == [node_id]);
|
||||
|
||||
TextButton::new(name)
|
||||
.icon(icon)
|
||||
.disabled(!in_open_network || already_selected)
|
||||
.tooltip_label(if is_layer { "Select Layer" } else { "Select Node" })
|
||||
.tooltip_description(match (in_open_network, already_selected, is_layer) {
|
||||
(false, _, true) => "This layer is not in the part of the graph currently open.",
|
||||
(false, _, false) => "This node is not in the part of the graph currently open.",
|
||||
(true, true, true) => "This is already the selected layer.",
|
||||
(true, true, false) => "This is already the selected node.",
|
||||
(true, false, _) => "",
|
||||
})
|
||||
.on_update(move |_| select())
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
impl TableItemLayout for NodeId {
|
||||
fn type_name() -> &'static str {
|
||||
"NodeId"
|
||||
@@ -1098,7 +1116,7 @@ impl TableItemLayout for NodeId {
|
||||
data.breadcrumbs.push(node_id_display_label(*self, data.network_interface, &data.node_lookup_network_path));
|
||||
self.value_page(data)
|
||||
}
|
||||
// Shown inline as the node's icon, name, a button to select it, and visibility and lock toggles. The lookups use
|
||||
// Shown inline as a button with the node's icon and name that selects it. The lookups use
|
||||
// `data.node_lookup_network_path` (set by the enclosing `List<NodeId>` if rendering a path) so they resolve at any nesting depth.
|
||||
fn value_widgets(&self, _target: PathStep, data: &LayoutData) -> Vec<WidgetInstance> {
|
||||
let node_id = *self;
|
||||
@@ -1110,63 +1128,14 @@ impl TableItemLayout for NodeId {
|
||||
return vec![TextLabel::new(node_id_display_label(node_id, network_interface, &network_path)).widget_instance()];
|
||||
}
|
||||
|
||||
let is_layer = network_interface.is_layer(&node_id, &network_path);
|
||||
let is_locked = network_interface.is_locked(&node_id, &network_path);
|
||||
let is_visible = network_interface.is_visible(&node_id, &network_path);
|
||||
let icon = network_interface.node_icon(&node_id, &network_path);
|
||||
let name = network_interface.display_name(&node_id, &network_path);
|
||||
let in_open_network = network_path == data.selection_network_path;
|
||||
let already_selected = network_interface.selected_nodes_in_nested_network(&network_path).is_some_and(|selected| selected.0 == [node_id]);
|
||||
|
||||
let path_for_visibility = network_path.clone();
|
||||
let path_for_lock = network_path;
|
||||
|
||||
vec![
|
||||
IconLabel::new(icon).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextLabel::new(name).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
IconButton::new("SelectAll", 24)
|
||||
.disabled(!in_open_network || already_selected)
|
||||
.tooltip_label(if is_layer { "Select Layer" } else { "Select Node" })
|
||||
.tooltip_description(match (in_open_network, already_selected, is_layer) {
|
||||
(false, _, true) => "This layer is not in the part of the graph currently open.",
|
||||
(false, _, false) => "This node is not in the part of the graph currently open.",
|
||||
(true, true, true) => "This is already the selected layer.",
|
||||
(true, true, false) => "This is already the selected node.",
|
||||
(true, false, _) => "",
|
||||
})
|
||||
// Starts from the root of the newly selected node's data, since the current drill-down path means nothing there
|
||||
.on_update(move |_| Message::Batched {
|
||||
messages: Box::new([DataPanelMessage::TruncateElementPath { len: 0 }.into(), NodeGraphMessage::SelectedNodesSet { nodes: vec![node_id] }.into()]),
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
IconButton::new(if is_visible { "EyeVisible" } else { "EyeHidden" }, 24)
|
||||
.hover_icon(if is_visible { "EyeHide" } else { "EyeShow" })
|
||||
.tooltip_label(if is_visible { "Hide" } else { "Show" })
|
||||
.on_update(move |_| {
|
||||
NodeGraphMessage::ToggleVisibility {
|
||||
node_id,
|
||||
network_path: path_for_visibility.clone(),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
IconButton::new(if is_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24)
|
||||
.hover_icon(if is_locked { "PadlockUnlocked" } else { "PadlockLocked" })
|
||||
.disabled(!is_layer)
|
||||
.tooltip_label(if is_locked { "Unlock" } else { "Lock" })
|
||||
.tooltip_description(if is_layer { "" } else { "Only layers can be locked." })
|
||||
.on_update(move |_| {
|
||||
NodeGraphMessage::ToggleLocked {
|
||||
node_id,
|
||||
network_path: path_for_lock.clone(),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
]
|
||||
// Selecting starts from the root of the newly selected node's data, since the current drill-down path means nothing there
|
||||
let select = move || Message::Batched {
|
||||
messages: Box::new([
|
||||
DataPanelMessage::TruncateElementPath { len: 0 }.into(),
|
||||
NodeGraphMessage::SelectedNodesSet { nodes: vec![node_id] }.into(),
|
||||
]),
|
||||
};
|
||||
vec![node_reference_button(node_id, network_interface, &network_path, data.selection_network_path, select)]
|
||||
}
|
||||
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
vec![LayoutGroup::row(self.value_widgets(PathStep::Element(0), data))]
|
||||
|
||||
@@ -34,7 +34,7 @@ pub enum DocumentMessage {
|
||||
#[child]
|
||||
Overlays(OverlaysMessage),
|
||||
#[child]
|
||||
PropertiesPanel(PropertiesPanelMessage),
|
||||
Inspector(InspectorMessage),
|
||||
#[child]
|
||||
DataPanel(DataPanelMessage),
|
||||
#[child]
|
||||
@@ -104,7 +104,7 @@ pub enum DocumentMessage {
|
||||
parent: LayerNodeIdentifier,
|
||||
insert_index: usize,
|
||||
},
|
||||
ReorderPropertiesSection {
|
||||
ReorderInspectorSection {
|
||||
node_id: NodeId,
|
||||
insert_index: usize,
|
||||
duplicate: bool,
|
||||
@@ -249,10 +249,17 @@ pub enum DocumentMessage {
|
||||
tree_path: Vec<NodeId>,
|
||||
recursive: bool,
|
||||
},
|
||||
ToggleNodePropertiesSectionExpanded {
|
||||
ToggleNodeInspectorSectionExpanded {
|
||||
node_id: NodeId,
|
||||
recursive: bool,
|
||||
},
|
||||
ToggleNodeInspectorInputChain {
|
||||
node_id: NodeId,
|
||||
input_index: usize,
|
||||
},
|
||||
ToggleLayerChainExpanded {
|
||||
layer_id: NodeId,
|
||||
},
|
||||
ToggleSelectedVisibility,
|
||||
ToggleSelectedLocked,
|
||||
ToggleGridVisibility,
|
||||
@@ -262,6 +269,7 @@ pub enum DocumentMessage {
|
||||
upstream_footprints: HashMap<NodeId, Footprint>,
|
||||
local_transforms: HashMap<NodeId, DAffine2>,
|
||||
first_element_source_id: HashMap<NodeId, Option<NodeId>>,
|
||||
document_to_viewport: DAffine2,
|
||||
},
|
||||
UpdateClickTargets {
|
||||
click_targets: HashMap<NodeId, Vec<Arc<ClickTarget>>>,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::document_diff::diff_networks;
|
||||
use super::node_graph::document_node_definitions;
|
||||
use super::node_graph::{document_node_definitions, node_inspector};
|
||||
use super::utility_types::error::EditorError;
|
||||
use super::utility_types::misc::{GroupFolderType, SNAP_FUNCTIONS_FOR_BOUNDING_BOXES, SNAP_FUNCTIONS_FOR_PATHS, SnappingOptions, SnappingState};
|
||||
use super::utility_types::network_interface::{self, NodeNetworkInterface, TransactionStatus};
|
||||
@@ -8,18 +8,17 @@ use super::{CursorMoveError, DocumentHistory};
|
||||
use crate::application::{GRAPHITE_GIT_COMMIT_HASH, generate_uuid};
|
||||
use crate::consts::{
|
||||
ASYMPTOTIC_EFFECT, BLEND_COUNT_PER_LAYER, COLOR_OVERLAY_GRAY, DEFAULT_DOCUMENT_NAME, FILE_EXTENSION, GDD_FILE_EXTENSION, LAYER_INDENT_OFFSET, NODE_CHAIN_WIDTH, SCALE_EFFECT, SCROLLBAR_SPACING,
|
||||
VIEWPORT_ROTATE_SNAP_INTERVAL,
|
||||
};
|
||||
use crate::messages::frontend::utility_types::FileFilter;
|
||||
use crate::messages::input_mapper::utility_types::macros::action_shortcut;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::data_panel::{DataPanelMessageContext, DataPanelMessageHandler};
|
||||
use crate::messages::portfolio::document::graph_operation::utility_types::{ModifyInputsContext, TransformIn};
|
||||
use crate::messages::portfolio::document::inspector::inspector_message_handler::InspectorMessageContext;
|
||||
use crate::messages::portfolio::document::node_graph::NodeGraphMessageContext;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
||||
use crate::messages::portfolio::document::overlays::grid_overlays::{grid_overlay, overlay_options};
|
||||
use crate::messages::portfolio::document::overlays::utility_types::{OverlaysType, OverlaysVisibilitySettings, Pivot};
|
||||
use crate::messages::portfolio::document::properties_panel::properties_panel_message_handler::PropertiesPanelMessageContext;
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
|
||||
use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, FlipAxis, PTZ};
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::{ChainInsertionPoint, FlowType, InputConnector, NodeTemplate, OutputConnector};
|
||||
@@ -65,7 +64,7 @@ pub struct DocumentMessageContext<'a> {
|
||||
pub preferences: &'a PreferencesMessageHandler,
|
||||
pub data_panel_open: bool,
|
||||
pub layers_panel_open: bool,
|
||||
pub properties_panel_open: bool,
|
||||
pub inspector_open: bool,
|
||||
pub viewport: &'a ViewportMessageHandler,
|
||||
pub resource_storage: &'a ResourceStorageMessageHandler,
|
||||
pub fonts: &'a FontsMessageHandler,
|
||||
@@ -96,7 +95,7 @@ pub struct DocumentMessageHandler {
|
||||
#[serde(skip)]
|
||||
pub overlays_message_handler: OverlaysMessageHandler,
|
||||
#[serde(skip)]
|
||||
pub properties_panel_message_handler: PropertiesPanelMessageHandler,
|
||||
pub inspector_message_handler: InspectorMessageHandler,
|
||||
#[serde(skip)]
|
||||
pub data_panel_message_handler: DataPanelMessageHandler,
|
||||
|
||||
@@ -112,9 +111,15 @@ pub struct DocumentMessageHandler {
|
||||
/// Tracks which layer occurrences are collapsed in the Layers panel, keyed by tree path.
|
||||
#[serde(deserialize_with = "deserialize_collapsed_layers", default)]
|
||||
pub collapsed: CollapsedLayers,
|
||||
/// The node IDs whose section is collapsed in the Properties panel.
|
||||
/// The node IDs whose section is collapsed in the Inspector.
|
||||
#[serde(default, alias = "properties_panel_collapsed_sections")]
|
||||
pub inspector_collapsed_sections: Vec<NodeId>,
|
||||
/// The input (if any) whose feeding chain a node's Inspector section shows within it, for each node where that differs from the default of a layer's chain input.
|
||||
#[serde(default)]
|
||||
pub properties_panel_collapsed_sections: Vec<NodeId>,
|
||||
pub inspector_expanded_input_chains: Vec<(NodeId, Option<usize>)>,
|
||||
/// The layer node IDs whose chain is expanded into a row per node in the Layers panel.
|
||||
#[serde(default)]
|
||||
pub layers_panel_expanded_chains: Vec<NodeId>,
|
||||
/// The full Git commit hash of the Graphite repository that was used to build the editor.
|
||||
/// We save this to provide a hint about which version of the editor was used to create the document.
|
||||
#[serde(skip_deserializing, default)]
|
||||
@@ -195,7 +200,7 @@ impl Default for DocumentMessageHandler {
|
||||
navigation_handler: NavigationMessageHandler::default(),
|
||||
node_graph_handler: NodeGraphMessageHandler::default(),
|
||||
overlays_message_handler: OverlaysMessageHandler::default(),
|
||||
properties_panel_message_handler: PropertiesPanelMessageHandler::default(),
|
||||
inspector_message_handler: InspectorMessageHandler::default(),
|
||||
data_panel_message_handler: DataPanelMessageHandler::default(),
|
||||
// ============================================
|
||||
// Fields that are saved in the document format
|
||||
@@ -203,7 +208,9 @@ impl Default for DocumentMessageHandler {
|
||||
network_interface: default_document_network_interface(),
|
||||
resources: ResourceMessageHandler::default(),
|
||||
collapsed: CollapsedLayers::default(),
|
||||
properties_panel_collapsed_sections: Vec::new(),
|
||||
inspector_collapsed_sections: Vec::new(),
|
||||
inspector_expanded_input_chains: Vec::new(),
|
||||
layers_panel_expanded_chains: Vec::new(),
|
||||
commit_hash: GRAPHITE_GIT_COMMIT_HASH.to_string(),
|
||||
document_ptz: PTZ::default(),
|
||||
render_mode: RenderMode::default(),
|
||||
@@ -246,7 +253,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
preferences,
|
||||
data_panel_open,
|
||||
layers_panel_open,
|
||||
properties_panel_open,
|
||||
inspector_open,
|
||||
resource_storage,
|
||||
fonts,
|
||||
} = context;
|
||||
@@ -273,21 +280,19 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
self.overlays_message_handler
|
||||
.process_message(message, responses, OverlaysMessageContext { visibility_settings, viewport });
|
||||
}
|
||||
DocumentMessage::PropertiesPanel(message) => {
|
||||
let wire_in_progress_output_types = self.node_graph_handler.wire_in_progress_output_types(&self.network_interface, &self.selection_network_path);
|
||||
let context = PropertiesPanelMessageContext {
|
||||
DocumentMessage::Inspector(message) => {
|
||||
let context = InspectorMessageContext {
|
||||
executor,
|
||||
document_id,
|
||||
network_interface: &mut self.network_interface,
|
||||
resources: &self.resources,
|
||||
selection_network_path: &self.selection_network_path,
|
||||
document_name: self.name.as_str(),
|
||||
fonts,
|
||||
properties_panel_open,
|
||||
properties_panel_collapsed_sections: &self.properties_panel_collapsed_sections,
|
||||
wire_in_progress_output_types: &wire_in_progress_output_types,
|
||||
inspector_open,
|
||||
inspector_collapsed_sections: &self.inspector_collapsed_sections,
|
||||
inspector_expanded_input_chains: &self.inspector_expanded_input_chains,
|
||||
};
|
||||
self.properties_panel_message_handler.process_message(message, responses, context);
|
||||
self.inspector_message_handler.process_message(message, responses, context);
|
||||
}
|
||||
DocumentMessage::DataPanel(message) => {
|
||||
self.data_panel_message_handler.process_message(
|
||||
@@ -310,7 +315,9 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
breadcrumb_network_path: &self.breadcrumb_network_path,
|
||||
document_id,
|
||||
collapsed: &mut self.collapsed,
|
||||
properties_panel_collapsed_sections: &mut self.properties_panel_collapsed_sections,
|
||||
inspector_collapsed_sections: &mut self.inspector_collapsed_sections,
|
||||
inspector_expanded_input_chains: &mut self.inspector_expanded_input_chains,
|
||||
layers_panel_expanded_chains: &mut self.layers_panel_expanded_chains,
|
||||
ipp,
|
||||
graph_view_overlay_open: self.graph_view_overlay_open,
|
||||
graph_fade_artwork_percentage: self.graph_fade_artwork_percentage,
|
||||
@@ -540,7 +547,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
DocumentMessage::DuplicateSelectedLayersTo { parent, insert_index } => {
|
||||
if !self.selection_network_path.is_empty() {
|
||||
@@ -609,6 +616,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
DocumentMessage::EnterNestedNetwork { node_id } => {
|
||||
self.node_graph_handler.leave_network(&mut self.network_interface, &self.breadcrumb_network_path, responses);
|
||||
self.breadcrumb_network_path.push(node_id);
|
||||
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
|
||||
responses.add(NodeGraphMessage::UnloadWires);
|
||||
@@ -637,13 +645,12 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
self.node_graph_handler.end_wire_in_progress(&mut self.network_interface, &self.selection_network_path, responses);
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
}
|
||||
// Abort reordering an import or export
|
||||
else if self.node_graph_handler.is_reordering_import_export() {
|
||||
self.node_graph_handler.abort_import_export_reorder(responses);
|
||||
}
|
||||
// Close the context menu if it's open
|
||||
else if self
|
||||
.node_graph_handler
|
||||
.context_menu
|
||||
.as_ref()
|
||||
.is_some_and(|context_menu| matches!(context_menu.context_menu_data, super::node_graph::utility_types::ContextMenuData::CreateNode { compatible_type: None }))
|
||||
{
|
||||
else if self.node_graph_handler.context_menu.is_some() {
|
||||
self.node_graph_handler.context_menu = None;
|
||||
responses.add(FrontendMessage::UpdateContextMenuInformation { context_menu_information: None });
|
||||
}
|
||||
@@ -657,6 +664,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
}
|
||||
}
|
||||
DocumentMessage::ExitNestedNetwork { steps_back } => {
|
||||
self.node_graph_handler.leave_network(&mut self.network_interface, &self.breadcrumb_network_path, responses);
|
||||
for _ in 0..steps_back {
|
||||
self.breadcrumb_network_path.pop();
|
||||
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
|
||||
@@ -738,8 +746,12 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
responses.add(NodeGraphMessage::UpdateGraphBarRight);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(NodeGraphMessage::UpdateHints);
|
||||
responses.add(NodeGraphMessage::UpdateEdges);
|
||||
} else {
|
||||
// The closed graph won't get the pointer up that ends a wire drag, so abandon it as Escape would
|
||||
if self.end_node_graph_wire_in_progress(responses) {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
}
|
||||
|
||||
responses.add(ToolMessage::ActivateTool { tool_type: *current_tool });
|
||||
responses.add(OverlaysMessage::Draw); // Redraw overlays when graph is closed
|
||||
}
|
||||
@@ -807,8 +819,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
DocumentMessage::MoveSelectedLayersTo { parent, insert_index } => {
|
||||
self.move_selected_layers_to(parent, insert_index, responses);
|
||||
}
|
||||
DocumentMessage::ReorderPropertiesSection { node_id, insert_index, duplicate } => {
|
||||
// The Properties panel shows draggable sections in two cases, disambiguated by the current selection:
|
||||
DocumentMessage::ReorderInspectorSection { node_id, insert_index, duplicate } => {
|
||||
// The Inspector shows draggable sections in two cases, disambiguated by the current selection:
|
||||
// a single selected layer (reorder within its node chain) or no selection (reorder the pinned nodes).
|
||||
let selected_nodes = self.network_interface.selected_nodes_in_nested_network(&self.selection_network_path);
|
||||
let Some(selected_nodes) = selected_nodes else { return };
|
||||
@@ -839,10 +851,10 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
responses.add(DocumentMessage::MoveChainNodes { node_ids, layer, insert_index });
|
||||
}
|
||||
} else if layers.is_empty() && nodes.is_empty() {
|
||||
// Reorder a pinned node, which is purely a Properties panel display order (no graph rerender needed, and nothing to duplicate into)
|
||||
// Reorder a pinned node, which is purely a Inspector display order (no graph rerender needed, and nothing to duplicate into)
|
||||
responses.add(DocumentMessage::AddTransaction);
|
||||
responses.add(NodeGraphMessage::ReorderPinnedNode { node_id, insert_index });
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
}
|
||||
DocumentMessage::MoveChainNodes { node_ids, layer, insert_index } => {
|
||||
@@ -851,7 +863,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
responses.add(NodeGraphMessage::MoveChainNodes { node_ids, layer, insert_index });
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
DocumentMessage::DuplicateChainNodes {
|
||||
node_ids,
|
||||
@@ -871,7 +883,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
});
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
DocumentMessage::PasteChainNodes { copies } => {
|
||||
// Layers and their chains live in the document network, so a nested one open in the graph has no chain to paste into
|
||||
@@ -913,7 +925,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
}
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
DocumentMessage::PasteNodes { nodes } => {
|
||||
// Over the same selection they were copied from, nodes are duplicated into their flow, and otherwise they're pasted loose into the graph and shown there
|
||||
@@ -1460,7 +1472,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
PanelType::Layers => self.selection_network_path = vec![],
|
||||
_ => {}
|
||||
}
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
responses.add(NodeGraphMessage::UpdateLayerPanel);
|
||||
responses.add(NodeGraphMessage::UpdateInSelectedNetwork);
|
||||
}
|
||||
@@ -1652,28 +1664,48 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
}
|
||||
DocumentMessage::ToggleNodePropertiesSectionExpanded { node_id, recursive } => {
|
||||
let expand = self.properties_panel_collapsed_sections.contains(&node_id);
|
||||
DocumentMessage::ToggleNodeInspectorSectionExpanded { node_id, recursive } => {
|
||||
let expand = self.inspector_collapsed_sections.contains(&node_id);
|
||||
|
||||
// Recursively, every section in the chain follows along, from its layer back to where another layer begins
|
||||
let network_path = &self.selection_network_path;
|
||||
let chain = recursive
|
||||
.then(|| self.network_interface.downstream_layer_for_chain_node(&node_id, network_path))
|
||||
.flatten()
|
||||
.map(|layer| std::iter::once(layer).chain(self.network_interface.layer_chain_nodes(layer, network_path)).collect::<Vec<_>>())
|
||||
// A node that only leads into a chain from the side, or into no layer at all, isn't part of one
|
||||
.filter(|chain| chain.contains(&node_id));
|
||||
let node_ids = chain.unwrap_or_else(|| vec![node_id]);
|
||||
// Recursively, every section nested within this one follows along
|
||||
let node_ids = if recursive {
|
||||
node_inspector::nested_section_nodes(node_id, &self.inspector_expanded_input_chains, &self.network_interface, &self.selection_network_path)
|
||||
} else {
|
||||
vec![node_id]
|
||||
};
|
||||
|
||||
for node_id in node_ids {
|
||||
if expand {
|
||||
self.properties_panel_collapsed_sections.retain(|id| *id != node_id);
|
||||
} else if !self.properties_panel_collapsed_sections.contains(&node_id) {
|
||||
self.properties_panel_collapsed_sections.push(node_id);
|
||||
self.inspector_collapsed_sections.retain(|id| *id != node_id);
|
||||
} else if !self.inspector_collapsed_sections.contains(&node_id) {
|
||||
self.inspector_collapsed_sections.push(node_id);
|
||||
}
|
||||
}
|
||||
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
DocumentMessage::ToggleNodeInspectorInputChain { node_id, input_index } => {
|
||||
// A section shows at most one input's chain, so showing this one hides any other
|
||||
let network_path = &self.selection_network_path;
|
||||
let default = node_inspector::default_expanded_input_chain(&node_id, &self.network_interface, network_path);
|
||||
let current = node_inspector::expanded_input_chain(&node_id, &self.inspector_expanded_input_chains, &self.network_interface, network_path);
|
||||
let expanded = (current != Some(input_index)).then_some(input_index);
|
||||
|
||||
self.inspector_expanded_input_chains.retain(|(id, _)| *id != node_id);
|
||||
if expanded != default {
|
||||
self.inspector_expanded_input_chains.push((node_id, expanded));
|
||||
}
|
||||
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
DocumentMessage::ToggleLayerChainExpanded { layer_id } => {
|
||||
if self.layers_panel_expanded_chains.contains(&layer_id) {
|
||||
self.layers_panel_expanded_chains.retain(|id| *id != layer_id);
|
||||
} else {
|
||||
self.layers_panel_expanded_chains.push(layer_id);
|
||||
}
|
||||
|
||||
responses.add(NodeGraphMessage::UpdateLayerPanel);
|
||||
}
|
||||
DocumentMessage::ToggleSelectedLocked => responses.add(NodeGraphMessage::ToggleSelectedLocked),
|
||||
DocumentMessage::ToggleSelectedVisibility => {
|
||||
@@ -1697,8 +1729,9 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
upstream_footprints,
|
||||
local_transforms,
|
||||
first_element_source_id,
|
||||
document_to_viewport,
|
||||
} => {
|
||||
self.network_interface.update_transforms(upstream_footprints, local_transforms);
|
||||
self.network_interface.update_transforms(upstream_footprints, local_transforms, document_to_viewport);
|
||||
self.network_interface.update_first_element_source_id(first_element_source_id);
|
||||
}
|
||||
DocumentMessage::UpdateClickTargets { click_targets } => {
|
||||
@@ -1890,7 +1923,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
||||
|
||||
responses.add(DocumentMessage::RenderRulers);
|
||||
responses.add(DocumentMessage::RenderScrollbars);
|
||||
responses.add(NodeGraphMessage::UpdateEdges);
|
||||
responses.add(NodeGraphMessage::UpdateBoxSelection);
|
||||
responses.add(NodeGraphMessage::UpdateImportsExports);
|
||||
|
||||
@@ -2773,6 +2805,16 @@ impl DocumentMessageHandler {
|
||||
self.graph_view_overlay_open
|
||||
}
|
||||
|
||||
/// Ends any wire being dragged in the node graph, collapsing a node expanded for it, and returns whether there was one.
|
||||
pub fn end_node_graph_wire_in_progress(&mut self, responses: &mut VecDeque<Message>) -> bool {
|
||||
if self.node_graph_handler.wire_in_progress_from_connector.is_none() {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.node_graph_handler.end_wire_in_progress(&mut self.network_interface, &self.selection_network_path, responses);
|
||||
true
|
||||
}
|
||||
|
||||
pub fn set_auto_save_state(&mut self, is_saved: bool) {
|
||||
if is_saved {
|
||||
self.auto_saved_hash = Some(self.current_hash());
|
||||
@@ -3700,39 +3742,9 @@ impl DocumentMessageHandler {
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
];
|
||||
|
||||
widgets.extend(navigation_controls(&self.document_ptz, &self.navigation_handler, false));
|
||||
|
||||
let tilt_value = self.navigation_handler.snapped_tilt(self.document_ptz.tilt()) / (std::f64::consts::PI / 180.);
|
||||
if tilt_value.abs() > 0.00001 {
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(tilt_value))
|
||||
.unit("°")
|
||||
.increment_behavior(NumberInputIncrementBehavior::Callback)
|
||||
.increment_callback_increase(|number_input: &NumberInput| {
|
||||
let one = 1. + f64::EPSILON * 100.;
|
||||
NavigationMessage::CanvasTiltSet {
|
||||
angle_radians: ((number_input.value.unwrap() / VIEWPORT_ROTATE_SNAP_INTERVAL + one).floor() * VIEWPORT_ROTATE_SNAP_INTERVAL).to_radians(),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.increment_callback_decrease(|number_input: &NumberInput| {
|
||||
let one = 1. + f64::EPSILON * 100.;
|
||||
NavigationMessage::CanvasTiltSet {
|
||||
angle_radians: ((number_input.value.unwrap() / VIEWPORT_ROTATE_SNAP_INTERVAL - one).ceil() * VIEWPORT_ROTATE_SNAP_INTERVAL).to_radians(),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.tooltip_label("Canvas Tilt")
|
||||
.on_update(|number_input: &NumberInput| {
|
||||
NavigationMessage::CanvasTiltSet {
|
||||
angle_radians: number_input.value.unwrap().to_radians(),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
// Layers only exist in the document network, so a selection inside a subgraph has none to frame
|
||||
let has_selection = self.selection_network_path().is_empty() && self.network_interface.selected_nodes().selected_visible_layers(&self.network_interface).next().is_some();
|
||||
widgets.extend(navigation_controls(&self.document_ptz, &self.navigation_handler, false, has_selection));
|
||||
|
||||
widgets.extend([
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
@@ -3829,7 +3841,7 @@ impl DocumentMessageHandler {
|
||||
.selected_index(blend_mode.and_then(|blend_mode| blend_mode.index_in_list_svg_subset()).map(|index| index as u32))
|
||||
.disabled(disabled)
|
||||
.draw_icon(false)
|
||||
.max_width(100)
|
||||
.sizing(WidgetSizing::default().grow(false))
|
||||
.tooltip_label("Blend Mode")
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
@@ -3851,7 +3863,7 @@ impl DocumentMessageHandler {
|
||||
}
|
||||
})
|
||||
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
||||
.max_width(100)
|
||||
.sizing(WidgetSizing::default().max_width(100))
|
||||
.tooltip_label("Opacity")
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
@@ -3873,7 +3885,7 @@ impl DocumentMessageHandler {
|
||||
}
|
||||
})
|
||||
.on_commit(|_| DocumentMessage::AddTransaction.into())
|
||||
.max_width(100)
|
||||
.sizing(WidgetSizing::default().max_width(100))
|
||||
.tooltip_label("Fill Opacity")
|
||||
.widget_instance(),
|
||||
];
|
||||
@@ -4247,42 +4259,131 @@ impl<'a> ClickXRayIter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHandler, node_graph: bool) -> Vec<WidgetInstance> {
|
||||
let mut list = vec![
|
||||
IconButton::new("ZoomIn", 24)
|
||||
.tooltip_label("Zoom In")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasZoomIncrease))
|
||||
.on_update(|_| NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }.into())
|
||||
.widget_instance(),
|
||||
IconButton::new("ZoomOut", 24)
|
||||
.tooltip_label("Zoom Out")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasZoomDecrease))
|
||||
.on_update(|_| NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }.into())
|
||||
.widget_instance(),
|
||||
IconButton::new("ZoomReset", 24)
|
||||
.tooltip_label("Reset Tilt and Zoom to 100%")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasTiltResetAndZoomTo100Percent))
|
||||
.on_update(|_| NavigationMessage::CanvasTiltResetAndZoomTo100Percent.into())
|
||||
.disabled(ptz.tilt().abs() < 1e-4 && (ptz.zoom() - 1.).abs() < 1e-4)
|
||||
.widget_instance(),
|
||||
/// The zoom field and a popover of the other view controls.
|
||||
pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHandler, node_graph: bool, has_selection: bool) -> Vec<WidgetInstance> {
|
||||
let tilt_degrees = navigation_handler.snapped_tilt(ptz.tilt()).to_degrees();
|
||||
let tilted = tilt_degrees.abs() > 0.00001;
|
||||
|
||||
let row_label = |label: &str| TextLabel::new(label).table_align(true).sizing(WidgetSizing::fixed(40)).widget_instance();
|
||||
|
||||
// Buttons line up in four equal columns, with the fit buttons and the tilt field each spanning two
|
||||
let column = WidgetSizing::fixed(52);
|
||||
let half_row = WidgetSizing::default().basis(0).grow(true);
|
||||
|
||||
// Framing the content, then stepping and preset zoom levels
|
||||
let mut popover = vec![
|
||||
LayoutGroup::row(vec![
|
||||
TextLabel::new("View").bold(true).table_align(true).sizing(WidgetSizing::fixed(40)).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
TextButton::new("All")
|
||||
.icon("FrameAll")
|
||||
.tooltip_label("Zoom to Fit")
|
||||
.tooltip_description(if node_graph {
|
||||
"Frames all the nodes."
|
||||
} else {
|
||||
"Frames all the artwork, without zooming in past 100%, and undoes any tilt or flip."
|
||||
})
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ZoomCanvasToFitAll))
|
||||
.sizing(half_row)
|
||||
.on_update(|_| DocumentMessage::ZoomCanvasToFitAll.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextButton::new("Selection")
|
||||
.icon("FrameSelected")
|
||||
.tooltip_label("Zoom to Selection")
|
||||
.tooltip_description(if node_graph { "Frames the selected nodes." } else { "Frames the selected layers." })
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::FitViewportToSelection))
|
||||
.sizing(half_row)
|
||||
.disabled(!has_selection)
|
||||
.on_update(|_| NavigationMessage::FitViewportToSelection.into())
|
||||
.widget_instance(),
|
||||
]),
|
||||
LayoutGroup::row(vec![
|
||||
row_label("Zoom"),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
TextButton::new("")
|
||||
.icon("ZoomOut")
|
||||
.tooltip_label("Zoom Out")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasZoomDecrease))
|
||||
.sizing(column)
|
||||
.on_update(|_| NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextButton::new("")
|
||||
.icon("ZoomIn")
|
||||
.tooltip_label("Zoom In")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasZoomIncrease))
|
||||
.sizing(column)
|
||||
.on_update(|_| NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextButton::new("100%")
|
||||
.tooltip_label("Zoom to 100%")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ZoomCanvasTo100Percent))
|
||||
.sizing(column)
|
||||
.on_update(|_| DocumentMessage::ZoomCanvasTo100Percent.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextButton::new("200%")
|
||||
.tooltip_label("Zoom to 200%")
|
||||
.tooltip_shortcut(action_shortcut!(DocumentMessageDiscriminant::ZoomCanvasTo200Percent))
|
||||
.sizing(column)
|
||||
.on_update(|_| DocumentMessage::ZoomCanvasTo200Percent.into())
|
||||
.widget_instance(),
|
||||
]),
|
||||
];
|
||||
if ptz.flip && !node_graph {
|
||||
list.push(
|
||||
IconButton::new("Reverse", 24)
|
||||
.tooltip_label("Unflip Canvas")
|
||||
.tooltip_description("Flip the canvas back to its standard orientation.")
|
||||
|
||||
// The node graph can't be tilted or flipped
|
||||
if !node_graph {
|
||||
popover.push(LayoutGroup::row(vec![
|
||||
row_label("Tilt"),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(tilt_degrees))
|
||||
.unit("°")
|
||||
.mode(NumberInputMode::Range)
|
||||
.range_min(Some(-180.))
|
||||
.range_max(Some(180.))
|
||||
.tooltip_label("Canvas Tilt")
|
||||
.on_update(|number_input: &NumberInput| {
|
||||
NavigationMessage::CanvasTiltSet {
|
||||
angle_radians: number_input.value.unwrap().to_radians(),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextButton::new("")
|
||||
.icon("TiltReset")
|
||||
.tooltip_label("Reset Tilt")
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasTiltSet))
|
||||
.sizing(column)
|
||||
.disabled(!tilted)
|
||||
.on_update(|_| NavigationMessage::CanvasTiltSet { angle_radians: 0. }.into())
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
TextButton::new("")
|
||||
.icon("FlipHorizontal")
|
||||
.emphasized(ptz.flip)
|
||||
.tooltip_label(if ptz.flip { "Unflip Canvas" } else { "Flip Canvas" })
|
||||
.tooltip_description(if ptz.flip {
|
||||
"Flip the canvas back to its standard orientation."
|
||||
} else {
|
||||
"Mirrors the view horizontally without changing the artwork."
|
||||
})
|
||||
.tooltip_shortcut(action_shortcut!(NavigationMessageDiscriminant::CanvasFlip))
|
||||
.sizing(column)
|
||||
.on_update(|_| NavigationMessage::CanvasFlip.into())
|
||||
.widget_instance(),
|
||||
);
|
||||
]));
|
||||
}
|
||||
list.extend([
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
|
||||
vec![
|
||||
NumberInput::new(Some(navigation_handler.snapped_zoom(ptz.zoom()) * 100.))
|
||||
.unit("%")
|
||||
.min(0.000001)
|
||||
.max(1000000.)
|
||||
.tooltip_label(if node_graph { "Node Graph Zoom" } else { "Canvas Zoom" })
|
||||
.sizing(WidgetSizing::default().min_width(80))
|
||||
.on_update(|number_input: &NumberInput| {
|
||||
NavigationMessage::CanvasZoomSet {
|
||||
zoom_factor: number_input.value.unwrap() / 100.,
|
||||
@@ -4293,8 +4394,8 @@ pub fn navigation_controls(ptz: &PTZ, navigation_handler: &NavigationMessageHand
|
||||
.increment_callback_decrease(|_| NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }.into())
|
||||
.increment_callback_increase(|_| NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }.into())
|
||||
.widget_instance(),
|
||||
]);
|
||||
list
|
||||
PopoverButton::new().popover_layout(Layout(popover)).tooltip_label("View Options").widget_instance(),
|
||||
]
|
||||
}
|
||||
|
||||
impl Iterator for ClickXRayIter<'_> {
|
||||
|
||||
+47
-1
@@ -138,7 +138,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for
|
||||
return;
|
||||
};
|
||||
if set_stroke_paint_order(network_interface, &[], stroke_node_id, paint_order) {
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
}
|
||||
@@ -1111,6 +1111,52 @@ mod tests {
|
||||
assert_eq!(paint_order, PaintOrder::StrokeAbove, "the rewrite should move the stroke back upstream of the fill");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn stroke_order_set_keeps_the_layer_chain_in_place() {
|
||||
use crate::test_utils::test_prelude::*;
|
||||
use graphene_std::vector::style::PaintOrder;
|
||||
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
|
||||
let layer = editor.active_document().metadata().all_layers().next().unwrap();
|
||||
|
||||
// Each node of the layer's chain from the layer outward, with its offset from the layer if it is chain-positioned
|
||||
let chain_layout = |editor: &EditorTestUtils| {
|
||||
let interface = &editor.active_document().network_interface;
|
||||
let layer_position = interface.position(&layer.to_node(), &[]).unwrap_or_default();
|
||||
interface
|
||||
.layer_chain_nodes(layer.to_node(), &[])
|
||||
.into_iter()
|
||||
.map(|node_id| {
|
||||
let offset = interface.is_chain(&node_id, &[]).then(|| interface.position(&node_id, &[]).unwrap_or_default() - layer_position);
|
||||
(interface.display_name(&node_id, &[]), offset)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
let original = chain_layout(&editor);
|
||||
assert!(
|
||||
original.iter().all(|(_, offset)| offset.is_some()),
|
||||
"a fresh shape's nodes should all be chain-positioned: {original:?}"
|
||||
);
|
||||
|
||||
editor
|
||||
.handle_message(GraphOperationMessage::StrokeOrderSet {
|
||||
layer,
|
||||
paint_order: PaintOrder::StrokeBelow,
|
||||
})
|
||||
.await;
|
||||
|
||||
// Only the Fill and Stroke nodes trade places, so the chain keeps every slot
|
||||
let swap_name = |name: &str| match name {
|
||||
"Fill" => "Stroke".to_string(),
|
||||
"Stroke" => "Fill".to_string(),
|
||||
other => other.to_string(),
|
||||
};
|
||||
let expected = original.iter().map(|(name, offset)| (swap_name(name), *offset)).collect::<Vec<_>>();
|
||||
assert_eq!(chain_layout(&editor), expected, "the swap should leave the layer's chain intact");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_node_inserted_between_the_fill_and_stroke_makes_the_order_swap_inapplicable() {
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_proto_node_type;
|
||||
|
||||
@@ -752,7 +752,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
};
|
||||
|
||||
transform_utils::update_transform(self.network_interface, &transform_node_id, last_transform_value);
|
||||
self.responses.add(PropertiesPanelMessage::Refresh);
|
||||
self.responses.add(InspectorMessage::Refresh);
|
||||
self.responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
|
||||
@@ -959,7 +959,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
transform_utils::update_transform(self.network_interface, &transform_node_id, transform);
|
||||
|
||||
// Refresh the render and editor UI
|
||||
self.responses.add(PropertiesPanelMessage::Refresh);
|
||||
self.responses.add(InspectorMessage::Refresh);
|
||||
if !skip_rerender {
|
||||
self.responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
@@ -970,7 +970,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
return;
|
||||
};
|
||||
self.network_interface.vector_modify(&path_node_id, modification_type);
|
||||
self.responses.add(PropertiesPanelMessage::Refresh);
|
||||
self.responses.add(InspectorMessage::Refresh);
|
||||
self.responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
|
||||
@@ -1002,10 +1002,10 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Set the input, refresh the Properties panel, and run the document graph if skip_rerender is false
|
||||
/// Set the input, refresh the Inspector, and run the document graph if skip_rerender is false
|
||||
pub fn set_input_with_refresh(&mut self, input_connector: InputConnector, input: NodeInput, skip_rerender: bool) {
|
||||
self.network_interface.set_input(&input_connector, input, &[]);
|
||||
self.responses.add(PropertiesPanelMessage::Refresh);
|
||||
self.responses.add(InspectorMessage::Refresh);
|
||||
if !skip_rerender {
|
||||
self.responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
@@ -1057,6 +1057,14 @@ pub fn set_stroke_paint_order(network_interface: &mut NodeNetworkInterface, netw
|
||||
};
|
||||
let downstream_consumers = primary_output_consumers(network_interface, network_path, downstream);
|
||||
|
||||
// The rewiring knocks chain nodes out to absolute positions, so record how the pair and the chain feeding it were placed
|
||||
let original_placements = network_interface
|
||||
.upstream_flow_back_from_nodes(vec![downstream], network_path, FlowType::HorizontalFlow)
|
||||
.enumerate()
|
||||
.take_while(|(index, node_id)| *index < 2 || network_interface.is_chain(node_id, network_path))
|
||||
.map(|(_, node_id)| (node_id, network_interface.is_chain(&node_id, network_path), network_interface.position(&node_id, network_path)))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
network_interface.set_input(&InputConnector::node_at_index(downstream, 0), upstream_source, network_path);
|
||||
network_interface.set_input(&InputConnector::node_at_index(upstream, 0), NodeInput::node(downstream, 0), network_path);
|
||||
for consumer in &downstream_consumers {
|
||||
@@ -1066,5 +1074,15 @@ pub fn set_stroke_paint_order(network_interface: &mut NodeNetworkInterface, netw
|
||||
network_interface.set_input(consumer, NodeInput::node(upstream, 0), network_path);
|
||||
}
|
||||
|
||||
// Each node of the pair takes over the other's place, and the chain feeding the pair is restored as it was
|
||||
let swapped_nodes = [upstream, downstream].into_iter().chain(original_placements.iter().skip(2).map(|(node_id, _, _)| *node_id));
|
||||
for (node_id, (_, was_chain, position)) in swapped_nodes.zip(&original_placements) {
|
||||
if *was_chain {
|
||||
network_interface.set_chain_position(&node_id, network_path);
|
||||
} else if let Some(position) = position {
|
||||
network_interface.set_absolute_position(&node_id, *position, network_path);
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
#[impl_message(Message, DocumentMessage, PropertiesPanel)]
|
||||
#[impl_message(Message, DocumentMessage, Inspector)]
|
||||
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub enum PropertiesPanelMessage {
|
||||
pub enum InspectorMessage {
|
||||
// Messages
|
||||
Clear,
|
||||
Refresh,
|
||||
@@ -0,0 +1,77 @@
|
||||
use graphene_std::uuid::NodeId;
|
||||
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::NodeInspectorContext;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::NodeNetworkInterface;
|
||||
use crate::messages::prelude::*;
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
|
||||
#[derive(ExtractField)]
|
||||
pub struct InspectorMessageContext<'a> {
|
||||
pub executor: &'a mut NodeGraphExecutor,
|
||||
pub document_id: DocumentId,
|
||||
pub network_interface: &'a mut NodeNetworkInterface,
|
||||
pub resources: &'a ResourceMessageHandler,
|
||||
pub selection_network_path: &'a [NodeId],
|
||||
pub fonts: &'a FontsMessageHandler,
|
||||
pub inspector_open: bool,
|
||||
pub inspector_collapsed_sections: &'a [NodeId],
|
||||
pub inspector_expanded_input_chains: &'a [(NodeId, Option<usize>)],
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, ExtractField)]
|
||||
pub struct InspectorMessageHandler {}
|
||||
|
||||
#[message_handler_data]
|
||||
impl MessageHandler<InspectorMessage, InspectorMessageContext<'_>> for InspectorMessageHandler {
|
||||
fn process_message(&mut self, message: InspectorMessage, responses: &mut VecDeque<Message>, context: InspectorMessageContext) {
|
||||
let InspectorMessageContext {
|
||||
executor,
|
||||
document_id,
|
||||
network_interface,
|
||||
resources,
|
||||
selection_network_path,
|
||||
fonts,
|
||||
inspector_open,
|
||||
inspector_collapsed_sections,
|
||||
inspector_expanded_input_chains,
|
||||
} = context;
|
||||
|
||||
match message {
|
||||
InspectorMessage::Clear => {
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::default(),
|
||||
layout_target: LayoutTarget::Inspector,
|
||||
});
|
||||
}
|
||||
InspectorMessage::Refresh => {
|
||||
if !inspector_open {
|
||||
responses.add(InspectorMessage::Clear);
|
||||
return;
|
||||
}
|
||||
|
||||
let mut node_inspector_context = NodeInspectorContext {
|
||||
responses,
|
||||
executor,
|
||||
document_id,
|
||||
network_interface,
|
||||
resources,
|
||||
selection_network_path,
|
||||
fonts,
|
||||
inspector_collapsed_sections,
|
||||
inspector_expanded_input_chains,
|
||||
};
|
||||
let layout = Layout(NodeGraphMessageHandler::collate_inspector_sections(&mut node_inspector_context));
|
||||
|
||||
node_inspector_context.responses.add(LayoutMessage::SendLayout {
|
||||
layout,
|
||||
layout_target: LayoutTarget::Inspector,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn actions(&self) -> ActionList {
|
||||
actions!(InspectorMessageDiscriminant;)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
mod inspector_message;
|
||||
pub mod inspector_message_handler;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use inspector_message::{InspectorMessage, InspectorMessageDiscriminant};
|
||||
#[doc(inline)]
|
||||
pub use inspector_message_handler::InspectorMessageHandler;
|
||||
@@ -7,10 +7,10 @@ pub(crate) mod storage_tests;
|
||||
|
||||
pub mod data_panel;
|
||||
pub mod graph_operation;
|
||||
pub mod inspector;
|
||||
pub mod navigation;
|
||||
pub mod node_graph;
|
||||
pub mod overlays;
|
||||
pub mod properties_panel;
|
||||
pub mod resource;
|
||||
pub mod utility_types;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ pub enum NavigationMessage {
|
||||
CanvasPanAbort { x_not_y_axis: bool },
|
||||
CanvasPanByViewportFraction { delta: DVec2 },
|
||||
CanvasPanMouseWheel { use_y_as_x: bool, artwork_behind_graph: bool },
|
||||
CanvasTiltResetAndZoomTo100Percent,
|
||||
CanvasTiltSet { angle_radians: f64 },
|
||||
CanvasZoomDecrease { center_on_mouse: bool },
|
||||
CanvasZoomIncrease { center_on_mouse: bool },
|
||||
|
||||
@@ -196,20 +196,6 @@ impl MessageHandler<NavigationMessage, NavigationMessageContext<'_>> for Navigat
|
||||
} * -VIEWPORT_SCROLL_RATE;
|
||||
responses.add(NavigationMessage::CanvasPan { delta });
|
||||
}
|
||||
NavigationMessage::CanvasTiltResetAndZoomTo100Percent => {
|
||||
let Some(ptz) = get_ptz_mut(document_ptz, network_interface, graph_view_overlay_open, breadcrumb_network_path) else {
|
||||
log::error!("Could not get mutable PTZ in CanvasTiltResetAndZoomTo100Percent");
|
||||
return;
|
||||
};
|
||||
ptz.set_tilt(0.);
|
||||
ptz.set_zoom(1.);
|
||||
if graph_view_overlay_open {
|
||||
responses.add(NodeGraphMessage::UpdateGraphBarRight);
|
||||
} else {
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
}
|
||||
responses.add(DocumentMessage::PTZUpdate);
|
||||
}
|
||||
NavigationMessage::CanvasTiltSet { angle_radians } => {
|
||||
let Some(ptz) = get_ptz_mut(document_ptz, network_interface, graph_view_overlay_open, breadcrumb_network_path) else {
|
||||
log::error!("Could not get mutable PTZ in CanvasTiltSet");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod document_node_derive;
|
||||
|
||||
use super::node_properties::choice::enum_choice;
|
||||
use super::node_properties::{self, ParameterWidgetsInfo, SliderRange};
|
||||
use super::node_inspector::choice::enum_choice;
|
||||
use super::node_inspector::{self, ParameterWidgetsInfo, SliderRange};
|
||||
use super::utility_types::{FrontendNodeType, InputTypeConstraint};
|
||||
use crate::messages::frontend::IconName;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
@@ -23,7 +23,7 @@ use graphene_std::vector::Vector;
|
||||
use graphene_std::*;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
pub struct NodePropertiesContext<'a> {
|
||||
pub struct NodeInspectorContext<'a> {
|
||||
pub responses: &'a mut VecDeque<Message>,
|
||||
pub executor: &'a mut NodeGraphExecutor,
|
||||
pub document_id: DocumentId,
|
||||
@@ -31,20 +31,19 @@ pub struct NodePropertiesContext<'a> {
|
||||
pub resources: &'a ResourceMessageHandler,
|
||||
pub fonts: &'a FontsMessageHandler,
|
||||
pub selection_network_path: &'a [NodeId],
|
||||
pub document_name: &'a str,
|
||||
/// The node IDs whose Properties panel sections the user has collapsed.
|
||||
pub properties_panel_collapsed_sections: &'a [NodeId],
|
||||
/// The types a wire being dragged from an output could carry, so compatible inputs can be marked as drop targets.
|
||||
pub wire_in_progress_output_types: &'a [Type],
|
||||
/// The node IDs whose Inspector sections the user has collapsed.
|
||||
pub inspector_collapsed_sections: &'a [NodeId],
|
||||
/// The input (if any) whose feeding chain a node's section shows, for each node where that differs from the default.
|
||||
pub inspector_expanded_input_chains: &'a [(NodeId, Option<usize>)],
|
||||
}
|
||||
|
||||
impl NodePropertiesContext<'_> {
|
||||
impl NodeInspectorContext<'_> {
|
||||
pub fn call_widget_override(&mut self, node_id: &NodeId, index: usize) -> Option<Vec<LayoutGroup>> {
|
||||
let input_properties_row = self.network_interface.persistent_input_metadata(node_id, index, self.selection_network_path)?;
|
||||
let input_inspector_row = self.network_interface.persistent_input_metadata(node_id, index, self.selection_network_path)?;
|
||||
|
||||
// The stored override wins, falling back to the definition's own so documents saved before it gained one still
|
||||
// pick it up. Only `Custom` is recovered, since the other kinds also need input data stored at insertion time.
|
||||
let widget_override = input_properties_row.widget_override.clone().or_else(|| {
|
||||
let widget_override = input_inspector_row.widget_override.clone().or_else(|| {
|
||||
let implementation = self.network_interface.implementation(node_id, self.selection_network_path)?;
|
||||
let DocumentNodeImplementation::ProtoNode(proto_node_identifier) = implementation else {
|
||||
return None;
|
||||
@@ -139,8 +138,8 @@ pub struct DocumentNodeDefinition {
|
||||
|
||||
/// Node level overrides are stored based on the reference, not the instance. If the node is modified such that it becomes a local version
|
||||
/// (for example an input is added), the reference is no longer to the definition, and the overrides are lost.
|
||||
/// Most nodes should not use node based properties, since they are less flexible than input level properties.
|
||||
pub properties: Option<&'static str>,
|
||||
/// Most nodes should not use a node-level Inspector override, since it is less flexible than an input-level override.
|
||||
pub inspector: Option<&'static str>,
|
||||
}
|
||||
|
||||
// We use the once_cell to use the document node definitions throughout the editor without passing a reference
|
||||
@@ -162,7 +161,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("An empty node network you can use to create your own custom nodes."),
|
||||
properties: None,
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Merge",
|
||||
@@ -228,13 +227,17 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: vec![NodeInput::type_default(list!(Graphic), true), NodeInput::type_default(list!(Graphic), true)],
|
||||
input_metadata: vec![("Base", "TODO").into(), ("Content", "TODO").into()],
|
||||
input_metadata: vec![
|
||||
("Base", "The stack of layers below this one, which the content is placed above.").into(),
|
||||
("Content", "The artwork this layer adds to the stack as a single item.").into(),
|
||||
],
|
||||
output_names: vec!["Out".to_string()],
|
||||
output_descriptions: vec!["The stack of layers with this layer's content placed on top.".to_string()],
|
||||
node_type_metadata: NodeTypePersistentMetadata::layer(IVec2::new(0, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("Merges the provided content as a new item in the layer's compositing stack."),
|
||||
properties: None,
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Artboard",
|
||||
@@ -310,11 +313,11 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
NodeInput::value(TaggedValue::Bool(true), false),
|
||||
],
|
||||
input_metadata: vec![
|
||||
("Base", "TODO").into(),
|
||||
InputMetadata::with_name_description_override("Content", "TODO", WidgetOverride::Hidden),
|
||||
("Base", "The stack of artboards below this one, which this artboard is placed above.").into(),
|
||||
("Content", "Graphics to include within the artboard.").into(),
|
||||
InputMetadata::with_name_description_override(
|
||||
"Location",
|
||||
"TODO",
|
||||
"Coordinate of the top-left corner of the artboard within the document.",
|
||||
WidgetOverride::Vec2(Vec2InputSettings {
|
||||
x: "X".to_string(),
|
||||
y: "Y".to_string(),
|
||||
@@ -325,7 +328,7 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
),
|
||||
InputMetadata::with_name_description_override(
|
||||
"Dimensions",
|
||||
"TODO",
|
||||
"Width and height of the artboard within the document.",
|
||||
WidgetOverride::Vec2(Vec2InputSettings {
|
||||
x: "W".to_string(),
|
||||
y: "H".to_string(),
|
||||
@@ -334,15 +337,16 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
..Default::default()
|
||||
}),
|
||||
),
|
||||
InputMetadata::with_name_description_override("Background", "TODO", WidgetOverride::Custom("artboard_background".to_string())),
|
||||
("Clip", "TODO").into(),
|
||||
InputMetadata::with_name_description_override("Background", "Color of the artboard background.", WidgetOverride::Custom("artboard_background".to_string())),
|
||||
("Clip", "Whether to cut off the contained content that extends outside the artboard, or keep it visible.").into(),
|
||||
],
|
||||
output_names: vec!["Out".to_string()],
|
||||
output_descriptions: vec!["The stack of artboards with this artboard placed on top.".to_string()],
|
||||
node_type_metadata: NodeTypePersistentMetadata::layer(IVec2::new(0, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("Creates a new Artboard which can be used as a working surface."),
|
||||
properties: None,
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Blend",
|
||||
@@ -506,18 +510,27 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
NodeInput::type_default(item!(Vector), false),
|
||||
],
|
||||
input_metadata: vec![
|
||||
("Content", "TODO").into(),
|
||||
("Count", "TODO").into(),
|
||||
("Reverse", "TODO").into(),
|
||||
("Distribution", "TODO").into(),
|
||||
("Path", "TODO").into(),
|
||||
("Content", "The vector objects to create intermediate shapes between.").into(),
|
||||
(
|
||||
"Count",
|
||||
"The number of shapes spanning from the first object to the last, repeated for each subpath of the control path.",
|
||||
)
|
||||
.into(),
|
||||
("Reverse", "Flip the stacking order of the shapes, so the ones nearest the first object are on top.").into(),
|
||||
("Distribution", "What changes evenly from one shape to the next, which sets how the intermediate shapes are spaced.").into(),
|
||||
(
|
||||
"Path",
|
||||
"An optional control path with one anchor point per object. Curved segments shape the trajectory of the blend instead of traveling straight.",
|
||||
)
|
||||
.into(),
|
||||
],
|
||||
output_names: vec!["Out".to_string()],
|
||||
output_descriptions: vec!["The blended shapes, from the first object to the last.".to_string()],
|
||||
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(0, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("TODO"),
|
||||
properties: None,
|
||||
description: Cow::Borrowed("Creates a series of intermediate shapes that gradually transition between vector objects, optionally along a control path."),
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Origins to Polyline",
|
||||
@@ -591,13 +604,14 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: vec![NodeInput::type_default(list!(Vector), true)],
|
||||
input_metadata: vec![("Vector", "TODO").into()],
|
||||
input_metadata: vec![("Vector", "The vector objects to connect in order by their origins.").into()],
|
||||
output_names: vec!["Vector".to_string()],
|
||||
output_descriptions: vec!["An open polyline with an anchor point at the origin of each object.".to_string()],
|
||||
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(0, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("TODO"),
|
||||
properties: None,
|
||||
description: Cow::Borrowed("Connects the origins of vector objects in order with an open polyline, such as to make a control path for the **Blend** and **Morph** nodes."),
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Load Image",
|
||||
@@ -627,12 +641,16 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: vec![NodeInput::value(TaggedValue::None, false), NodeInput::value(TaggedValue::String("graphite:null".to_string()), false)],
|
||||
input_metadata: vec![("Empty", "TODO").into(), ("URL", "TODO").into()],
|
||||
input_metadata: vec![
|
||||
("Empty", "Has no effect, since the image is loaded from the URL.").into(),
|
||||
("URL", "The web address or local asset path of the image to load.").into(),
|
||||
],
|
||||
output_names: vec!["Image".to_string()],
|
||||
output_descriptions: vec!["The loaded image, which is empty if it fails to load or decode.".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("Loads an image from a given URL."),
|
||||
properties: None,
|
||||
inspector: None,
|
||||
},
|
||||
#[cfg(all(feature = "gpu", target_family = "wasm"))]
|
||||
DocumentNodeDefinition {
|
||||
@@ -680,12 +698,16 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
false,
|
||||
),
|
||||
],
|
||||
input_metadata: vec![("Artwork", "TODO").into(), ("Footprint", "TODO").into()],
|
||||
input_metadata: vec![
|
||||
("Artwork", "The graphics to render as an image.").into(),
|
||||
("Footprint", "The area of the document to render, and the resolution to render it at.").into(),
|
||||
],
|
||||
output_names: vec!["Canvas".to_string()],
|
||||
output_descriptions: vec!["The rendered image.".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("TODO"),
|
||||
properties: None,
|
||||
description: Cow::Borrowed("Renders a view of the input graphics within an area defined by the *Footprint*, producing a raster image."),
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Extract",
|
||||
@@ -694,12 +716,13 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
node_template: NodeTemplate {
|
||||
implementation: NodeTemplateImplementation::Extract,
|
||||
inputs: vec![NodeInput::type_default(concrete!(DocumentNode), true)],
|
||||
input_metadata: vec![("Node", "TODO").into()],
|
||||
input_metadata: vec![("Node", "The node to output as data rather than evaluating it.").into()],
|
||||
output_names: vec!["Document Node".to_string()],
|
||||
output_descriptions: vec!["The connected node itself, as data.".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("TODO"),
|
||||
properties: None,
|
||||
description: Cow::Borrowed("Outputs the connected node itself as data, rather than the result of evaluating it."),
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Regex Find",
|
||||
@@ -767,12 +790,16 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
("Multiline", "Make `^` and `$` match the start and end of each line, not just the whole string.").into(),
|
||||
],
|
||||
output_names: vec!["Match".to_string(), "Captures".to_string()],
|
||||
output_descriptions: vec![
|
||||
"The whole portion of the string matching the pattern, or empty if there is no match.".to_string(),
|
||||
"The text matched by each capture group in the pattern, in order.".to_string(),
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed(
|
||||
r#"Finds a portion of the string matching a regular expression pattern. With "Match Index" at its default 0, it selects the first non-overlapping occurrence, but others may be selected. Capture groups, if any, are produced as a list in the "Captures" output."#,
|
||||
),
|
||||
properties: None,
|
||||
inspector: None,
|
||||
},
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Path",
|
||||
@@ -812,72 +839,88 @@ fn document_node_definitions() -> HashMap<DefinitionIdentifier, DocumentNodeDefi
|
||||
NodeInput::type_default(item!(Vector), true),
|
||||
NodeInput::value(TaggedValue::VectorModification(Default::default()), false),
|
||||
],
|
||||
input_metadata: vec![("Content", "TODO").into(), ("Modification", "TODO").into()],
|
||||
input_metadata: vec![
|
||||
("Content", "The original shape that edits made with the Pen and Path tools are applied to.").into(),
|
||||
("Modification", "The edits made with the Pen and Path tools, stored as changes to points and segments.").into(),
|
||||
],
|
||||
output_names: vec!["Modified".to_string()],
|
||||
output_descriptions: vec!["The shape with the Pen and Path tool edits applied.".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
description: Cow::Borrowed("TODO"),
|
||||
properties: None,
|
||||
description: Cow::Borrowed("Holds the edits made with the Pen and Path tools, applying them to the incoming shape."),
|
||||
inspector: None,
|
||||
},
|
||||
];
|
||||
|
||||
document_node_derive::post_process_nodes(custom)
|
||||
}
|
||||
|
||||
type NodeProperties = HashMap<String, Box<dyn Fn(NodeId, &mut NodePropertiesContext) -> Vec<LayoutGroup> + Send + Sync>>;
|
||||
type NodeInspector = HashMap<String, Box<dyn Fn(NodeId, &mut NodeInspectorContext) -> Vec<LayoutGroup> + Send + Sync>>;
|
||||
|
||||
// TODO: Replace with `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>) or similar
|
||||
pub static NODE_OVERRIDES: once_cell::sync::Lazy<NodeProperties> = once_cell::sync::Lazy::new(static_node_properties);
|
||||
pub static NODE_OVERRIDES: once_cell::sync::Lazy<NodeInspector> = once_cell::sync::Lazy::new(static_node_inspector);
|
||||
|
||||
/// Defines the logic for inputs to display a custom Properties panel widget.
|
||||
fn static_node_properties() -> NodeProperties {
|
||||
let mut map: NodeProperties = HashMap::new();
|
||||
map.insert("brightness_contrast_properties".to_string(), Box::new(node_properties::brightness_contrast_properties));
|
||||
map.insert("channel_mixer_properties".to_string(), Box::new(node_properties::channel_mixer_properties));
|
||||
map.insert("levels_properties".to_string(), Box::new(node_properties::levels_properties));
|
||||
map.insert("transfer_curves_properties".to_string(), Box::new(node_properties::transfer_curves_properties));
|
||||
map.insert("hue_saturation_properties".to_string(), Box::new(node_properties::hue_saturation_properties));
|
||||
map.insert("black_and_white_properties".to_string(), Box::new(node_properties::black_and_white_properties));
|
||||
map.insert("threshold_properties".to_string(), Box::new(node_properties::threshold_properties));
|
||||
map.insert("vibrance_properties".to_string(), Box::new(node_properties::vibrance_properties));
|
||||
map.insert("color_balance_properties".to_string(), Box::new(node_properties::color_balance_properties));
|
||||
map.insert("fill_properties".to_string(), Box::new(node_properties::fill_properties));
|
||||
map.insert("stroke_properties".to_string(), Box::new(node_properties::stroke_properties));
|
||||
map.insert("offset_path_properties".to_string(), Box::new(node_properties::offset_path_properties));
|
||||
map.insert("selective_color_properties".to_string(), Box::new(node_properties::selective_color_properties));
|
||||
map.insert("exposure_properties".to_string(), Box::new(node_properties::exposure_properties));
|
||||
map.insert("format_number_properties".to_string(), Box::new(node_properties::format_number_properties));
|
||||
map.insert("string_capitalization_properties".to_string(), Box::new(node_properties::string_capitalization_properties));
|
||||
map.insert("rectangle_properties".to_string(), Box::new(node_properties::rectangle_properties));
|
||||
map.insert("grid_properties".to_string(), Box::new(node_properties::grid_properties));
|
||||
map.insert("spiral_properties".to_string(), Box::new(node_properties::spiral_properties));
|
||||
map.insert("sample_polyline_properties".to_string(), Box::new(node_properties::sample_polyline_properties));
|
||||
/// Defines the logic for inputs to display a custom Inspector widget.
|
||||
fn static_node_inspector() -> NodeInspector {
|
||||
let mut map: NodeInspector = HashMap::new();
|
||||
map.insert("brightness_contrast_inspector".to_string(), Box::new(node_inspector::brightness_contrast_inspector));
|
||||
map.insert("channel_mixer_inspector".to_string(), Box::new(node_inspector::channel_mixer_inspector));
|
||||
map.insert("levels_inspector".to_string(), Box::new(node_inspector::levels_inspector));
|
||||
map.insert("transfer_curves_inspector".to_string(), Box::new(node_inspector::transfer_curves_inspector));
|
||||
map.insert("hue_saturation_inspector".to_string(), Box::new(node_inspector::hue_saturation_inspector));
|
||||
map.insert("black_and_white_inspector".to_string(), Box::new(node_inspector::black_and_white_inspector));
|
||||
map.insert("threshold_inspector".to_string(), Box::new(node_inspector::threshold_inspector));
|
||||
map.insert("vibrance_inspector".to_string(), Box::new(node_inspector::vibrance_inspector));
|
||||
map.insert("color_balance_inspector".to_string(), Box::new(node_inspector::color_balance_inspector));
|
||||
map.insert("fill_inspector".to_string(), Box::new(node_inspector::fill_inspector));
|
||||
map.insert("stroke_inspector".to_string(), Box::new(node_inspector::stroke_inspector));
|
||||
map.insert("offset_path_inspector".to_string(), Box::new(node_inspector::offset_path_inspector));
|
||||
map.insert("selective_color_inspector".to_string(), Box::new(node_inspector::selective_color_inspector));
|
||||
map.insert("exposure_inspector".to_string(), Box::new(node_inspector::exposure_inspector));
|
||||
map.insert("format_number_inspector".to_string(), Box::new(node_inspector::format_number_inspector));
|
||||
map.insert("string_capitalization_inspector".to_string(), Box::new(node_inspector::string_capitalization_inspector));
|
||||
map.insert("rectangle_inspector".to_string(), Box::new(node_inspector::rectangle_inspector));
|
||||
map.insert("grid_inspector".to_string(), Box::new(node_inspector::grid_inspector));
|
||||
map.insert("spiral_inspector".to_string(), Box::new(node_inspector::spiral_inspector));
|
||||
map.insert("sample_polyline_inspector".to_string(), Box::new(node_inspector::sample_polyline_inspector));
|
||||
map.insert(
|
||||
"monitor_properties".to_string(),
|
||||
Box::new(|_node_id, _context| node_properties::string_properties("Used internally by the editor to obtain a layer thumbnail.")),
|
||||
"monitor_inspector".to_string(),
|
||||
Box::new(|_node_id, _context| node_inspector::string_inspector("Used internally by the editor to obtain a layer thumbnail.")),
|
||||
);
|
||||
map
|
||||
}
|
||||
|
||||
type InputProperties = HashMap<String, Box<dyn Fn(NodeId, usize, &mut NodePropertiesContext) -> Result<Vec<LayoutGroup>, String> + Send + Sync>>;
|
||||
type InputInspector = HashMap<String, Box<dyn Fn(NodeId, usize, &mut NodeInspectorContext) -> Result<Vec<LayoutGroup>, String> + Send + Sync>>;
|
||||
|
||||
// TODO: Replace with `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>) or similar
|
||||
static INPUT_OVERRIDES: once_cell::sync::Lazy<InputProperties> = once_cell::sync::Lazy::new(static_input_properties);
|
||||
static INPUT_OVERRIDES: once_cell::sync::Lazy<InputInspector> = once_cell::sync::Lazy::new(static_input_inspector);
|
||||
|
||||
/// Defines the logic for inputs to display a custom Properties panel widget.
|
||||
fn static_input_properties() -> InputProperties {
|
||||
let mut map: InputProperties = HashMap::new();
|
||||
map.insert("hidden".to_string(), Box::new(|_node_id, _index, _context| Ok(Vec::new())));
|
||||
/// Defines the logic for inputs to display a custom Inspector widget.
|
||||
fn static_input_inspector() -> InputInspector {
|
||||
let mut map: InputInspector = HashMap::new();
|
||||
map.insert(
|
||||
"hidden".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
Ok(node_inspector::exposed_parameter_row(&ParameterWidgetsInfo::at_index(node_id, index, true, context))
|
||||
.into_iter()
|
||||
.collect())
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"string".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let Some(value) = context.network_interface.input_data(&node_id, index, "string_properties", context.selection_network_path) else {
|
||||
return Err(format!("Could not get string properties for node {node_id}"));
|
||||
// Falls back to the legacy key
|
||||
let network_interface = &context.network_interface;
|
||||
let Some(value) = network_interface
|
||||
.input_data(&node_id, index, "string_inspector", context.selection_network_path)
|
||||
.or_else(|| network_interface.input_data(&node_id, index, "string_properties", context.selection_network_path))
|
||||
else {
|
||||
return Err(format!("Could not get string Inspector input data for node {node_id}"));
|
||||
};
|
||||
let Some(string) = value.as_str() else {
|
||||
return Err(format!("Could not downcast string properties for node {node_id}"));
|
||||
return Err(format!("Could not downcast string Inspector input data for node {node_id}"));
|
||||
};
|
||||
Ok(node_properties::string_properties(string))
|
||||
Ok(node_inspector::string_inspector(string))
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -948,7 +991,7 @@ fn static_input_properties() -> InputProperties {
|
||||
true
|
||||
});
|
||||
|
||||
Ok(vec![LayoutGroup::row(node_properties::number_widget(
|
||||
Ok(vec![LayoutGroup::row(node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, blank_assist, context),
|
||||
number_input,
|
||||
))])
|
||||
@@ -970,7 +1013,7 @@ fn static_input_properties() -> InputProperties {
|
||||
if let Some(unit) = field.unit {
|
||||
number_input = number_input.unit(unit);
|
||||
}
|
||||
// Typing is clamped only by the hard bounds; the slider extent prefers the soft bounds (see `property_from_type`)
|
||||
// Typing is clamped only by the hard bounds; the slider extent prefers the soft bounds (see `inspector_row_from_type`)
|
||||
if let Some(hard_min) = field.number_hard_min {
|
||||
number_input = number_input.min(hard_min);
|
||||
}
|
||||
@@ -989,7 +1032,7 @@ fn static_input_properties() -> InputProperties {
|
||||
}
|
||||
};
|
||||
// NOTE: The bool input MUST be at the input index directly before the f64 input!
|
||||
Ok(vec![LayoutGroup::row(node_properties::optional_f64_widget(
|
||||
Ok(vec![LayoutGroup::row(node_inspector::optional_f64_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, false, context),
|
||||
index - 1,
|
||||
number_input,
|
||||
@@ -1008,7 +1051,7 @@ fn static_input_properties() -> InputProperties {
|
||||
max: 100.,
|
||||
default: Some(100.),
|
||||
};
|
||||
Ok(vec![LayoutGroup::row(node_properties::optional_f64_widget(
|
||||
Ok(vec![LayoutGroup::row(node_inspector::optional_f64_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, false, context),
|
||||
index - 1,
|
||||
number_input,
|
||||
@@ -1019,7 +1062,7 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
// A type-witness input, whose stored value's type selects the node's row: the dropdown lists the types the rows accept there
|
||||
"type_choice".to_string(),
|
||||
Box::new(|node_id, index, context| Ok(vec![node_properties::type_choice_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context))])),
|
||||
Box::new(|node_id, index, context| Ok(vec![node_inspector::type_choice_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context))])),
|
||||
);
|
||||
map.insert(
|
||||
"vec2".to_string(),
|
||||
@@ -1061,7 +1104,7 @@ fn static_input_properties() -> InputProperties {
|
||||
.and_then(|value| value.as_bool())
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(vec![node_properties::vec2_widget(
|
||||
Ok(vec![node_inspector::vec2_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
&x,
|
||||
&y,
|
||||
@@ -1072,10 +1115,10 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_scale".to_string(),
|
||||
"noise_inspector_scale".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, _, _, _, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let scale = node_properties::number_widget(
|
||||
let (_, coherent_noise_active, _, _, _, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let scale = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default().min(0.).disabled(!coherent_noise_active),
|
||||
);
|
||||
@@ -1083,28 +1126,28 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_noise_type".to_string(),
|
||||
"noise_inspector_noise_type".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let noise_type_row = enum_choice::<NoiseType>().for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context)).property_row();
|
||||
let noise_type_row = enum_choice::<NoiseType>().for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context)).inspector_row();
|
||||
Ok(vec![noise_type_row, LayoutGroup::row(Vec::new())])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_domain_warp_type".to_string(),
|
||||
"noise_inspector_domain_warp_type".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, _, _, _, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let (_, coherent_noise_active, _, _, _, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let domain_warp_type = enum_choice::<DomainWarpType>()
|
||||
.for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context))
|
||||
.disabled(!coherent_noise_active)
|
||||
.property_row();
|
||||
.inspector_row();
|
||||
Ok(vec![domain_warp_type])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_domain_warp_amplitude".to_string(),
|
||||
"noise_inspector_domain_warp_amplitude".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, _, _, domain_warp_active, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let domain_warp_amplitude = node_properties::number_widget(
|
||||
let (_, coherent_noise_active, _, _, domain_warp_active, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let domain_warp_amplitude = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default().min(0.).disabled(!coherent_noise_active || !domain_warp_active),
|
||||
);
|
||||
@@ -1112,21 +1155,21 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_fractal_type".to_string(),
|
||||
"noise_inspector_fractal_type".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, _, _, _, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let (_, coherent_noise_active, _, _, _, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_type_row = enum_choice::<FractalType>()
|
||||
.for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context))
|
||||
.disabled(!coherent_noise_active)
|
||||
.property_row();
|
||||
.inspector_row();
|
||||
Ok(vec![fractal_type_row])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_fractal_octaves".to_string(),
|
||||
"noise_inspector_fractal_octaves".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_octaves = node_properties::number_widget(
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_octaves = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default()
|
||||
.mode_range()
|
||||
@@ -1140,10 +1183,10 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_fractal_lacunarity".to_string(),
|
||||
"noise_inspector_fractal_lacunarity".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_lacunarity = node_properties::number_widget(
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_lacunarity = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default()
|
||||
.mode_range()
|
||||
@@ -1155,10 +1198,10 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_fractal_gain".to_string(),
|
||||
"noise_inspector_fractal_gain".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_gain = node_properties::number_widget(
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_gain = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default()
|
||||
.mode_range()
|
||||
@@ -1170,10 +1213,10 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_fractal_weighted_strength".to_string(),
|
||||
"noise_inspector_fractal_weighted_strength".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_weighted_strength = node_properties::range_slider_widget(
|
||||
let (fractal_active, coherent_noise_active, _, _, _, domain_warp_only_fractal_type_wrongly_active) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_weighted_strength = node_inspector::range_slider_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default()
|
||||
.min(0.)
|
||||
@@ -1185,10 +1228,10 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_ping_pong_strength".to_string(),
|
||||
"noise_inspector_ping_pong_strength".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (fractal_active, coherent_noise_active, _, ping_pong_active, _, domain_warp_only_fractal_type_wrongly_active) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_ping_pong_strength = node_properties::number_widget(
|
||||
let (fractal_active, coherent_noise_active, _, ping_pong_active, _, domain_warp_only_fractal_type_wrongly_active) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let fractal_ping_pong_strength = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default()
|
||||
.mode_range()
|
||||
@@ -1200,32 +1243,32 @@ fn static_input_properties() -> InputProperties {
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_cellular_distance_function".to_string(),
|
||||
"noise_inspector_cellular_distance_function".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, cellular_noise_active, _, _, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let (_, coherent_noise_active, cellular_noise_active, _, _, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let cellular_distance_function_row = enum_choice::<CellularDistanceFunction>()
|
||||
.for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context))
|
||||
.disabled(!coherent_noise_active || !cellular_noise_active)
|
||||
.property_row();
|
||||
.inspector_row();
|
||||
Ok(vec![cellular_distance_function_row])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_cellular_return_type".to_string(),
|
||||
"noise_inspector_cellular_return_type".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, cellular_noise_active, _, _, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let (_, coherent_noise_active, cellular_noise_active, _, _, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let cellular_return_type = enum_choice::<CellularReturnType>()
|
||||
.for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context))
|
||||
.disabled(!coherent_noise_active || !cellular_noise_active)
|
||||
.property_row();
|
||||
.inspector_row();
|
||||
Ok(vec![cellular_return_type])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"noise_properties_cellular_jitter".to_string(),
|
||||
"noise_inspector_cellular_jitter".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let (_, coherent_noise_active, cellular_noise_active, _, _, _) = node_properties::query_noise_pattern_state(node_id, context)?;
|
||||
let cellular_jitter = node_properties::number_widget(
|
||||
let (_, coherent_noise_active, cellular_noise_active, _, _, _) = node_inspector::query_noise_pattern_state(node_id, context)?;
|
||||
let cellular_jitter = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default()
|
||||
.mode_range()
|
||||
@@ -1239,15 +1282,15 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"assign_colors_gradient".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let gradient_row = node_properties::color_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context), ColorInput::default().allow_none(false));
|
||||
let gradient_row = node_inspector::color_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context), ColorInput::default().allow_none(false));
|
||||
Ok(vec![gradient_row])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"assign_colors_seed".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let randomize_enabled = node_properties::query_assign_colors_randomize(node_id, context)?;
|
||||
let seed_row = node_properties::number_widget(
|
||||
let randomize_enabled = node_inspector::query_assign_colors_randomize(node_id, context)?;
|
||||
let seed_row = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default().min(0.).int().disabled(!randomize_enabled),
|
||||
);
|
||||
@@ -1257,8 +1300,8 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"assign_colors_repeat_every".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let randomize_enabled = node_properties::query_assign_colors_randomize(node_id, context)?;
|
||||
let repeat_every_row = node_properties::number_widget(
|
||||
let randomize_enabled = node_inspector::query_assign_colors_randomize(node_id, context)?;
|
||||
let repeat_every_row = node_inspector::number_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
NumberInput::default().min(0.).int().disabled(randomize_enabled),
|
||||
);
|
||||
@@ -1268,9 +1311,9 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"transform_rotation".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let mut widgets = node_properties::start_widgets(&ParameterWidgetsInfo::at_index(node_id, index, true, context));
|
||||
let mut widgets = node_inspector::start_widgets(&ParameterWidgetsInfo::at_index(node_id, index, true, context));
|
||||
|
||||
let document_node = node_properties::get_document_node(node_id, context)?;
|
||||
let document_node = node_inspector::get_document_node(node_id, context)?;
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
return Err("Input not found in transform rotation input override".to_string());
|
||||
};
|
||||
@@ -1282,12 +1325,12 @@ fn static_input_properties() -> InputProperties {
|
||||
.mode(NumberInputMode::Range)
|
||||
.range_min(Some(-180.))
|
||||
.range_max(Some(180.))
|
||||
.on_update(node_properties::update_value_at_index(
|
||||
.on_update(node_inspector::update_value_at_index(
|
||||
|number_input: &NumberInput| TaggedValue::Number(number_input.value.unwrap()),
|
||||
node_id,
|
||||
index,
|
||||
))
|
||||
.on_commit(node_properties::commit_value)
|
||||
.on_commit(node_inspector::commit_value)
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
@@ -1299,7 +1342,7 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"transform_translation".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
Ok(vec![node_properties::vec2_widget(
|
||||
Ok(vec![node_inspector::vec2_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
"X",
|
||||
"Y",
|
||||
@@ -1313,7 +1356,7 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"transform_scale".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
Ok(vec![node_properties::vec2_widget(
|
||||
Ok(vec![node_inspector::vec2_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
"W",
|
||||
"H",
|
||||
@@ -1327,9 +1370,9 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"transform_skew".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let mut widgets = node_properties::start_widgets(&ParameterWidgetsInfo::at_index(node_id, index, true, context));
|
||||
let mut widgets = node_inspector::start_widgets(&ParameterWidgetsInfo::at_index(node_id, index, true, context));
|
||||
|
||||
let document_node = node_properties::get_document_node(node_id, context)?;
|
||||
let document_node = node_inspector::get_document_node(node_id, context)?;
|
||||
let Some(input) = document_node.inputs.get(index) else {
|
||||
return Err("Input not found in transform skew input override".to_string());
|
||||
};
|
||||
@@ -1341,12 +1384,12 @@ fn static_input_properties() -> InputProperties {
|
||||
.unit("°")
|
||||
.min(-89.9)
|
||||
.max(89.9)
|
||||
.on_update(node_properties::update_value_at_index(
|
||||
.on_update(node_inspector::update_value_at_index(
|
||||
move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(input.value.unwrap(), val.y)),
|
||||
node_id,
|
||||
index,
|
||||
))
|
||||
.on_commit(node_properties::commit_value)
|
||||
.on_commit(node_inspector::commit_value)
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(val.y))
|
||||
@@ -1354,12 +1397,12 @@ fn static_input_properties() -> InputProperties {
|
||||
.unit("°")
|
||||
.min(-89.9)
|
||||
.max(89.9)
|
||||
.on_update(node_properties::update_value_at_index(
|
||||
.on_update(node_inspector::update_value_at_index(
|
||||
move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(val.x, input.value.unwrap())),
|
||||
node_id,
|
||||
index,
|
||||
))
|
||||
.on_commit(node_properties::commit_value)
|
||||
.on_commit(node_inspector::commit_value)
|
||||
.widget_instance(),
|
||||
]);
|
||||
}
|
||||
@@ -1369,14 +1412,14 @@ fn static_input_properties() -> InputProperties {
|
||||
);
|
||||
map.insert(
|
||||
"text_area".to_string(),
|
||||
Box::new(|node_id, index, context| Ok(vec![LayoutGroup::row(node_properties::text_area_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context)))])),
|
||||
Box::new(|node_id, index, context| Ok(vec![LayoutGroup::row(node_inspector::text_area_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context)))])),
|
||||
);
|
||||
map.insert(
|
||||
// A math expression, flagged with a warning icon while it fails to parse
|
||||
"math_expression".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let info = ParameterWidgetsInfo::at_index(node_id, index, true, context);
|
||||
Ok(vec![LayoutGroup::row(node_properties::math_expression_widget(info, false))])
|
||||
Ok(vec![LayoutGroup::row(node_inspector::math_expression_widget(info, false))])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -1384,7 +1427,7 @@ fn static_input_properties() -> InputProperties {
|
||||
"math_expression_or_reducer".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let info = ParameterWidgetsInfo::at_index(node_id, index, true, context);
|
||||
Ok(vec![LayoutGroup::row(node_properties::math_expression_widget(info, true))])
|
||||
Ok(vec![LayoutGroup::row(node_inspector::math_expression_widget(info, true))])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
@@ -1394,7 +1437,7 @@ fn static_input_properties() -> InputProperties {
|
||||
if context.fonts.font_catalog.is_empty() {
|
||||
context.responses.add(FontsMessage::LoadCatalog);
|
||||
}
|
||||
let (font, style) = node_properties::font_inputs(ParameterWidgetsInfo::at_index(node_id, index, true, context));
|
||||
let (font, style) = node_inspector::font_inputs(ParameterWidgetsInfo::at_index(node_id, index, true, context));
|
||||
let mut result = vec![LayoutGroup::row(font)];
|
||||
if let Some(style) = style {
|
||||
result.push(LayoutGroup::row(style));
|
||||
@@ -1405,21 +1448,21 @@ fn static_input_properties() -> InputProperties {
|
||||
map.insert(
|
||||
"image_file".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let widgets = node_properties::resource_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context), vec![TypeFilter::raster()]);
|
||||
let widgets = node_inspector::resource_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context), vec![TypeFilter::raster()]);
|
||||
Ok(vec![LayoutGroup::row(widgets)])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"lut_file".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
let widgets = node_properties::resource_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context), vec![TypeFilter::lut()]);
|
||||
let widgets = node_inspector::resource_widget(ParameterWidgetsInfo::at_index(node_id, index, true, context), vec![TypeFilter::lut()]);
|
||||
Ok(vec![LayoutGroup::row(widgets)])
|
||||
}),
|
||||
);
|
||||
map.insert(
|
||||
"artboard_background".to_string(),
|
||||
Box::new(|node_id, index, context| {
|
||||
Ok(vec![node_properties::color_widget(
|
||||
Ok(vec![node_inspector::color_widget(
|
||||
ParameterWidgetsInfo::at_index(node_id, index, true, context),
|
||||
ColorInput::default().allow_none(false),
|
||||
)])
|
||||
@@ -1430,7 +1473,7 @@ fn static_input_properties() -> InputProperties {
|
||||
Box::new(|node_id, index, context| {
|
||||
let choices = enum_choice::<text::TextAlign>()
|
||||
.for_socket(ParameterWidgetsInfo::at_index(node_id, index, true, context))
|
||||
.property_row();
|
||||
.inspector_row();
|
||||
Ok(vec![choices])
|
||||
}),
|
||||
);
|
||||
@@ -1596,12 +1639,7 @@ pub fn collect_node_types() -> Vec<FrontendNodeType> {
|
||||
pub fn collect_node_descriptions() -> Vec<(String, String)> {
|
||||
DOCUMENT_NODE_TYPES
|
||||
.iter()
|
||||
.map(|(identifier, definition)| {
|
||||
(
|
||||
identifier.serialized(),
|
||||
if definition.description != "TODO" { definition.description.to_string() } else { String::new() },
|
||||
)
|
||||
})
|
||||
.map(|(identifier, definition)| (identifier.serialized(), definition.description.to_string()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -1627,7 +1665,7 @@ impl DocumentNodeDefinition {
|
||||
}
|
||||
});
|
||||
|
||||
// Ensure that the input properties are initialized for every input of every node
|
||||
// Ensure that the input metadata is initialized for every input of every node
|
||||
template.normalize_input_metadata();
|
||||
|
||||
template
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ pub(super) fn post_process_nodes(custom: Vec<DocumentNodeDefinition>) -> HashMap
|
||||
icon,
|
||||
fields,
|
||||
description,
|
||||
properties,
|
||||
inspector,
|
||||
context_features,
|
||||
output_fields,
|
||||
..
|
||||
@@ -107,7 +107,7 @@ pub(super) fn post_process_nodes(custom: Vec<DocumentNodeDefinition>) -> HashMap
|
||||
category,
|
||||
icon: *icon,
|
||||
description: Cow::Borrowed(description),
|
||||
properties: *properties,
|
||||
inspector: *inspector,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
pub mod document_node_definitions;
|
||||
mod node_graph_message;
|
||||
mod node_graph_message_handler;
|
||||
pub mod node_properties;
|
||||
pub mod node_inspector;
|
||||
pub mod utility_types;
|
||||
|
||||
#[doc(inline)]
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::messages::portfolio::document::node_graph::document_node_definitions:
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::{ChainInsertionPoint, ChainNodeCopy, ImportOrExport, InputConnector, NodeTemplate, OutputConnector, RootNode};
|
||||
use crate::messages::prelude::*;
|
||||
use glam::{DVec2, IVec2};
|
||||
use glam::IVec2;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{NodeId, NodeInput};
|
||||
use graph_craft::proto::GraphErrors;
|
||||
@@ -19,8 +19,16 @@ pub enum NodeGraphMessage {
|
||||
},
|
||||
AddPathNode,
|
||||
AddImport,
|
||||
AddPrimaryImport,
|
||||
AddSecondaryImport,
|
||||
/// Adds the import at `import_index` wired to `input_connector`, from a wire dragged out of a dimmed connector for adding one.
|
||||
/// Index 0 fills the empty primary, and any other is the next secondary import.
|
||||
AddImportAndConnect {
|
||||
import_index: usize,
|
||||
input_connector: InputConnector,
|
||||
},
|
||||
/// Inserts a Passthrough node beside the import that takes over the wires it fed, so nodes can be placed in front of all of them at once.
|
||||
AddImportPassthrough {
|
||||
import_index: usize,
|
||||
},
|
||||
AddExport,
|
||||
AddPrimaryExport,
|
||||
AddSecondaryExport,
|
||||
@@ -60,6 +68,10 @@ pub enum NodeGraphMessage {
|
||||
DisconnectInput {
|
||||
input_connector: InputConnector,
|
||||
},
|
||||
/// Disconnects every wire an import feeds, or the wire feeding an export.
|
||||
DisconnectImportExport {
|
||||
index: ImportOrExport,
|
||||
},
|
||||
DisconnectRootNode,
|
||||
SetRootNodeToRestore {
|
||||
root_node_to_restore: RootNode,
|
||||
@@ -71,7 +83,10 @@ pub enum NodeGraphMessage {
|
||||
set_to_exposed: bool,
|
||||
start_transaction: bool,
|
||||
},
|
||||
ExposeEncapsulatingPrimaryInput {
|
||||
/// Whether the subgraph node shows its input for an import as a connector rather than as a parameter in the Inspector.
|
||||
/// A hidden primary import also disappears from the subgraph.
|
||||
ExposeEncapsulatingInput {
|
||||
input_index: usize,
|
||||
exposed: bool,
|
||||
},
|
||||
ExposePrimaryExport {
|
||||
@@ -139,16 +154,6 @@ pub enum NodeGraphMessage {
|
||||
},
|
||||
/// Sent every frame while a dragged wire hovers a node, to expand it once the hover delay passes.
|
||||
WireHoverTick,
|
||||
/// Begins dragging a wire out of an input connector shown in the Properties panel.
|
||||
StartWireFromPropertiesPanel {
|
||||
input_connector: InputConnector,
|
||||
editor_position: DVec2,
|
||||
},
|
||||
/// Reports whether the wire in progress is over the Properties panel, and which input connector there it hovers (at its editor position).
|
||||
SetWirePropertiesPanelHover {
|
||||
hovering_panel: bool,
|
||||
target: Option<(InputConnector, DVec2)>,
|
||||
},
|
||||
ShakeNode,
|
||||
UpdateNodeGraphWidth,
|
||||
RemoveImport {
|
||||
@@ -157,6 +162,10 @@ pub enum NodeGraphMessage {
|
||||
RemoveExport {
|
||||
export_index: usize,
|
||||
},
|
||||
/// Removes an import or export, or hides it if it's the primary, since the primary slot always remains.
|
||||
RemoveImportExport {
|
||||
index: ImportOrExport,
|
||||
},
|
||||
ReorderImport {
|
||||
start_index: usize,
|
||||
end_index: usize,
|
||||
@@ -240,6 +249,14 @@ pub enum NodeGraphMessage {
|
||||
name: String,
|
||||
index: ImportOrExport,
|
||||
},
|
||||
SetImportExportDescription {
|
||||
description: String,
|
||||
index: ImportOrExport,
|
||||
},
|
||||
SetImportExportDescriptionImpl {
|
||||
description: String,
|
||||
index: ImportOrExport,
|
||||
},
|
||||
ToggleSelectedAsLayersOrNodes,
|
||||
ToggleSelectedLocked,
|
||||
ToggleLocked {
|
||||
@@ -274,7 +291,6 @@ pub enum NodeGraphMessage {
|
||||
node_ids: Vec<NodeId>,
|
||||
network_path: Vec<NodeId>,
|
||||
},
|
||||
UpdateEdges,
|
||||
UpdateBoxSelection,
|
||||
UpdateImportsExports,
|
||||
UpdateLayerPanel,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+303
-209
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,3 @@
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::{InputConnector, OutputConnector};
|
||||
use glam::DVec2;
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_std::{Type, simplify_identifier_name};
|
||||
|
||||
@@ -53,9 +51,8 @@ pub struct FrontendGraphInput {
|
||||
pub resolved_type: String,
|
||||
#[serde(rename = "validTypes")]
|
||||
pub valid_types: Vec<String>,
|
||||
#[serde(rename = "connectedTo")]
|
||||
/// Either "nothing", "import #{index}", or "{node name} #{output_index}".
|
||||
pub connected_to: String,
|
||||
/// Whether a wire feeds this input.
|
||||
pub connected: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
@@ -67,10 +64,11 @@ pub struct FrontendGraphOutput {
|
||||
pub description: String,
|
||||
#[serde(rename = "resolvedType")]
|
||||
pub resolved_type: String,
|
||||
/// If connected to an export, it is "export index {index}".
|
||||
/// If connected to a node, it is "{node name} input {input_index}".
|
||||
#[serde(rename = "connectedTo")]
|
||||
pub connected_to: Vec<String>,
|
||||
/// Every type this output could produce given its node's current inputs, or empty where that isn't known.
|
||||
#[serde(rename = "possibleTypes")]
|
||||
pub possible_types: Vec<String>,
|
||||
/// Whether this output feeds at least one wire.
|
||||
pub connected: bool,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
@@ -163,18 +161,15 @@ pub enum ContextMenuData {
|
||||
#[serde(rename = "compatibleType")]
|
||||
compatible_type: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
/// The connector a wire being dragged starts from, which stays fixed while its other end follows the pointer.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum WireInProgressAnchor {
|
||||
/// Dragged from an output toward a compatible input.
|
||||
Output(OutputConnector),
|
||||
/// Dragged from an input toward a compatible output.
|
||||
Input {
|
||||
input_connector: InputConnector,
|
||||
/// Set when dragged out of the Properties panel, in viewport coordinates, since the input may not be exposed in the graph.
|
||||
properties_panel_position: Option<DVec2>,
|
||||
/// An import or export of the viewed subgraph, by its index among the imports or the exports.
|
||||
ModifyImportExport {
|
||||
#[serde(rename = "isImport")]
|
||||
is_import: bool,
|
||||
index: u32,
|
||||
/// For an import, whether the subgraph node shows its input as a connector rather than as a parameter in the Inspector.
|
||||
exposed: bool,
|
||||
/// Whether any wire is attached to it within the subgraph.
|
||||
connected: bool,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -211,8 +206,8 @@ pub struct FrontendClickTargets {
|
||||
pub icon_click_targets: Vec<String>,
|
||||
#[serde(rename = "allNodesBoundingBox")]
|
||||
pub all_nodes_bounding_box: String,
|
||||
#[serde(rename = "modifyImportExport")]
|
||||
pub modify_import_export: Vec<String>,
|
||||
#[serde(rename = "importExportNames")]
|
||||
pub import_export_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||
|
||||
@@ -231,7 +231,7 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
widgets.push(LayoutGroup::row(vec![TextLabel::new("Grid").bold(true).widget_instance()]));
|
||||
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Type").min_width(60).max_width(60).table_align(true).widget_instance(),
|
||||
TextLabel::new("Type").sizing(WidgetSizing::fixed(60)).table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
RadioInput::new(vec![
|
||||
RadioEntryData::new("rectangular").label("Rectangular").on_update(update_val(grid, |grid, _| {
|
||||
@@ -253,7 +253,7 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
};
|
||||
})),
|
||||
])
|
||||
.min_width(200)
|
||||
.sizing(WidgetSizing::default().min_width(200))
|
||||
.selected_index(Some(match grid.grid_type {
|
||||
GridType::Rectangular { .. } => 0,
|
||||
GridType::Isometric { .. } => 1,
|
||||
@@ -262,7 +262,7 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
]));
|
||||
|
||||
let mut color_widgets = vec![
|
||||
TextLabel::new("Display").min_width(60).max_width(60).table_align(true).widget_instance(),
|
||||
TextLabel::new("Display").sizing(WidgetSizing::fixed(60)).table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
];
|
||||
color_widgets.extend([
|
||||
@@ -287,32 +287,32 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
widgets.push(LayoutGroup::row(color_widgets));
|
||||
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Origin").min_width(60).max_width(60).table_align(true).widget_instance(),
|
||||
TextLabel::new("Origin").sizing(WidgetSizing::fixed(60)).table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(grid.origin.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min_width(98)
|
||||
.sizing(WidgetSizing::default().min_width(98))
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.x)))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(grid.origin.y))
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min_width(98)
|
||||
.sizing(WidgetSizing::default().min_width(98))
|
||||
.on_update(update_origin(grid, |grid| Some(&mut grid.origin.y)))
|
||||
.widget_instance(),
|
||||
]));
|
||||
|
||||
match grid.grid_type {
|
||||
GridType::Rectangular { spacing } => widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Spacing").min_width(60).max_width(60).table_align(true).widget_instance(),
|
||||
TextLabel::new("Spacing").sizing(WidgetSizing::fixed(60)).table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(spacing.x))
|
||||
.label("X")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.sizing(WidgetSizing::default().min_width(98))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.x)))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
@@ -320,33 +320,33 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
|
||||
.label("Y")
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(98)
|
||||
.sizing(WidgetSizing::default().min_width(98))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.rectangular_spacing().map(|spacing| &mut spacing.y)))
|
||||
.widget_instance(),
|
||||
])),
|
||||
GridType::Isometric { y_axis_spacing, angle_a, angle_b } => {
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Y Spacing").min_width(60).max_width(60).table_align(true).widget_instance(),
|
||||
TextLabel::new("Y Spacing").sizing(WidgetSizing::fixed(60)).table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(y_axis_spacing))
|
||||
.unit(" px")
|
||||
.min(0.)
|
||||
.min_width(200)
|
||||
.sizing(WidgetSizing::default().min_width(200))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.isometric_y_spacing()))
|
||||
.widget_instance(),
|
||||
]));
|
||||
widgets.push(LayoutGroup::row(vec![
|
||||
TextLabel::new("Angles").min_width(60).max_width(60).table_align(true).widget_instance(),
|
||||
TextLabel::new("Angles").sizing(WidgetSizing::fixed(60)).table_align(true).widget_instance(),
|
||||
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(angle_a))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.sizing(WidgetSizing::default().min_width(98))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_a()))
|
||||
.widget_instance(),
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
NumberInput::new(Some(angle_b))
|
||||
.unit("°")
|
||||
.min_width(98)
|
||||
.sizing(WidgetSizing::default().min_width(98))
|
||||
.on_update(update_origin(grid, |grid| grid.grid_type.angle_b()))
|
||||
.widget_instance(),
|
||||
]));
|
||||
|
||||
@@ -9,7 +9,8 @@ pub struct OverlaysMessageContext<'a> {
|
||||
|
||||
#[derive(Debug, Clone, Default, ExtractField)]
|
||||
pub struct OverlaysMessageHandler {
|
||||
pub overlay_providers: HashSet<OverlayProvider>,
|
||||
/// In the order they were added, which is the order they draw in.
|
||||
pub overlay_providers: Vec<OverlayProvider>,
|
||||
#[cfg(target_family = "wasm")]
|
||||
canvas: Option<web_sys::HtmlCanvasElement>,
|
||||
#[cfg(target_family = "wasm")]
|
||||
@@ -100,10 +101,12 @@ impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMes
|
||||
let _ = (responses, visibility_settings, viewport);
|
||||
}
|
||||
OverlaysMessage::AddProvider { provider: message } => {
|
||||
self.overlay_providers.insert(message);
|
||||
// A provider added again moves to the end, so it draws on top from then on
|
||||
self.overlay_providers.retain(|provider| !std::ptr::fn_addr_eq(*provider, message));
|
||||
self.overlay_providers.push(message);
|
||||
}
|
||||
OverlaysMessage::RemoveProvider { provider: message } => {
|
||||
self.overlay_providers.remove(&message);
|
||||
self.overlay_providers.retain(|provider| !std::ptr::fn_addr_eq(*provider, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1043,7 +1043,7 @@ impl OverlayContext {
|
||||
};
|
||||
let y = match pivot[1] {
|
||||
Pivot::Start => padding + metrics.font_bounding_box_ascent() - metrics.font_bounding_box_descent(),
|
||||
Pivot::Middle => (metrics.font_bounding_box_ascent() + metrics.font_bounding_box_descent()) / 2.,
|
||||
Pivot::Middle => (metrics.font_bounding_box_ascent() - metrics.font_bounding_box_descent()) / 2.,
|
||||
Pivot::End => -padding,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
mod properties_panel_message;
|
||||
pub mod properties_panel_message_handler;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use properties_panel_message::{PropertiesPanelMessage, PropertiesPanelMessageDiscriminant};
|
||||
#[doc(inline)]
|
||||
pub use properties_panel_message_handler::PropertiesPanelMessageHandler;
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
use graphene_std::Type;
|
||||
use graphene_std::uuid::NodeId;
|
||||
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::NodePropertiesContext;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::NodeNetworkInterface;
|
||||
use crate::messages::prelude::*;
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
|
||||
#[derive(ExtractField)]
|
||||
pub struct PropertiesPanelMessageContext<'a> {
|
||||
pub executor: &'a mut NodeGraphExecutor,
|
||||
pub document_id: DocumentId,
|
||||
pub network_interface: &'a mut NodeNetworkInterface,
|
||||
pub resources: &'a ResourceMessageHandler,
|
||||
pub selection_network_path: &'a [NodeId],
|
||||
pub document_name: &'a str,
|
||||
pub fonts: &'a FontsMessageHandler,
|
||||
pub properties_panel_open: bool,
|
||||
pub properties_panel_collapsed_sections: &'a [NodeId],
|
||||
pub wire_in_progress_output_types: &'a [Type],
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, ExtractField)]
|
||||
pub struct PropertiesPanelMessageHandler {}
|
||||
|
||||
#[message_handler_data]
|
||||
impl MessageHandler<PropertiesPanelMessage, PropertiesPanelMessageContext<'_>> for PropertiesPanelMessageHandler {
|
||||
fn process_message(&mut self, message: PropertiesPanelMessage, responses: &mut VecDeque<Message>, context: PropertiesPanelMessageContext) {
|
||||
let PropertiesPanelMessageContext {
|
||||
executor,
|
||||
document_id,
|
||||
network_interface,
|
||||
resources,
|
||||
selection_network_path,
|
||||
document_name,
|
||||
fonts,
|
||||
properties_panel_open,
|
||||
properties_panel_collapsed_sections,
|
||||
wire_in_progress_output_types,
|
||||
} = context;
|
||||
|
||||
match message {
|
||||
PropertiesPanelMessage::Clear => {
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::default(),
|
||||
layout_target: LayoutTarget::PropertiesPanel,
|
||||
});
|
||||
}
|
||||
PropertiesPanelMessage::Refresh => {
|
||||
if !properties_panel_open {
|
||||
responses.add(PropertiesPanelMessage::Clear);
|
||||
return;
|
||||
}
|
||||
|
||||
let mut node_properties_context = NodePropertiesContext {
|
||||
responses,
|
||||
executor,
|
||||
document_id,
|
||||
network_interface,
|
||||
resources,
|
||||
selection_network_path,
|
||||
document_name,
|
||||
fonts,
|
||||
properties_panel_collapsed_sections,
|
||||
wire_in_progress_output_types,
|
||||
};
|
||||
let layout = Layout(NodeGraphMessageHandler::collate_properties(&mut node_properties_context));
|
||||
|
||||
node_properties_context.responses.add(LayoutMessage::SendLayout {
|
||||
layout,
|
||||
layout_target: LayoutTarget::PropertiesPanel,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn actions(&self) -> ActionList {
|
||||
actions!(PropertiesMessageDiscriminant;)
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,29 @@ use std::collections::{BTreeSet, HashMap};
|
||||
|
||||
use document_graph_storage::{NodeMetadataSource, PeerId, Registry, to_value};
|
||||
|
||||
use super::test_support::{load_demo, node_paths};
|
||||
use super::test_support::{load_demo, load_demo_with_output_descriptions, node_paths, open_demo};
|
||||
use crate::messages::portfolio::document::document_message_handler::DocumentMessageHandler;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions::{DefinitionIdentifier, resolve_document_node_type};
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::NodeLocator;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::storage_metadata::{DocumentSettings, StorageMetadataView, build_interface_from_storage};
|
||||
use crate::messages::portfolio::document::utility_types::nodes::CollapsedLayers;
|
||||
use crate::messages::portfolio::document_storage_io::load_legacy_document;
|
||||
use graph_craft::application_io::resource::HashMapResourceStorage;
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_std::vector::style::RenderMode;
|
||||
|
||||
/// Storage drops output descriptions that are all empty, which means the same as having none.
|
||||
fn normalize_output_descriptions(output_descriptions: Vec<String>) -> Vec<String> {
|
||||
if output_descriptions.iter().all(String::is_empty) { Vec::new() } else { output_descriptions }
|
||||
}
|
||||
|
||||
/// Loads a demo artwork, round-trips its `NodeNetwork + NodeNetworkInterface metadata` through
|
||||
/// `Registry`, and asserts every node's `ui::*` attributes survive unchanged.
|
||||
///
|
||||
/// Uses one demo (rather than the full set) because this is an exhaustive per-node check.
|
||||
#[test]
|
||||
fn editor_metadata_round_trip_against_demo() {
|
||||
let document = load_demo("changing-seasons.graphite");
|
||||
let document = load_demo_with_output_descriptions("changing-seasons.graphite");
|
||||
let interface = &document.network_interface;
|
||||
let source = StorageMetadataView::new(interface);
|
||||
|
||||
@@ -39,6 +48,7 @@ fn editor_metadata_round_trip_against_demo() {
|
||||
let mut checked_any_position = false;
|
||||
let mut checked_any_layer = false;
|
||||
let mut checked_any_input_metadata = false;
|
||||
let mut checked_any_output_description = false;
|
||||
|
||||
for (network_path, local_id) in node_paths(interface) {
|
||||
let expected_position = source.position(&network_path, local_id);
|
||||
@@ -47,6 +57,7 @@ fn editor_metadata_round_trip_against_demo() {
|
||||
let expected_locked = source.locked(&network_path, local_id);
|
||||
let expected_pinned = source.pinned(&network_path, local_id);
|
||||
let expected_output_names = source.output_names(&network_path, local_id);
|
||||
let expected_output_descriptions = normalize_output_descriptions(source.output_descriptions(&network_path, local_id));
|
||||
|
||||
// Use the node's input count as the slot-by-slot iteration bound for the per-input metadata checks.
|
||||
let input_count = interface.document_node(&local_id, &network_path).map(|node| node.inputs.len()).unwrap_or(0);
|
||||
@@ -73,6 +84,10 @@ fn editor_metadata_round_trip_against_demo() {
|
||||
assert_eq!(entry.locked, expected_locked, "locked mismatch for node {local_id:?} in network {network_path:?}");
|
||||
assert_eq!(entry.pinned, expected_pinned, "pinned mismatch for node {local_id:?} in network {network_path:?}");
|
||||
assert_eq!(entry.output_names, expected_output_names, "output_names mismatch for node {local_id:?} in network {network_path:?}");
|
||||
assert_eq!(
|
||||
entry.output_descriptions, expected_output_descriptions,
|
||||
"output_descriptions mismatch for node {local_id:?} in network {network_path:?}"
|
||||
);
|
||||
|
||||
// Per-input metadata: the entry's `input_metadata` has one slot per input, each matching the trait's
|
||||
// per-field view (same "empty string ↔ None" normalization as `display_name`).
|
||||
@@ -115,6 +130,9 @@ fn editor_metadata_round_trip_against_demo() {
|
||||
if any_input_metadata_present {
|
||||
checked_any_input_metadata = true;
|
||||
}
|
||||
if !expected_output_descriptions.is_empty() {
|
||||
checked_any_output_description = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity: a real artwork should exercise at least these two shapes; otherwise the test is
|
||||
@@ -124,6 +142,7 @@ fn editor_metadata_round_trip_against_demo() {
|
||||
// Demo artworks always have some custom widget overrides / input names; if not, the
|
||||
// per-input round-trip isn't actually being exercised here.
|
||||
assert!(checked_any_input_metadata, "demo artwork produced no per-input metadata: fixture is wrong or extraction is broken");
|
||||
assert!(checked_any_output_description, "no output descriptions were round-tripped: fixture is wrong or extraction is broken");
|
||||
}
|
||||
|
||||
/// Full editor-side round-trip: original interface → Registry → (NodeNetwork, Vec<entry>) →
|
||||
@@ -131,7 +150,7 @@ fn editor_metadata_round_trip_against_demo() {
|
||||
/// the original when read through `StorageMetadataView`.
|
||||
#[test]
|
||||
fn editor_interface_rebuild_round_trip() {
|
||||
let document = load_demo("changing-seasons.graphite");
|
||||
let document = load_demo_with_output_descriptions("changing-seasons.graphite");
|
||||
let original = &document.network_interface;
|
||||
let original_view = StorageMetadataView::new(original);
|
||||
|
||||
@@ -213,6 +232,11 @@ fn editor_interface_rebuild_round_trip() {
|
||||
original_view.output_names(&network_path, local_id),
|
||||
"output_names mismatch for node {local_id:?} in network {network_path:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
normalize_output_descriptions(rebuilt_view.output_descriptions(&network_path, local_id)),
|
||||
normalize_output_descriptions(original_view.output_descriptions(&network_path, local_id)),
|
||||
"output_descriptions mismatch for node {local_id:?} in network {network_path:?}"
|
||||
);
|
||||
}
|
||||
|
||||
// Symmetric: every node in the original must also exist in the rebuilt interface.
|
||||
@@ -284,6 +308,57 @@ fn migrating_a_document_records_no_changes() {
|
||||
assert!(recorded.is_empty(), "migration left {} recorded changes behind", recorded.len());
|
||||
}
|
||||
|
||||
/// The first Merge node in a document, as its network path and ID.
|
||||
fn first_merge(document: &DocumentMessageHandler) -> (Vec<NodeId>, NodeId) {
|
||||
let merge = Some(DefinitionIdentifier::Network("Merge".into()));
|
||||
node_paths(&document.network_interface)
|
||||
.into_iter()
|
||||
.find(|(network_path, node_id)| document.network_interface.reference(node_id, network_path) == merge)
|
||||
.expect("the demo artwork should have a Merge node")
|
||||
}
|
||||
|
||||
/// Opening a document fills in the output descriptions of a node saved before its definition had any.
|
||||
#[test]
|
||||
fn opening_a_document_fills_output_descriptions_a_node_was_saved_without() {
|
||||
let mut document = open_demo("changing-seasons.graphite");
|
||||
let (network_path, node_id) = first_merge(&document);
|
||||
|
||||
// Saved as it would have been before Merge's definition described its output
|
||||
let mut node = document.network_interface.node_mut(NodeLocator::new(node_id, &network_path)).expect("the Merge node should exist");
|
||||
node.set_output_descriptions(Vec::new());
|
||||
|
||||
let content = document.serialize_document();
|
||||
let reopened = load_legacy_document(content, &HashMapResourceStorage::new(), false).expect("the saved document should open");
|
||||
|
||||
let definition_description = resolve_document_node_type(&DefinitionIdentifier::Network("Merge".into()))
|
||||
.and_then(|definition| definition.node_template.output_descriptions.first().cloned())
|
||||
.filter(|description| !description.is_empty())
|
||||
.expect("Merge's definition should describe its output");
|
||||
assert_eq!(
|
||||
reopened.network_interface.output_description(&node_id, 0, &network_path),
|
||||
definition_description,
|
||||
"the Merge node should be given its definition's output description"
|
||||
);
|
||||
}
|
||||
|
||||
/// An output description that was emptied stays empty when the document is saved and opened again, rather than being filled from the definition.
|
||||
#[test]
|
||||
fn an_emptied_output_description_stays_empty_after_reopening() {
|
||||
let mut document = open_demo("changing-seasons.graphite");
|
||||
let (network_path, node_id) = first_merge(&document);
|
||||
|
||||
let mut node = document.network_interface.node_mut(NodeLocator::new(node_id, &network_path)).expect("the Merge node should exist");
|
||||
node.set_output_descriptions(vec![String::new()]);
|
||||
|
||||
let content = document.serialize_document();
|
||||
let reopened = load_legacy_document(content, &HashMapResourceStorage::new(), false).expect("the saved document should open");
|
||||
assert_eq!(
|
||||
reopened.network_interface.output_description(&node_id, 0, &network_path),
|
||||
"",
|
||||
"the emptied description should stay empty"
|
||||
);
|
||||
}
|
||||
|
||||
/// The pinned display order is document state, so it survives a registry round trip. It names nodes and
|
||||
/// the stored form uses storage IDs, so this also checks the references resolve back to the right
|
||||
/// runtime nodes.
|
||||
|
||||
@@ -10,8 +10,8 @@ use graph_craft::application_io::resource::HashMapResourceStorage;
|
||||
use graph_craft::document::{DocumentNodeImplementation, NodeId};
|
||||
|
||||
use crate::messages::portfolio::document::document_message_handler::DocumentMessageHandler;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::NodeNetworkInterface;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::storage_metadata::{DocumentSettings, StorageMetadataView, build_interface_from_storage};
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::{NodeLocator, NodeNetworkInterface};
|
||||
|
||||
/// Load a demo `.graphite` straight into a `DocumentMessageHandler` for inspection.
|
||||
pub fn load_demo(file_name: &str) -> DocumentMessageHandler {
|
||||
@@ -20,6 +20,33 @@ pub fn load_demo(file_name: &str) -> DocumentMessageHandler {
|
||||
DocumentMessageHandler::deserialize_document(&content).unwrap_or_else(|e| panic!("Failed to deserialize {path}: {e:?}"))
|
||||
}
|
||||
|
||||
/// Open a demo `.graphite` the way the editor does, with its migrations and load-time fix-ups.
|
||||
pub fn open_demo(file_name: &str) -> DocumentMessageHandler {
|
||||
let path = format!("../demo-artwork/{file_name}");
|
||||
let content = std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("Failed to read {path}: {e}"));
|
||||
crate::messages::portfolio::document_storage_io::load_legacy_document(content, &HashMapResourceStorage::new(), false).unwrap_or_else(|e| panic!("Failed to open {path}: {e:?}"))
|
||||
}
|
||||
|
||||
/// Load a demo `.graphite` and describe every subgraph node's outputs, which the demos predate, so a round trip has output descriptions to carry.
|
||||
pub fn load_demo_with_output_descriptions(file_name: &str) -> DocumentMessageHandler {
|
||||
let mut document = load_demo(file_name);
|
||||
let interface = &mut document.network_interface;
|
||||
|
||||
for (network_path, node_id) in node_paths(interface) {
|
||||
let node_path = [network_path.as_slice(), &[node_id]].concat();
|
||||
let Some(export_count) = interface.nested_network(&node_path).map(|network| network.exports.len()) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let output_descriptions = (0..export_count).map(|index| format!("Output {index} of node {node_id}.")).collect();
|
||||
if let Some(mut node) = interface.node_mut(NodeLocator::new(node_id, &network_path)) {
|
||||
node.set_output_descriptions(output_descriptions);
|
||||
}
|
||||
}
|
||||
|
||||
document
|
||||
}
|
||||
|
||||
/// Walk every node in every nested network and collect `(network_path, local_id)` pairs, so a test can
|
||||
/// iterate every node addressable from the metadata side.
|
||||
pub fn node_paths(interface: &NodeNetworkInterface) -> Vec<(Vec<NodeId>, NodeId)> {
|
||||
|
||||
@@ -11,10 +11,11 @@ use graphene_std::math::quad::Quad;
|
||||
use graphene_std::transform::Footprint;
|
||||
use graphene_std::vector::Vector;
|
||||
use graphene_std::vector::click_target::{ClickTarget, ClickTargetType};
|
||||
use kurbo::{Affine, BezPath};
|
||||
use kurbo::BezPath;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::num::NonZeroU64;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
// ================
|
||||
// DocumentMetadata
|
||||
@@ -44,6 +45,11 @@ pub struct DocumentMetadata {
|
||||
pub layer_appearance_attributes: HashMap<LayerNodeIdentifier, Arc<Appearance>>,
|
||||
/// Transform from document space to viewport space.
|
||||
pub document_to_viewport: DAffine2,
|
||||
/// The transform from document space to viewport space that the latest render was made with, which is the one `upstream_footprints` include.
|
||||
pub rendered_document_to_viewport: DAffine2,
|
||||
/// A number that is replaced whenever the layer structure, or the geometry and transforms a render reported, change.
|
||||
/// Anything derived from them is up to date for as long as this is the number it was derived at.
|
||||
pub generation: u64,
|
||||
}
|
||||
|
||||
// =================================
|
||||
@@ -124,6 +130,30 @@ impl DocumentMetadata {
|
||||
self.document_to_viewport.inverse() * self.transform_to_viewport_if_feeds(layer, network_interface)
|
||||
}
|
||||
|
||||
/// The transformation to document space from layer space as the latest render had it.
|
||||
/// Unlike [`Self::transform_to_document`], this stays correct after the view changes and before the next render reports back.
|
||||
pub fn transform_to_document_as_rendered(&self, layer: LayerNodeIdentifier) -> DAffine2 {
|
||||
self.document_to_viewport_placing(layer).inverse() * self.transform_to_viewport(layer)
|
||||
}
|
||||
|
||||
/// The counterpart of [`Self::transform_to_document_as_rendered`] for [`Self::transform_to_document_if_feeds`].
|
||||
pub fn transform_to_document_as_rendered_if_feeds(&self, layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> DAffine2 {
|
||||
self.document_to_viewport_placing(layer).inverse() * self.transform_to_viewport_if_feeds(layer, network_interface)
|
||||
}
|
||||
|
||||
/// The view that [`Self::transform_to_viewport`] places a layer by: the latest render's for a layer it reported a footprint for, and the present one for any other, such as the root.
|
||||
fn document_to_viewport_placing(&self, layer: LayerNodeIdentifier) -> DAffine2 {
|
||||
let reported = layer != LayerNodeIdentifier::ROOT_PARENT && self.upstream_footprints.contains_key(&layer.to_node());
|
||||
if reported { self.rendered_document_to_viewport } else { self.document_to_viewport }
|
||||
}
|
||||
|
||||
/// Notes that the layer structure, or something a render reported, has changed.
|
||||
pub fn mark_changed(&mut self) {
|
||||
// Drawing from one counter for every document keeps a number from ever standing for two states, including across the swaps that undo and redo make
|
||||
static NEXT_GENERATION: AtomicU64 = AtomicU64::new(1);
|
||||
self.generation = NEXT_GENERATION.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn transform_to_viewport_with_first_transform_node_if_group(&self, layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> DAffine2 {
|
||||
let footprint = self.upstream_footprints.get(&layer.to_node()).map(|footprint| footprint.transform).unwrap_or(self.document_to_viewport);
|
||||
let local_transform = self.local_transforms.get(&layer.to_node()).copied();
|
||||
@@ -183,23 +213,6 @@ impl DocumentMetadata {
|
||||
.reduce(Quad::combine_bounds)
|
||||
}
|
||||
|
||||
/// Get the loose bounding box of the click target of the specified layer in the specified transform space
|
||||
pub fn loose_bounding_box_with_transform(&self, layer: LayerNodeIdentifier, transform: DAffine2) -> Option<[DVec2; 2]> {
|
||||
self.visual_targets(layer)?
|
||||
.iter()
|
||||
.filter_map(|click_target| match click_target.target_type() {
|
||||
ClickTargetType::Path(path) => {
|
||||
let mut transformed = path.clone();
|
||||
transformed.apply_affine(Affine::new(transform.to_cols_array()));
|
||||
|
||||
let control_box = transformed.control_box();
|
||||
(!transformed.is_empty()).then(|| [DVec2::new(control_box.min_x(), control_box.min_y()), DVec2::new(control_box.max_x(), control_box.max_y())])
|
||||
}
|
||||
ClickTargetType::FreePoint(_) => click_target.bounding_box_with_transform(transform),
|
||||
})
|
||||
.reduce(Quad::combine_bounds)
|
||||
}
|
||||
|
||||
/// Calculate the corners of the bounding box but with a nonzero size.
|
||||
///
|
||||
/// If the layer bounds are `0` in either axis then they are changed to be `1`.
|
||||
@@ -595,6 +608,63 @@ pub struct NodeRelations {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_transform_as_rendered_stays_put_while_the_view_moves_on() {
|
||||
let layer = LayerNodeIdentifier::new_unchecked(NodeId(3));
|
||||
let rendered_view = DAffine2::from_scale_angle_translation(DVec2::splat(2.), 0.3, DVec2::new(40., -10.));
|
||||
let layer_to_document = DAffine2::from_translation(DVec2::new(100., 50.)) * DAffine2::from_angle(0.5);
|
||||
|
||||
// A render made at one view reports where it drew the layer
|
||||
let mut metadata = DocumentMetadata {
|
||||
document_to_viewport: rendered_view,
|
||||
rendered_document_to_viewport: rendered_view,
|
||||
..Default::default()
|
||||
};
|
||||
let footprint = Footprint {
|
||||
transform: rendered_view * layer_to_document,
|
||||
..Default::default()
|
||||
};
|
||||
metadata.upstream_footprints.insert(layer.to_node(), footprint);
|
||||
assert!(metadata.transform_to_document_as_rendered(layer).abs_diff_eq(layer_to_document, 1e-9));
|
||||
|
||||
// Panning and zooming before the next render reports back leaves the layer where it was in the document
|
||||
metadata.document_to_viewport = DAffine2::from_scale_angle_translation(DVec2::splat(5.), -0.2, DVec2::new(-300., 80.));
|
||||
assert!(metadata.transform_to_document_as_rendered(layer).abs_diff_eq(layer_to_document, 1e-9));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_root_and_a_layer_without_a_footprint_stay_put_as_rendered_while_the_view_moves_on() {
|
||||
let unreported_layer = LayerNodeIdentifier::new_unchecked(NodeId(3));
|
||||
let rendered_view = DAffine2::from_scale_angle_translation(DVec2::splat(2.), 0.3, DVec2::new(40., -10.));
|
||||
let mut metadata = DocumentMetadata {
|
||||
document_to_viewport: rendered_view,
|
||||
rendered_document_to_viewport: rendered_view,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Panning and zooming before the next render reports back leaves them lined up with the document
|
||||
metadata.document_to_viewport = DAffine2::from_scale_angle_translation(DVec2::splat(5.), -0.2, DVec2::new(-300., 80.));
|
||||
for layer in [LayerNodeIdentifier::ROOT_PARENT, unreported_layer] {
|
||||
assert!(metadata.transform_to_document_as_rendered(layer).abs_diff_eq(DAffine2::IDENTITY, 1e-9));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_two_states_share_a_generation() {
|
||||
let mut first = DocumentMetadata::default();
|
||||
let mut second = DocumentMetadata::default();
|
||||
|
||||
first.mark_changed();
|
||||
let earlier = first.clone();
|
||||
second.mark_changed();
|
||||
first.mark_changed();
|
||||
|
||||
// A copy kept from before, as undo keeps one, still has the number that stood for its own state alone
|
||||
let generations = [earlier.generation, first.generation, second.generation, DocumentMetadata::default().generation];
|
||||
assert!(generations.iter().enumerate().all(|(index, generation)| !generations[..index].contains(generation)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tree() {
|
||||
let mut metadata = DocumentMetadata::default();
|
||||
|
||||
@@ -64,7 +64,6 @@ pub struct SnappingState {
|
||||
pub snapping_enabled: bool,
|
||||
pub grid_snapping: bool,
|
||||
pub artboards: bool,
|
||||
pub tolerance: f64,
|
||||
pub bounding_box: BoundingBoxSnapping,
|
||||
pub path: PathSnapping,
|
||||
pub grid: GridSnapping,
|
||||
@@ -76,7 +75,6 @@ impl Default for SnappingState {
|
||||
snapping_enabled: true,
|
||||
grid_snapping: false,
|
||||
artboards: true,
|
||||
tolerance: 8.,
|
||||
bounding_box: BoundingBoxSnapping::default(),
|
||||
path: PathSnapping::default(),
|
||||
grid: GridSnapping::default(),
|
||||
@@ -84,36 +82,6 @@ impl Default for SnappingState {
|
||||
}
|
||||
}
|
||||
|
||||
impl SnappingState {
|
||||
pub const fn target_enabled(&self, target: SnapTarget) -> bool {
|
||||
if !self.snapping_enabled {
|
||||
return false;
|
||||
}
|
||||
match target {
|
||||
SnapTarget::BoundingBox(target) => match target {
|
||||
BoundingBoxSnapTarget::CornerPoint => self.bounding_box.corner_point,
|
||||
BoundingBoxSnapTarget::EdgeMidpoint => self.bounding_box.edge_midpoint,
|
||||
BoundingBoxSnapTarget::CenterPoint => self.bounding_box.center_point,
|
||||
},
|
||||
SnapTarget::Path(target) => match target {
|
||||
PathSnapTarget::AnchorPointWithColinearHandles | PathSnapTarget::AnchorPointWithFreeHandles => self.path.anchor_point,
|
||||
PathSnapTarget::LineMidpoint => self.path.line_midpoint,
|
||||
PathSnapTarget::AlongPath => self.path.along_path,
|
||||
PathSnapTarget::NormalToPath => self.path.normal_to_path,
|
||||
PathSnapTarget::TangentToPath => self.path.tangent_to_path,
|
||||
PathSnapTarget::IntersectionPoint => self.path.path_intersection_point,
|
||||
PathSnapTarget::PerpendicularToEndpoint => self.path.perpendicular_from_endpoint,
|
||||
},
|
||||
SnapTarget::Artboard(_) => self.artboards,
|
||||
SnapTarget::Grid(_) => self.grid_snapping,
|
||||
SnapTarget::Alignment(AlignmentSnapTarget::AlignWithAnchorPoint) => self.path.align_with_anchor_point,
|
||||
SnapTarget::Alignment(_) => self.bounding_box.align_with_edges,
|
||||
SnapTarget::DistributeEvenly(_) => self.bounding_box.distribute_evenly,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct BoundingBoxSnapping {
|
||||
@@ -144,9 +112,7 @@ pub struct PathSnapping {
|
||||
pub along_path: bool,
|
||||
pub normal_to_path: bool,
|
||||
pub tangent_to_path: bool,
|
||||
pub path_intersection_point: bool,
|
||||
pub align_with_anchor_point: bool, // TODO: Rename
|
||||
pub perpendicular_from_endpoint: bool,
|
||||
}
|
||||
|
||||
impl Default for PathSnapping {
|
||||
@@ -157,9 +123,7 @@ impl Default for PathSnapping {
|
||||
along_path: true,
|
||||
normal_to_path: true,
|
||||
tangent_to_path: true,
|
||||
path_intersection_point: true,
|
||||
align_with_anchor_point: true,
|
||||
perpendicular_from_endpoint: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,136 +233,6 @@ impl GridSnapping {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum BoundingBoxSnapSource {
|
||||
CornerPoint,
|
||||
CenterPoint,
|
||||
EdgeMidpoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for BoundingBoxSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
BoundingBoxSnapSource::CornerPoint => write!(f, "Bounding Box: Corner Point"),
|
||||
BoundingBoxSnapSource::CenterPoint => write!(f, "Bounding Box: Center Point"),
|
||||
BoundingBoxSnapSource::EdgeMidpoint => write!(f, "Bounding Box: Edge Midpoint"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ArtboardSnapSource {
|
||||
CornerPoint,
|
||||
CenterPoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for ArtboardSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ArtboardSnapSource::CornerPoint => write!(f, "Artboard: Corner Point"),
|
||||
ArtboardSnapSource::CenterPoint => write!(f, "Artboard: Center Point"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum PathSnapSource {
|
||||
AnchorPointWithColinearHandles,
|
||||
AnchorPointWithFreeHandles,
|
||||
HandlePoint,
|
||||
LineMidpoint,
|
||||
IntersectionPoint,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GradientSnapSource {
|
||||
Endpoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for GradientSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
GradientSnapSource::Endpoint => write!(f, "Gradient: Endpoint"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for PathSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
PathSnapSource::AnchorPointWithColinearHandles | PathSnapSource::AnchorPointWithFreeHandles => write!(f, "Path: Anchor Point"),
|
||||
PathSnapSource::HandlePoint => write!(f, "Path: Handle Point"),
|
||||
PathSnapSource::LineMidpoint => write!(f, "Path: Line Midpoint"),
|
||||
PathSnapSource::IntersectionPoint => write!(f, "Path: Intersection Point"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AlignmentSnapSource {
|
||||
BoundingBoxCornerPoint,
|
||||
BoundingBoxCenterPoint,
|
||||
BoundingBoxEdgeMidpoint,
|
||||
ArtboardCornerPoint,
|
||||
ArtboardCenterPoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for AlignmentSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AlignmentSnapSource::BoundingBoxCornerPoint => write!(f, "{}", BoundingBoxSnapSource::CornerPoint),
|
||||
AlignmentSnapSource::BoundingBoxCenterPoint => write!(f, "{}", BoundingBoxSnapSource::CenterPoint),
|
||||
AlignmentSnapSource::BoundingBoxEdgeMidpoint => write!(f, "{}", BoundingBoxSnapSource::EdgeMidpoint),
|
||||
AlignmentSnapSource::ArtboardCornerPoint => write!(f, "{}", ArtboardSnapSource::CornerPoint),
|
||||
AlignmentSnapSource::ArtboardCenterPoint => write!(f, "{}", ArtboardSnapSource::CenterPoint),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SnapSource {
|
||||
#[default]
|
||||
None,
|
||||
BoundingBox(BoundingBoxSnapSource),
|
||||
Artboard(ArtboardSnapSource),
|
||||
Path(PathSnapSource),
|
||||
Alignment(AlignmentSnapSource),
|
||||
Gradient(GradientSnapSource),
|
||||
}
|
||||
|
||||
impl SnapSource {
|
||||
pub fn is_some(&self) -> bool {
|
||||
self != &Self::None
|
||||
}
|
||||
pub fn bounding_box(&self) -> bool {
|
||||
matches!(self, Self::BoundingBox(_) | Self::Artboard(_))
|
||||
}
|
||||
pub fn align(&self) -> bool {
|
||||
matches!(self, Self::Alignment(_))
|
||||
}
|
||||
pub fn center(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::Alignment(AlignmentSnapSource::ArtboardCenterPoint | AlignmentSnapSource::BoundingBoxCenterPoint)
|
||||
| Self::Artboard(ArtboardSnapSource::CenterPoint)
|
||||
| Self::BoundingBox(BoundingBoxSnapSource::CenterPoint)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
SnapSource::None => write!(f, "None"),
|
||||
SnapSource::BoundingBox(bounding_box_snap_source) => write!(f, "{bounding_box_snap_source}"),
|
||||
SnapSource::Artboard(artboard_snap_source) => write!(f, "{artboard_snap_source}"),
|
||||
SnapSource::Path(path_snap_source) => write!(f, "{path_snap_source}"),
|
||||
SnapSource::Alignment(alignment_snap_source) => write!(f, "{alignment_snap_source}"),
|
||||
SnapSource::Gradient(gradient_snap_source) => write!(f, "{gradient_snap_source}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type GetSnapState = for<'a> fn(&'a mut SnappingState) -> &'a mut bool;
|
||||
pub const SNAP_FUNCTIONS_FOR_BOUNDING_BOXES: [(&str, GetSnapState, &str); 5] = [
|
||||
(
|
||||
@@ -427,7 +261,7 @@ pub const SNAP_FUNCTIONS_FOR_BOUNDING_BOXES: [(&str, GetSnapState, &str); 5] = [
|
||||
"Snaps to a consistent distance offset established by the bounding boxes of nearby layers.",
|
||||
),
|
||||
];
|
||||
pub const SNAP_FUNCTIONS_FOR_PATHS: [(&str, GetSnapState, &str); 7] = [
|
||||
pub const SNAP_FUNCTIONS_FOR_PATHS: [(&str, GetSnapState, &str); 6] = [
|
||||
(
|
||||
"Align with Anchor Points",
|
||||
(|snapping_state: &mut SnappingState| &mut snapping_state.path.align_with_anchor_point) as GetSnapState,
|
||||
@@ -444,205 +278,23 @@ pub const SNAP_FUNCTIONS_FOR_PATHS: [(&str, GetSnapState, &str); 7] = [
|
||||
(|snapping_state: &mut SnappingState| &mut snapping_state.path.line_midpoint) as GetSnapState,
|
||||
"Snaps to the point at the middle of any straight line segment of a vector path.",
|
||||
),
|
||||
(
|
||||
"Path Intersection Points",
|
||||
(|snapping_state: &mut SnappingState| &mut snapping_state.path.path_intersection_point) as GetSnapState,
|
||||
"Snaps to any points where vector paths intersect.",
|
||||
),
|
||||
(
|
||||
"Along Paths",
|
||||
(|snapping_state: &mut SnappingState| &mut snapping_state.path.along_path) as GetSnapState,
|
||||
"Snaps along the length of any vector path.",
|
||||
),
|
||||
(
|
||||
// TODO: This works correctly for line segments, but not curved segments.
|
||||
// TODO: Therefore, we should make this use the normal in relation to the incoming curve, not the straight line between the incoming curve's start point and the path.
|
||||
"Normal to Paths",
|
||||
(|snapping_state: &mut SnappingState| &mut snapping_state.path.normal_to_path) as GetSnapState,
|
||||
// TODO: Fix the bug/limitation that requires 'Intersections of Paths' to be enabled
|
||||
"Snaps a line to a point perpendicular to a vector path.\n(Due to a bug, 'Intersections of Paths' must be enabled.)",
|
||||
"Snaps a line to a point perpendicular to a vector path.",
|
||||
),
|
||||
(
|
||||
// TODO: This works correctly for line segments, but not curved segments.
|
||||
// TODO: Therefore, we should make this use the tangent in relation to the incoming curve, not the straight line between the incoming curve's start point and the path.
|
||||
"Tangent to Paths",
|
||||
(|snapping_state: &mut SnappingState| &mut snapping_state.path.tangent_to_path) as GetSnapState,
|
||||
// TODO: Fix the bug/limitation that requires 'Intersections of Paths' to be enabled
|
||||
"Snaps a line to a point tangent to a vector path.\n(Due to a bug, 'Intersections of Paths' must be enabled.)",
|
||||
"Snaps a line to a point tangent to a vector path.",
|
||||
),
|
||||
];
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum BoundingBoxSnapTarget {
|
||||
CornerPoint,
|
||||
CenterPoint,
|
||||
EdgeMidpoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for BoundingBoxSnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
BoundingBoxSnapTarget::CornerPoint => write!(f, "Bounding Box: Corner Point"),
|
||||
BoundingBoxSnapTarget::CenterPoint => write!(f, "Bounding Box: Center Point"),
|
||||
BoundingBoxSnapTarget::EdgeMidpoint => write!(f, "Bounding Box: Edge Midpoint"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum PathSnapTarget {
|
||||
AnchorPointWithColinearHandles,
|
||||
AnchorPointWithFreeHandles,
|
||||
LineMidpoint,
|
||||
AlongPath,
|
||||
NormalToPath,
|
||||
TangentToPath,
|
||||
IntersectionPoint,
|
||||
PerpendicularToEndpoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for PathSnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
PathSnapTarget::AnchorPointWithColinearHandles | PathSnapTarget::AnchorPointWithFreeHandles => write!(f, "Path: Anchor Point"),
|
||||
PathSnapTarget::LineMidpoint => write!(f, "Path: Line Midpoint"),
|
||||
PathSnapTarget::AlongPath => write!(f, "Path: Along Path"),
|
||||
PathSnapTarget::NormalToPath => write!(f, "Path: Normal to Path"),
|
||||
PathSnapTarget::TangentToPath => write!(f, "Path: Tangent to Path"),
|
||||
PathSnapTarget::IntersectionPoint => write!(f, "Path: Intersection Point"),
|
||||
PathSnapTarget::PerpendicularToEndpoint => write!(f, "Path: Perp. to Endpoint"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ArtboardSnapTarget {
|
||||
CornerPoint,
|
||||
CenterPoint,
|
||||
AlongEdge,
|
||||
}
|
||||
|
||||
impl fmt::Display for ArtboardSnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ArtboardSnapTarget::CornerPoint => write!(f, "Artboard: Corner Point"),
|
||||
ArtboardSnapTarget::CenterPoint => write!(f, "Artboard: Center Point"),
|
||||
ArtboardSnapTarget::AlongEdge => write!(f, "Artboard: Along Edge"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GridSnapTarget {
|
||||
Line,
|
||||
LineNormal,
|
||||
Intersection,
|
||||
}
|
||||
|
||||
impl fmt::Display for GridSnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
GridSnapTarget::Line => write!(f, "Grid: Along Line"),
|
||||
GridSnapTarget::LineNormal => write!(f, "Grid: Normal to Line"),
|
||||
GridSnapTarget::Intersection => write!(f, "Grid: Intersection Point"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AlignmentSnapTarget {
|
||||
BoundingBoxCornerPoint,
|
||||
BoundingBoxCenterPoint,
|
||||
ArtboardCornerPoint,
|
||||
ArtboardCenterPoint,
|
||||
AlignWithAnchorPoint,
|
||||
IntersectionPoint,
|
||||
PerpendicularToEndpoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for AlignmentSnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AlignmentSnapTarget::BoundingBoxCornerPoint => write!(f, "{}", BoundingBoxSnapTarget::CornerPoint),
|
||||
AlignmentSnapTarget::BoundingBoxCenterPoint => write!(f, "{}", BoundingBoxSnapTarget::CenterPoint),
|
||||
AlignmentSnapTarget::ArtboardCornerPoint => write!(f, "{}", ArtboardSnapTarget::CornerPoint),
|
||||
AlignmentSnapTarget::ArtboardCenterPoint => write!(f, "{}", ArtboardSnapTarget::CenterPoint),
|
||||
AlignmentSnapTarget::AlignWithAnchorPoint => write!(f, "{}", PathSnapTarget::AnchorPointWithColinearHandles),
|
||||
AlignmentSnapTarget::IntersectionPoint => write!(f, "{}", PathSnapTarget::IntersectionPoint),
|
||||
AlignmentSnapTarget::PerpendicularToEndpoint => write!(f, "{}", PathSnapTarget::PerpendicularToEndpoint),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DistributionSnapTarget {
|
||||
X,
|
||||
Y,
|
||||
Right,
|
||||
Left,
|
||||
Up,
|
||||
Down,
|
||||
XY,
|
||||
}
|
||||
|
||||
impl fmt::Display for DistributionSnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
DistributionSnapTarget::X => write!(f, "Distribute: X"),
|
||||
DistributionSnapTarget::Y => write!(f, "Distribute: Y"),
|
||||
DistributionSnapTarget::Right => write!(f, "Distribute: Right"),
|
||||
DistributionSnapTarget::Left => write!(f, "Distribute: Left"),
|
||||
DistributionSnapTarget::Up => write!(f, "Distribute: Up"),
|
||||
DistributionSnapTarget::Down => write!(f, "Distribute: Down"),
|
||||
DistributionSnapTarget::XY => write!(f, "Distribute: XY"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DistributionSnapTarget {
|
||||
pub const fn is_x(&self) -> bool {
|
||||
matches!(self, Self::Left | Self::Right | Self::X)
|
||||
}
|
||||
pub const fn is_y(&self) -> bool {
|
||||
matches!(self, Self::Up | Self::Down | Self::Y)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SnapTarget {
|
||||
#[default]
|
||||
None,
|
||||
BoundingBox(BoundingBoxSnapTarget),
|
||||
Path(PathSnapTarget),
|
||||
Artboard(ArtboardSnapTarget),
|
||||
Grid(GridSnapTarget),
|
||||
Alignment(AlignmentSnapTarget),
|
||||
DistributeEvenly(DistributionSnapTarget),
|
||||
}
|
||||
|
||||
impl SnapTarget {
|
||||
pub fn is_some(&self) -> bool {
|
||||
self != &Self::None
|
||||
}
|
||||
pub fn bounding_box(&self) -> bool {
|
||||
matches!(self, Self::BoundingBox(_) | Self::Artboard(_))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SnapTarget {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
SnapTarget::None => write!(f, "None"),
|
||||
SnapTarget::BoundingBox(bounding_box_snap_target) => write!(f, "{bounding_box_snap_target}"),
|
||||
SnapTarget::Path(path_snap_target) => write!(f, "{path_snap_target}"),
|
||||
SnapTarget::Artboard(artboard_snap_target) => write!(f, "{artboard_snap_target}"),
|
||||
SnapTarget::Grid(grid_snap_target) => write!(f, "{grid_snap_target}"),
|
||||
SnapTarget::Alignment(alignment_snap_target) => write!(f, "{alignment_snap_target}"),
|
||||
SnapTarget::DistributeEvenly(distribution_snap_target) => write!(f, "{distribution_snap_target}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: implement icons for SnappingOptions eventually
|
||||
pub enum SnappingOptions {
|
||||
BoundingBoxes,
|
||||
|
||||
@@ -54,7 +54,7 @@ impl NodeNetworkInterface {
|
||||
// A peer can name a slot past the end of this network's exports, which is an insert here
|
||||
// rather than a write to a slot that does not exist yet.
|
||||
Some(input) if *export_index >= self.number_of_exports(network_path) => {
|
||||
self.insert_export_slot(network_path, *export_index, input.clone(), String::new());
|
||||
self.insert_export_slot(network_path, *export_index, input.clone(), String::new(), String::new());
|
||||
}
|
||||
Some(input) => {
|
||||
self.set_input_slot(&InputConnector::Export(*export_index), network_path, input.clone());
|
||||
@@ -107,6 +107,7 @@ impl NodeNetworkInterface {
|
||||
NodeMetadataChange::Locked(locked) => node.set_locked(*locked),
|
||||
NodeMetadataChange::Pinned(pinned) => node.set_pinned(*pinned),
|
||||
NodeMetadataChange::OutputNames(output_names) => node.set_output_names(output_names.clone()),
|
||||
NodeMetadataChange::OutputDescriptions(output_descriptions) => node.set_output_descriptions(output_descriptions.clone()),
|
||||
NodeMetadataChange::InputName { index, name } => node.set_input_name(*index, name.clone()),
|
||||
NodeMetadataChange::WidgetOverride { index, widget_override } => node.set_widget_override(*index, widget_override.clone()),
|
||||
};
|
||||
|
||||
@@ -337,39 +337,6 @@ impl NodeNetworkInterface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modify_import_export(&mut self, network_path: &[NodeId]) -> Option<&ModifyImportExportClickTarget> {
|
||||
self.load_modify_import_export(network_path);
|
||||
|
||||
let Some(transient) = self.network_transient_mut(network_path) else {
|
||||
log::error!("Could not get nested network_metadata in modify_import_export");
|
||||
return None;
|
||||
};
|
||||
let Some(click_targets) = transient.modify_import_export.get_loaded_mut() else {
|
||||
log::error!("Could not load modify import export in modify_import_export");
|
||||
return None;
|
||||
};
|
||||
Some(click_targets)
|
||||
}
|
||||
|
||||
pub fn load_modify_import_export(&self, network_path: &[NodeId]) {
|
||||
let Some(network_metadata) = self.network_metadata(network_path) else {
|
||||
log::error!("Could not get nested network_metadata in load_modify_import_export");
|
||||
return;
|
||||
};
|
||||
network_metadata
|
||||
.transient_metadata
|
||||
.modify_import_export
|
||||
.ensure_loaded(|| self.compute_modify_import_export(network_path));
|
||||
}
|
||||
|
||||
pub(crate) fn unload_modify_import_export(&mut self, network_path: &[NodeId]) {
|
||||
let Some(transient) = self.network_transient_mut(network_path) else {
|
||||
log::error!("Could not get nested network_metadata in unload_modify_import_export");
|
||||
return;
|
||||
};
|
||||
transient.modify_import_export.unload();
|
||||
}
|
||||
|
||||
/// Reads the owned nodes of a layer through &self if they are loaded.
|
||||
pub(crate) fn with_owned_nodes_if_loaded<R>(&self, node_id: &NodeId, network_path: &[NodeId], read: impl FnOnce(&HashSet<NodeId>) -> R) -> Option<R> {
|
||||
let layer_node = self.node_metadata(node_id, network_path)?;
|
||||
@@ -853,14 +820,6 @@ impl NodeNetworkInterface {
|
||||
.with_loaded_or(|| self.compute_node_click_targets(node_id, network_path), read)
|
||||
}
|
||||
|
||||
/// Reads the modify import/export click targets through &self, loading them first if needed.
|
||||
pub(crate) fn with_modify_import_export<R>(&self, network_path: &[NodeId], read: impl FnOnce(&ModifyImportExportClickTarget) -> R) -> Option<R> {
|
||||
self.network_metadata(network_path)?
|
||||
.transient_metadata
|
||||
.modify_import_export
|
||||
.with_loaded_or(|| self.compute_modify_import_export(network_path), read)
|
||||
}
|
||||
|
||||
/// Reads the node click targets through &self if they are already loaded.
|
||||
pub(crate) fn with_node_click_targets_if_loaded<R>(&self, node_id: &NodeId, network_path: &[NodeId], read: impl FnOnce(&DocumentNodeClickTargets) -> R) -> Option<R> {
|
||||
let node_metadata = self.node_metadata(node_id, network_path)?;
|
||||
|
||||
+623
-3
@@ -1,10 +1,12 @@
|
||||
use super::{
|
||||
ChainInsertionPoint, FlowType, InputConnector, NodeNetworkInterface, NodeNetworkTemplate, NodeTemplate, NodeTemplateImplementation, OutputConnector, Previewing, RootNode, TransactionStatus,
|
||||
ChainInsertionPoint, FlowType, ImportOrExport, InputConnector, NodeNetworkInterface, NodeNetworkTemplate, NodeTemplate, NodeTemplateImplementation, NodeTypePersistentMetadata, OutputConnector,
|
||||
Previewing, RootNode, TransactionStatus,
|
||||
};
|
||||
use crate::messages::portfolio::document::node_graph::utility_types::Direction;
|
||||
use crate::messages::portfolio::document::node_graph::utility_types::{ContextMenuData, Direction};
|
||||
use crate::messages::portfolio::document::utility_types::wires::GraphWireStyle;
|
||||
use crate::test_utils::test_prelude::*;
|
||||
use graph_craft::document::NodeInput;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNodeImplementation, NodeInput};
|
||||
use graphene_std::uuid::NodeId;
|
||||
|
||||
fn assert_invariants(editor: &EditorTestUtils, context: &str) {
|
||||
@@ -982,6 +984,326 @@ async fn signature_edits_keep_parallel_metadata_in_sync() {
|
||||
assert_invariants(&editor, "after removing the added export");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn reordering_an_import_to_the_front_makes_it_the_exposed_primary() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
|
||||
// Dropping an import or export just below itself leaves it where it was
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.reorder_import(1, 2, &path);
|
||||
assert!(
|
||||
network_interface.reference(&merge, &[]).is_some(),
|
||||
"dropping an import back where it was should leave the subgraph matching its definition"
|
||||
);
|
||||
network_interface.reorder_export(0, 1, &path);
|
||||
assert!(
|
||||
network_interface.reference(&merge, &[]).is_some(),
|
||||
"dropping an export back where it was should leave the subgraph matching its definition"
|
||||
);
|
||||
|
||||
network_interface.add_import(TaggedValue::Number(1.), false, -1, "Parameter", "", &path);
|
||||
let parameter_index = network_interface.number_of_imports(&path) - 1;
|
||||
let previous_primary_name = network_interface.displayed_import_name(0, &path);
|
||||
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::ReorderImport {
|
||||
start_index: parameter_index,
|
||||
end_index: 0,
|
||||
})
|
||||
.await;
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let new_primary = network_interface
|
||||
.document_node(&merge, &[])
|
||||
.and_then(|node| node.inputs.first())
|
||||
.expect("Merge should have a primary input");
|
||||
assert!(new_primary.is_exposed(), "a parameter moved to the front should be exposed as the primary import");
|
||||
assert_eq!(network_interface.displayed_import_name(0, &path), "Parameter");
|
||||
assert_eq!(
|
||||
network_interface.displayed_import_name(1, &path),
|
||||
previous_primary_name,
|
||||
"the previous primary should become the first secondary import"
|
||||
);
|
||||
|
||||
assert_invariants(&editor, "after reordering a parameter to be the primary import");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn moving_the_primary_import_among_the_secondary_ones_leaves_an_empty_primary() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.add_import(TaggedValue::Number(1.), true, -1, "Parameter", "", &path);
|
||||
let primary_name = network_interface.displayed_import_name(0, &path);
|
||||
let secondary_name = network_interface.displayed_import_name(1, &path);
|
||||
let fed_by_primary = fed_inputs(&editor, &OutputConnector::Import(0), &path);
|
||||
|
||||
// Drop the primary between the first and second secondary imports
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor.handle_message(NodeGraphMessage::ReorderImport { start_index: 0, end_index: 2 }).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(network_interface.hidden_primary_import(&path), "the primary's place should be left empty");
|
||||
assert_eq!(network_interface.displayed_import_name(1, &path), secondary_name, "the first secondary import should stay secondary");
|
||||
assert_eq!(network_interface.displayed_import_name(2, &path), primary_name, "the moved import should land where it was dropped");
|
||||
assert_eq!(
|
||||
fed_inputs(&editor, &OutputConnector::Import(2), &path),
|
||||
fed_by_primary,
|
||||
"the moved import should keep feeding what it fed"
|
||||
);
|
||||
|
||||
assert_invariants(&editor, "after moving the primary import among the secondary ones");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_primary_import_can_become_the_first_secondary_and_an_empty_primary_can_be_filled() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let primary_name = network_interface.displayed_import_name(0, &path);
|
||||
let secondary_name = network_interface.displayed_import_name(1, &path);
|
||||
let import_count = network_interface.number_of_imports(&path);
|
||||
|
||||
// Dropped just below the separator, the primary becomes the first secondary import
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor.handle_message(NodeGraphMessage::ReorderImport { start_index: 0, end_index: 1 }).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(network_interface.hidden_primary_import(&path), "the primary's place should be left empty");
|
||||
assert_eq!(network_interface.displayed_import_name(1, &path), primary_name, "the moved import should be the first secondary one");
|
||||
assert_eq!(network_interface.displayed_import_name(2, &path), secondary_name);
|
||||
|
||||
// Dropping a secondary import into the empty primary fills it, rather than keeping the empty one as a secondary import
|
||||
editor.handle_message(NodeGraphMessage::ReorderImport { start_index: 2, end_index: 0 }).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(!network_interface.hidden_primary_import(&path), "the primary should be filled");
|
||||
assert_eq!(network_interface.displayed_import_name(0, &path), secondary_name);
|
||||
assert_eq!(network_interface.displayed_import_name(1, &path), primary_name);
|
||||
assert_eq!(network_interface.number_of_imports(&path), import_count, "the empty primary should be gone rather than pushed down");
|
||||
|
||||
assert_invariants(&editor, "after filling an empty primary import");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_primary_export_can_become_the_first_secondary() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor.handle_message(NodeGraphMessage::AddSecondaryExport).await;
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let primary_source = network_interface.upstream_output_connector(&InputConnector::Export(0), &path);
|
||||
assert!(primary_source.is_some(), "Merge's primary export should be wired");
|
||||
|
||||
editor.handle_message(NodeGraphMessage::ReorderExport { start_index: 0, end_index: 1 }).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(network_interface.hidden_primary_export(&path), "the primary's place should be left empty");
|
||||
assert_eq!(
|
||||
network_interface.upstream_output_connector(&InputConnector::Export(1), &path),
|
||||
primary_source,
|
||||
"the moved export should be the first secondary one"
|
||||
);
|
||||
assert_eq!(network_interface.number_of_exports(&path), 3, "the empty primary should be added in front of both exports");
|
||||
|
||||
assert_invariants(&editor, "after making the primary export secondary");
|
||||
}
|
||||
|
||||
/// The inputs fed by `output_connector` in the network at `network_path`, in no particular order.
|
||||
fn fed_inputs(editor: &EditorTestUtils, output_connector: &OutputConnector, network_path: &[NodeId]) -> HashSet<InputConnector> {
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
network_interface
|
||||
.with_outward_wires(network_path, |outward_wires| outward_wires.get(output_connector).cloned())
|
||||
.flatten()
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn adding_an_import_passthrough_takes_over_the_wires_the_import_fed() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
let content_import = OutputConnector::Import(1);
|
||||
let fed_before = fed_inputs(&editor, &content_import, &path);
|
||||
assert!(!fed_before.is_empty(), "Merge's content import should feed its subgraph: fixture is wrong");
|
||||
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor.handle_message(NodeGraphMessage::AddImportPassthrough { import_index: 1 }).await;
|
||||
|
||||
let fed_after = fed_inputs(&editor, &content_import, &path);
|
||||
let [InputConnector::Node { node_id: passthrough, input_index: 0 }] = fed_after.into_iter().collect::<Vec<_>>()[..] else {
|
||||
panic!("the import should feed only the Passthrough's primary input");
|
||||
};
|
||||
assert_eq!(
|
||||
fed_inputs(&editor, &OutputConnector::primary_output(passthrough), &path),
|
||||
fed_before,
|
||||
"the Passthrough should feed what the import fed"
|
||||
);
|
||||
|
||||
assert_invariants(&editor, "after adding an import passthrough");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn editing_import_and_export_descriptions_stores_them_on_the_subgraph_node() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::SetImportExportDescription {
|
||||
description: "The artwork to add.".to_string(),
|
||||
index: ImportOrExport::Import(1),
|
||||
})
|
||||
.await;
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::SetImportExportDescription {
|
||||
description: "The combined result.".to_string(),
|
||||
index: ImportOrExport::Export(0),
|
||||
})
|
||||
.await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let import_description = network_interface.persistent_input_metadata(&merge, 1, &[]).map(|metadata| metadata.input_description.as_str());
|
||||
assert_eq!(import_description, Some("The artwork to add."));
|
||||
assert_eq!(network_interface.output_description(&merge, 0, &[]), "The combined result.");
|
||||
|
||||
assert_invariants(&editor, "after editing import and export descriptions");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_empty_import_connectors_add_the_next_import_or_fill_the_empty_primary() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
let import_count = editor.active_document().network_interface.number_of_imports(&path);
|
||||
|
||||
// With a primary, the only one is past the last import
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let empty_connectors = network_interface.empty_import_export_connectors(true, &path);
|
||||
assert_eq!(empty_connectors.iter().map(|(index, _)| *index).collect::<Vec<_>>(), vec![import_count]);
|
||||
|
||||
// The attribute name given to Merge's interior Write Attribute node
|
||||
let write_attribute = network_interface
|
||||
.nested_network(&path)
|
||||
.and_then(|network| {
|
||||
network
|
||||
.nodes
|
||||
.iter()
|
||||
.find(|(_, node)| node.implementation == DocumentNodeImplementation::ProtoNode(graphene_std::graphic::write_attribute::IDENTIFIER))
|
||||
})
|
||||
.map(|(node_id, _)| *node_id)
|
||||
.expect("Merge should contain a Write Attribute node");
|
||||
let value_input = InputConnector::node_at_index(write_attribute, 1);
|
||||
let Some(NodeInput::Value { tagged_value, .. }) = network_interface.input_from_connector(&value_input, &path) else {
|
||||
panic!("Merge's Write Attribute node should be given its attribute name as a value");
|
||||
};
|
||||
let displaced_value = (**tagged_value).clone();
|
||||
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::AddImportAndConnect {
|
||||
import_index: import_count,
|
||||
input_connector: value_input,
|
||||
})
|
||||
.await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert_eq!(network_interface.number_of_imports(&path), import_count + 1, "the next import should be added");
|
||||
assert!(
|
||||
fed_inputs(&editor, &OutputConnector::Import(import_count), &path).contains(&value_input),
|
||||
"the new import should be wired to the input"
|
||||
);
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let new_input = network_interface.input_from_connector(&InputConnector::node_at_index(merge, import_count), &[]);
|
||||
assert!(
|
||||
matches!(new_input, Some(NodeInput::Value { tagged_value, exposed: true }) if **tagged_value == displaced_value),
|
||||
"the new import should take over the value its wire displaced, found {new_input:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
network_interface.displayed_import_name(import_count, &path),
|
||||
displaced_value.ty().nested_type().to_string(),
|
||||
"an import without a name should be shown by the type it took over"
|
||||
);
|
||||
|
||||
// Emptying the primary adds a connector in its place, which fills it again from an input that's already wired
|
||||
editor.handle_message(NodeGraphMessage::ExposeEncapsulatingInput { input_index: 0, exposed: false }).await;
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(network_interface.empty_import_export_connectors(true, &path).iter().any(|(index, _)| *index == 0));
|
||||
|
||||
// The content given to Merge's interior Write Attribute node by its Into Group node
|
||||
let wired_input = InputConnector::node_at_index(write_attribute, 0);
|
||||
assert!(
|
||||
matches!(network_interface.input_from_connector(&wired_input, &path), Some(NodeInput::Node { .. })),
|
||||
"Merge's Write Attribute node should be wired its content from another node"
|
||||
);
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::AddImportAndConnect {
|
||||
import_index: 0,
|
||||
input_connector: wired_input,
|
||||
})
|
||||
.await;
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(!network_interface.hidden_primary_import(&path), "the empty primary should be filled");
|
||||
assert_eq!(network_interface.number_of_imports(&path), import_count + 1, "filling the empty primary shouldn't add another import");
|
||||
|
||||
let drawn_wire = network_interface
|
||||
.network_metadata(&path)
|
||||
.and_then(|network_metadata| network_metadata.transient_metadata.wires.borrow().get(&wired_input).cloned())
|
||||
.and_then(|wire| wire.wire_path_update);
|
||||
let current_wire = network_interface.wire_path_from_input(&wired_input, GraphWireStyle::default(), false, &path);
|
||||
assert_eq!(drawn_wire, current_wire, "the input's wire should be redrawn from its new import");
|
||||
|
||||
assert_invariants(&editor, "after adding imports from the empty connectors");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn showing_a_secondary_import_in_the_inspector_keeps_its_wires_in_the_subgraph() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
let content_import = OutputConnector::Import(1);
|
||||
let fed_before = fed_inputs(&editor, &content_import, &path);
|
||||
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
editor.handle_message(NodeGraphMessage::ExposeEncapsulatingInput { input_index: 1, exposed: false }).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let content_input = network_interface
|
||||
.input_from_connector(&InputConnector::node_at_index(merge, 1), &[])
|
||||
.expect("Merge should have a content input");
|
||||
assert!(!content_input.is_exposed(), "the subgraph node should show the input as a parameter instead of a connector");
|
||||
assert_eq!(
|
||||
fed_inputs(&editor, &content_import, &path),
|
||||
fed_before,
|
||||
"the import should still feed the same inputs within the subgraph"
|
||||
);
|
||||
|
||||
assert_invariants(&editor, "after showing a secondary import in the Inspector");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn toggle_preview_transitions_with_a_connected_export() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
@@ -1086,6 +1408,71 @@ fn replacing_inputs_keeps_the_loaded_wire_cache_exact() {
|
||||
assert_interface_invariants(&network_interface, "after rewiring the source into the replaced node");
|
||||
}
|
||||
|
||||
// A chain node is placed only by its link into the next node, so it leaves the chain only when replacing inputs drops that link
|
||||
#[test]
|
||||
fn replacing_inputs_breaks_a_chain_only_where_its_link_is_dropped() {
|
||||
let (layer, chain_node, side_consumer) = (NodeId(1), NodeId(2), NodeId(3));
|
||||
let mut network_interface = NodeNetworkInterface::default();
|
||||
network_interface.insert_node(
|
||||
layer,
|
||||
NodeTemplate {
|
||||
inputs: vec![value_input(); 2],
|
||||
node_type_metadata: NodeTypePersistentMetadata::layer(IVec2::ZERO),
|
||||
..Default::default()
|
||||
},
|
||||
&[],
|
||||
);
|
||||
let two_exports = NodeNetworkTemplate {
|
||||
exports: vec![NodeInput::value(TaggedValue::None, true), value_input()],
|
||||
..Default::default()
|
||||
};
|
||||
network_interface.insert_node(
|
||||
chain_node,
|
||||
NodeTemplate {
|
||||
inputs: vec![value_input()],
|
||||
implementation: NodeTemplateImplementation::Network(two_exports),
|
||||
output_names: vec![String::new(); 2],
|
||||
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(-7, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
&[],
|
||||
);
|
||||
network_interface.insert_node(
|
||||
side_consumer,
|
||||
NodeTemplate {
|
||||
inputs: vec![value_input(); 2],
|
||||
..Default::default()
|
||||
},
|
||||
&[],
|
||||
);
|
||||
|
||||
// Only consumers of the primary output keep a node out of a chain, so one feeding a parameter from its second output still joins
|
||||
network_interface.set_input(&InputConnector::node_at_index(side_consumer, 1), NodeInput::node(chain_node, 1), &[]);
|
||||
network_interface.set_input(&InputConnector::node_at_index(layer, 1), NodeInput::node(chain_node, 0), &[]);
|
||||
assert!(network_interface.is_chain(&chain_node, &[]), "the node should join the layer's chain");
|
||||
let chain_position = network_interface.position(&chain_node, &[]);
|
||||
|
||||
let replacement = || {
|
||||
let mut template = NodeTemplate {
|
||||
inputs: vec![value_input(); 2],
|
||||
..Default::default()
|
||||
};
|
||||
template.normalize_input_metadata();
|
||||
template
|
||||
};
|
||||
|
||||
network_interface.replace_inputs(&side_consumer, &[], &mut replacement());
|
||||
assert!(
|
||||
network_interface.is_chain(&chain_node, &[]),
|
||||
"dropping the wire from its second output should leave the node in the chain"
|
||||
);
|
||||
|
||||
network_interface.replace_inputs(&layer, &[], &mut replacement());
|
||||
assert!(!network_interface.is_chain(&chain_node, &[]), "dropping its link into the layer should take the node out of the chain");
|
||||
assert_eq!(network_interface.position(&chain_node, &[]), chain_position, "the node should stay where the chain placed it");
|
||||
assert_interface_invariants(&network_interface, "after replacing the inputs around a chain node");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replacing_an_implementation_keeps_its_outputs_listed_in_the_wire_cache() {
|
||||
let (mut network_interface, _, node, _) = wired_interface();
|
||||
@@ -1204,3 +1591,236 @@ fn adding_an_import_ahead_of_a_wired_input_keeps_the_loaded_wire_cache_exact() {
|
||||
let consumers = network_interface.outward_wires(&[]).and_then(|wires| wires.get(&OutputConnector::node(source, 0)).cloned());
|
||||
assert_eq!(consumers.as_deref(), Some([InputConnector::node_at_index(node, 1)].as_slice()));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_subgraph_output_fed_by_a_value_can_produce_its_type() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.add_export(TaggedValue::Number(1.), -1, "", &path);
|
||||
network_interface.add_export(TaggedValue::None, -1, "", &path);
|
||||
let number_output = OutputConnector::node(merge, network_interface.number_of_exports(&path) - 2);
|
||||
let placeholder_output = OutputConnector::node(merge, network_interface.number_of_exports(&path) - 1);
|
||||
|
||||
let number_type = TaggedValue::Number(1.).ty().nested_type().clone();
|
||||
assert_eq!(
|
||||
network_interface.possible_output_types(&number_output, &[]),
|
||||
vec![number_type],
|
||||
"an export given a value can only produce its type"
|
||||
);
|
||||
assert!(
|
||||
network_interface.possible_output_types(&placeholder_output, &[]).is_empty(),
|
||||
"a new export's empty placeholder shouldn't be listed as a type it can produce"
|
||||
);
|
||||
}
|
||||
|
||||
/// Presses at `from` and releases at `to`, both in the graph space of the network at `path`, as the node graph receives a mouse drag.
|
||||
async fn drag_in_graph(editor: &mut EditorTestUtils, path: &[NodeId], from: DVec2, to: DVec2) {
|
||||
let node_graph_to_viewport = editor
|
||||
.active_document()
|
||||
.network_interface
|
||||
.network_metadata(path)
|
||||
.expect("the network should have metadata")
|
||||
.persistent_metadata
|
||||
.navigation_metadata
|
||||
.node_graph_to_viewport;
|
||||
let (from, to) = (node_graph_to_viewport.transform_point2(from), node_graph_to_viewport.transform_point2(to));
|
||||
|
||||
editor.move_mouse(from.x, from.y, ModifierKeys::empty(), MouseKeys::empty()).await;
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::PointerDown {
|
||||
shift_click: false,
|
||||
control_click: false,
|
||||
alt_click: false,
|
||||
right_click: false,
|
||||
})
|
||||
.await;
|
||||
editor.move_mouse(to.x, to.y, ModifierKeys::empty(), MouseKeys::LEFT).await;
|
||||
editor.handle_message(NodeGraphMessage::PointerMove { shift: Key::Shift }).await;
|
||||
editor.handle_message(NodeGraphMessage::PointerUp).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_wire_dragged_backward_from_an_empty_input_connects_to_the_output_it_is_dropped_on() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let rectangle = editor.create_node_by_name_at(rectangle_definition(), 0, 0).await;
|
||||
let fill = editor.create_node_by_name_at(fill_definition(), 20, 0).await;
|
||||
let fill_content = InputConnector::node_at_index(fill, 0);
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert!(network_interface.upstream_output_connector(&fill_content, &[]).is_none(), "Fill's content should start out unwired");
|
||||
let input_position = network_interface.input_position(&fill_content, &[]).expect("Fill's content should have a position");
|
||||
let output_position = network_interface
|
||||
.output_position(&OutputConnector::node(rectangle, 0), &[])
|
||||
.expect("Rectangle's output should have a position");
|
||||
|
||||
drag_in_graph(&mut editor, &[], input_position, output_position).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert_eq!(
|
||||
network_interface.upstream_output_connector(&fill_content, &[]),
|
||||
Some(OutputConnector::node(rectangle, 0)),
|
||||
"the wire dragged back from Fill's content should connect it to Rectangle's output"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_wire_dragged_backward_onto_empty_space_wires_the_node_picked_from_the_menu() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let fill = editor.create_node_by_name_at(fill_definition(), 20, 0).await;
|
||||
let fill_content = InputConnector::node_at_index(fill, 0);
|
||||
let input_position = editor
|
||||
.active_document()
|
||||
.network_interface
|
||||
.input_position(&fill_content, &[])
|
||||
.expect("Fill's content should have a position");
|
||||
|
||||
drag_in_graph(&mut editor, &[], input_position, input_position - DVec2::new(240., 0.)).await;
|
||||
|
||||
let context_menu = editor.active_document().node_graph_handler.context_menu.clone();
|
||||
assert!(
|
||||
matches!(context_menu.map(|menu| menu.context_menu_data), Some(ContextMenuData::CreateNode { compatible_type: None })),
|
||||
"dropping the wire on empty space should open the node menu without filtering it"
|
||||
);
|
||||
|
||||
let rectangle = NodeId::new();
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::CreateNodeFromContextMenu {
|
||||
node_id: Some(rectangle),
|
||||
node_type: rectangle_definition(),
|
||||
xy: Some((0, 0)),
|
||||
add_transaction: true,
|
||||
})
|
||||
.await;
|
||||
assert_eq!(
|
||||
editor.active_document().network_interface.upstream_output_connector(&fill_content, &[]),
|
||||
Some(OutputConnector::node(rectangle, 0)),
|
||||
"the node picked from the menu should be wired into Fill's content"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_wire_dragged_backward_from_the_dimmed_export_connector_adds_an_export() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let export_count = network_interface.number_of_exports(&path);
|
||||
let (new_export_index, empty_export_position) = *network_interface
|
||||
.empty_import_export_connectors(false, &path)
|
||||
.last()
|
||||
.expect("there should be a dimmed connector for adding an export");
|
||||
let result_output = network_interface
|
||||
.upstream_output_connector(&InputConnector::Export(0), &path)
|
||||
.expect("Merge's export should be fed by a node inside it");
|
||||
let result_position = network_interface
|
||||
.output_position(&result_output, &path)
|
||||
.expect("the node feeding Merge's export should have an output position");
|
||||
|
||||
drag_in_graph(&mut editor, &path, empty_export_position, result_position).await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
assert_eq!(network_interface.number_of_exports(&path), export_count + 1, "the export should be added");
|
||||
assert_eq!(
|
||||
network_interface.upstream_output_connector(&InputConnector::Export(new_export_index), &path),
|
||||
Some(result_output),
|
||||
"the added export should be wired from the output the wire was dropped on"
|
||||
);
|
||||
|
||||
assert_invariants(&editor, "after dragging a wire backward from the dimmed export connector");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn clicking_an_empty_input_without_dragging_leaves_it_and_opens_no_menu() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let fill = editor.create_node_by_name_at(fill_definition(), 20, 0).await;
|
||||
let fill_content = InputConnector::node_at_index(fill, 0);
|
||||
let input_position = editor
|
||||
.active_document()
|
||||
.network_interface
|
||||
.input_position(&fill_content, &[])
|
||||
.expect("Fill's content should have a position");
|
||||
|
||||
drag_in_graph(&mut editor, &[], input_position, input_position).await;
|
||||
|
||||
assert!(editor.active_document().node_graph_handler.context_menu.is_none(), "a click shouldn't open the node menu");
|
||||
assert!(
|
||||
editor.active_document().network_interface.upstream_output_connector(&fill_content, &[]).is_none(),
|
||||
"a click shouldn't wire anything into Fill's content"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn leaving_a_subgraph_ends_the_wire_and_closes_the_node_menu_left_open_in_it() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let merge = editor.create_node_by_name_at(merge_definition(), 0, 0).await;
|
||||
let path = vec![merge];
|
||||
editor.handle_message(DocumentMessage::EnterNestedNetwork { node_id: merge }).await;
|
||||
|
||||
let (_, empty_export_position) = *editor
|
||||
.active_document()
|
||||
.network_interface
|
||||
.empty_import_export_connectors(false, &path)
|
||||
.last()
|
||||
.expect("there should be a dimmed connector for adding an export");
|
||||
drag_in_graph(&mut editor, &path, empty_export_position, empty_export_position - DVec2::new(240., 0.)).await;
|
||||
assert!(
|
||||
editor.active_document().node_graph_handler.context_menu.is_some(),
|
||||
"dropping the wire on empty space should open the node menu"
|
||||
);
|
||||
|
||||
editor.handle_message(DocumentMessage::ExitNestedNetwork { steps_back: 1 }).await;
|
||||
|
||||
let node_graph_handler = &editor.active_document().node_graph_handler;
|
||||
assert!(node_graph_handler.context_menu.is_none(), "the node menu should close with the subgraph it was opened in");
|
||||
assert!(node_graph_handler.wire_in_progress_from_connector.is_none(), "the wire should end with the subgraph it was dragged in");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn clicking_a_connected_input_leaves_it_connected_when_a_later_wire_is_dragged_away() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
|
||||
let rectangle = editor.create_node_by_name_at(rectangle_definition(), 0, 0).await;
|
||||
let other_rectangle = editor.create_node_by_name_at(rectangle_definition(), 0, 10).await;
|
||||
let fill = editor.create_node_by_name_at(fill_definition(), 20, 0).await;
|
||||
let fill_content = InputConnector::node_at_index(fill, 0);
|
||||
editor
|
||||
.handle_message(NodeGraphMessage::CreateWire {
|
||||
output_connector: OutputConnector::node(rectangle, 0),
|
||||
input_connector: fill_content,
|
||||
})
|
||||
.await;
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let input_position = network_interface.input_position(&fill_content, &[]).expect("Fill's content should have a position");
|
||||
let other_output_position = network_interface
|
||||
.output_position(&OutputConnector::node(other_rectangle, 0), &[])
|
||||
.expect("the other Rectangle's output should have a position");
|
||||
|
||||
// Click Fill's wired content without dragging, then drag a new wire out of the other Rectangle into empty space
|
||||
drag_in_graph(&mut editor, &[], input_position, input_position).await;
|
||||
drag_in_graph(&mut editor, &[], other_output_position, other_output_position + DVec2::new(240., 240.)).await;
|
||||
|
||||
assert_eq!(
|
||||
editor.active_document().network_interface.upstream_output_connector(&fill_content, &[]),
|
||||
Some(OutputConnector::node(rectangle, 0)),
|
||||
"Fill's content should still be wired from the first Rectangle"
|
||||
);
|
||||
}
|
||||
+1
@@ -146,6 +146,7 @@ impl From<DocumentNodePersistentMetadataStringReference> for DocumentNodePersist
|
||||
display_name: old.display_name,
|
||||
input_metadata: old.input_metadata,
|
||||
output_names: old.output_names,
|
||||
output_descriptions: Vec::new(),
|
||||
locked: old.locked,
|
||||
pinned: old.pinned,
|
||||
node_type_metadata: old.node_type_metadata,
|
||||
|
||||
+11
@@ -60,6 +60,8 @@ pub enum NodeMetadataChange {
|
||||
Pinned(bool),
|
||||
/// The whole vec, since the encoding is one array-valued attribute rather than a slot each.
|
||||
OutputNames(Vec<String>),
|
||||
/// The whole vec, for the same reason as `OutputNames`.
|
||||
OutputDescriptions(Vec<String>),
|
||||
InputName {
|
||||
index: usize,
|
||||
name: String,
|
||||
@@ -340,6 +342,11 @@ fn node_metadata_ops(global_id: document_graph_storage::NodeId, change: &NodeMet
|
||||
let value = (!output_names.is_empty()).then(|| serialize_attribute(node_attr::ui::OUTPUT_NAMES, output_names)).transpose()?;
|
||||
vec![node_attribute(node_attr::ui::OUTPUT_NAMES, value)]
|
||||
}
|
||||
NodeMetadataChange::OutputDescriptions(output_descriptions) => {
|
||||
let any_description = output_descriptions.iter().any(|description| !description.is_empty());
|
||||
let value = any_description.then(|| serialize_attribute(node_attr::ui::OUTPUT_DESCRIPTIONS, output_descriptions)).transpose()?;
|
||||
vec![node_attribute(node_attr::ui::OUTPUT_DESCRIPTIONS, value)]
|
||||
}
|
||||
NodeMetadataChange::InputName { index, name } => vec![input_attribute(node_attr::input::ui::NAME, *index, non_empty(name))?],
|
||||
NodeMetadataChange::WidgetOverride { index, widget_override } => {
|
||||
let value = widget_override.as_deref().and_then(non_empty);
|
||||
@@ -917,6 +924,10 @@ impl document_graph_storage::NodeMetadataSource for MetadataCopySource<'_> {
|
||||
self.metadata_for(metadata_path, node_id).map(|metadata| metadata.output_names.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn output_descriptions(&self, metadata_path: &[NodeId], node_id: NodeId) -> Vec<String> {
|
||||
self.metadata_for(metadata_path, node_id).map(|metadata| metadata.output_descriptions.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn input_name(&self, metadata_path: &[NodeId], node_id: NodeId, input_index: usize) -> Option<&str> {
|
||||
self.metadata_for(metadata_path, node_id)
|
||||
.and_then(|metadata| metadata.input_metadata.get(input_index))
|
||||
|
||||
+131
@@ -647,3 +647,134 @@ fn a_deleted_ui_key_is_not_cleared_again() {
|
||||
let writes = ui_attribute_writes(Some(¤t), &Attributes::new());
|
||||
assert_eq!(writes.iter().map(|write| write.key.as_str()).collect::<Vec<_>>(), ["ui::locked"]);
|
||||
}
|
||||
|
||||
fn merge_definition() -> DefinitionIdentifier {
|
||||
DefinitionIdentifier::Network("Merge".to_string())
|
||||
}
|
||||
|
||||
/// A subgraph's output descriptions are addressed by export index, so each has to move with its export as exports are added, reordered, and removed.
|
||||
#[tokio::test]
|
||||
async fn output_descriptions_follow_their_exports() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
let merge = editor.create_node_by_name(merge_definition()).await;
|
||||
|
||||
{
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.add_export(TaggedValue::None, -1, "", &[merge]);
|
||||
network_interface.add_export(TaggedValue::None, -1, "", &[merge]);
|
||||
|
||||
let mut node = network_interface.node_mut(super::NodeLocator::new(merge, &[])).expect("Merge should exist");
|
||||
node.set_output_descriptions(["First.", "Second.", "Third."].map(String::from).to_vec());
|
||||
}
|
||||
let working = convert(&editor);
|
||||
editor.active_document_mut().network_interface.discard_deltas();
|
||||
|
||||
{
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.reorder_export(2, 0, &[merge]);
|
||||
network_interface.remove_export(1, &[merge]);
|
||||
}
|
||||
|
||||
let network_interface = &editor.active_document().network_interface;
|
||||
let descriptions = (0..network_interface.number_of_exports(&[merge]))
|
||||
.map(|index| network_interface.output_description(&merge, index, &[]))
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(descriptions, ["Third.", "Second."], "the descriptions should have moved with their exports");
|
||||
|
||||
let emitted = editor.active_document_mut().network_interface.take_deltas();
|
||||
let constructed = construct(&editor, &emitted, &working);
|
||||
let diffed = compute_deltas(&working, &convert(&editor));
|
||||
assert_same_stored_effect(&working, constructed, diffed, "moved output descriptions");
|
||||
}
|
||||
|
||||
/// A subgraph whose output descriptions are all empty stores none, so adding or removing an export leaves nothing to write for them.
|
||||
#[tokio::test]
|
||||
async fn exports_of_a_subgraph_without_descriptions_emit_no_description_write() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
let merge = editor.create_node_by_name(merge_definition()).await;
|
||||
{
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
let mut node = network_interface.node_mut(super::NodeLocator::new(merge, &[])).expect("Merge should exist");
|
||||
node.set_output_descriptions(Vec::new());
|
||||
}
|
||||
editor.active_document_mut().network_interface.discard_deltas();
|
||||
|
||||
{
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.add_export(TaggedValue::None, -1, "", &[merge]);
|
||||
let last_export = network_interface.number_of_exports(&[merge]) - 1;
|
||||
network_interface.remove_export(last_export, &[merge]);
|
||||
}
|
||||
|
||||
let emitted = editor.active_document_mut().network_interface.take_deltas();
|
||||
let description_writes = emitted
|
||||
.iter()
|
||||
.filter(|delta| {
|
||||
matches!(
|
||||
delta,
|
||||
EditorDelta::NodeMetadata {
|
||||
change: NodeMetadataChange::OutputDescriptions(_),
|
||||
..
|
||||
}
|
||||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(description_writes, 0, "no descriptions are stored, so none should be written: {emitted:#?}");
|
||||
}
|
||||
|
||||
/// Storage keeps a subgraph's whole description list once any entry says something, so an export added past the described ones still changes what's stored.
|
||||
#[tokio::test]
|
||||
async fn adding_an_export_past_the_described_ones_matches_the_diff() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
let merge = editor.create_node_by_name(merge_definition()).await;
|
||||
|
||||
let working = convert(&editor);
|
||||
editor.active_document_mut().network_interface.discard_deltas();
|
||||
|
||||
editor.active_document_mut().network_interface.add_export(TaggedValue::None, -1, "", &[merge]);
|
||||
|
||||
let emitted = editor.active_document_mut().network_interface.take_deltas();
|
||||
let constructed = construct(&editor, &emitted, &working);
|
||||
let diffed = compute_deltas(&working, &convert(&editor));
|
||||
assert_same_stored_effect(&working, constructed, diffed, "an export added past the described ones");
|
||||
}
|
||||
|
||||
/// Adding or removing an export past the end of a shorter description list leaves the list as it was, so no description write is recorded.
|
||||
#[tokio::test]
|
||||
async fn exports_past_the_end_of_the_description_list_emit_no_description_write() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
let merge = editor.create_node_by_name(merge_definition()).await;
|
||||
{
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.add_export(TaggedValue::None, -1, "", &[merge]);
|
||||
let mut node = network_interface.node_mut(super::NodeLocator::new(merge, &[])).expect("Merge should exist");
|
||||
node.set_output_descriptions(vec!["Described.".to_string()]);
|
||||
}
|
||||
editor.active_document_mut().network_interface.discard_deltas();
|
||||
|
||||
{
|
||||
let network_interface = &mut editor.active_document_mut().network_interface;
|
||||
network_interface.add_export(TaggedValue::None, -1, "", &[merge]);
|
||||
let last_export = network_interface.number_of_exports(&[merge]) - 1;
|
||||
network_interface.remove_export(last_export, &[merge]);
|
||||
}
|
||||
|
||||
let emitted = editor.active_document_mut().network_interface.take_deltas();
|
||||
let description_writes = emitted
|
||||
.iter()
|
||||
.filter(|delta| {
|
||||
matches!(
|
||||
delta,
|
||||
EditorDelta::NodeMetadata {
|
||||
change: NodeMetadataChange::OutputDescriptions(_),
|
||||
..
|
||||
}
|
||||
)
|
||||
})
|
||||
.count();
|
||||
assert_eq!(description_writes, 0, "the description list didn't change, so it shouldn't be written: {emitted:#?}");
|
||||
}
|
||||
+97
-72
@@ -1,6 +1,7 @@
|
||||
//! The shapes the node graph frontend is sent: one entry per visible port, carrying its type, its
|
||||
//! name and what it connects to. Read-only projections of the graph, never a source of truth.
|
||||
//! name and whether it's connected. Read-only projections of the graph, rather than a source of truth.
|
||||
|
||||
use super::resolved_types::TypeSource;
|
||||
use super::*;
|
||||
|
||||
impl NodeNetworkInterface {
|
||||
@@ -43,48 +44,23 @@ impl NodeNetworkInterface {
|
||||
let data_type = input_type.displayed_type();
|
||||
let resolved_type = input_type.resolved_type_node_string();
|
||||
|
||||
let connected_to = self
|
||||
.upstream_output_connector(input_connector, network_path)
|
||||
.map(|output_connector| match output_connector {
|
||||
OutputConnector::Node { node_id, output_index } => {
|
||||
let name = self.display_name(&node_id, network_path);
|
||||
format!("Connected to output #{output_index} of \"{name}\", ID: {node_id}.")
|
||||
}
|
||||
OutputConnector::Import(import_index) => format!("Connected to import #{import_index}."),
|
||||
})
|
||||
.unwrap_or("Connected to nothing.".to_string());
|
||||
let connected = self.upstream_output_connector(input_connector, network_path).is_some();
|
||||
|
||||
let (name, description) = match input_connector {
|
||||
InputConnector::Node { node_id, input_index } => self.displayed_input_name_and_description(node_id, *input_index, network_path),
|
||||
InputConnector::Export(export_index) => {
|
||||
// Get export name from parent node metadata input, which must match the number of exports.
|
||||
// Empty string means to use type, or "Export + index" if type is empty determined
|
||||
let export_name = if network_path.is_empty() {
|
||||
"Canvas".to_string()
|
||||
} else {
|
||||
self.encapsulating_node_metadata(network_path)
|
||||
.and_then(|encapsulating_metadata| encapsulating_metadata.persistent_metadata.output_names.get(*export_index).cloned())
|
||||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
let export_name = if !export_name.is_empty() {
|
||||
export_name
|
||||
} else if let Some(export_type_name) = input_type.compiled_nested_type().map(ToString::to_string) {
|
||||
export_type_name
|
||||
} else {
|
||||
format!("Export #{}", export_index)
|
||||
};
|
||||
|
||||
(export_name, String::new())
|
||||
}
|
||||
InputConnector::Export(export_index) => (self.displayed_export_name(*export_index, network_path), self.export_description(*export_index, network_path)),
|
||||
};
|
||||
|
||||
let valid_types = self.potential_valid_input_types(input_connector, network_path).iter().map(ToString::to_string).collect::<Vec<_>>();
|
||||
let valid_types = {
|
||||
// Dedupe while preserving order
|
||||
let mut found = HashSet::new();
|
||||
valid_types.into_iter().filter(|s| found.insert(s.clone())).collect::<Vec<_>>()
|
||||
let valid_types = match input_connector {
|
||||
InputConnector::Node { .. } => self.potential_valid_input_types(input_connector, network_path),
|
||||
// An export takes any type itself, so it's limited only by what its subgraph node's output feeds, or at the document's root, what can be rendered
|
||||
InputConnector::Export(_) => self
|
||||
.complete_valid_input_types(input_connector, network_path)
|
||||
.into_iter()
|
||||
.filter(|valid_type| !valid_type.nested_type().is_generic())
|
||||
.collect(),
|
||||
};
|
||||
let valid_types = distinct_type_names(&valid_types);
|
||||
|
||||
Some(FrontendGraphInput {
|
||||
data_type,
|
||||
@@ -92,7 +68,7 @@ impl NodeNetworkInterface {
|
||||
name,
|
||||
description,
|
||||
valid_types,
|
||||
connected_to,
|
||||
connected,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -110,61 +86,39 @@ impl NodeNetworkInterface {
|
||||
let output_name = node_metadata.persistent_metadata.output_names.get(*output_index).cloned().unwrap_or_default();
|
||||
|
||||
let output_name = if !output_name.is_empty() { output_name } else { output_type.resolved_type_node_string() };
|
||||
(output_name, String::new())
|
||||
(output_name, self.output_description(node_id, *output_index, network_path))
|
||||
}
|
||||
OutputConnector::Import(import_index) => {
|
||||
// Get the import name from the encapsulating node input metadata
|
||||
let Some((encapsulating_node_id, encapsulating_path)) = network_path.split_last() else {
|
||||
// Return None if it is an import in the document network
|
||||
// Return None if it is an import in the document network
|
||||
if network_path.is_empty() {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
// Return None if the primary input is hidden and this is the primary import
|
||||
if *import_index == 0 && self.hidden_primary_import(network_path) {
|
||||
return None;
|
||||
};
|
||||
let (import_name, description) = self.displayed_input_name_and_description(encapsulating_node_id, *import_index, encapsulating_path);
|
||||
|
||||
let import_name = if !import_name.is_empty() {
|
||||
import_name
|
||||
} else if let Some(import_type_name) = output_type.compiled_nested_type().map(ToString::to_string) {
|
||||
import_type_name
|
||||
} else {
|
||||
format!("Import #{}", import_index)
|
||||
};
|
||||
|
||||
(import_name, description)
|
||||
(self.displayed_import_name(*import_index, network_path), self.import_description(*import_index, network_path))
|
||||
}
|
||||
};
|
||||
let data_type = output_type.displayed_type();
|
||||
let resolved_type = output_type.resolved_type_node_string();
|
||||
let mut connected_to = self
|
||||
.with_outward_wires(network_path, |outward_wires| outward_wires.get(output_connector).cloned())
|
||||
.flatten()
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.map(|input| match input {
|
||||
&InputConnector::Node { node_id, input_index } => {
|
||||
let name = self.display_name(&node_id, network_path);
|
||||
format!("Connected to input #{input_index} of \"{name}\", ID: {node_id}.")
|
||||
}
|
||||
InputConnector::Export(export_index) => format!("Connected to export #{export_index}."),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if connected_to.is_empty() {
|
||||
connected_to.push("Connected to nothing.".to_string());
|
||||
}
|
||||
let possible_types = distinct_type_names(&self.possible_output_types(output_connector, network_path));
|
||||
let connected = self
|
||||
.with_outward_wires(network_path, |outward_wires| outward_wires.get(output_connector).is_some_and(|inputs| !inputs.is_empty()))
|
||||
.unwrap_or_default();
|
||||
|
||||
Some(FrontendGraphOutput {
|
||||
data_type,
|
||||
resolved_type,
|
||||
name,
|
||||
description,
|
||||
connected_to,
|
||||
possible_types,
|
||||
connected,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the input name to display in the properties panel. If the name is empty then the type is used.
|
||||
/// Returns the input name to display in the Inspector. If the name is empty then the type is used.
|
||||
pub fn displayed_input_name_and_description(&self, node_id: &NodeId, input_index: usize, network_path: &[NodeId]) -> (String, String) {
|
||||
let Some(input_metadata) = self.persistent_input_metadata(node_id, input_index, network_path) else {
|
||||
log::warn!("input metadata not found in displayed_input_name_and_description");
|
||||
@@ -178,4 +132,75 @@ impl NodeNetworkInterface {
|
||||
};
|
||||
(name, description)
|
||||
}
|
||||
|
||||
/// The name a subgraph's import is shown with: its encapsulating node's input name, or else its type, or else its number.
|
||||
pub fn displayed_import_name(&self, import_index: usize, network_path: &[NodeId]) -> String {
|
||||
let Some((encapsulating_node_id, encapsulating_path)) = network_path.split_last() else {
|
||||
return String::new();
|
||||
};
|
||||
|
||||
let import_name = self
|
||||
.persistent_input_metadata(encapsulating_node_id, import_index, encapsulating_path)
|
||||
.map(|metadata| metadata.input_name.clone())
|
||||
.unwrap_or_default();
|
||||
if !import_name.is_empty() {
|
||||
return import_name;
|
||||
}
|
||||
|
||||
// Never left blank, which would look like a dimmed connector for adding an import
|
||||
established_type_name(&self.output_type(&OutputConnector::Import(import_index), network_path)).unwrap_or_else(|| format!("Import #{import_index}"))
|
||||
}
|
||||
|
||||
/// The description of a subgraph's import, which its encapsulating node stores for the input.
|
||||
pub fn import_description(&self, import_index: usize, network_path: &[NodeId]) -> String {
|
||||
let Some((encapsulating_node_id, encapsulating_path)) = network_path.split_last() else {
|
||||
return String::new();
|
||||
};
|
||||
|
||||
self.persistent_input_metadata(encapsulating_node_id, import_index, encapsulating_path)
|
||||
.map(|metadata| metadata.input_description.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The name a network's export is shown with: its encapsulating node's output name, or else its type, or else its number.
|
||||
/// The document network has one export, the canvas.
|
||||
pub fn displayed_export_name(&self, export_index: usize, network_path: &[NodeId]) -> String {
|
||||
if network_path.is_empty() {
|
||||
return "Canvas".to_string();
|
||||
}
|
||||
|
||||
let export_name = self
|
||||
.encapsulating_node_metadata(network_path)
|
||||
.and_then(|metadata| metadata.persistent_metadata.output_names.get(export_index).cloned())
|
||||
.unwrap_or_default();
|
||||
if !export_name.is_empty() {
|
||||
return export_name;
|
||||
}
|
||||
|
||||
// Never left blank, which would look like a dimmed connector for adding an export
|
||||
established_type_name(&self.input_type(&InputConnector::Export(export_index), network_path)).unwrap_or_else(|| format!("Export #{export_index}"))
|
||||
}
|
||||
|
||||
/// The description of a network's export, which its encapsulating node stores for the output.
|
||||
pub fn export_description(&self, export_index: usize, network_path: &[NodeId]) -> String {
|
||||
let Some((encapsulating_node_id, encapsulating_path)) = network_path.split_last() else {
|
||||
return String::new();
|
||||
};
|
||||
|
||||
self.output_description(encapsulating_node_id, export_index, encapsulating_path)
|
||||
}
|
||||
}
|
||||
|
||||
/// The displayed name of the type a connector carries, unless it's unknown or the empty type of a value input yet to be given a value.
|
||||
fn established_type_name(type_source: &TypeSource) -> Option<String> {
|
||||
type_source
|
||||
.compiled_nested_type()
|
||||
.filter(|nested_type| **nested_type != graph_craft::concrete!(()))
|
||||
.map(ToString::to_string)
|
||||
}
|
||||
|
||||
/// The displayed names of `types` in order, leaving out repeats where distinct types share a name.
|
||||
fn distinct_type_names(types: &[Type]) -> Vec<String> {
|
||||
let mut found = HashSet::new();
|
||||
types.iter().map(ToString::to_string).filter(|name| found.insert(name.clone())).collect()
|
||||
}
|
||||
+80
-56
@@ -164,63 +164,39 @@ impl NodeNetworkInterface {
|
||||
Some(document_node_click_targets)
|
||||
}
|
||||
|
||||
/// The add, remove and reorder handles that sit beside each import and export port.
|
||||
pub(super) fn compute_modify_import_export(&self, network_path: &[NodeId]) -> Option<ModifyImportExportClickTarget> {
|
||||
let mut reorder_imports_exports = Ports::new();
|
||||
let mut remove_imports_exports = Ports::new();
|
||||
/// The areas covered by the names beside each import and export port, which can be dragged to reorder them or right-clicked for a menu.
|
||||
/// Laid out as the frontend draws them, just past the connector.
|
||||
pub fn import_export_name_bounds(&self, network_path: &[NodeId]) -> Vec<(ImportOrExport, [DVec2; 2])> {
|
||||
// How far past the port's center the name begins
|
||||
const IMPORT_NAME_INSET: f64 = 8.;
|
||||
const EXPORT_NAME_INSET: f64 = 9.;
|
||||
const FONT_SIZE: f64 = 14.;
|
||||
|
||||
if !network_path.is_empty() {
|
||||
let ports_built = self.with_import_export_ports(network_path, |import_exports| {
|
||||
for (import_index, import_click_target) in import_exports.output_ports() {
|
||||
let Some(import_bounding_box) = import_click_target.bounding_box() else {
|
||||
log::error!("Could not get export bounding box in compute_modify_import_export");
|
||||
continue;
|
||||
};
|
||||
let reorder_import_center = (import_bounding_box[0] + import_bounding_box[1]) / 2. + DVec2::new(-12., 0.);
|
||||
|
||||
if *import_index == 0 {
|
||||
let remove_import_center = reorder_import_center + DVec2::new(-4., 0.);
|
||||
let remove_import = ClickTarget::new_with_path(rectangle_path(remove_import_center - DVec2::new(8., 8.), remove_import_center + DVec2::new(8., 8.)), 0.);
|
||||
remove_imports_exports.insert_custom_output_port(*import_index, remove_import);
|
||||
} else {
|
||||
let remove_import_center = reorder_import_center + DVec2::new(-12., 0.);
|
||||
let reorder_import = ClickTarget::new_with_path(rectangle_path(reorder_import_center - DVec2::new(3., 4.), reorder_import_center + DVec2::new(3., 4.)), 0.);
|
||||
let remove_import = ClickTarget::new_with_path(rectangle_path(remove_import_center - DVec2::new(8., 8.), remove_import_center + DVec2::new(8., 8.)), 0.);
|
||||
reorder_imports_exports.insert_custom_output_port(*import_index, reorder_import);
|
||||
remove_imports_exports.insert_custom_output_port(*import_index, remove_import);
|
||||
}
|
||||
}
|
||||
|
||||
for (export_index, export_click_target) in import_exports.input_ports() {
|
||||
let Some(export_bounding_box) = export_click_target.bounding_box() else {
|
||||
log::error!("Could not get export bounding box in compute_modify_import_export");
|
||||
continue;
|
||||
};
|
||||
let reorder_export_center = (export_bounding_box[0] + export_bounding_box[1]) / 2. + DVec2::new(12., 0.);
|
||||
|
||||
if *export_index == 0 {
|
||||
let remove_export_center = reorder_export_center + DVec2::new(4., 0.);
|
||||
let remove_export = ClickTarget::new_with_path(rectangle_path(remove_export_center - DVec2::new(8., 8.), remove_export_center + DVec2::new(8., 8.)), 0.);
|
||||
remove_imports_exports.insert_custom_input_port(*export_index, remove_export);
|
||||
} else {
|
||||
let remove_export_center = reorder_export_center + DVec2::new(12., 0.);
|
||||
let reorder_export = ClickTarget::new_with_path(rectangle_path(reorder_export_center - DVec2::new(3., 4.), reorder_export_center + DVec2::new(3., 4.)), 0.);
|
||||
let remove_export = ClickTarget::new_with_path(rectangle_path(remove_export_center - DVec2::new(8., 8.), remove_export_center + DVec2::new(8., 8.)), 0.);
|
||||
reorder_imports_exports.insert_custom_input_port(*export_index, reorder_export);
|
||||
remove_imports_exports.insert_custom_input_port(*export_index, remove_export);
|
||||
}
|
||||
}
|
||||
});
|
||||
if ports_built.is_none() {
|
||||
log::error!("Could not get import_export_ports in compute_modify_import_export");
|
||||
return None;
|
||||
}
|
||||
if network_path.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
Some(ModifyImportExportClickTarget {
|
||||
remove_imports_exports,
|
||||
reorder_imports_exports,
|
||||
})
|
||||
let port_center = |click_target: &ClickTarget| click_target.bounding_box().map(|[min, max]| (min + max) / 2.);
|
||||
let Some((import_centers, export_centers)) = self.with_import_export_ports(network_path, |import_exports| {
|
||||
let import_centers: Vec<_> = import_exports.output_ports().filter_map(|(index, click_target)| Some((*index, port_center(click_target)?))).collect();
|
||||
let export_centers: Vec<_> = import_exports.input_ports().filter_map(|(index, click_target)| Some((*index, port_center(click_target)?))).collect();
|
||||
(import_centers, export_centers)
|
||||
}) else {
|
||||
return Vec::new();
|
||||
};
|
||||
|
||||
let half_row = DVec2::new(0., HALF_GRID_SIZE as f64);
|
||||
let imports = import_centers.into_iter().map(|(import_index, center)| {
|
||||
let name_width = text_width(&self.displayed_import_name(import_index, network_path), FONT_SIZE);
|
||||
let name_right = center - DVec2::new(IMPORT_NAME_INSET, 0.);
|
||||
(ImportOrExport::Import(import_index), [name_right - DVec2::new(name_width, 0.) - half_row, name_right + half_row])
|
||||
});
|
||||
let exports = export_centers.into_iter().map(|(export_index, center)| {
|
||||
let name_width = text_width(&self.displayed_export_name(export_index, network_path), FONT_SIZE);
|
||||
let name_left = center + DVec2::new(EXPORT_NAME_INSET, 0.);
|
||||
(ImportOrExport::Export(export_index), [name_left - half_row, name_left + DVec2::new(name_width, 0.) + half_row])
|
||||
});
|
||||
imports.chain(exports).collect()
|
||||
}
|
||||
|
||||
/// A port for each import and export of the network, placed down the left and right edges.
|
||||
@@ -235,18 +211,60 @@ impl NodeNetworkInterface {
|
||||
if !network_path.is_empty() {
|
||||
let import_start_index = if self.hidden_primary_import(network_path) { 1 } else { 0 };
|
||||
for import_index in import_start_index..self.number_of_imports(network_path) {
|
||||
import_export_ports.insert_output_port_at_center(import_index, import_export_position.0.as_dvec2() + DVec2::new(0., import_index as f64 * 24.));
|
||||
import_export_ports.insert_output_port_at_center(import_index, import_export_position.0.as_dvec2() + DVec2::new(0., import_export_row_offset(import_index)));
|
||||
}
|
||||
}
|
||||
|
||||
let export_start_index = if self.hidden_primary_export(network_path) { 1 } else { 0 };
|
||||
for export_index in export_start_index..network.exports.len() {
|
||||
import_export_ports.insert_input_port_at_center(export_index, import_export_position.1.as_dvec2() + DVec2::new(0., export_index as f64 * 24.));
|
||||
import_export_ports.insert_input_port_at_center(export_index, import_export_position.1.as_dvec2() + DVec2::new(0., import_export_row_offset(export_index)));
|
||||
}
|
||||
|
||||
Some(import_export_ports)
|
||||
}
|
||||
|
||||
/// The dimmed connectors a subgraph shows for adding an import (or else export), as the index each one adds with its center. One fills the primary's place
|
||||
/// while it's empty, and one sits an extra grid cell below the last row so it isn't mistaken for an unnamed one.
|
||||
pub fn empty_import_export_connectors(&self, is_import: bool, network_path: &[NodeId]) -> Vec<(usize, DVec2)> {
|
||||
if network_path.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let Some((import_position, export_position)) = self.import_export_position(network_path) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let first_row_center = if is_import { import_position } else { export_position }.as_dvec2();
|
||||
|
||||
let count = if is_import { self.number_of_imports(network_path) } else { self.number_of_exports(network_path) };
|
||||
let primary_hidden = if is_import {
|
||||
self.hidden_primary_import(network_path)
|
||||
} else {
|
||||
self.hidden_primary_export(network_path)
|
||||
};
|
||||
|
||||
let mut connectors = Vec::new();
|
||||
if count == 0 || primary_hidden {
|
||||
connectors.push((0, first_row_center));
|
||||
}
|
||||
let next_index = count.max(1);
|
||||
connectors.push((next_index, first_row_center + DVec2::new(0., import_export_row_offset(next_index) + GRID_SIZE as f64)));
|
||||
connectors
|
||||
}
|
||||
|
||||
/// Where an import (or else an export) dragged to height `y` in node graph space would be dropped, as the index it's moved before.
|
||||
/// Index 0 takes the primary's place.
|
||||
pub fn import_export_drop_position(&self, y: f64, is_import: bool, network_path: &[NodeId]) -> Option<usize> {
|
||||
let (import_position, export_position) = self.import_export_position(network_path)?;
|
||||
let first_row_center = if is_import { import_position.y } else { export_position.y } as f64;
|
||||
let row_count = if is_import { self.number_of_imports(network_path) } else { self.number_of_exports(network_path) };
|
||||
|
||||
// Above the separator, centered in the gap under the first row, it takes the primary's place.
|
||||
// Below it, it goes before the first secondary row below the pointer, or after the last.
|
||||
if y < first_row_center + GRID_SIZE as f64 {
|
||||
return Some(0);
|
||||
}
|
||||
Some((1..row_count).find(|&row| first_row_center + import_export_row_offset(row) > y).unwrap_or(row_count))
|
||||
}
|
||||
|
||||
/// The width of a layer in grid units, which covers its thumbnail, its name and its icons. Cached
|
||||
/// because measuring the name's text is slow.
|
||||
pub(super) fn compute_layer_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> u32 {
|
||||
@@ -343,3 +361,9 @@ impl NodeNetworkInterface {
|
||||
Some((rounded_import_top_left.as_ivec2(), rounded_export_top_right.as_ivec2()))
|
||||
}
|
||||
}
|
||||
|
||||
/// How far below the first import or export the one at `index` sits, with a grid cell of space separating the primary from the secondary ones.
|
||||
fn import_export_row_offset(index: usize) -> f64 {
|
||||
let rows = if index == 0 { 0 } else { index + 1 };
|
||||
(rows * GRID_SIZE as usize) as f64
|
||||
}
|
||||
+24
-13
@@ -82,25 +82,18 @@ impl NodeNetworkInterface {
|
||||
let bounds = self.all_nodes_bounding_box(network_path).unwrap_or([DVec2::ZERO, DVec2::ZERO]);
|
||||
let all_nodes_bounding_box = rectangle_path(bounds[0], bounds[1]).to_svg();
|
||||
|
||||
let mut modify_import_export = Vec::new();
|
||||
self.with_modify_import_export(network_path, |modify_import_export_click_targets| {
|
||||
for click_target in modify_import_export_click_targets
|
||||
.remove_imports_exports
|
||||
.click_targets()
|
||||
.chain(modify_import_export_click_targets.reorder_imports_exports.click_targets())
|
||||
{
|
||||
if let ClickTargetType::Path(path) = click_target.target_type() {
|
||||
modify_import_export.push(path.to_svg());
|
||||
}
|
||||
}
|
||||
});
|
||||
let import_export_names = self
|
||||
.import_export_name_bounds(network_path)
|
||||
.into_iter()
|
||||
.map(|(_, [name_min, name_max])| rectangle_path(name_min, name_max).to_svg())
|
||||
.collect();
|
||||
FrontendClickTargets {
|
||||
node_click_targets,
|
||||
layer_click_targets,
|
||||
connector_click_targets,
|
||||
icon_click_targets,
|
||||
all_nodes_bounding_box,
|
||||
modify_import_export,
|
||||
import_export_names,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +190,24 @@ impl NodeNetworkInterface {
|
||||
.next()
|
||||
}
|
||||
|
||||
/// The dimmed connector for adding an import (or else export) under `point`, given in node graph space, as the index it adds with its center.
|
||||
pub fn empty_import_export_connector_at(&self, point: DVec2, is_import: bool, network_path: &[NodeId]) -> Option<(usize, DVec2)> {
|
||||
// The same reach as an import or export port's click target
|
||||
const CONNECTOR_RADIUS: f64 = 8.;
|
||||
|
||||
self.empty_import_export_connectors(is_import, network_path)
|
||||
.into_iter()
|
||||
.find(|(_, center)| center.distance(point) <= CONNECTOR_RADIUS)
|
||||
}
|
||||
|
||||
/// The import or export with its name under `point`, given in node graph space.
|
||||
pub fn import_export_name_from_point(&self, point: DVec2, network_path: &[NodeId]) -> Option<ImportOrExport> {
|
||||
self.import_export_name_bounds(network_path)
|
||||
.into_iter()
|
||||
.find(|(_, [name_min, name_max])| name_min.cmple(point).all() && point.cmple(*name_max).all())
|
||||
.map(|(import_or_export, _)| import_or_export)
|
||||
}
|
||||
|
||||
pub fn input_connector_from_click(&self, click: DVec2, network_path: &[NodeId]) -> Option<InputConnector> {
|
||||
let Some(network_metadata) = self.network_metadata(network_path) else {
|
||||
log::error!("Could not get nested network_metadata in input_connector_from_click");
|
||||
|
||||
+1
-3
@@ -20,11 +20,9 @@ impl NodeNetworkInterface {
|
||||
self.unload_all_nodes_bounding_box(network_path);
|
||||
}
|
||||
|
||||
/// Unloads the network's import and export strip: the ports themselves and the handles beside them
|
||||
/// for adding, removing and reordering.
|
||||
/// Unloads the network's import and export ports.
|
||||
pub(crate) fn invalidate_import_export(&mut self, network_path: &[NodeId]) {
|
||||
self.unload_import_export_ports(network_path);
|
||||
self.unload_modify_import_export(network_path);
|
||||
}
|
||||
|
||||
/// Unloads what a node's name or lock state feeds: a layer's width, and the geometry sized from it.
|
||||
|
||||
+89
-7
@@ -77,7 +77,7 @@ impl NodeNetworkInterface {
|
||||
/// Inserts a new export at insert index. If the insert index is -1 it is inserted at the end. The output_name is used by the encapsulating node.
|
||||
pub fn add_export(&mut self, default_value: TaggedValue, insert_index: isize, output_name: &str, network_path: &[NodeId]) {
|
||||
let inserted_index = if insert_index == -1 { self.number_of_exports(network_path) } else { insert_index as usize };
|
||||
if !self.insert_export_slot(network_path, inserted_index, NodeInput::value(default_value, true), output_name.to_string()) {
|
||||
if !self.insert_export_slot(network_path, inserted_index, NodeInput::value(default_value, true), output_name.to_string(), String::new()) {
|
||||
return;
|
||||
}
|
||||
self.clear_encapsulating_reference(network_path);
|
||||
@@ -287,7 +287,7 @@ impl NodeNetworkInterface {
|
||||
if end_index > start_index {
|
||||
end_index -= 1;
|
||||
}
|
||||
if !self.move_export_slot(network_path, start_index, end_index) {
|
||||
if end_index == start_index || !self.move_export_slot(network_path, start_index, end_index) {
|
||||
return;
|
||||
}
|
||||
self.clear_encapsulating_reference(network_path);
|
||||
@@ -317,7 +317,7 @@ impl NodeNetworkInterface {
|
||||
if end_index > start_index {
|
||||
end_index -= 1;
|
||||
}
|
||||
if !self.move_input_slot(NodeLocator::new(parent_id, &encapsulating_network_path), start_index, end_index) {
|
||||
if end_index == start_index || !self.move_input_slot(NodeLocator::new(parent_id, &encapsulating_network_path), start_index, end_index) {
|
||||
return;
|
||||
}
|
||||
self.clear_encapsulating_reference(network_path);
|
||||
@@ -402,6 +402,25 @@ impl NodeNetworkInterface {
|
||||
let new_inputs = std::mem::take(&mut new_template.inputs);
|
||||
let new_input_metadata = std::mem::take(&mut new_template.input_metadata);
|
||||
|
||||
// A chain whose link into this node is dropped loses the layer it's positioned against, so it becomes absolute while that layer is still reachable
|
||||
let chain_input_index = if self.is_layer(node_id, network_path) { LAYER_SECONDARY_INPUT_INDEX } else { PRIMARY_INPUT_INDEX };
|
||||
let disconnected_chain_node = self
|
||||
.document_node(node_id, network_path)
|
||||
.and_then(|node| node.inputs.get(chain_input_index))
|
||||
.filter(|old_input| new_inputs.get(chain_input_index) != Some(*old_input))
|
||||
.and_then(|old_input| match old_input {
|
||||
NodeInput::Node {
|
||||
node_id: upstream_node_id,
|
||||
output_index: PRIMARY_OUTPUT_INDEX,
|
||||
..
|
||||
} => Some(*upstream_node_id),
|
||||
_ => None,
|
||||
})
|
||||
.filter(|upstream_node_id| self.is_chain(upstream_node_id, network_path));
|
||||
if let Some(upstream_node_id) = disconnected_chain_node {
|
||||
self.set_upstream_chain_to_absolute(&upstream_node_id, network_path);
|
||||
}
|
||||
|
||||
let Some(mut node) = self.node_mut(NodeLocator::new(*node_id, network_path)) else {
|
||||
log::error!("Could not get node {node_id} in replace_inputs");
|
||||
return None;
|
||||
@@ -435,6 +454,48 @@ impl NodeNetworkInterface {
|
||||
node.resize_output_names(number_of_exports);
|
||||
}
|
||||
|
||||
/// Used when opening a `.graphite` document to update the descriptions each node stores a copy of: "TODO" input descriptions take the definition's
|
||||
/// text (or become empty where the node no longer matches it), and a node saved without any output descriptions takes the definition's.
|
||||
pub fn validate_descriptions(&mut self, node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId]) {
|
||||
let definition_template = self
|
||||
.reference(node_id, network_path)
|
||||
.as_ref()
|
||||
.and_then(resolve_document_node_type)
|
||||
.map(|definition| &definition.node_template);
|
||||
|
||||
let definition_input_metadata = definition_template
|
||||
.map(|template| &template.input_metadata)
|
||||
.filter(|input_metadata| input_metadata.len() == node.inputs.len());
|
||||
let input_descriptions: Vec<(usize, String)> = (0..node.inputs.len())
|
||||
.filter(|&index| {
|
||||
let stored_metadata = self.persistent_input_metadata(node_id, index, network_path);
|
||||
stored_metadata.is_some_and(|metadata| metadata.input_description.trim().eq_ignore_ascii_case("TODO"))
|
||||
})
|
||||
.map(|index| {
|
||||
let description = definition_input_metadata.and_then(|input_metadata| input_metadata.get(index));
|
||||
(index, description.map(|metadata| metadata.persistent_metadata.input_description.clone()).unwrap_or_default())
|
||||
})
|
||||
.collect();
|
||||
|
||||
// An emptied description keeps its slot, so only a node saved before it had output descriptions stores none at all
|
||||
let has_output_descriptions = |output_descriptions: &[String]| output_descriptions.iter().any(|description| !description.is_empty());
|
||||
let stores_output_descriptions = self
|
||||
.node_metadata(node_id, network_path)
|
||||
.is_some_and(|metadata| !metadata.persistent_metadata.output_descriptions.is_empty());
|
||||
let output_descriptions = definition_template
|
||||
.filter(|template| has_output_descriptions(&template.output_descriptions) && !stores_output_descriptions)
|
||||
.filter(|template| template.output_names.len() == self.number_of_outputs(node_id, network_path))
|
||||
.map(|template| template.output_descriptions.clone());
|
||||
|
||||
let Some(mut node_entry) = self.node_mut(NodeLocator::new(*node_id, network_path)) else { return };
|
||||
for (index, description) in input_descriptions {
|
||||
node_entry.set_input_description(index, description);
|
||||
}
|
||||
if let Some(output_descriptions) = output_descriptions {
|
||||
node_entry.set_output_descriptions(output_descriptions);
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep metadata in sync with the new implementation if this is used by anything other than the upgrade scripts.
|
||||
/// Only works with network nodes. Proto nodes use their ID as the reference.
|
||||
pub fn set_reference(&mut self, node_id: &NodeId, network_path: &[NodeId], reference_name: Option<String>) {
|
||||
@@ -584,14 +645,14 @@ impl NodeNetworkInterface {
|
||||
self.try_set_upstream_to_chain(input_connector, network_path);
|
||||
}
|
||||
|
||||
// A wire to or from the imports appeared or vanished
|
||||
(NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. }, NodeInput::Import { .. })
|
||||
// A wire to or from the imports changed
|
||||
(NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. } | NodeInput::Import { .. }, NodeInput::Import { .. })
|
||||
| (NodeInput::Import { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. }) => {
|
||||
self.unload_wire(input_connector, network_path);
|
||||
}
|
||||
|
||||
// A node was disconnected
|
||||
(NodeInput::Node { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. }) => {
|
||||
(NodeInput::Node { .. }, NodeInput::Value { .. } | NodeInput::Scope { .. } | NodeInput::Inline { .. } | NodeInput::Import { .. }) => {
|
||||
self.unload_wire(input_connector, network_path);
|
||||
|
||||
if let Some((old_upstream_node_id, previous_position)) = disconnected_upstream
|
||||
@@ -1031,6 +1092,27 @@ impl NodeNetworkInterface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_import_export_description(&mut self, description: String, index: ImportOrExport, network_path: &[NodeId]) {
|
||||
let Some((encapsulating_node_id, encapsulating_network_path)) = network_path.split_last() else {
|
||||
log::error!("Could not get encapsulating network in set_import_export_description");
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(mut node) = self.node_mut(NodeLocator::new(*encapsulating_node_id, encapsulating_network_path)) else {
|
||||
log::error!("Could not get encapsulating node in set_import_export_description");
|
||||
return;
|
||||
};
|
||||
|
||||
let description_changed = match index {
|
||||
ImportOrExport::Import(import_index) => node.set_input_description(import_index, description),
|
||||
ImportOrExport::Export(export_index) => node.set_output_description(export_index, description),
|
||||
};
|
||||
|
||||
if description_changed {
|
||||
self.transaction_modified();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_pinned(&mut self, node_id: &NodeId, network_path: &[NodeId], pinned: bool) {
|
||||
let Some(mut node) = self.node_mut(NodeLocator::new(*node_id, network_path)) else {
|
||||
log::error!("Could not get node {node_id} in set_pinned");
|
||||
@@ -1045,7 +1127,7 @@ impl NodeNetworkInterface {
|
||||
self.transaction_modified();
|
||||
}
|
||||
|
||||
/// Reorders a pinned node within its network's Properties panel display order so it ends up at `insert_index` among the
|
||||
/// Reorders a pinned node within its network's Inspector display order so it ends up at `insert_index` among the
|
||||
/// pinned nodes (0 being the topmost). Rebuilds the order from the list as currently shown, which also drops stale entries.
|
||||
pub fn reorder_pinned_node(&mut self, node_id: NodeId, insert_index: usize, network_path: &[NodeId]) {
|
||||
let shown = self.ordered_pinned_nodes(network_path);
|
||||
|
||||
@@ -542,6 +542,42 @@ impl NodeNetworkInterface {
|
||||
self.view(network_path).ok().and_then(|view| view.persistent_input_metadata(node_id, index).ok())
|
||||
}
|
||||
|
||||
/// Whether the input is internal state of its proto node (named with a leading `_`), which is never exposed to the graph.
|
||||
pub fn is_internal_input(&self, node_id: &NodeId, index: usize, network_path: &[NodeId]) -> bool {
|
||||
let Some(DocumentNodeImplementation::ProtoNode(proto_node_identifier)) = self.implementation(node_id, network_path) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(node_metadata) = graphene_std::registry::NODE_METADATA.lock() else { return false };
|
||||
|
||||
node_metadata
|
||||
.get(proto_node_identifier)
|
||||
.and_then(|metadata| metadata.fields.get(index))
|
||||
.is_some_and(|field| field.internal)
|
||||
}
|
||||
|
||||
/// The description stored for a node's output, or else for a proto node, the doc comment on its field in the struct a multi-output node returns.
|
||||
pub fn output_description(&self, node_id: &NodeId, output_index: usize, network_path: &[NodeId]) -> String {
|
||||
let stored_description = self
|
||||
.node_metadata(node_id, network_path)
|
||||
.and_then(|node_metadata| node_metadata.persistent_metadata.output_descriptions.get(output_index))
|
||||
.filter(|description| !description.is_empty());
|
||||
if let Some(stored_description) = stored_description {
|
||||
return stored_description.clone();
|
||||
}
|
||||
|
||||
let Some(DocumentNodeImplementation::ProtoNode(proto_node_identifier)) = self.implementation(node_id, network_path) else {
|
||||
return String::new();
|
||||
};
|
||||
let Ok(node_metadata) = graphene_std::registry::NODE_METADATA.lock() else { return String::new() };
|
||||
|
||||
node_metadata
|
||||
.get(proto_node_identifier)
|
||||
.and_then(|metadata| metadata.output_fields.as_ref())
|
||||
.and_then(|output_fields| output_fields.fields.get(output_fields.field_index_for_output(output_index)?))
|
||||
.map(|field| field.description.to_string())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn set_input_override(&mut self, node_id: &NodeId, index: usize, widget_override: Option<String>, network_path: &[NodeId]) {
|
||||
let Some(mut node) = self.node_mut(NodeLocator::new(*node_id, network_path)) else {
|
||||
log::error!("Could not get node {node_id} in set_input_override");
|
||||
@@ -556,7 +592,7 @@ impl NodeNetworkInterface {
|
||||
.unwrap_or_else(|| "Custom Node".to_string())
|
||||
}
|
||||
|
||||
/// The uneditable name in the Properties panel which represents the function name of the node implementation.
|
||||
/// The uneditable name in the Inspector which represents the function name of the node implementation.
|
||||
pub fn implementation_name(&self, node_id: &NodeId, network_path: &[NodeId]) -> String {
|
||||
self.query(network_path, "implementation_name", |view| Ok(view.implementation_name(node_id)))
|
||||
.unwrap_or_else(|| "Custom Node".to_string())
|
||||
|
||||
+39
-20
@@ -319,31 +319,50 @@ impl NodeNetworkInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/// The types an output could produce: its compiled type, or else the return types of the registry implementations matching its node's inputs.
|
||||
/// The types an output could produce: its compiled type, or else what [`Self::possible_output_types`] finds.
|
||||
pub fn potential_output_types(&self, output_connector: &OutputConnector, network_path: &[NodeId]) -> Vec<Type> {
|
||||
if let Some(compiled_type) = self.output_type(output_connector, network_path).compiled_nested_type() {
|
||||
return vec![compiled_type.clone()];
|
||||
}
|
||||
|
||||
// Nodes outside the compiled graph, such as disconnected ones, have no resolved type
|
||||
let OutputConnector::Node { node_id, output_index: 0 } = output_connector else {
|
||||
log::debug!("[wire-drag] No registry fallback for {output_connector:?}");
|
||||
return Vec::new();
|
||||
};
|
||||
let Some(DocumentNodeImplementation::ProtoNode(proto_node_identifier)) = self.implementation(node_id, network_path) else {
|
||||
log::debug!("[wire-drag] No registry fallback for non-proto node implementation {:?}", self.implementation(node_id, network_path));
|
||||
return Vec::new();
|
||||
};
|
||||
self.possible_output_types(output_connector, network_path)
|
||||
}
|
||||
|
||||
let all_implementations = NODE_REGISTRY.get(proto_node_identifier).map(|implementations| implementations.keys().cloned().collect::<Vec<_>>());
|
||||
let input_types = (0..self.number_of_inputs(node_id, network_path))
|
||||
.map(|index| self.input_type_not_invalid(&InputConnector::node_at_index(*node_id, index), network_path))
|
||||
.collect::<Vec<_>>();
|
||||
log::debug!("[wire-drag] Registry fallback for {proto_node_identifier:?} with input types {input_types:?} among implementations {all_implementations:?}");
|
||||
|
||||
self.implementations_matching_inputs(proto_node_identifier, node_id, None, network_path)
|
||||
.map(|node_io| node_io.return_value.nested_type().clone())
|
||||
.collect()
|
||||
/// Every type an output could produce given its node's current inputs, regardless of the one it was compiled with. An import can carry whatever its
|
||||
/// subgraph node's input accepts. Only the primary output of a proto node is known, since a node's other outputs are fields of its return value.
|
||||
pub fn possible_output_types(&self, output_connector: &OutputConnector, network_path: &[NodeId]) -> Vec<Type> {
|
||||
match output_connector {
|
||||
OutputConnector::Import(import_index) => {
|
||||
let Some((encapsulating_node_id, encapsulating_path)) = network_path.split_last() else {
|
||||
return Vec::new();
|
||||
};
|
||||
self.potential_valid_input_types(&InputConnector::node_at_index(*encapsulating_node_id, *import_index), encapsulating_path)
|
||||
}
|
||||
OutputConnector::Node { node_id, output_index } => match self.implementation(node_id, network_path) {
|
||||
Some(DocumentNodeImplementation::ProtoNode(proto_node_identifier)) if *output_index == 0 => self
|
||||
.implementations_matching_inputs(proto_node_identifier, node_id, None, network_path)
|
||||
.map(|node_io| node_io.return_value.nested_type().clone())
|
||||
.collect(),
|
||||
// A subgraph's output carries whatever feeds its export
|
||||
Some(DocumentNodeImplementation::Network(_)) => {
|
||||
let nested_path = [network_path, &[*node_id]].concat();
|
||||
let export = InputConnector::Export(*output_index);
|
||||
match self.upstream_output_connector(&export, &nested_path) {
|
||||
Some(upstream_output) => self.possible_output_types(&upstream_output, &nested_path),
|
||||
// A value given to the export, unless it's a new export's empty placeholder
|
||||
None => self
|
||||
.input_type(&export, &nested_path)
|
||||
.compiled_nested_type()
|
||||
.filter(|value_type| **value_type != concrete!(()))
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
_ => Vec::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// The registry implementations of a proto node whose inputs accept the node's current input types, ignoring `disregarded_input_index`.
|
||||
@@ -419,12 +438,12 @@ impl NodeNetworkInterface {
|
||||
Some((encapsulating_node, encapsulating_path)) => self.valid_output_types(&OutputConnector::node(*encapsulating_node, *export_index), encapsulating_path),
|
||||
None => {
|
||||
// Valid types for the export are all types that can be fed into the render node
|
||||
let render_node = graphene_std::render_node::render::IDENTIFIER;
|
||||
let render_node = graphene_std::render_node::render_intermediate::IDENTIFIER;
|
||||
let Some(implementations) = NODE_REGISTRY.get(&render_node) else {
|
||||
log::error!("Protonode {render_node:?} not found in registry");
|
||||
return Vec::new();
|
||||
};
|
||||
implementations.keys().map(|types| types.inputs[1].clone()).collect()
|
||||
implementations.keys().filter_map(|types| types.inputs.first().cloned()).collect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -106,6 +106,10 @@ impl NodeMetadataSource for StorageMetadataView<'_> {
|
||||
self.persistent(network_path, local_id).map(|p| p.output_names.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn output_descriptions(&self, network_path: &[NodeId], local_id: NodeId) -> Vec<String> {
|
||||
self.persistent(network_path, local_id).map(|p| p.output_descriptions.clone()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn storage_node_id(&self, network_path: &[NodeId], local_id: NodeId) -> Option<document_graph_storage::NodeId> {
|
||||
self.persistent(network_path, local_id)?.storage_id.map(document_graph_storage::NodeId)
|
||||
}
|
||||
@@ -374,6 +378,9 @@ fn apply_entries_into_tree(network: &NodeNetwork, metadata: &mut NodeNetworkMeta
|
||||
if !entry.output_names.is_empty() {
|
||||
persistent.output_names = entry.output_names;
|
||||
}
|
||||
if !entry.output_descriptions.is_empty() {
|
||||
persistent.output_descriptions = entry.output_descriptions;
|
||||
}
|
||||
|
||||
document_node_metadata.transient_metadata = DocumentNodeTransientMetadata::default();
|
||||
}
|
||||
|
||||
+43
-2
@@ -274,7 +274,17 @@ impl NodeMut<'_> {
|
||||
changed
|
||||
}
|
||||
|
||||
/// The identifier of the widget override the properties panel uses for this input, or `None` for the
|
||||
pub(crate) fn set_input_description(&mut self, input_index: usize, input_description: String) -> bool {
|
||||
let Some(input_metadata) = self.metadata.input_metadata.get_mut(input_index) else { return false };
|
||||
let changed = input_metadata.persistent_metadata.input_description != input_description;
|
||||
input_metadata.persistent_metadata.input_description = input_description;
|
||||
if changed {
|
||||
self.emit_input_metadata();
|
||||
}
|
||||
changed
|
||||
}
|
||||
|
||||
/// The identifier of the widget override the Inspector uses for this input, or `None` for the
|
||||
/// widget generated from its type.
|
||||
pub(crate) fn set_widget_override(&mut self, input_index: usize, widget_override: Option<String>) -> bool {
|
||||
let Some(input_metadata) = self.metadata.input_metadata.get_mut(input_index) else { return false };
|
||||
@@ -313,6 +323,37 @@ impl NodeMut<'_> {
|
||||
changed
|
||||
}
|
||||
|
||||
pub(crate) fn set_output_description(&mut self, output_index: usize, output_description: String) -> bool {
|
||||
if output_index >= self.metadata.output_names.len() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let output_descriptions = &mut self.metadata.output_descriptions;
|
||||
if output_descriptions.get(output_index).map_or("", String::as_str) == output_description {
|
||||
return false;
|
||||
}
|
||||
|
||||
if output_index >= output_descriptions.len() {
|
||||
output_descriptions.resize(output_index + 1, String::new());
|
||||
}
|
||||
output_descriptions[output_index] = output_description;
|
||||
|
||||
let change = NodeMetadataChange::OutputDescriptions(output_descriptions.clone());
|
||||
self.deltas.metadata(change);
|
||||
true
|
||||
}
|
||||
|
||||
/// The encapsulating node's descriptions for the network's exports, replaced together since they are stored as one array.
|
||||
pub(crate) fn set_output_descriptions(&mut self, output_descriptions: Vec<String>) -> bool {
|
||||
let changed = self.metadata.output_descriptions != output_descriptions;
|
||||
self.metadata.output_descriptions = output_descriptions;
|
||||
if changed {
|
||||
let change = NodeMetadataChange::OutputDescriptions(self.metadata.output_descriptions.clone());
|
||||
self.deltas.metadata(change);
|
||||
}
|
||||
changed
|
||||
}
|
||||
|
||||
/// The metadata array the node's inputs index, one entry per input.
|
||||
pub(crate) fn input_metadata(&self) -> &[InputMetadata] {
|
||||
&self.metadata.input_metadata
|
||||
@@ -447,7 +488,7 @@ impl NetworkMut<'_> {
|
||||
changed
|
||||
}
|
||||
|
||||
/// The display order of pinned nodes in the Properties panel.
|
||||
/// The display order of pinned nodes in the Inspector.
|
||||
pub(crate) fn set_pinned_order(&mut self, pinned_node_order: Vec<NodeId>) -> bool {
|
||||
let changed = self.metadata.pinned_node_order != pinned_node_order;
|
||||
self.metadata.pinned_node_order = pinned_node_order;
|
||||
|
||||
+76
-24
@@ -92,9 +92,9 @@ impl NodeNetworkInterface {
|
||||
self.insert_input_slot(locator, to, input, metadata)
|
||||
}
|
||||
|
||||
/// Inserts an export at `index`, clamped to the end, along with the name the encapsulating node shows
|
||||
/// for it. The document network has no encapsulating node, so it carries no name.
|
||||
pub(crate) fn insert_export_slot(&mut self, network_path: &[NodeId], index: usize, export: NodeInput, output_name: String) -> bool {
|
||||
/// Inserts an export at `index`, clamped to the end, along with the name and description the encapsulating
|
||||
/// node shows for it. The document network has no encapsulating node, so it carries neither.
|
||||
pub(crate) fn insert_export_slot(&mut self, network_path: &[NodeId], index: usize, export: NodeInput, output_name: String, output_description: String) -> bool {
|
||||
let Some(network) = self.network_graph_mut(network_path) else {
|
||||
log::error!("Could not get nested network in insert_export_slot");
|
||||
return false;
|
||||
@@ -103,15 +103,26 @@ impl NodeNetworkInterface {
|
||||
let index = index.min(network.exports.len());
|
||||
network.exports.insert(index, export);
|
||||
|
||||
let mut descriptions_changed = false;
|
||||
if let Some(encapsulating_node_metadata) = self.encapsulating_node_metadata_mut(network_path) {
|
||||
let output_names = &mut encapsulating_node_metadata.persistent_metadata.output_names;
|
||||
output_names.insert(index.min(output_names.len()), output_name);
|
||||
let persistent_metadata = &mut encapsulating_node_metadata.persistent_metadata;
|
||||
persistent_metadata.output_names.insert(index.min(persistent_metadata.output_names.len()), output_name);
|
||||
|
||||
// A missing description is empty, so only a non-empty one past the end needs the gap filled
|
||||
let output_descriptions = &mut persistent_metadata.output_descriptions;
|
||||
descriptions_changed = !output_description.is_empty() || (index <= output_descriptions.len() && has_description(output_descriptions));
|
||||
if index <= output_descriptions.len() {
|
||||
output_descriptions.insert(index, output_description);
|
||||
} else if !output_description.is_empty() {
|
||||
output_descriptions.resize(index, String::new());
|
||||
output_descriptions.push(output_description);
|
||||
}
|
||||
}
|
||||
self.emit_exports_from(network_path, index, None);
|
||||
self.emit_exports_from(network_path, index, None, descriptions_changed);
|
||||
true
|
||||
}
|
||||
|
||||
/// Removes the export at `index` together with the encapsulating node's name for it.
|
||||
/// Removes the export at `index` together with the encapsulating node's name and description for it.
|
||||
pub(crate) fn remove_export_slot(&mut self, network_path: &[NodeId], index: usize) -> Option<NodeInput> {
|
||||
let Some(network) = self.network_graph_mut(network_path) else {
|
||||
log::error!("Could not get nested network in remove_export_slot");
|
||||
@@ -126,22 +137,27 @@ impl NodeNetworkInterface {
|
||||
// The list shrank by one, so what was the last index now has no slot and has to be cleared.
|
||||
let vacated = network.exports.len();
|
||||
|
||||
let mut descriptions_changed = false;
|
||||
if let Some(encapsulating_node_metadata) = self.encapsulating_node_metadata_mut(network_path) {
|
||||
let output_names = &mut encapsulating_node_metadata.persistent_metadata.output_names;
|
||||
if index < output_names.len() {
|
||||
output_names.remove(index);
|
||||
let persistent_metadata = &mut encapsulating_node_metadata.persistent_metadata;
|
||||
if index < persistent_metadata.output_names.len() {
|
||||
persistent_metadata.output_names.remove(index);
|
||||
}
|
||||
descriptions_changed = index < persistent_metadata.output_descriptions.len() && has_description(&persistent_metadata.output_descriptions);
|
||||
if index < persistent_metadata.output_descriptions.len() {
|
||||
persistent_metadata.output_descriptions.remove(index);
|
||||
}
|
||||
}
|
||||
self.emit_exports_from(network_path, index, Some(vacated));
|
||||
self.emit_exports_from(network_path, index, Some(vacated), descriptions_changed);
|
||||
Some(export)
|
||||
}
|
||||
|
||||
/// Records every export slot from `index` on, plus a clear for `vacated` when the list shrank.
|
||||
///
|
||||
/// Export slots are addressed by index, so inserting or removing one changes the meaning of every
|
||||
/// later slot and each has to be restated. The encapsulating node's names for them ride along as one
|
||||
/// whole-array metadata write.
|
||||
fn emit_exports_from(&mut self, network_path: &[NodeId], index: usize, vacated: Option<usize>) {
|
||||
/// later slot and each has to be restated. The encapsulating node's names, and its descriptions unless
|
||||
/// they're all empty, ride along as whole-array metadata writes.
|
||||
fn emit_exports_from(&mut self, network_path: &[NodeId], index: usize, vacated: Option<usize>, descriptions_changed: bool) {
|
||||
let Some(network) = self.network.network().nested_network(network_path) else { return };
|
||||
let exports: Vec<_> = network.exports.iter().skip(index).cloned().collect();
|
||||
|
||||
@@ -162,22 +178,31 @@ impl NodeNetworkInterface {
|
||||
|
||||
let Some((&node_id, parent_path)) = network_path.split_last() else { return };
|
||||
let Some(metadata) = self.encapsulating_node_metadata(network_path) else { return };
|
||||
let change = NodeMetadataChange::OutputNames(metadata.persistent_metadata.output_names.clone());
|
||||
self.deltas.push(EditorDelta::NodeMetadata {
|
||||
network_path: parent_path.to_vec(),
|
||||
node_id,
|
||||
change,
|
||||
});
|
||||
let output_names = NodeMetadataChange::OutputNames(metadata.persistent_metadata.output_names.clone());
|
||||
let output_descriptions = descriptions_changed.then(|| NodeMetadataChange::OutputDescriptions(metadata.persistent_metadata.output_descriptions.clone()));
|
||||
for change in std::iter::once(output_names).chain(output_descriptions) {
|
||||
self.deltas.push(EditorDelta::NodeMetadata {
|
||||
network_path: parent_path.to_vec(),
|
||||
node_id,
|
||||
change,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Moves the export at `from` to `to`, carrying the encapsulating node's name for it.
|
||||
/// Moves the export at `from` to `to`, carrying the encapsulating node's name and description for it.
|
||||
pub(crate) fn move_export_slot(&mut self, network_path: &[NodeId], from: usize, to: usize) -> bool {
|
||||
let name = self
|
||||
let (name, description) = self
|
||||
.encapsulating_node_metadata(network_path)
|
||||
.and_then(|metadata| metadata.persistent_metadata.output_names.get(from).cloned())
|
||||
.map(|metadata| {
|
||||
let persistent_metadata = &metadata.persistent_metadata;
|
||||
(
|
||||
persistent_metadata.output_names.get(from).cloned().unwrap_or_default(),
|
||||
persistent_metadata.output_descriptions.get(from).cloned().unwrap_or_default(),
|
||||
)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let Some(export) = self.remove_export_slot(network_path, from) else { return false };
|
||||
self.insert_export_slot(network_path, to, export, name)
|
||||
self.insert_export_slot(network_path, to, export, name, description)
|
||||
}
|
||||
|
||||
/// Writes the input at `connector`, returning the input it replaced.
|
||||
@@ -335,6 +360,28 @@ impl NodeNetworkInterface {
|
||||
self.deltas.clear();
|
||||
}
|
||||
|
||||
/// Records the open transaction's bookkeeping, so writes that are undone before [`Self::restore_transaction_checkpoint`] don't count toward it.
|
||||
pub fn transaction_checkpoint(&mut self) -> TransactionCheckpoint {
|
||||
self.scan_transaction_edited_nodes();
|
||||
|
||||
TransactionCheckpoint {
|
||||
status: self.transaction_status,
|
||||
edited_nodes: self.transaction_edited_nodes.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Puts back the open transaction's bookkeeping from [`Self::transaction_checkpoint`] once the writes made since then are undone, leaving their deltas unread.
|
||||
pub fn restore_transaction_checkpoint(&mut self, checkpoint: TransactionCheckpoint) {
|
||||
if self.transaction_status == TransactionStatus::Finished {
|
||||
return;
|
||||
}
|
||||
|
||||
self.transaction_status = checkpoint.status;
|
||||
self.transaction_edited_nodes_changed |= self.transaction_edited_nodes != checkpoint.edited_nodes;
|
||||
self.transaction_edited_nodes = checkpoint.edited_nodes;
|
||||
self.transaction_edited_nodes_scanned = self.deltas.len();
|
||||
}
|
||||
|
||||
/// Reads the open transaction's writes since the last call, returning whether that changed which nodes it has written to.
|
||||
pub fn update_transaction_edited_nodes(&mut self) -> bool {
|
||||
self.scan_transaction_edited_nodes();
|
||||
@@ -383,6 +430,11 @@ impl NodeNetworkInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether any of `descriptions` says anything, since storage keeps the whole list then, but not a list that's all empty.
|
||||
fn has_description(descriptions: &[String]) -> bool {
|
||||
descriptions.iter().any(|description| !description.is_empty())
|
||||
}
|
||||
|
||||
/// The slot `connector` addresses, whether it is a node's input or one of the network's exports.
|
||||
fn input_slot_mut<'a>(network: &'a mut NodeNetwork, connector: &InputConnector) -> Option<&'a mut NodeInput> {
|
||||
match connector {
|
||||
|
||||
+10
-2
@@ -58,6 +58,7 @@ impl NodeNetworkInterface {
|
||||
|
||||
/// Loads the structure of layer nodes from a node graph.
|
||||
pub fn load_structure(&mut self) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.structure = HashMap::from_iter([(LayerNodeIdentifier::ROOT_PARENT, NodeRelations::default())]);
|
||||
|
||||
// Only load structure if there is a root node
|
||||
@@ -144,24 +145,29 @@ impl NodeNetworkInterface {
|
||||
self.document_metadata.text_frames.retain(|layer, _| self.document_metadata.structure.contains_key(layer));
|
||||
}
|
||||
|
||||
/// Update the cached transforms of the layers
|
||||
pub fn update_transforms(&mut self, upstream_footprints: HashMap<NodeId, Footprint>, local_transforms: HashMap<NodeId, DAffine2>) {
|
||||
/// Update the cached transforms of the layers, which a render made with the given view reported
|
||||
pub fn update_transforms(&mut self, upstream_footprints: HashMap<NodeId, Footprint>, local_transforms: HashMap<NodeId, DAffine2>, document_to_viewport: DAffine2) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.upstream_footprints = upstream_footprints;
|
||||
self.document_metadata.local_transforms = local_transforms;
|
||||
self.document_metadata.rendered_document_to_viewport = document_to_viewport;
|
||||
}
|
||||
|
||||
/// Update the cached first item's source id of the layers
|
||||
pub fn update_first_element_source_id(&mut self, new: HashMap<NodeId, Option<NodeId>>) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.first_element_source_ids = new;
|
||||
}
|
||||
|
||||
/// Update the cached click targets of the layers
|
||||
pub fn update_click_targets(&mut self, new_click_targets: HashMap<LayerNodeIdentifier, Vec<Arc<ClickTarget>>>) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.click_targets = new_click_targets;
|
||||
}
|
||||
|
||||
/// Update the cached source-geometry outline targets of the layers
|
||||
pub fn update_outlines(&mut self, new_outlines: HashMap<LayerNodeIdentifier, Vec<Arc<ClickTarget>>>) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.outlines = new_outlines;
|
||||
}
|
||||
|
||||
@@ -178,11 +184,13 @@ impl NodeNetworkInterface {
|
||||
|
||||
/// Update the vector modify of the layers
|
||||
pub fn update_vector_modify(&mut self, new_vector_modify: HashMap<NodeId, Vector>) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.vector_modify = new_vector_modify;
|
||||
}
|
||||
|
||||
/// Update the layer vector data (for layers without Path nodes)
|
||||
pub fn update_vector_data(&mut self, new_layer_vector_data: HashMap<LayerNodeIdentifier, Arc<Vector>>) {
|
||||
self.document_metadata.mark_changed();
|
||||
self.document_metadata.layer_vector_data = new_layer_vector_data;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,14 @@ pub struct NodeTemplate {
|
||||
pub context_features: ContextDependencies,
|
||||
/// A name chosen by the user for this instance of the node. Empty indicates no given name, in which case the implementation name is displayed in italics.
|
||||
pub display_name: String,
|
||||
/// Metadata to override the properties panel widgets for each input. Kept the same length as `inputs`.
|
||||
/// Metadata to override the Inspector widgets for each input. Kept the same length as `inputs`.
|
||||
pub input_metadata: Vec<InputMetadata>,
|
||||
pub output_names: Vec<String>,
|
||||
/// Indexed like `output_names`, where a missing or empty entry means the output has no description.
|
||||
pub output_descriptions: Vec<String>,
|
||||
/// Represents the lock icon for locking/unlocking the node in the graph UI.
|
||||
pub locked: bool,
|
||||
/// Indicates that the node will be shown in the Properties panel when it would otherwise be empty.
|
||||
/// Indicates that the node will be shown in the Inspector when it would otherwise be empty.
|
||||
pub pinned: bool,
|
||||
/// Whether the node is displayed as a left-to-right node or bottom-to-top layer, along with its position.
|
||||
pub node_type_metadata: NodeTypePersistentMetadata,
|
||||
@@ -62,6 +64,7 @@ impl Default for NodeTemplate {
|
||||
display_name: String::new(),
|
||||
input_metadata: Vec::new(),
|
||||
output_names: Vec::new(),
|
||||
output_descriptions: Vec::new(),
|
||||
locked: false,
|
||||
pinned: false,
|
||||
node_type_metadata: NodeTypePersistentMetadata::default(),
|
||||
@@ -95,7 +98,7 @@ pub struct NodeNetworkTemplate {
|
||||
///
|
||||
/// [`DocumentNodeDefinition`]: crate::messages::portfolio::document::node_graph::document_node_definitions::DocumentNodeDefinition
|
||||
pub reference: Option<String>,
|
||||
/// The display order of pinned nodes in the Properties panel.
|
||||
/// The display order of pinned nodes in the Inspector.
|
||||
pub pinned_node_order: Vec<NodeId>,
|
||||
pub previewing: Previewing,
|
||||
pub navigation_metadata: NavigationMetadata,
|
||||
@@ -122,6 +125,7 @@ impl NodeTemplate {
|
||||
display_name,
|
||||
input_metadata,
|
||||
output_names,
|
||||
output_descriptions,
|
||||
locked,
|
||||
pinned,
|
||||
node_type_metadata,
|
||||
@@ -163,6 +167,7 @@ impl NodeTemplate {
|
||||
display_name,
|
||||
input_metadata,
|
||||
output_names,
|
||||
output_descriptions,
|
||||
locked,
|
||||
pinned,
|
||||
node_type_metadata,
|
||||
@@ -181,6 +186,7 @@ impl NodeTemplate {
|
||||
display_name,
|
||||
mut input_metadata,
|
||||
output_names,
|
||||
output_descriptions,
|
||||
locked,
|
||||
pinned,
|
||||
node_type_metadata,
|
||||
@@ -205,6 +211,7 @@ impl NodeTemplate {
|
||||
display_name,
|
||||
input_metadata,
|
||||
output_names,
|
||||
output_descriptions,
|
||||
locked,
|
||||
pinned,
|
||||
node_type_metadata,
|
||||
|
||||
@@ -446,7 +446,7 @@ pub struct NodeNetworkPersistentMetadata {
|
||||
/// Node metadata must exist for every document node in the network
|
||||
#[serde(serialize_with = "graphene_std::vector::serialize_hashmap", deserialize_with = "graphene_std::vector::deserialize_hashmap")]
|
||||
pub node_metadata: HashMap<NodeId, DocumentNodeMetadata>,
|
||||
/// The display order of pinned nodes in the Properties panel (shown when nothing is selected in this network), keyed by node ID.
|
||||
/// The display order of pinned nodes in the Inspector (shown when nothing is selected in this network), keyed by node ID.
|
||||
#[serde(default)]
|
||||
pub pinned_node_order: Vec<NodeId>,
|
||||
/// Cached metadata for each node, which is calculated when adding a node to node_metadata
|
||||
@@ -527,8 +527,6 @@ pub struct NodeNetworkTransientMetadata {
|
||||
pub(crate) outward_wires: TransientCache<HashMap<OutputConnector, Vec<InputConnector>>>,
|
||||
/// All export connector click targets
|
||||
pub(crate) import_export_ports: TransientCache<Ports>,
|
||||
/// Click targets for adding, removing, and moving import/export ports
|
||||
pub(crate) modify_import_export: TransientCache<ModifyImportExportClickTarget>,
|
||||
|
||||
/// Cached wire SVG paths per input connector, where an entry's presence means that wire is loaded.
|
||||
pub(crate) wires: std::cell::RefCell<HashMap<InputConnector, WirePathUpdate>>,
|
||||
@@ -536,14 +534,6 @@ pub struct NodeNetworkTransientMetadata {
|
||||
pub(crate) drag_offsets: std::cell::RefCell<HashMap<NodeId, i32>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ModifyImportExportClickTarget {
|
||||
// Subtract icon that appears when hovering over an import/export
|
||||
pub remove_imports_exports: Ports,
|
||||
// Grip drag icon that appears when hovering over an import/export
|
||||
pub reorder_imports_exports: Ports,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NetworkEdgeDistance {
|
||||
/// The viewport pixel distance between the left edge of the node graph and the exports.
|
||||
@@ -630,7 +620,7 @@ pub enum WidgetOverride {
|
||||
Custom(String),
|
||||
}
|
||||
|
||||
// TODO: Custom deserialization/serialization to ensure number of properties row matches number of node inputs
|
||||
// TODO: Custom deserialization/serialization to ensure number of input metadata rows matches number of node inputs
|
||||
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct InputPersistentMetadata {
|
||||
/// A general datastore than can store key value pairs of any types for any input
|
||||
@@ -661,40 +651,40 @@ impl InputPersistentMetadata {
|
||||
WidgetOverride::Hidden => {
|
||||
self.widget_override = Some("hidden".to_string());
|
||||
}
|
||||
WidgetOverride::String(string_properties) => {
|
||||
self.input_data.insert("string_properties".to_string(), Value::String(string_properties));
|
||||
WidgetOverride::String(string_inspector) => {
|
||||
self.input_data.insert("string_inspector".to_string(), Value::String(string_inspector));
|
||||
self.widget_override = Some("string".to_string());
|
||||
}
|
||||
WidgetOverride::Number(mut number_properties) => {
|
||||
if let Some(unit) = number_properties.unit.take() {
|
||||
WidgetOverride::Number(mut number_inspector) => {
|
||||
if let Some(unit) = number_inspector.unit.take() {
|
||||
self.input_data.insert("unit".to_string(), json!(unit));
|
||||
}
|
||||
if let Some(min) = number_properties.min.take() {
|
||||
if let Some(min) = number_inspector.min.take() {
|
||||
self.input_data.insert("min".to_string(), json!(min));
|
||||
}
|
||||
if let Some(max) = number_properties.max.take() {
|
||||
if let Some(max) = number_inspector.max.take() {
|
||||
self.input_data.insert("max".to_string(), json!(max));
|
||||
}
|
||||
if let Some(step) = number_properties.step.take() {
|
||||
if let Some(step) = number_inspector.step.take() {
|
||||
self.input_data.insert("step".to_string(), json!(step));
|
||||
}
|
||||
if let Some(range_min) = number_properties.range_min.take() {
|
||||
if let Some(range_min) = number_inspector.range_min.take() {
|
||||
self.input_data.insert("range_min".to_string(), json!(range_min));
|
||||
}
|
||||
if let Some(range_max) = number_properties.range_max.take() {
|
||||
if let Some(range_max) = number_inspector.range_max.take() {
|
||||
self.input_data.insert("range_max".to_string(), json!(range_max));
|
||||
}
|
||||
self.input_data.insert("mode".to_string(), json!(number_properties.mode));
|
||||
self.input_data.insert("is_integer".to_string(), Value::Bool(number_properties.is_integer));
|
||||
self.input_data.insert("blank_assist".to_string(), Value::Bool(number_properties.blank_assist));
|
||||
self.input_data.insert("mode".to_string(), json!(number_inspector.mode));
|
||||
self.input_data.insert("is_integer".to_string(), Value::Bool(number_inspector.is_integer));
|
||||
self.input_data.insert("blank_assist".to_string(), Value::Bool(number_inspector.blank_assist));
|
||||
self.widget_override = Some("number".to_string());
|
||||
}
|
||||
WidgetOverride::Vec2(vec2_properties) => {
|
||||
self.input_data.insert("x".to_string(), json!(vec2_properties.x));
|
||||
self.input_data.insert("y".to_string(), json!(vec2_properties.y));
|
||||
self.input_data.insert("unit".to_string(), json!(vec2_properties.unit));
|
||||
self.input_data.insert("is_integer".to_string(), Value::Bool(vec2_properties.is_integer));
|
||||
if let Some(min) = vec2_properties.min {
|
||||
WidgetOverride::Vec2(vec2_inspector) => {
|
||||
self.input_data.insert("x".to_string(), json!(vec2_inspector.x));
|
||||
self.input_data.insert("y".to_string(), json!(vec2_inspector.y));
|
||||
self.input_data.insert("unit".to_string(), json!(vec2_inspector.unit));
|
||||
self.input_data.insert("is_integer".to_string(), Value::Bool(vec2_inspector.is_integer));
|
||||
if let Some(min) = vec2_inspector.min {
|
||||
self.input_data.insert("min".to_string(), json!(min));
|
||||
}
|
||||
self.widget_override = Some("vec2".to_string());
|
||||
@@ -724,14 +714,17 @@ pub struct DocumentNodePersistentMetadata {
|
||||
/// A name chosen by the user for this instance of the node. Empty indicates no given name, in which case the implementation name is displayed to the user in italics.
|
||||
#[serde(default)]
|
||||
pub display_name: String,
|
||||
/// Stores metadata to override the properties in the properties panel for each input. These can either be generated automatically based on the type, or with a custom function.
|
||||
/// Stores metadata to override the widgets in the Inspector for each input. These can either be generated automatically based on the type, or with a custom function.
|
||||
/// Must match the length of node inputs
|
||||
pub input_metadata: Vec<InputMetadata>,
|
||||
pub output_names: Vec<String>,
|
||||
/// Indexed like `output_names`, where a missing or empty entry means the output has no description.
|
||||
#[serde(default)]
|
||||
pub output_descriptions: Vec<String>,
|
||||
/// Represents the lock icon for locking/unlocking the node in the graph UI. When locked, a node cannot be moved in the graph UI.
|
||||
#[serde(default)]
|
||||
pub locked: bool,
|
||||
/// Indicates that the node will be shown in the Properties panel when it would otherwise be empty, letting a user easily edit its properties by just deselecting everything.
|
||||
/// Indicates that the node will be shown in the Inspector when it would otherwise be empty, letting a user easily edit its inputs by just deselecting everything.
|
||||
#[serde(default)]
|
||||
pub pinned: bool,
|
||||
/// Metadata that is specific to either nodes or layers, which are chosen states for displaying as a left-to-right node or bottom-to-top layer.
|
||||
@@ -920,6 +913,13 @@ pub enum TransactionStatus {
|
||||
Finished,
|
||||
}
|
||||
|
||||
/// The open transaction's bookkeeping from [`NodeNetworkInterface::transaction_checkpoint`], to put back once the writes made after it are undone.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TransactionCheckpoint {
|
||||
pub(super) status: TransactionStatus,
|
||||
pub(super) edited_nodes: HashSet<NodeId>,
|
||||
}
|
||||
|
||||
/// How [`NodeNetworkInterface::is_sole_dependent`] should treat a downstream connector it encounters.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) enum SoleDependentStep {
|
||||
|
||||
@@ -131,7 +131,7 @@ impl<'a, 'p> NetworkView<'a, 'p> {
|
||||
.is_some_and(|reference| reference == DefinitionIdentifier::Network("Merge".into()))
|
||||
}
|
||||
|
||||
/// The uneditable name in the Properties panel which represents the function name of the node implementation.
|
||||
/// The uneditable name in the Inspector which represents the function name of the node implementation.
|
||||
pub fn implementation_name(&self, node_id: &NodeId) -> String {
|
||||
self.reference(node_id)
|
||||
.ok()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use super::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
|
||||
use super::network_interface::NodeNetworkInterface;
|
||||
use crate::messages::frontend::IconName;
|
||||
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils;
|
||||
use glam::DVec2;
|
||||
use graph_craft::document::{NodeId, NodeNetwork};
|
||||
@@ -35,9 +34,9 @@ pub struct LayerPanelEntry {
|
||||
/// The nodes in the chain feeding this layer, in the graph's left-to-right order.
|
||||
#[serde(rename = "chainNodes")]
|
||||
pub chain_nodes: Vec<LayerPanelChainNode>,
|
||||
/// The data type flowing from the chain into the layer, which colors the connector between them.
|
||||
#[serde(rename = "chainDataType")]
|
||||
pub chain_data_type: FrontendGraphDataType,
|
||||
/// Whether the chain is expanded into a row per node beneath the layer's row.
|
||||
#[serde(rename = "chainExpanded")]
|
||||
pub chain_expanded: bool,
|
||||
/// How the active tool edits the layer node itself, if it does, for the tooltip of its outlined icon.
|
||||
#[serde(rename = "toolTargetDescription")]
|
||||
pub tool_target_description: Option<String>,
|
||||
@@ -68,6 +67,9 @@ pub struct LayerPanelChainNode {
|
||||
pub id: NodeId,
|
||||
pub icon: IconName,
|
||||
pub name: String,
|
||||
/// The name shown in place of a custom one, as the placeholder while renaming.
|
||||
#[serde(rename = "implementationName")]
|
||||
pub implementation_name: String,
|
||||
/// Whether the node is selected, shown in every layer whose chain shares it.
|
||||
pub selected: bool,
|
||||
/// Whether the node can be dragged to reorder it, unlike a source node (with no primary input) fixed at the chain's upstream end.
|
||||
|
||||
@@ -153,6 +153,8 @@ impl Axis {
|
||||
pub struct Translation {
|
||||
pub dragged_distance: DVec2,
|
||||
pub typed_distance: Option<f64>,
|
||||
/// The distance a snap moved the dragged distance to, in the same terms, which is applied in its place.
|
||||
pub snapped: Option<DVec2>,
|
||||
pub constraint: Axis,
|
||||
}
|
||||
|
||||
@@ -166,10 +168,11 @@ impl Translation {
|
||||
Axis::Both => self.dragged_distance,
|
||||
}
|
||||
} else {
|
||||
let distance = self.snapped.unwrap_or(self.dragged_distance);
|
||||
match self.constraint {
|
||||
Axis::Both => self.dragged_distance,
|
||||
Axis::X => DVec2::X * self.dragged_distance.dot(state.constraint_axis(self.constraint).unwrap_or_default()),
|
||||
Axis::Y => DVec2::Y * self.dragged_distance.dot(state.constraint_axis(self.constraint).unwrap_or_default()),
|
||||
Axis::Both => distance,
|
||||
Axis::X => DVec2::X * distance.dot(state.constraint_axis(self.constraint).unwrap_or_default()),
|
||||
Axis::Y => DVec2::Y * distance.dot(state.constraint_axis(self.constraint).unwrap_or_default()),
|
||||
}
|
||||
};
|
||||
let displacement_viewport = displacement * document_to_viewport.matrix2.y_axis.length(); // Values are local to the viewport but scaled so values are relative to the current scale.
|
||||
@@ -183,6 +186,7 @@ impl Translation {
|
||||
Self {
|
||||
dragged_distance: self.dragged_distance + delta,
|
||||
typed_distance: None,
|
||||
snapped: None,
|
||||
constraint: self.constraint,
|
||||
}
|
||||
}
|
||||
@@ -190,18 +194,23 @@ impl Translation {
|
||||
Self {
|
||||
dragged_distance: change,
|
||||
typed_distance: None,
|
||||
snapped: None,
|
||||
constraint: self.constraint,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn negate(self) -> Self {
|
||||
let dragged_distance = -self.dragged_distance;
|
||||
Self { dragged_distance, ..self }
|
||||
Self {
|
||||
dragged_distance,
|
||||
snapped: None,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_constraint(self, target: Axis, local: bool) -> (Self, bool) {
|
||||
let (constraint, local) = self.constraint.contrainted_to_axis(target, local);
|
||||
(Self { constraint, ..self }, local)
|
||||
(Self { constraint, snapped: None, ..self }, local)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,17 +218,20 @@ impl Translation {
|
||||
pub struct Rotation {
|
||||
pub dragged_angle: f64,
|
||||
pub typed_angle: Option<f64>,
|
||||
/// The angle a snap moved the dragged angle to, which is applied in its place.
|
||||
pub snapped: Option<f64>,
|
||||
}
|
||||
|
||||
impl Rotation {
|
||||
pub fn to_f64(self, increment_mode: bool) -> f64 {
|
||||
let angle = self.snapped.unwrap_or(self.dragged_angle);
|
||||
if let Some(value) = self.typed_angle {
|
||||
value.to_radians()
|
||||
} else if increment_mode {
|
||||
let increment_resolution = ROTATE_INCREMENT.to_radians();
|
||||
(self.dragged_angle / increment_resolution).round() * increment_resolution
|
||||
(angle / increment_resolution).round() * increment_resolution
|
||||
} else {
|
||||
self.dragged_angle
|
||||
angle
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,18 +240,20 @@ impl Rotation {
|
||||
Self {
|
||||
dragged_angle: self.dragged_angle + delta,
|
||||
typed_angle: None,
|
||||
snapped: None,
|
||||
}
|
||||
}
|
||||
pub fn set_amount(self, angle: f64) -> Self {
|
||||
Self {
|
||||
dragged_angle: angle,
|
||||
typed_angle: None,
|
||||
snapped: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn negate(self) -> Self {
|
||||
let dragged_angle = -self.dragged_angle;
|
||||
Self { dragged_angle, ..self }
|
||||
Self { dragged_angle, snapped: None, ..self }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +261,8 @@ impl Rotation {
|
||||
pub struct Scale {
|
||||
pub dragged_factor: f64,
|
||||
pub typed_factor: Option<f64>,
|
||||
/// The factor a snap moved the dragged factor to, which is applied in its place.
|
||||
pub snapped: Option<f64>,
|
||||
pub constraint: Axis,
|
||||
}
|
||||
|
||||
@@ -255,6 +271,7 @@ impl Default for Scale {
|
||||
Self {
|
||||
dragged_factor: 1.,
|
||||
typed_factor: None,
|
||||
snapped: None,
|
||||
constraint: Axis::default(),
|
||||
}
|
||||
}
|
||||
@@ -262,7 +279,7 @@ impl Default for Scale {
|
||||
|
||||
impl Scale {
|
||||
pub fn to_f64(self, increment: bool) -> f64 {
|
||||
let factor = if let Some(value) = self.typed_factor { value } else { self.dragged_factor };
|
||||
let factor = self.typed_factor.or(self.snapped).unwrap_or(self.dragged_factor);
|
||||
if increment { (factor / SCALE_INCREMENT).round() * SCALE_INCREMENT } else { factor }
|
||||
}
|
||||
|
||||
@@ -278,7 +295,11 @@ impl Scale {
|
||||
|
||||
pub fn negate(self) -> Self {
|
||||
let dragged_factor = -self.dragged_factor;
|
||||
Self { dragged_factor, ..self }
|
||||
Self {
|
||||
dragged_factor,
|
||||
snapped: None,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -286,6 +307,7 @@ impl Scale {
|
||||
Self {
|
||||
dragged_factor: (self.dragged_factor + delta),
|
||||
typed_factor: None,
|
||||
snapped: None,
|
||||
constraint: self.constraint,
|
||||
}
|
||||
}
|
||||
@@ -294,13 +316,14 @@ impl Scale {
|
||||
Self {
|
||||
dragged_factor: 1. + change,
|
||||
typed_factor: None,
|
||||
snapped: None,
|
||||
constraint: self.constraint,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_constraint(self, target: Axis, local: bool) -> (Self, bool) {
|
||||
let (constraint, local) = self.constraint.contrainted_to_axis(target, local);
|
||||
(Self { constraint, ..self }, local)
|
||||
(Self { constraint, snapped: None, ..self }, local)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +366,7 @@ impl TransformOperation {
|
||||
transformation = normalized_transform * transformation * normalized_transform.inverse();
|
||||
|
||||
selected.update_transforms(transformation, Some(state.pivot_viewport(document)), Some(*self));
|
||||
self.hints(selected.responses, state.is_transforming_in_local_space);
|
||||
self.hints(selected.responses, state.is_transforming_in_local_space, state.is_snapping);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,8 +414,19 @@ impl TransformOperation {
|
||||
self.apply_transform_operation(selected, state, document);
|
||||
}
|
||||
|
||||
pub fn hints(&self, responses: &mut VecDeque<Message>, local: bool) {
|
||||
/// Goes back to applying the amount the pointer asks for, rather than where a snap moved it.
|
||||
pub fn clear_snapped(&mut self) {
|
||||
match self {
|
||||
TransformOperation::None => (),
|
||||
TransformOperation::Grabbing(translation) => translation.snapped = None,
|
||||
TransformOperation::Rotating(rotation) => rotation.snapped = None,
|
||||
TransformOperation::Scaling(scale) => scale.snapped = None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hints(&self, responses: &mut VecDeque<Message>, local: bool, snapping: bool) {
|
||||
use crate::messages::input_mapper::utility_types::keyboard::{Key, MouseMotion};
|
||||
use crate::messages::tool::common_functionality::snap_session::snapping_hints;
|
||||
use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo};
|
||||
|
||||
let mut input_hints = Vec::new();
|
||||
@@ -452,6 +486,9 @@ impl TransformOperation {
|
||||
}
|
||||
}
|
||||
hint_groups.push(HintGroup(typing_hints));
|
||||
if snapping && !self.is_typing() {
|
||||
hint_groups.push(snapping_hints());
|
||||
}
|
||||
|
||||
HintData(hint_groups).send_layout(responses);
|
||||
}
|
||||
|
||||
@@ -1139,6 +1139,37 @@ pub fn document_migration_replace_resources_referenced_by_hash(document_serializ
|
||||
(out, hash_to_id)
|
||||
}
|
||||
|
||||
/// Whether the node is a subgraph that feeds its first input through a Monitor into a Transform proto node and forwards the other four inputs unchanged, making it equivalent to a bare Transform node.
|
||||
fn is_monitored_transform_subgraph(node: &DocumentNode) -> bool {
|
||||
let DocumentNodeImplementation::Network(network) = &node.implementation else { return false };
|
||||
if node.inputs.len() < 5 || network.nodes.len() != 2 {
|
||||
return false;
|
||||
}
|
||||
|
||||
let find_proto_node = |identifier: &ProtoNodeIdentifier| {
|
||||
network.nodes.iter().find(|(_, inner_node)| match &inner_node.implementation {
|
||||
DocumentNodeImplementation::ProtoNode(inner_identifier) => inner_identifier.as_str().split('<').next() == Some(identifier.as_str()),
|
||||
_ => false,
|
||||
})
|
||||
};
|
||||
let Some((monitor_id, monitor)) = find_proto_node(&graphene_std::memo::monitor::IDENTIFIER) else {
|
||||
return false;
|
||||
};
|
||||
let Some((transform_id, transform)) = find_proto_node(&graphene_std::transform_nodes::transform::IDENTIFIER) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let is_import_at = |input: &NodeInput, expected_index: usize| matches!(input, NodeInput::Import { import_index, .. } if *import_index == expected_index);
|
||||
|
||||
let monitor_reads_first_import = matches!(monitor.inputs.as_slice(), [input] if is_import_at(input, 0));
|
||||
let transform_reads_monitor_and_other_imports = transform.inputs.len() == 5
|
||||
&& matches!(&transform.inputs[0], NodeInput::Node { node_id, output_index: 0 } if node_id == monitor_id)
|
||||
&& transform.inputs.iter().enumerate().skip(1).all(|(index, input)| is_import_at(input, index));
|
||||
let exports_transform = matches!(network.exports.as_slice(), [NodeInput::Node { node_id, output_index: 0 }] if node_id == transform_id);
|
||||
|
||||
monitor_reads_first_import && transform_reads_monitor_and_other_imports && exports_transform
|
||||
}
|
||||
|
||||
pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_node_definitions_on_open: bool) {
|
||||
document.network_interface.migrate_path_modify_node();
|
||||
document.network_interface.normalize_stored_types();
|
||||
@@ -1172,13 +1203,17 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
|
||||
}
|
||||
|
||||
// The "Transform" wrapper network was replaced with the `transform` proto node directly. Convert old `Network("Transform")` instances to the proto node, forwarding the 5 user-facing inputs (Value, Translation, Rotation, Scale, Skew) and dropping the legacy migration sentinels (Origin Offset, Scale Appearance) at indices 5 and 6 if present.
|
||||
// Some old documents store it as a Custom Node subgraph with no reference, where a Monitor feeds the Transform proto node. Those are converted the same way.
|
||||
// Pre-pass for the same reason as the Brush migration above: replacing the outer Transform's network impl orphans its child paths.
|
||||
let transform_layers: Vec<(NodeId, Vec<NodeId>, usize)> = document
|
||||
.network_interface
|
||||
.document_network()
|
||||
.recursive_nodes()
|
||||
.filter_map(|(node_id, node, path)| {
|
||||
(document.network_interface.reference(node_id, &path) == Some(DefinitionIdentifier::Network("Transform".into()))).then_some((*node_id, path, node.inputs.len()))
|
||||
let reference = document.network_interface.reference(node_id, &path);
|
||||
let is_transform_wrapper = reference == Some(DefinitionIdentifier::Network("Transform".into())) || (reference.is_none() && is_monitored_transform_subgraph(node));
|
||||
|
||||
is_transform_wrapper.then_some((*node_id, path, node.inputs.len()))
|
||||
})
|
||||
.collect();
|
||||
for (node_id, network_path, old_inputs_count) in &transform_layers {
|
||||
@@ -1195,7 +1230,7 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
|
||||
}
|
||||
|
||||
// Pre-2024 documents stored Transform with 6 inputs and used radians for Rotation and `tan(radians)` for Skew. Detect that legacy
|
||||
// shape (no input at index 6) and convert the units to degrees so the values match what the new Properties panel widgets expect.
|
||||
// shape (no input at index 6) and convert the units to degrees so the values match what the new Inspector widgets expect.
|
||||
if *old_inputs_count == 6 {
|
||||
match old_inputs.get(2) {
|
||||
Some(NodeInput::Value { tagged_value, exposed }) => {
|
||||
@@ -1817,9 +1852,34 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
|
||||
// Only nodes that have not been modified and still refer to a definition can be updated
|
||||
let reference = document.network_interface.reference(node_id, network_path)?;
|
||||
|
||||
// Show the Artboard's Content input in the Inspector, which the definition once hid
|
||||
if reference == DefinitionIdentifier::Network("Artboard".into())
|
||||
&& document
|
||||
.network_interface
|
||||
.persistent_input_metadata(node_id, 1, network_path)
|
||||
.and_then(|metadata| metadata.widget_override.as_deref())
|
||||
== Some("hidden")
|
||||
{
|
||||
document.network_interface.set_input_override(node_id, 1, None, network_path);
|
||||
}
|
||||
|
||||
// Legacy `noise_properties_*` widget overrides
|
||||
for input_index in 0..node.inputs.len() {
|
||||
let renamed_override = document
|
||||
.network_interface
|
||||
.persistent_input_metadata(node_id, input_index, network_path)
|
||||
.and_then(|metadata| metadata.widget_override.as_deref())
|
||||
.and_then(|widget_override| widget_override.strip_prefix("noise_properties_"))
|
||||
.map(|suffix| format!("noise_inspector_{suffix}"));
|
||||
|
||||
if let Some(renamed_override) = renamed_override {
|
||||
document.network_interface.set_input_override(node_id, input_index, Some(renamed_override), network_path);
|
||||
}
|
||||
}
|
||||
|
||||
let mut inputs_count = node.inputs.len();
|
||||
|
||||
// The expression nodes gained an output-type input, a type witness the Properties panel edits. A node from before it
|
||||
// The expression nodes gained an output-type input, a type witness the Inspector edits. A node from before it
|
||||
// takes the definition's default choice, Number, which is the output type every such node had.
|
||||
let expression_node_identifiers = [graphene_std::math_nodes::math_fx::IDENTIFIER, graphene_std::math_nodes::math_f::IDENTIFIER];
|
||||
if expression_node_identifiers.iter().any(|identifier| reference == DefinitionIdentifier::ProtoNode(identifier.clone())) && inputs_count == 2 {
|
||||
@@ -2808,7 +2868,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
|
||||
}
|
||||
}
|
||||
|
||||
// Add the "Depth" parameter to the "Read Index" node
|
||||
// Add the "Loop Level" parameter to the "Read Index" node
|
||||
if reference == DefinitionIdentifier::ProtoNode(graphene_std::context::read_index::IDENTIFIER) && inputs_count == 0 {
|
||||
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
|
||||
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
|
||||
@@ -2817,8 +2877,15 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
|
||||
let mut node_path = network_path.to_vec();
|
||||
node_path.push(*node_id);
|
||||
|
||||
let loop_level_description = node_template
|
||||
.input_metadata
|
||||
.get(1)
|
||||
.map(|metadata| metadata.persistent_metadata.input_description.clone())
|
||||
.unwrap_or_default();
|
||||
document.network_interface.add_import(TaggedValue::None, false, 0, "Primary", "", &node_path);
|
||||
document.network_interface.add_import(TaggedValue::Integer(0), false, 1, "Loop Level", "TODO", &node_path);
|
||||
document
|
||||
.network_interface
|
||||
.add_import(TaggedValue::Integer(0), false, 1, "Loop Level", &loop_level_description, &node_path);
|
||||
}
|
||||
|
||||
// Drop the placeholder primary input the "Read Vector" node used to carry, since it reads its value from the context
|
||||
@@ -3449,6 +3516,66 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// The retired "Paint Order" input is migrated by rebuilding the Stroke node's inputs and then reordering it with its Fill node
|
||||
#[tokio::test]
|
||||
async fn opening_a_stroke_with_a_retired_paint_order_keeps_the_layer_chain() {
|
||||
use crate::messages::portfolio::document_storage_io::load_legacy_document;
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils::get_stroke_paint_order;
|
||||
use crate::test_utils::capture_logged_errors;
|
||||
use crate::test_utils::test_prelude::*;
|
||||
use graph_craft::application_io::resource::HashMapResourceStorage;
|
||||
|
||||
// Each node of the layer's chain from the layer outward, with its offset from the layer if it is chain-positioned
|
||||
let chain_layout = |document: &DocumentMessageHandler, layer: NodeId| {
|
||||
let interface = &document.network_interface;
|
||||
let layer_position = interface.position(&layer, &[]).unwrap_or_default();
|
||||
interface
|
||||
.layer_chain_nodes(layer, &[])
|
||||
.into_iter()
|
||||
.map(|node_id| {
|
||||
let offset = interface.is_chain(&node_id, &[]).then(|| interface.position(&node_id, &[]).unwrap_or_default() - layer_position);
|
||||
(interface.display_name(&node_id, &[]), offset)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
let mut editor = EditorTestUtils::create();
|
||||
editor.new_document().await;
|
||||
editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
|
||||
let document = editor.active_document_mut();
|
||||
let layer = document.metadata().all_layers().next().unwrap().to_node();
|
||||
let original = chain_layout(document, layer);
|
||||
|
||||
// Save the shape's Stroke node as an older editor did, with "Paint Order" set to draw the stroke below the fill
|
||||
let stroke_reference = DefinitionIdentifier::ProtoNode(graphene_std::vector::stroke::IDENTIFIER);
|
||||
let stroke_node_id = document
|
||||
.network_interface
|
||||
.layer_chain_nodes(layer, &[])
|
||||
.into_iter()
|
||||
.find(|node_id| document.network_interface.reference(node_id, &[]).as_ref() == Some(&stroke_reference))
|
||||
.expect("a fresh shape should have a Stroke node in its chain");
|
||||
let mut inputs = document.network_interface.document_node(&stroke_node_id, &[]).unwrap().inputs.clone();
|
||||
inputs.insert(7, NodeInput::value(TaggedValue::PaintOrder(PaintOrder::StrokeBelow), false));
|
||||
let mut legacy_stroke = NodeTemplate { inputs, ..Default::default() };
|
||||
legacy_stroke.normalize_input_metadata();
|
||||
document.network_interface.replace_inputs(&stroke_node_id, &[], &mut legacy_stroke);
|
||||
let serialized = document.serialize_document();
|
||||
|
||||
let (opened, errors) = capture_logged_errors(|| load_legacy_document(serialized, &HashMapResourceStorage::new(), false));
|
||||
let opened = opened.expect("the document should open");
|
||||
assert!(errors.is_empty(), "opening the document logged errors: {errors:?}");
|
||||
|
||||
// The Fill and Stroke nodes trade places, and the chain keeps every slot
|
||||
assert_eq!(get_stroke_paint_order(LayerNodeIdentifier::new_unchecked(layer), &opened.network_interface), PaintOrder::StrokeBelow);
|
||||
let swap_name = |name: &str| match name {
|
||||
"Fill" => "Stroke".to_string(),
|
||||
"Stroke" => "Fill".to_string(),
|
||||
other => other.to_string(),
|
||||
};
|
||||
let expected = original.iter().map(|(name, offset)| (swap_name(name), *offset)).collect::<Vec<_>>();
|
||||
assert_eq!(chain_layout(&opened, layer), expected, "the migration should leave the layer's chain intact");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn null_floats_load_as_zero() {
|
||||
use crate::messages::portfolio::document::utility_types::misc::PTZ;
|
||||
|
||||
@@ -322,6 +322,7 @@ pub(super) fn load_legacy_document(document_serialized_content: String, byte_sto
|
||||
for (node_id, node, path) in document.network_interface.document_network().clone().recursive_nodes() {
|
||||
document.network_interface.validate_input_metadata(node_id, node, &path);
|
||||
document.network_interface.validate_output_names(node_id, node, &path);
|
||||
document.network_interface.validate_descriptions(node_id, node, &path);
|
||||
}
|
||||
|
||||
// Ensure layers are positioned as stacks if they are upstream siblings of another layer
|
||||
|
||||
@@ -10,6 +10,7 @@ pub enum FontsMessage {
|
||||
CatalogLoaded {
|
||||
catalog: FontCatalog,
|
||||
},
|
||||
CatalogLoadFailed,
|
||||
ResourceResolved {
|
||||
font: Font,
|
||||
hash: ResourceHash,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::consts::{FONT_CATALOG_REQUEST_TIMEOUT_MILLISECONDS, FONT_CATALOG_RETRY_DELAY_MILLISECONDS};
|
||||
use crate::messages::portfolio::fonts::FALLBACK_FONT_RESOURCE;
|
||||
use crate::messages::portfolio::fonts::utility_types::FontCatalog;
|
||||
use crate::messages::prelude::*;
|
||||
@@ -8,35 +9,72 @@ use std::sync::Arc;
|
||||
#[derive(ExtractField)]
|
||||
pub struct FontsMessageContext<'a> {
|
||||
pub resource_storage: &'a ResourceStorageMessageHandler,
|
||||
pub current_time: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, ExtractField)]
|
||||
pub struct FontsMessageHandler {
|
||||
pub font_catalog: Arc<FontCatalog>,
|
||||
catalog_request: CatalogRequest,
|
||||
font_hashes: HashMap<Font, ResourceHash>,
|
||||
font_data: HashMap<ResourceHash, Resource>,
|
||||
}
|
||||
|
||||
/// State of the font catalog request shared by every `FontsMessage::LoadCatalog`.
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq)]
|
||||
enum CatalogRequest {
|
||||
#[default]
|
||||
Idle,
|
||||
/// A request is unanswered or the last one failed, so another waits until this time.
|
||||
Waiting { until: u64 },
|
||||
}
|
||||
|
||||
#[message_handler_data]
|
||||
impl MessageHandler<FontsMessage, FontsMessageContext<'_>> for FontsMessageHandler {
|
||||
fn process_message(&mut self, message: FontsMessage, responses: &mut VecDeque<Message>, context: FontsMessageContext) {
|
||||
let FontsMessageContext { resource_storage } = context;
|
||||
let FontsMessageContext { resource_storage, current_time } = context;
|
||||
|
||||
match message {
|
||||
FontsMessage::LoadCatalog => {
|
||||
// Senders ask on every message until the catalog arrives, so wait out an unanswered or failed request before sending another
|
||||
let waiting = matches!(self.catalog_request, CatalogRequest::Waiting { until } if current_time < until);
|
||||
if !self.font_catalog.is_empty() || waiting {
|
||||
return;
|
||||
}
|
||||
self.catalog_request = CatalogRequest::Waiting {
|
||||
until: current_time + FONT_CATALOG_REQUEST_TIMEOUT_MILLISECONDS,
|
||||
};
|
||||
|
||||
responses.add(NetworkMessage::request(async move |client| {
|
||||
let Some(catalog) = FontCatalog::load_from_api(&client).await else {
|
||||
log::error!("failed to load font catalog");
|
||||
return Message::NoOp;
|
||||
log::error!("Failed to load the font catalog");
|
||||
return FontsMessage::CatalogLoadFailed.into();
|
||||
};
|
||||
FontsMessage::CatalogLoaded { catalog }.into()
|
||||
}));
|
||||
}
|
||||
FontsMessage::CatalogLoadFailed => {
|
||||
self.catalog_request = CatalogRequest::Waiting {
|
||||
until: current_time + FONT_CATALOG_RETRY_DELAY_MILLISECONDS,
|
||||
};
|
||||
}
|
||||
FontsMessage::CatalogLoaded { catalog } => {
|
||||
// An empty catalog counts as a failure, and one equal to the current catalog (from overlapping requests) changes nothing
|
||||
if catalog.is_empty() {
|
||||
self.catalog_request = CatalogRequest::Waiting {
|
||||
until: current_time + FONT_CATALOG_RETRY_DELAY_MILLISECONDS,
|
||||
};
|
||||
return;
|
||||
}
|
||||
self.catalog_request = CatalogRequest::Idle;
|
||||
if *self.font_catalog == catalog {
|
||||
return;
|
||||
}
|
||||
|
||||
self.font_catalog = Arc::new(catalog);
|
||||
responses.add(PortfolioMessage::ResolveResources);
|
||||
responses.add(ToolMessage::RefreshToolOptions);
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
FontsMessage::ResourceResolved { font, hash } => {
|
||||
let font = self.normalize(font);
|
||||
@@ -114,3 +152,81 @@ impl FontsMessageHandler {
|
||||
self.font_catalog.normalize(font)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::messages::portfolio::fonts::utility_types::FontCatalogFamily;
|
||||
|
||||
fn process(handler: &mut FontsMessageHandler, message: FontsMessage, current_time: u64) -> VecDeque<Message> {
|
||||
let resource_storage = ResourceStorageMessageHandler::default();
|
||||
let mut responses = VecDeque::new();
|
||||
handler.process_message(
|
||||
message,
|
||||
&mut responses,
|
||||
FontsMessageContext {
|
||||
resource_storage: &resource_storage,
|
||||
current_time,
|
||||
},
|
||||
);
|
||||
responses
|
||||
}
|
||||
|
||||
fn catalog_requests_sent(handler: &mut FontsMessageHandler, current_time: u64) -> usize {
|
||||
let responses = process(handler, FontsMessage::LoadCatalog, current_time);
|
||||
responses.iter().filter(|message| matches!(message, Message::Network(_))).count()
|
||||
}
|
||||
|
||||
fn catalog() -> FontCatalog {
|
||||
FontCatalog::from(vec![FontCatalogFamily {
|
||||
name: "Lato".to_string(),
|
||||
styles: Vec::new(),
|
||||
}])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_requests_wait_for_an_unanswered_or_failed_one() {
|
||||
let mut handler = FontsMessageHandler::default();
|
||||
|
||||
assert_eq!(catalog_requests_sent(&mut handler, 0), 1);
|
||||
assert_eq!(
|
||||
catalog_requests_sent(&mut handler, FONT_CATALOG_REQUEST_TIMEOUT_MILLISECONDS - 1),
|
||||
0,
|
||||
"An unanswered request should block another"
|
||||
);
|
||||
assert_eq!(
|
||||
catalog_requests_sent(&mut handler, FONT_CATALOG_REQUEST_TIMEOUT_MILLISECONDS),
|
||||
1,
|
||||
"A request unanswered for too long should be retried"
|
||||
);
|
||||
|
||||
// A failure, or an empty catalog in its place, waits the retry delay
|
||||
for (failure_time, failure) in [(100_000, FontsMessage::CatalogLoadFailed), (200_000, FontsMessage::CatalogLoaded { catalog: FontCatalog::default() })] {
|
||||
assert!(process(&mut handler, failure, failure_time).is_empty());
|
||||
|
||||
let retry_time = failure_time + FONT_CATALOG_RETRY_DELAY_MILLISECONDS;
|
||||
assert_eq!(
|
||||
catalog_requests_sent(&mut handler, retry_time - 1),
|
||||
0,
|
||||
"A failure should block another request until the retry delay passes"
|
||||
);
|
||||
assert_eq!(catalog_requests_sent(&mut handler, retry_time), 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_arrivals_after_the_first_change_nothing() {
|
||||
let mut handler = FontsMessageHandler::default();
|
||||
|
||||
assert!(!process(&mut handler, FontsMessage::CatalogLoaded { catalog: catalog() }, 0).is_empty());
|
||||
assert_eq!(*handler.font_catalog, catalog());
|
||||
assert_eq!(catalog_requests_sent(&mut handler, 0), 0, "A loaded catalog should need no request");
|
||||
|
||||
assert!(
|
||||
process(&mut handler, FontsMessage::CatalogLoaded { catalog: catalog() }, 0).is_empty(),
|
||||
"An equal catalog should send no refreshes"
|
||||
);
|
||||
assert!(process(&mut handler, FontsMessage::CatalogLoaded { catalog: FontCatalog::default() }, 0).is_empty());
|
||||
assert_eq!(*handler.font_catalog, catalog(), "An empty catalog should not replace a loaded one");
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
resource_storage,
|
||||
data_panel_open: self.workspace.panel_layout.is_panel_visible(PanelType::Data) && !self.workspace.panel_layout.focus_document,
|
||||
layers_panel_open: self.workspace.panel_layout.is_panel_visible(PanelType::Layers) && !self.workspace.panel_layout.focus_document,
|
||||
properties_panel_open: self.workspace.panel_layout.is_panel_visible(PanelType::Properties) && !self.workspace.panel_layout.focus_document,
|
||||
inspector_open: self.workspace.panel_layout.is_panel_visible(PanelType::Inspector) && !self.workspace.panel_layout.focus_document,
|
||||
};
|
||||
document.process_message(message, responses, document_inputs);
|
||||
refresh_transaction_edited_nodes(document, true, responses);
|
||||
@@ -115,7 +115,10 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
self.failed_documents.process_message(message, responses, context);
|
||||
}
|
||||
PortfolioMessage::Fonts(message) => {
|
||||
let context = FontsMessageContext { resource_storage };
|
||||
let context = FontsMessageContext {
|
||||
resource_storage,
|
||||
current_time: ipp.time,
|
||||
};
|
||||
self.fonts.process_message(message, responses, context);
|
||||
}
|
||||
PortfolioMessage::Ingest(message) => {
|
||||
@@ -192,7 +195,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
resource_storage,
|
||||
data_panel_open: self.workspace.panel_layout.is_panel_visible(PanelType::Data) && !self.workspace.panel_layout.focus_document,
|
||||
layers_panel_open: self.workspace.panel_layout.is_panel_visible(PanelType::Layers) && !self.workspace.panel_layout.focus_document,
|
||||
properties_panel_open: self.workspace.panel_layout.is_panel_visible(PanelType::Properties) && !self.workspace.panel_layout.focus_document,
|
||||
inspector_open: self.workspace.panel_layout.is_panel_visible(PanelType::Inspector) && !self.workspace.panel_layout.focus_document,
|
||||
};
|
||||
document.process_message(message, responses, document_inputs);
|
||||
refresh_transaction_edited_nodes(document, self.active_document_id == Some(document_id), responses);
|
||||
@@ -247,7 +250,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
responses.add(ToolMessage::DeactivateTools);
|
||||
|
||||
// Clear relevant UI layouts if there are no documents
|
||||
responses.add(PropertiesPanelMessage::Clear);
|
||||
responses.add(InspectorMessage::Clear);
|
||||
responses.add(DocumentMessage::ClearLayersPanel);
|
||||
responses.add(DataPanelMessage::ClearLayout);
|
||||
HintData::clear_layout(responses);
|
||||
@@ -271,13 +274,13 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
// Is this the last document?
|
||||
if self.document_ids.len() == 1 && self.document_ids[0] == document_id {
|
||||
// Clear UI layouts that assume the existence of a document
|
||||
responses.add(PropertiesPanelMessage::Clear);
|
||||
responses.add(InspectorMessage::Clear);
|
||||
responses.add(DocumentMessage::ClearLayersPanel);
|
||||
responses.add(DataPanelMessage::ClearLayout);
|
||||
HintData::clear_layout(responses);
|
||||
}
|
||||
|
||||
// Actually delete the document (delay to delete document is required to let the document and properties panel messages above get processed)
|
||||
// Actually delete the document (delay to delete document is required to let the document and Inspector messages above get processed)
|
||||
responses.add(PortfolioMessage::DeleteDocument { document_id });
|
||||
responses.add(remove_stored_document(self.document_store.clone(), document_id));
|
||||
|
||||
@@ -789,6 +792,16 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
});
|
||||
}
|
||||
PortfolioMessage::SelectDocument { document_id } => {
|
||||
// The document we are leaving won't get the pointer up that ends a wire drag in its graph, so abort the drag there before switching
|
||||
if self.active_document_id != Some(document_id)
|
||||
&& let Some(document) = self.active_document_mut()
|
||||
&& document.end_node_graph_wire_in_progress(responses)
|
||||
{
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
responses.add(PortfolioMessage::SelectDocument { document_id });
|
||||
return;
|
||||
}
|
||||
|
||||
// Auto-save the document we are leaving
|
||||
let mut node_graph_open = false;
|
||||
if let Some(document) = self.active_document() {
|
||||
@@ -846,7 +859,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||
document.is_loaded = true;
|
||||
responses.add(PortfolioMessage::ResolveDocumentResources { document_id });
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
responses.add(PropertiesPanelMessage::Clear);
|
||||
responses.add(InspectorMessage::Clear);
|
||||
}
|
||||
}
|
||||
PortfolioMessage::RenameDocument { new_name } => {
|
||||
|
||||
@@ -9,7 +9,8 @@ pub enum PanelType {
|
||||
Welcome,
|
||||
Document,
|
||||
Layers,
|
||||
Properties,
|
||||
#[serde(alias = "Properties")]
|
||||
Inspector,
|
||||
Data,
|
||||
}
|
||||
|
||||
@@ -19,7 +20,7 @@ impl From<String> for PanelType {
|
||||
"Welcome" => PanelType::Welcome,
|
||||
"Document" => PanelType::Document,
|
||||
"Layers" => PanelType::Layers,
|
||||
"Properties" => PanelType::Properties,
|
||||
"Inspector" | "Properties" => PanelType::Inspector,
|
||||
"Data" => PanelType::Data,
|
||||
_ => panic!("Unknown panel type: {value}"),
|
||||
}
|
||||
@@ -28,7 +29,7 @@ impl From<String> for PanelType {
|
||||
|
||||
impl PanelType {
|
||||
pub fn non_document_panels() -> &'static [PanelType] {
|
||||
&[PanelType::Layers, PanelType::Properties, PanelType::Data]
|
||||
&[PanelType::Layers, PanelType::Inspector, PanelType::Data]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +299,7 @@ impl WorkspacePanelLayout {
|
||||
|
||||
/// Place a panel at its default structural position in the layout tree.
|
||||
/// - Data: below the document in the left column (root child 0)
|
||||
/// - Properties: top of the right column (root child 1)
|
||||
/// - Inspector: top of the right column (root child 1)
|
||||
/// - Layers: bottom of the right column (root child 1)
|
||||
fn restore_panel_to_default_position(&mut self, panel_type: PanelType) {
|
||||
let new_id = self.next_id();
|
||||
@@ -315,9 +316,9 @@ impl WorkspacePanelLayout {
|
||||
|
||||
// Determine which root child column to insert into and at which position
|
||||
let (root_child_index, insert_at_end) = match panel_type {
|
||||
PanelType::Data => (0, true), // Left column, after document
|
||||
PanelType::Properties => (1, false), // Right column, at top
|
||||
PanelType::Layers => (1, true), // Right column, at bottom
|
||||
PanelType::Data => (0, true), // Left column, after document
|
||||
PanelType::Inspector => (1, false), // Right column, at top
|
||||
PanelType::Layers => (1, true), // Right column, at bottom
|
||||
_ => (1, true),
|
||||
};
|
||||
|
||||
@@ -375,7 +376,7 @@ impl Default for WorkspacePanelLayout {
|
||||
// Default layout (sizes are recalculated by `recalculate_default_sizes` before being sent to the frontend):
|
||||
// Row [
|
||||
// Column [Document]
|
||||
// Column [Properties, Layers]
|
||||
// Column [Inspector, Layers]
|
||||
// ]
|
||||
Self {
|
||||
root: PanelLayoutSubdivision::Split {
|
||||
@@ -402,7 +403,7 @@ impl Default for WorkspacePanelLayout {
|
||||
subdivision: PanelLayoutSubdivision::PanelGroup {
|
||||
id: PanelGroupId(1),
|
||||
state: PanelGroupState {
|
||||
tabs: vec![PanelType::Properties],
|
||||
tabs: vec![PanelType::Inspector],
|
||||
active_tab_index: 0,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -31,7 +31,7 @@ pub enum WorkspaceMessage {
|
||||
},
|
||||
ToggleFocusDocument,
|
||||
ToggleDataPanelOpen,
|
||||
TogglePropertiesPanelOpen,
|
||||
ToggleInspectorOpen,
|
||||
ToggleLayersPanelOpen,
|
||||
UpdatePanelsLayout,
|
||||
ResetWorkspaceLayout,
|
||||
|
||||
@@ -251,12 +251,12 @@ impl MessageHandler<WorkspaceMessage, WorkspaceMessageContext> for WorkspaceMess
|
||||
responses.add(MenuBarMessage::SendLayout);
|
||||
responses.add(WorkspaceMessage::UpdatePanelsLayout);
|
||||
}
|
||||
WorkspaceMessage::TogglePropertiesPanelOpen => {
|
||||
WorkspaceMessage::ToggleInspectorOpen => {
|
||||
if self.panel_layout.focus_document {
|
||||
return;
|
||||
}
|
||||
|
||||
let panel_type = PanelType::Properties;
|
||||
let panel_type = PanelType::Inspector;
|
||||
self.toggle_dockable_panel(panel_type, has_active_document, has_no_documents, responses);
|
||||
}
|
||||
WorkspaceMessage::ToggleLayersPanelOpen => {
|
||||
@@ -334,7 +334,7 @@ impl MessageHandler<WorkspaceMessage, WorkspaceMessageContext> for WorkspaceMess
|
||||
// Extend with actions that are disabled when focusing the document
|
||||
if !self.panel_layout.focus_document {
|
||||
common.extend(actions!(WorkspaceMessageDiscriminant;
|
||||
TogglePropertiesPanelOpen,
|
||||
ToggleInspectorOpen,
|
||||
ToggleLayersPanelOpen,
|
||||
ToggleDataPanelOpen,
|
||||
));
|
||||
@@ -387,7 +387,7 @@ impl WorkspaceMessageHandler {
|
||||
/// This resets the backend's diffing state so it won't try to send updates to a frontend component that has been unmounted.
|
||||
fn destroy_panel_layouts(panel_type: PanelType, responses: &mut VecDeque<Message>) {
|
||||
let targets: &[LayoutTarget] = match panel_type {
|
||||
PanelType::Properties => &[LayoutTarget::PropertiesPanel],
|
||||
PanelType::Inspector => &[LayoutTarget::Inspector],
|
||||
PanelType::Layers => &[LayoutTarget::LayersPanelControlLeftBar, LayoutTarget::LayersPanelBottomLeftBar, LayoutTarget::LayersPanelBottomRightBar],
|
||||
PanelType::Data => &[LayoutTarget::DataPanel],
|
||||
PanelType::Document | PanelType::Welcome => return,
|
||||
@@ -403,8 +403,8 @@ impl WorkspaceMessageHandler {
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
|
||||
match panel_type {
|
||||
PanelType::Properties => {
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
PanelType::Inspector => {
|
||||
responses.add(InspectorMessage::Refresh);
|
||||
}
|
||||
PanelType::Layers => {
|
||||
if has_active_document {
|
||||
@@ -440,15 +440,15 @@ mod tests {
|
||||
};
|
||||
let group_of = |handler: &WorkspaceMessageHandler, panel_type| handler.panel_layout.find_panel(panel_type).expect("the default layout has this panel");
|
||||
|
||||
// The Layers panel joins the Properties panel's group as its active tab
|
||||
// The Layers panel joins the Inspector's group as its active tab
|
||||
let join = WorkspaceMessage::MovePanelTab {
|
||||
source_group: group_of(&handler, PanelType::Layers),
|
||||
target_group: group_of(&handler, PanelType::Properties),
|
||||
target_group: group_of(&handler, PanelType::Inspector),
|
||||
insert_index: 1,
|
||||
};
|
||||
handler.process_message(join, &mut VecDeque::new(), context());
|
||||
|
||||
// Splitting it back out beside the document leaves the Properties panel as the active tab of the group it left
|
||||
// Splitting it back out beside the document leaves the Inspector as the active tab of the group it left
|
||||
let split = WorkspaceMessage::SplitPanelGroup {
|
||||
target_group: group_of(&handler, PanelType::Document),
|
||||
direction: DockingSplitDirection::Right,
|
||||
@@ -458,6 +458,6 @@ mod tests {
|
||||
let mut responses = VecDeque::new();
|
||||
handler.process_message(split, &mut responses, context());
|
||||
|
||||
assert!(responses.contains(&PropertiesPanelMessage::Refresh.into()));
|
||||
assert!(responses.contains(&InspectorMessage::Refresh.into()));
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,10 @@ pub use crate::messages::menu_bar::{MenuBarMessage, MenuBarMessageDiscriminant,
|
||||
pub use crate::messages::network::{NetworkMessage, NetworkMessageContext, NetworkMessageDiscriminant, NetworkMessageHandler};
|
||||
pub use crate::messages::portfolio::document::data_panel::{DataPanelMessage, DataPanelMessageDiscriminant};
|
||||
pub use crate::messages::portfolio::document::graph_operation::{GraphOperationMessage, GraphOperationMessageContext, GraphOperationMessageDiscriminant, GraphOperationMessageHandler};
|
||||
pub use crate::messages::portfolio::document::inspector::{InspectorMessage, InspectorMessageDiscriminant, InspectorMessageHandler};
|
||||
pub use crate::messages::portfolio::document::navigation::{NavigationMessage, NavigationMessageContext, NavigationMessageDiscriminant, NavigationMessageHandler};
|
||||
pub use crate::messages::portfolio::document::node_graph::{NodeGraphMessage, NodeGraphMessageDiscriminant, NodeGraphMessageHandler};
|
||||
pub use crate::messages::portfolio::document::overlays::{OverlaysMessage, OverlaysMessageContext, OverlaysMessageDiscriminant, OverlaysMessageHandler};
|
||||
pub use crate::messages::portfolio::document::properties_panel::{PropertiesPanelMessage, PropertiesPanelMessageDiscriminant, PropertiesPanelMessageHandler};
|
||||
pub use crate::messages::portfolio::document::resource::{ResourceMessage, ResourceMessageContext, ResourceMessageDiscriminant, ResourceMessageHandler};
|
||||
pub use crate::messages::portfolio::document::{DocumentMessage, DocumentMessageContext, DocumentMessageDiscriminant, DocumentMessageHandler};
|
||||
pub use crate::messages::portfolio::failed_documents::{FailedDocumentsMessage, FailedDocumentsMessageContext, FailedDocumentsMessageDiscriminant, FailedDocumentsMessageHandler};
|
||||
|
||||
@@ -100,8 +100,7 @@ impl ToolColorOptions {
|
||||
Separator::new(SeparatorStyle::Related).widget_instance(),
|
||||
ColorInput::new(widget_value)
|
||||
.mixed(mixed_color)
|
||||
.min_width(48)
|
||||
.max_width(48)
|
||||
.sizing(WidgetSizing::fixed(48))
|
||||
.narrow(true)
|
||||
.on_update(color_callback)
|
||||
.widget_instance(),
|
||||
|
||||
Loaded 100 of 252 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user