Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Update egui/eframe to 0.37 (#9933)

JIJINBEI16f3b939b354
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md
index 135913571d..17350dbb55 100644
--- a/ATTRIBUTION.md
+++ b/ATTRIBUTION.md
@@ -896,11 +896,10 @@ copied into SolidCraft.
| Directory | Source | Licence | Changes |
|---|---|---|---|
-| vendor/accesskit_macos | accesskit_macos 0.26.3, https://github.com/AccessKit/accesskit (The AccessKit contributors) | MIT OR Apache-2.0 | the subclassing adapter and its tests from 0.27.2: dropping the adapter keeps AppKit's key-value observers (vendor/README.md) |
## Vendored renderer compatibility fix
-`vendor/egui-wgpu` is egui-wgpu 0.36.2 from https://github.com/emilk/egui
+`vendor/egui-wgpu` is egui-wgpu 0.37.0 from https://github.com/emilk/egui
(MIT OR Apache-2.0; both original licence texts are included). Rust sources and
its original `egui.wgsl` shader are retained; no images or other artwork are copied.
SolidCraft's narrow patch selects a safe 1x MSAA path on the chosen OpenGL adapter
diff --git a/Cargo.lock b/Cargo.lock
index 5a6aa4838b..47a8d217d0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,9 +4,9 @@ version = 4
[[package]]
name = "accesskit"
-version = "0.24.1"
+version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d3b7f7f85a7e5f68090000ed7622545829afd484d210358702ae4cb97dd0c320"
+checksum = "4e883d1d28c5fd5568c79ed2d2bd48d9f2fd3945c8974ed0f53690ceddb051be"
dependencies = [
"enumn",
"serde",
@@ -15,12 +15,12 @@ dependencies = [
[[package]]
name = "accesskit_atspi_common"
-version = "0.18.1"
+version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e8c61bee90b42a772d39d06a740207dc71a4e780004ace1db8d99fb1baaa954"
+checksum = "24f5baf62e34a4a6c30e3d697e4782f821a7337049c44c3b40576a27dfbb580d"
dependencies = [
"accesskit",
- "accesskit_consumer 0.36.0",
+ "accesskit_consumer",
"atspi-common",
"phf",
"serde",
@@ -29,41 +29,37 @@ dependencies = [
[[package]]
name = "accesskit_consumer"
-version = "0.35.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53cf47daed85312e763fbf85ceca136e0d7abc68e0a7e12abe11f48172bc3b10"
-dependencies = [
- "accesskit",
- "hashbrown 0.16.1",
-]
-
-[[package]]
-name = "accesskit_consumer"
-version = "0.36.0"
+version = "0.39.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25e0d7e25d06f4dc21d1774d67146e9e80d6789216cbd4d1e88185b0095dba60"
+checksum = "f3da8f27636015191b2264ee1df681503170a632cafd832fdc1edfdd4e3a2fd3"
dependencies = [
"accesskit",
- "hashbrown 0.16.1",
+ "hashbrown 0.17.1",
]
[[package]]
-name = "accesskit_consumer"
-version = "0.38.0"
+name = "accesskit_ios"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d10a236f96f87d70732e44520046785431ef01d5bcd6b041317bfadd2f88245"
+checksum = "a5280724673bbfa8b30a838c013500b719392989be3b97c5a9964062c252c232"
dependencies = [
"accesskit",
- "hashbrown 0.16.1",
+ "accesskit_consumer",
+ "hashbrown 0.17.1",
+ "objc2 0.5.3",
+ "objc2-foundation 0.2.2",
+ "objc2-ui-kit 0.2.2",
]
[[package]]
name = "accesskit_macos"
-version = "0.26.3"
+version = "0.27.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "123828ceeec755b05255e3976cb0852993202de98a0626c97dd8d34246991f84"
dependencies = [
"accesskit",
- "accesskit_consumer 0.38.0",
- "hashbrown 0.16.1",
+ "accesskit_consumer",
+ "hashbrown 0.17.1",
"objc2 0.5.3",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
@@ -71,9 +67,9 @@ dependencies = [
[[package]]
name = "accesskit_unix"
-version = "0.21.1"
+version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b016ca8db0ea0ea2ceff29a9d6240391492d960716aa471967c00e8cc8cb197c"
+checksum = "30d5192871228c54f1b0fb4a85cef000e11a3804f25d2165f14afa0daa67f3f6"
dependencies = [
"accesskit",
"accesskit_atspi_common",
@@ -89,13 +85,13 @@ dependencies = [
[[package]]
name = "accesskit_windows"
-version = "0.32.1"
+version = "0.35.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eff7009f1a532e917d66970a1e80c965140c6cfbbabbdde3d64e5431e6c78e21"
+checksum = "498668b90da9995302a0055aaecad4756932333da2ddef6baee1c00844c430fc"
dependencies = [
"accesskit",
- "accesskit_consumer 0.35.0",
- "hashbrown 0.16.1",
+ "accesskit_consumer",
+ "hashbrown 0.17.1",
"static_assertions",
"windows",
"windows-core",
@@ -103,11 +99,12 @@ dependencies = [
[[package]]
name = "accesskit_winit"
-version = "0.32.2"
+version = "0.34.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fe9a94394896352cc4660ca2288bd4ef883d83238853c038b44070c8f134313"
+checksum = "cd4ab4437b520ff03088fbe48676a11e7d44a929535e64b31432c1073e48dbcc"
dependencies = [
"accesskit",
+ "accesskit_ios",
"accesskit_macos",
"accesskit_unix",
"accesskit_windows",
@@ -203,6 +200,7 @@ dependencies = [
"parking_lot",
"percent-encoding",
"windows-sys 0.60.2",
+ "wl-clipboard-rs",
"x11rb",
]
@@ -687,42 +685,18 @@ dependencies = [
"thiserror 1.0.69",
]
-[[package]]
-name = "calloop"
-version = "0.14.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e"
-dependencies = [
- "bitflags 2.13.2",
- "polling",
- "rustix 1.1.5",
- "tracing",
-]
-
[[package]]
name = "calloop-wayland-source"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20"
dependencies = [
- "calloop 0.13.0",
+ "calloop",
"rustix 0.38.44",
"wayland-backend",
"wayland-client",
]
-[[package]]
-name = "calloop-wayland-source"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa"
-dependencies = [
- "calloop 0.14.5",
- "rustix 1.1.5",
- "wayland-backend",
- "wayland-client",
-]
-
[[package]]
name = "cbc"
version = "0.1.2"
@@ -1123,9 +1097,9 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"
[[package]]
name = "ecolor"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0656a7530b9e2841ee7a5f983965bdd9840c32f4012f759cfd44b912cced6b34"
+checksum = "31bcbef0d4263a63eb32c4834e5d711613035ce1333468e107d928923e21e6e2"
dependencies = [
"bytemuck",
"emath",
@@ -1134,9 +1108,9 @@ dependencies = [
[[package]]
name = "eframe"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55ad41fac6e3149abb4866e93df37dbd33baa95db525c3368c944584e95a5dc2"
+checksum = "9c5642501a65ca657d05f00c643a5c14ff2346cb3818032bfe23d58e1f8e5f84"
dependencies = [
"ahash",
"bytemuck",
@@ -1159,6 +1133,7 @@ dependencies = [
"profiling",
"raw-window-handle",
"ron",
+ "send_wrapper",
"serde",
"static_assertions",
"wasm-bindgen",
@@ -1171,9 +1146,9 @@ dependencies = [
[[package]]
name = "egui"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc938cc27cd911415e1e4d151bc56ff9df063d8db081374e87aeb805ea74b2ba"
+checksum = "bec9144f49b7a28b5f395d3147e325b4fe3e77ba686eac11d1bdf0a7da3f375f"
dependencies = [
"accesskit",
"ahash",
@@ -1193,7 +1168,7 @@ dependencies = [
[[package]]
name = "egui-wgpu"
-version = "0.36.2"
+version = "0.37.0"
dependencies = [
"ahash",
"bytemuck",
@@ -1211,32 +1186,34 @@ dependencies = [
[[package]]
name = "egui-winit"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "98466000559d66ba4db786a30448b01483946add4188e7f10f522a27b4fb89cc"
+checksum = "e4e449f4c4a2a60c7ccb4ba7fa4078417bfe1f9ddc03b5e05ce75748e33a70de"
dependencies = [
"accesskit_winit",
"arboard",
+ "block2 0.6.2",
"bytemuck",
"egui",
"log",
"objc2 0.6.5",
+ "objc2-app-kit 0.3.2",
"objc2-foundation 0.3.2",
"objc2-ui-kit 0.3.2",
"profiling",
"raw-window-handle",
"serde",
- "smithay-clipboard",
"web-time",
"webbrowser",
+ "windows-sys 0.61.2",
"winit",
]
[[package]]
name = "egui_glow"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "606ed4167daf341e5753d703285c4c1d562324b2c07aa8f405cd7d066fe58f3b"
+checksum = "9275ca5cc35a6b7c94e0e8cedf22542f66cb0cf45ed8ab2657c78ff49fec7268"
dependencies = [
"bytemuck",
"egui",
@@ -1254,9 +1231,9 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
[[package]]
name = "emath"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52c8d4141cf0f60fb2f7aefaf352d3ffa5171ef0ab09731c64391801e95e48f1"
+checksum = "e73ce90f54750be8672c02be0743fe47530e6f251e066f0ee2869b59eb297af5"
dependencies = [
"bytemuck",
"serde",
@@ -1330,9 +1307,9 @@ dependencies = [
[[package]]
name = "epaint"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0ec0308dc23130fc1a7d4623a8534c2ed069c6dc84e258ee4f3de99615aa1a3"
+checksum = "97bac86ae3dde93fc3951e790951caea739ff39a6c89d909cdaf1d9278dbb1bd"
dependencies = [
"ahash",
"bytemuck",
@@ -1350,15 +1327,16 @@ dependencies = [
"skrifa",
"smallvec",
"unicode-general-category",
+ "unicode-properties",
"unicode-segmentation",
"vello_cpu",
]
[[package]]
name = "epaint_default_fonts"
-version = "0.36.2"
+version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "773fa9c96dd0dbef887e39d0ed6177f141cce4d68e6041df77570aa3702dfa13"
+checksum = "cfc1cc505827f4c23eedc297975a0fd038268d41293f389dd8ff3b574aefab19"
[[package]]
name = "equivalent"
@@ -1444,6 +1422,12 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
+[[package]]
+name = "fixedbitset"
+version = "0.5.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
+
[[package]]
name = "flate2"
version = "1.1.10"
@@ -1455,6 +1439,12 @@ dependencies = [
"zlib-rs",
]
+[[package]]
+name = "foldhash"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+
[[package]]
name = "foldhash"
version = "0.2.0"
@@ -1651,12 +1641,12 @@ dependencies = [
[[package]]
name = "glifo"
-version = "0.2.0"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed4a1bb24121291d27230c1b1b44e07d6a9b28cefdb32fe1581dfb84e14f940a"
+checksum = "282a26c1e23de04bdab3e34a21b6f877a479b96737792516b9b8b8f69b6661be"
dependencies = [
"bytemuck",
- "foldhash",
+ "foldhash 0.2.0",
"hashbrown 0.17.1",
"log",
"peniko",
@@ -1826,6 +1816,15 @@ dependencies = [
"smallvec",
]
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "foldhash 0.1.5",
+]
+
[[package]]
name = "hashbrown"
version = "0.16.1"
@@ -1834,7 +1833,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"allocator-api2",
"equivalent",
- "foldhash",
+ "foldhash 0.2.0",
]
[[package]]
@@ -1843,7 +1842,7 @@ version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
dependencies = [
- "foldhash",
+ "foldhash 0.2.0",
]
[[package]]
@@ -2500,6 +2499,15 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
+[[package]]
+name = "nom"
+version = "8.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "num"
version = "0.4.3"
@@ -2956,6 +2964,16 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "os_pipe"
+version = "1.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "parking"
version = "2.2.1"
@@ -3004,11 +3022,22 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+[[package]]
+name = "petgraph"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455"
+dependencies = [
+ "fixedbitset",
+ "hashbrown 0.15.5",
+ "indexmap",
+]
+
[[package]]
name = "phf"
-version = "0.13.1"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf"
+checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6"
dependencies = [
"phf_macros",
"phf_shared",
@@ -3017,9 +3046,9 @@ dependencies = [
[[package]]
name = "phf_generator"
-version = "0.13.1"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737"
+checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100"
dependencies = [
"fastrand",
"phf_shared",
@@ -3027,9 +3056,9 @@ dependencies = [
[[package]]
name = "phf_macros"
-version = "0.13.1"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
+checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085"
dependencies = [
"phf_generator",
"phf_shared",
@@ -3040,9 +3069,9 @@ dependencies = [
[[package]]
name = "phf_shared"
-version = "0.13.1"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266"
+checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89"
dependencies = [
"siphasher",
]
@@ -3762,6 +3791,12 @@ version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
+[[package]]
+name = "send_wrapper"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
+
[[package]]
name = "serde"
version = "1.0.229"
@@ -3986,8 +4021,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016"
dependencies = [
"bitflags 2.13.2",
- "calloop 0.13.0",
- "calloop-wayland-source 0.3.0",
+ "calloop",
+ "calloop-wayland-source",
"cursor-icon",
"libc",
"log",
@@ -4004,44 +4039,6 @@ dependencies = [
"xkeysym",
]
-[[package]]
-name = "smithay-client-toolkit"
-version = "0.20.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0"
-dependencies = [
- "bitflags 2.13.2",
- "calloop 0.14.5",
- "calloop-wayland-source 0.4.1",
- "cursor-icon",
- "libc",
- "log",
- "memmap2",
- "rustix 1.1.5",
- "thiserror 2.0.21",
- "wayland-backend",
- "wayland-client",
- "wayland-csd-frame",
- "wayland-cursor",
- "wayland-protocols",
- "wayland-protocols-experimental",
- "wayland-protocols-misc",
- "wayland-protocols-wlr",
- "wayland-scanner",
- "xkeysym",
-]
-
-[[package]]
-name = "smithay-clipboard"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226"
-dependencies = [
- "libc",
- "smithay-client-toolkit 0.20.0",
- "wayland-backend",
-]
-
[[package]]
name = "smol_str"
version = "0.2.2"
@@ -4663,7 +4660,6 @@ version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
- "log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@@ -4689,6 +4685,17 @@ dependencies = [
"once_cell",
]
+[[package]]
+name = "tree_magic_mini"
+version = "3.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6"
+dependencies = [
+ "memchr",
+ "nom",
+ "petgraph",
+]
+
[[package]]
name = "ttf-parser"
version = "0.25.1"
@@ -4763,6 +4770,12 @@ version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
+[[package]]
+name = "unicode-properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "993ad287eb20e8ba755312801cfe1413e0f25d604075863acaddca10b04c1833"
+
[[package]]
name = "unicode-segmentation"
version = "1.13.3"
@@ -4846,9 +4859,9 @@ dependencies = [
[[package]]
name = "vello_common"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2e9aed918117e8152c9eddfd8362d73c465c23f26c44786aa331707b8a64fa2"
+checksum = "bbb2141a2bca6e6d598e471fd4d1d7eed8e020aad6a28187edda07f091a325dd"
dependencies = [
"bytemuck",
"fearless_simd",
@@ -4861,9 +4874,9 @@ dependencies = [
[[package]]
name = "vello_cpu"
-version = "0.1.0"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac7349e1f55f6b801c7c277958df4ea53e7f20f21e8014910ad888b2ecda93ea"
+checksum = "ace506ca414548966fcf3c283be94eb1cad8254de488791ee698bf438b0890a9"
dependencies = [
"bytemuck",
"glifo",
@@ -5038,32 +5051,6 @@ dependencies = [
"wayland-scanner",
]
-[[package]]
-name = "wayland-protocols-experimental"
-version = "20250721.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1"
-dependencies = [
- "bitflags 2.13.2",
- "wayland-backend",
- "wayland-client",
- "wayland-protocols",
- "wayland-scanner",
-]
-
-[[package]]
-name = "wayland-protocols-misc"
-version = "0.3.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8"
-dependencies = [
- "bitflags 2.13.2",
- "wayland-backend",
- "wayland-client",
- "wayland-protocols",
- "wayland-scanner",
-]
-
[[package]]
name = "wayland-protocols-plasma"
version = "0.3.12"
@@ -5641,7 +5628,7 @@ dependencies = [
"bitflags 2.13.2",
"block2 0.5.1",
"bytemuck",
- "calloop 0.13.0",
+ "calloop",
"cfg_aliases",
"concurrent-queue",
"core-foundation 0.9.4",
@@ -5662,7 +5649,7 @@ dependencies = [
"raw-window-handle",
"redox_syscall 0.4.1",
"rustix 0.38.44",
- "smithay-client-toolkit 0.19.2",
+ "smithay-client-toolkit",
"smol_str",
"tracing",
"unicode-segmentation",
@@ -5705,6 +5692,24 @@ version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
+[[package]]
+name = "wl-clipboard-rs"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "959c7ac3b8afde864f7a7448ac16f29b2b83350b7eccbf77fb781c3999aa6848"
+dependencies = [
+ "libc",
+ "log",
+ "os_pipe",
+ "rustix 1.1.5",
+ "thiserror 2.0.21",
+ "tree_magic_mini",
+ "wayland-backend",
+ "wayland-client",
+ "wayland-protocols",
+ "wayland-protocols-wlr",
+]
+
[[package]]
name = "writeable"
version = "0.6.4"
diff --git a/Cargo.toml b/Cargo.toml
index 203dc8c0e5..9b70d178f5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -103,11 +103,12 @@ tiny-skia = { version = "0.12", default-features = false, features = ["std", "si
toml = "1"
# ui
-egui = "0.36"
-eframe = { version = "0.36", default-features = false, features = ["persistence"] }
+# default_fonts: the built-in Hack is the UI's symbol fallback (#2955); 0.37 no longer turns it on.
+egui = { version = "0.37", features = ["default_fonts"] }
+eframe = { version = "0.37", default-features = false, features = ["persistence"] }
# Instant/SystemTime that also work in the browser (std panics on wasm32-unknown-unknown).
web-time = "1"
-egui-wgpu = "0.36"
+egui-wgpu = "0.37"
# the wgpu egui-wgpu uses, for compute (crates/gpu); backends come from the apps' features
wgpu = { version = "30", default-features = false, features = ["std", "wgsl"] }
naga = { version = "30", default-features = false }
@@ -162,12 +163,9 @@ debug = "line-tables-only"
egui-wgpu = { path = "vendor/egui-wgpu" }
# Deliver trackpad pinch and rotation gestures on Wayland (zwp_pointer_gestures_v1), which
-# winit 0.30 never binds and eframe 0.36 still requires winit 0.30.
+# winit 0.30 never binds and eframe 0.37 still requires winit 0.30.
winit = { path = "vendor/winit" }
-# macOS: dropping the accessibility adapter leaves AppKit's key-value observers intact (#7535).
-accesskit_macos = { path = "vendor/accesskit_macos" }
-
# Mutation testing (cargo-mutants, docs/mutation-testing.md): the ci profile with incremental
# builds, since every mutant rebuilds the crates above the one it changes.
[profile.mutants]
diff --git a/apps/solidcraft-web/src/linked.rs b/apps/solidcraft-web/src/linked.rs
index f75d99446f..42aca5372f 100644
--- a/apps/solidcraft-web/src/linked.rs
+++ b/apps/solidcraft-web/src/linked.rs
@@ -48,7 +48,7 @@ impl Download {
}
if solidcraft_ui_egui::documents::any_dirty(app) {
let mut answer = None;
- let closed = ui_kit::Window::new(egui::Id::new("open_link"), "status_warning", solidcraft_ui_egui::i18n::tr("web.open_link"))
+ let closed = ui_kit::Window::new(egui::Id::unique("open_link"), "status_warning", solidcraft_ui_egui::i18n::tr("web.open_link"))
.required()
.show_body(ctx, |ui| {
ui.label(solidcraft_ui_egui::i18n::tr("web.open_link_confirm"));
diff --git a/apps/solidcraft-web/src/main.rs b/apps/solidcraft-web/src/main.rs
index 966e0ac1b5..f55f0d447e 100644
--- a/apps/solidcraft-web/src/main.rs
+++ b/apps/solidcraft-web/src/main.rs
@@ -726,7 +726,7 @@ mod web {
return;
}
let mut act: Option<(&'static str, String)> = None;
- let closed = solidcraft_ui_egui::ui_kit::Window::new(egui::Id::new("sc_browser_files"), "folder", "Files in this browser")
+ let closed = solidcraft_ui_egui::ui_kit::Window::new(egui::Id::unique("sc_browser_files"), "folder", "Files in this browser")
// Room for long names; the kit still caps the window at the browser's width.
.cards(4.0)
.show_body(ctx, |ui| {
@@ -890,7 +890,7 @@ mod web {
fn recovery_prompt(&mut self, ctx: &egui::Context) {
let Some((name, path)) = self.files.recovery.borrow().clone() else { return };
let mut answer = None;
- let _ = solidcraft_ui_egui::ui_kit::Window::new(egui::Id::new("sc_browser_recovery"), "restore", "Recover unsaved work?")
+ let _ = solidcraft_ui_egui::ui_kit::Window::new(egui::Id::unique("sc_browser_recovery"), "restore", "Recover unsaved work?")
.required()
.show_body(ctx, |ui| {
ui.label(format!("“{name}” had unsaved changes when this page last closed."));
diff --git a/apps/solidcraft/src/main.rs b/apps/solidcraft/src/main.rs
index 5ad5b85a06..dfc8851b57 100644
--- a/apps/solidcraft/src/main.rs
+++ b/apps/solidcraft/src/main.rs
@@ -1792,7 +1792,7 @@ mod viewport_tests {
viewport.fullscreen = Some(fullscreen);
viewport.native_pixels_per_point = Some(retina);
super::fullscreen_content_insets(&mut raw, 32.0, zoom);
- let _ = ctx.run_ui(raw, |ui| super::content_ui(app, ui));
+ ctx.run_ui(raw, |ui| super::content_ui(app, ui)).textures_delta.clear();
};
// Enter, leave, and enter again: no stale inset when returning to a normal window.
for fullscreen in [false, true, false, true] {
diff --git a/apps/solidcraft/src/nav_bridge.rs b/apps/solidcraft/src/nav_bridge.rs
index 9e6fd95bfd..d9f7e576fa 100644
--- a/apps/solidcraft/src/nav_bridge.rs
+++ b/apps/solidcraft/src/nav_bridge.rs
@@ -434,7 +434,7 @@ mod tests {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), solidcraft_ui_egui::Services::default());
app.home.open = false;
let ctx = Context::default();
- let _ = ctx.run_ui(egui::RawInput { focused: true, ..Default::default() }, |_| {});
+ ctx.run_ui(egui::RawInput { focused: true, ..Default::default() }, |_| {}).textures_delta.clear();
let mut bridge = NavBridge { shared: Arc::new(Mutex::new(Shared::default())) };
let queue = |bridge: &NavBridge| {
let mut shared = bridge.shared.lock().unwrap();
diff --git a/apps/solidcraft/src/space_mouse.rs b/apps/solidcraft/src/space_mouse.rs
index af7cefd642..df0bfbd74e 100644
--- a/apps/solidcraft/src/space_mouse.rs
+++ b/apps/solidcraft/src/space_mouse.rs
@@ -1914,6 +1914,7 @@ mod tests {
fn wheel() -> egui::Event {
egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Line,
delta: egui::vec2(0.0, -1.0),
modifiers: Default::default(),
diff --git a/assets/icons/ui/source/navigation.rs b/assets/icons/ui/source/navigation.rs
index 82ef37ece5..b1ba3177bf 100644
--- a/assets/icons/ui/source/navigation.rs
+++ b/assets/icons/ui/source/navigation.rs
@@ -55,8 +55,7 @@ pub(crate) fn face_text(painter: &egui::Painter, face: &Facet, ink: Color32, fon
painter.ctx().add_plugin(LabelAtlas);
let text = Shape::Text(egui::epaint::TextShape::new(Pos2::ZERO, galley, ink));
let atlas = painter.ctx().fonts(|f| f.font_image_size());
- let primitives =
- painter.ctx().tessellate(vec![egui::epaint::ClippedShape { clip_rect: Rect::EVERYTHING, shape: text }], painter.ctx().pixels_per_point());
+ let primitives = painter.ctx().tessellate(vec![egui::epaint::ClippedShape::new(Rect::EVERYTHING, text)], painter.ctx().pixels_per_point());
for primitive in primitives {
if let egui::epaint::Primitive::Mesh(mut mesh) = primitive.primitive {
mesh.texture_id = LABEL_PIXELS;
diff --git a/assets/locales/pending/close-tab-name.json b/assets/locales/pending/close-tab-name.json
new file mode 100644
index 0000000000..f03f2711e3
--- /dev/null
+++ b/assets/locales/pending/close-tab-name.json
@@ -0,0 +1,13 @@
+{
+ "en": { "ui.close_tab": "Close tab" },
+ "ar": { "ui.close_tab": "إغلاق علامة التبويب" },
+ "de": { "ui.close_tab": "Tab schließen" },
+ "es": { "ui.close_tab": "Cerrar pestaña" },
+ "fr": { "ui.close_tab": "Fermer l’onglet" },
+ "he": { "ui.close_tab": "סגירת הלשונית" },
+ "ja": { "ui.close_tab": "タブを閉じる" },
+ "ko": { "ui.close_tab": "탭 닫기" },
+ "vi": { "ui.close_tab": "Đóng thẻ" },
+ "zh": { "ui.close_tab": "关闭标签页" },
+ "zh-TW": { "ui.close_tab": "關閉分頁" }
+}
diff --git a/crates/ui-egui/src/agent_chat/markdown_view.rs b/crates/ui-egui/src/agent_chat/markdown_view.rs
index a2174ea831..fe99aa1dce 100644
--- a/crates/ui-egui/src/agent_chat/markdown_view.rs
+++ b/crates/ui-egui/src/agent_chat/markdown_view.rs
@@ -23,7 +23,7 @@ fn blocks(ctx: &egui::Context, slot: usize, src: &str) -> Arc<Vec<Block>> {
let mut h = std::collections::hash_map::DefaultHasher::new();
src.hash(&mut h);
let key = h.finish();
- let id = egui::Id::new(("agent_chat_markdown", slot));
+ let id = egui::Id::unique(("agent_chat_markdown", slot));
if let Some((k, b)) = ctx.data(|d| d.get_temp::<(u64, Arc<Vec<Block>>)>(id))
&& k == key
{
@@ -67,7 +67,7 @@ fn host(url: &str) -> &str {
pub(super) fn selectable(ui: &mut egui::Ui, label: egui::Label) -> egui::Response {
use egui::text_selection::LabelSelectionState;
let (pos, galley, response) = label.selectable(true).layout_in_ui(ui);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), galley.text()));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), galley.text()));
// As `egui::Label` draws a label that is not a button.
let colour = ui.visuals().text_color();
if ui.is_rect_visible(response.rect) {
diff --git a/crates/ui-egui/src/agent_chat/mod.rs b/crates/ui-egui/src/agent_chat/mod.rs
index e447efe087..bf1e252daf 100644
--- a/crates/ui-egui/src/agent_chat/mod.rs
+++ b/crates/ui-egui/src/agent_chat/mod.rs
@@ -377,6 +377,8 @@ pub struct AgentChat {
pub panel_rect: Option<egui::Rect>,
/// A pointer press in the transcript owns keys just like a focused text editor.
keyboard_owned: bool,
+ /// The panel forgets its own width the next time it is drawn, so the preference applies.
+ pub(crate) forget_width: bool,
/// Unreserved sheet space, shared by the actual dock and its drag preview.
pub(crate) dock_space: Option<egui::Rect>,
/// The last message sent, kept to send again after a sign-in (its files too).
@@ -467,6 +469,7 @@ impl AgentChat {
pub(crate) fn swap_document(&mut self, other: &mut Self) {
std::mem::swap(self, other);
std::mem::swap(&mut self.open, &mut other.open);
+ std::mem::swap(&mut self.forget_width, &mut other.forget_width);
std::mem::swap(&mut self.following_document, &mut other.following_document);
std::mem::swap(&mut self.settings, &mut other.settings);
std::mem::swap(&mut self.control_starter, &mut other.control_starter);
@@ -2514,7 +2517,7 @@ pub fn control(app: &mut SolveApp, ctx: &egui::Context, p: &Value) -> Result<Val
}
if let Some(w) = p.get("width").and_then(Value::as_f64).filter(|w| w.is_finite()) {
app.preferences.agent_chat_width = (w as f32).clamp(panel::MIN_WIDTH, panel::MAX_WIDTH);
- panel::forget_width(ctx);
+ app.agent_chat.forget_width = true;
}
if let Some(path) = p.get("attach").and_then(Value::as_str) {
attach_path(app, path)?;
diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rs
index 414aac8baa..d2b771d627 100644
--- a/crates/ui-egui/src/agent_chat/panel.rs
+++ b/crates/ui-egui/src/agent_chat/panel.rs
@@ -44,8 +44,8 @@ pub fn toggle_shortcut(app: &mut SolveApp, ctx: &egui::Context) {
}
}
-fn panel_id(left: bool) -> Id {
- Id::new(if left { "sc_agent_chat_left" } else { "sc_agent_chat_right" })
+fn panel_salt(left: bool) -> &'static str {
+ if left { "sc_agent_chat_left" } else { "sc_agent_chat_right" }
}
/// The largest thumbnail of a message's picture, and its largest preview while hovered (points).
@@ -54,15 +54,6 @@ const THUMB_MAX: (f32, f32) = (150.0, 56.0);
#[cfg(not(target_arch = "wasm32"))]
const PREVIEW_MAX: (f32, f32) = (560.0, 380.0);
-/// Forget the panel's own idea of its width, so the preference applies on the next frame.
-pub fn forget_width(ctx: &egui::Context) {
- ctx.data_mut(|d| {
- for left in [true, false] {
- d.remove::<egui::containers::panel::PanelState>(panel_id(left));
- }
- });
-}
-
/// Show or hide the panel (a folded panel unfolds first).
pub fn toggle(app: &mut SolveApp) {
let c = &mut app.agent_chat;
@@ -123,7 +114,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
app.agent_chat.window_placed = false;
}
// New chat, when the chat has focus (its input, or the pointer over the panel).
- let in_chat = ctx.memory(|m| m.has_focus(Id::new("sc_agent_chat_input")))
+ let in_chat = ctx.memory(|m| m.has_focus(Id::unique("sc_agent_chat_input")))
|| ctx.pointer_hover_pos().is_some_and(|p| app.agent_chat.panel_rect.is_some_and(|r| r.contains(p)));
if app.agent_chat.open && in_chat && ctx.input_mut(|i| i.consume_shortcut(&NEW_CHAT_SHORTCUT)) {
request_new_chat(app);
@@ -153,18 +144,27 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
let left = app.preferences.agent_chat_side == "left";
let host = Container::new(ui.ctx(), Surface::Panel);
- let side = |id: Id| host.edge(id, if left { Edge::Left } else { Edge::Right });
+ let side = |salt: &'static str| host.edge(salt, if left { Edge::Left } else { Edge::Right });
if app.preferences.agent_chat_minimized {
- let r = host
- .show_edge(ui, side(Id::new("sc_agent_chat_strip")).exact_size(STRIP).resizable(false), host.edge_frame(t.panel), |ui| strip(app, ui));
+ let r = host.show_edge(ui, side("sc_agent_chat_strip").exact_size(STRIP).resizable(false), host.edge_frame(t.panel), |ui| strip(app, ui));
app.agent_chat.drop_rect = Some(r.response.rect);
show_drop_hint(app, &ctx);
return;
}
let width = app.preferences.agent_chat_width.clamp(MIN_WIDTH, MAX_WIDTH);
+ if std::mem::take(&mut app.agent_chat.forget_width) {
+ // A panel's state is keyed by the Ui it is shown in and its salt; either side's would
+ // override the preference once the panel moves there.
+ let scope = ui.scope_id();
+ ctx.data_mut(|d| {
+ for side in [true, false] {
+ d.remove::<egui::containers::panel::PanelState>(scope.with(panel_salt(side)));
+ }
+ });
+ }
let r = host.show_edge(
ui,
- side(panel_id(left)).default_size(width).size_range(MIN_WIDTH..=MAX_WIDTH).resizable(true),
+ side(panel_salt(left)).default_size(width).size_range(MIN_WIDTH..=MAX_WIDTH).resizable(true),
host.edge_frame(t.dialog_body),
|ui| ui_kit::scope(ui, |ui| body(app, ui, left)),
);
@@ -254,7 +254,7 @@ fn floating(app: &mut SolveApp, ui: &mut egui::Ui) {
let anchor = if left { bounds.left_top() } else { bounds.right_top() };
let frame = ui_kit::Panel::feature_frame(&ctx, app.ui.layout, side);
let inner = (vec2(width, height) - frame.total_margin().sum()).max(egui::Vec2::ZERO);
- let panel = ui_kit::Panel::new(tr("ui.assistant"), Id::new("sc_agent_chat_floating"), anchor, available, side, frame).width(width);
+ let panel = ui_kit::Panel::new(tr("ui.assistant"), Id::unique("sc_agent_chat_floating"), anchor, available, side, frame).width(width);
if let Some(card) = panel.fixed_window(&ctx, inner).show(&ctx, |ui| {
ui.set_min_size(inner);
ui.set_max_size(inner);
@@ -267,7 +267,7 @@ fn floating(app: &mut SolveApp, ui: &mut egui::Ui) {
} else {
Rect::from_x_y_ranges(rect.left()..=rect.left() + t.space_4, rect.y_range())
};
- let response = ui.interact(rail, Id::new("sc_agent_chat_resize"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
+ let response = ui.interact(rail, Id::unique("sc_agent_chat_resize"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
crate::scenario::publish_handle("agent_chat:resize", rail.center());
if response.dragged() {
let delta = ui.input(|i| i.pointer.delta().x) * if left { 1.0 } else { -1.0 };
@@ -459,7 +459,7 @@ fn gallery_window(app: &mut SolveApp, ctx: &egui::Context) {
let mut step: isize = if left { -1 } else { isize::from(right) };
let t = Tokens::get();
let max = ctx.content_rect().size() * vec2(0.8, 0.7);
- let modal = ui_kit::Container::new(ctx, ui_kit::Surface::Window).modal(Id::new("sc_agent_chat_gallery")).show(ctx, |ui| {
+ let modal = ui_kit::Container::new(ctx, ui_kit::Surface::Window).modal(Id::unique("sc_agent_chat_gallery")).show(ctx, |ui| {
ui.set_max_width(max.x);
ui.horizontal(|ui| {
let prev = ui_kit::button(ui, tr("ui.agent_chat_previous_picture"), ui_kit::Button::Enabled(count > 1));
@@ -517,7 +517,7 @@ fn show_drop_hint(app: &SolveApp, ctx: &egui::Context) {
#[cfg(not(target_arch = "wasm32"))]
fn drop_hint(ctx: &egui::Context, area: Rect) {
let t = Tokens::get();
- let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::new("sc_agent_chat_drop_hint")));
+ let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::unique("sc_agent_chat_drop_hint")));
let zone = area.shrink(6.0);
painter.rect(zone, t.radius_xl, t.accent.gamma_multiply(0.16), Stroke::new(2.0, t.accent), egui::StrokeKind::Inside);
let font = egui::FontId::proportional(Tokens::get().font_heading);
@@ -692,7 +692,7 @@ fn strip(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
let r = ui.max_rect();
let button = Rect::from_center_size(pos2(r.center().x, r.top() + 22.0), vec2(26.0, 26.0));
- let resp = ui.interact(button, Id::new("sc_agent_chat_unfold"), Sense::click());
+ let resp = ui.interact(button, Id::unique("sc_agent_chat_unfold"), Sense::click());
crate::scenario::publish_handle("agent_chat:unfold", button.center());
if resp.hovered() {
ui.painter().rect_filled(button, t.radius_sm, t.hover);
@@ -750,7 +750,7 @@ fn header(app: &mut SolveApp, ui: &mut egui::Ui, left: bool) {
}
// Drag the header across the window to dock on the other side.
if !popped {
- let drag = ui.interact(title, Id::new("sc_agent_chat_grip"), Sense::drag());
+ let drag = ui.interact(title, Id::unique("sc_agent_chat_grip"), Sense::drag());
crate::scenario::publish_handle("agent_chat:grip", title.center());
dock_drag(app, ui, &drag, left);
}
@@ -805,7 +805,7 @@ fn dock_drag(app: &mut SolveApp, ui: &egui::Ui, drag: &egui::Response, left: boo
};
crate::scenario::publish_rect("agent_chat:dock_hint", zone);
let t = Tokens::get();
- let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::new("sc_agent_chat_dock_hint")));
+ let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::unique("sc_agent_chat_dock_hint")));
painter.rect(zone, t.radius_xl, t.accent.gamma_multiply(0.18), Stroke::new(2.0, t.accent), egui::StrokeKind::Inside);
painter.text(
zone.center(),
@@ -877,7 +877,7 @@ fn desktop_body(app: &mut SolveApp, ui: &mut egui::Ui) {
let busy = state == State::Busy;
// Enter sends (queues while the agent works); Ctrl/Cmd+Enter sends now; Esc stops. They are
// read before the field sees them so no newline is typed.
- let focused = ui.memory(|m| m.has_focus(Id::new("sc_agent_chat_input")));
+ let focused = ui.memory(|m| m.has_focus(Id::unique("sc_agent_chat_input")));
let (steer, esc) = if focused {
ui.input_mut(|i| (i.consume_key(egui::Modifiers::COMMAND, egui::Key::Enter), busy && i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)))
} else {
@@ -886,7 +886,7 @@ fn desktop_body(app: &mut SolveApp, ui: &mut egui::Ui) {
let (mut send_clicked, mut stop_clicked, mut enter, mut pick_clicked) = (false, false, false, false);
let mut remove_picked_at = None;
let frame = Container::new(ui.ctx(), Surface::Viewport).edge_frame(egui::Color32::TRANSPARENT);
- let composer = Container::new(ui.ctx(), Surface::Viewport).edge(Id::new("sc_agent_chat_composer"), Edge::Bottom);
+ let composer = Container::new(ui.ctx(), Surface::Viewport).edge("sc_agent_chat_composer", Edge::Bottom);
composer.resizable(false).show_separator_line(false).frame(frame).show(ui, |ui| {
let footer = ui_kit::assistant_composer_footer(ui, |ui| {
let boxed = ui_kit::assistant_composer(ui, focused, |ui| {
@@ -912,7 +912,7 @@ fn desktop_body(app: &mut SolveApp, ui: &mut egui::Ui) {
.show(ui, |ui| {
ui_kit::assistant_input(
ui,
- Id::new("sc_agent_chat_input"),
+ Id::unique("sc_agent_chat_input"),
&mut app.agent_chat.input,
tr(if busy { "ui.agent_chat_placeholder_busy" } else { "ui.agent_chat_placeholder" }),
)
@@ -1395,7 +1395,7 @@ fn config_select(app: &mut SolveApp, ui: &mut egui::Ui, option: &acp::ConfigOpti
}
response
};
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ComboBox, enabled, format!("{name}: {selected}")));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::ComboBox, enabled, format!("{name}: {selected}")));
response.backing_on_hover_text(tip);
match picked {
Some(ui_kit::Picked::Listed(value)) => super::set_config_option(app, &option.id, &value),
@@ -1439,11 +1439,13 @@ mod config_ui_tests {
fn draw_switcher(app: &mut SolveApp, ctx: &egui::Context, width: f32) {
crate::scenario::clear_handles();
let screen = Rect::from_min_size(pos2(0.0, 0.0), vec2(width, 700.0));
- let _ = ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| {
+ ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| {
ui.allocate_ui(vec2(width - 16.0, 600.0), |ui| {
ui_kit::scope(ui, |ui| switcher(app, ui));
});
- });
+ })
+ .textures_delta
+ .clear();
}
#[test]
@@ -1744,7 +1746,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
});
if copyable {
let drawn = egui::Rect::from_x_y_ranges(before.x_range(), before.min.y..=ui.cursor().min.y);
- let resp = ui.interact(drawn, Id::new(("agent_chat_msg", n)), Sense::hover());
+ let resp = ui.interact(drawn, Id::unique(("agent_chat_msg", n)), Sense::hover());
copy_message_menu(ui, &resp, n, text);
}
}
@@ -1757,7 +1759,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
if !text.is_empty() {
copy_message_button(ui, n, text);
let drawn = egui::Rect::from_x_y_ranges(before.x_range(), before.min.y..=ui.cursor().min.y);
- let resp = ui.interact(drawn, Id::new(("agent_chat_msg", n)), Sense::hover());
+ let resp = ui.interact(drawn, Id::unique(("agent_chat_msg", n)), Sense::hover());
copy_message_menu(ui, &resp, n, text);
}
}
@@ -1927,7 +1929,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
});
match (&editing, edit_buf.as_mut()) {
(Some((i, _)), Some(buf)) if *i == n => {
- let te = ui_kit::message_field(ui, Id::new(("sc_agent_pending_input", n)), buf, "");
+ let te = ui_kit::message_field(ui, Id::unique(("sc_agent_pending_input", n)), buf, "");
crate::scenario::publish_rect("agent_chat:pending_input", te.rect);
ui.horizontal(|ui| {
if ui_kit::button(ui, tr("ui.agent_chat_save"), ui_kit::Button::Normal).clicked() {
diff --git a/crates/ui-egui/src/agent_chat/settings.rs b/crates/ui-egui/src/agent_chat/settings.rs
index 6538beb432..f87ad489a3 100644
--- a/crates/ui-egui/src/agent_chat/settings.rs
+++ b/crates/ui-egui/src/agent_chat/settings.rs
@@ -446,7 +446,7 @@ fn timeout_field(ui: &mut egui::Ui, secs: &mut u64, handle: &str) -> bool {
/// The free-text reasoning effort field with its hover hint; true when the text changed.
fn effort_field(ui: &mut egui::Ui, effort: &mut String, handle: &str) -> bool {
- let response = ui_kit::cell_editor(ui, ui.id().with("ai_reasoning_effort"), effort, tr("ui.ai_reasoning_effort_field_hint"), false)
+ let response = ui_kit::cell_editor(ui, ui.scope_id().with("ai_reasoning_effort"), effort, tr("ui.ai_reasoning_effort_field_hint"), false)
.backing_on_hover_text(tr("ui.ai_reasoning_effort_hint"));
crate::scenario::publish_target(handle, response.rect);
response.changed()
@@ -529,7 +529,7 @@ fn connecting_section(app: &mut SolveApp, ui: &mut egui::Ui) {
/// Custom instructions (#8220): text every new chat's system note carries.
fn instructions_section(app: &mut SolveApp, ui: &mut egui::Ui) {
ui_kit::settings_section(ui, "instructions", tr("ai.prefs.instructions"), |ui| {
- let id = egui::Id::new("prefs_agent_instructions");
+ let id = egui::Id::unique("prefs_agent_instructions");
let text = &mut app.preferences.agent_instructions;
let response = ui_kit::text_area(ui, tr("ai.prefs.instructions"), id, text, 6, acp::INSTRUCTIONS_LIMIT);
if response.has_focus() {
@@ -1038,7 +1038,7 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
return;
}
if let Some(url) = app.agent_chat.settings.add.as_ref().and_then(|s| s.confirm_insecure_http.clone()) {
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_ai_http_consent"), "status_warning", tr("ai.http.allow"))
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_ai_http_consent"), "status_warning", tr("ai.http.allow"))
.tone(ui_kit::Tone::Warning)
.actions(tr("ai.http.confirm"), tr("ui.cancel"), None)
.selected(ui_kit::Action::Cancel)
@@ -1074,7 +1074,7 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
// Editing keeps the agent's kind: the kind switch is for adding only.
let editing = app.agent_chat.settings.add.as_ref().is_some_and(|s| s.editing.is_some());
let (title, ok) = if editing { ("ui.ai_edit_agent_title", "ui.ai_save") } else { ("ui.ai_add_agent_title", "ui.ai_add") };
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_ai_add"), "settings", tr(title))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_ai_add"), "settings", tr(title))
.cards(2.0)
.fields()
.actions(tr(ok), "Cancel", None)
@@ -1176,7 +1176,7 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
ui_kit::text_field(ui, &mut s.name, "");
});
ui_kit::row(ui, tr("ui.ai_base_url"), |ui| {
- let r = ui_kit::cell_editor(ui, egui::Id::new("sc_ai_add_url"), &mut s.base_url, tr("ui.ai_url_hint"), false);
+ let r = ui_kit::cell_editor(ui, egui::Id::unique("sc_ai_add_url"), &mut s.base_url, tr("ui.ai_url_hint"), false);
s.list_again |= r.lost_focus();
if r.changed() {
s.insecure_http_url = None;
@@ -1220,7 +1220,7 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
ui_kit::row(ui, tr("ui.ai_key"), |ui| {
ui.add_enabled_ui(has_keychain, |ui| {
let hint = tr(if s.saved_key { "ui.ai_key_keep_hint" } else { "ui.ai_key_hint" });
- let r = ui_kit::password_field(ui, egui::Id::new("sc_ai_add_key"), &mut s.key, hint);
+ let r = ui_kit::password_field(ui, egui::Id::unique("sc_ai_add_key"), &mut s.key, hint);
crate::scenario::publish_target("ai_add:key", r.rect);
s.list_again |= r.lost_focus();
});
@@ -2431,7 +2431,7 @@ mod card_tests {
h.frames(3);
h.step(&json!({"text":" vendor/own "})).unwrap();
h.frames(3);
- assert!(h.ctx.memory(|m| m.has_focus(egui::Id::new("sc_ai_model:api-1").with("search"))), "the box keeps the focus over Preferences");
+ assert!(h.ctx.memory(|m| m.has_focus(egui::Id::unique("sc_ai_model:api-1").with("search"))), "the box keeps the focus over Preferences");
h.step(&json!({"click":{"handle":"prefs:ai_model:api-1:custom"}})).unwrap();
h.frames(3);
assert_eq!(model(&h).as_deref(), Some("vendor/own"));
diff --git a/crates/ui-egui/src/agent_chat/tests.rs b/crates/ui-egui/src/agent_chat/tests.rs
index 659a9ec965..e67984df38 100644
--- a/crates/ui-egui/src/agent_chat/tests.rs
+++ b/crates/ui-egui/src/agent_chat/tests.rs
@@ -1687,7 +1687,7 @@ fn custom_instructions_reach_the_system_note_of_each_new_session() {
h.frames(4);
assert!(crate::scenario::rect_of("prefs:agent_instructions").is_some(), "the field is on the AI page");
h.app.preferences.ai_features = true;
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("prefs_agent_instructions")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("prefs_agent_instructions")));
h.frames(2);
h.step(&json!({"text": "M3"})).unwrap();
h.frames(2);
diff --git a/crates/ui-egui/src/agent_cursor.rs b/crates/ui-egui/src/agent_cursor.rs
index f26fc67a76..54ab8d8c8c 100644
--- a/crates/ui-egui/src/agent_cursor.rs
+++ b/crates/ui-egui/src/agent_cursor.rs
@@ -485,7 +485,7 @@ pub fn paint(app: &SolveApp, ctx: &egui::Context) {
return;
}
let Some(p) = app.agent.pos else { return };
- let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Debug, egui::Id::new("sc_agent_cursor")));
+ let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Debug, egui::Id::unique("sc_agent_cursor")));
for (at, t0) in &app.agent.ripples {
let k = ((app.now - t0) / 0.6).clamp(0.0, 1.0) as f32;
painter.circle_stroke(*at, 6.0 + 22.0 * k, Stroke::new(3.0 * (1.0 - k) + 0.5, agent().gamma_multiply(1.0 - k)));
@@ -495,7 +495,7 @@ pub fn paint(app: &SolveApp, ctx: &egui::Context) {
use crate::ui_kit::{Container, Surface};
let t = crate::theme::Tokens::get();
Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_agent_command"))
+ .area(egui::Id::unique("sc_agent_command"))
.order(egui::Order::Debug)
.fixed_pos(p + vec2(15.0, 42.0))
.constrain(true)
diff --git a/crates/ui-egui/src/body_gizmo.rs b/crates/ui-egui/src/body_gizmo.rs
index 128c415ab4..2f5a6139b7 100644
--- a/crates/ui-egui/src/body_gizmo.rs
+++ b/crates/ui-egui/src/body_gizmo.rs
@@ -351,7 +351,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect, shown: cra
let view = Tokens::view();
let to_screen = |p: [f64; 2]| image.min + vec2(p[0] as f32 * step, p[1] as f32 * step);
let painter = ui.painter_at(outer);
- let shared: Shared = ui.ctx().data_mut(|d| d.get_temp_mut_or_default::<Shared>(egui::Id::new("body_gizmo_cache")).clone());
+ let shared: Shared = ui.ctx().data_mut(|d| d.get_temp_mut_or_default::<Shared>(egui::Id::unique("body_gizmo_cache")).clone());
let (hovered, handles) = shared
.lock()
.ok()
diff --git a/crates/ui-egui/src/bom_panel.rs b/crates/ui-egui/src/bom_panel.rs
index 108dba9e54..d61fcfd101 100644
--- a/crates/ui-egui/src/bom_panel.rs
+++ b/crates/ui-egui/src/bom_panel.rs
@@ -131,7 +131,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let rows: Vec<Value> = bom["rows"].as_array().cloned().unwrap_or_default();
let (mut export, mut apply_row) = (None, None);
let closed =
- crate::ui_kit::Window::new(egui::Id::new("sc_bom"), "bom", crate::i18n::tr_label("Bill of Materials")).cards(3.0).show_body(ctx, |ui| {
+ crate::ui_kit::Window::new(egui::Id::unique("sc_bom"), "bom", crate::i18n::tr_label("Bill of Materials")).cards(3.0).show_body(ctx, |ui| {
ui.horizontal_wrapped(|ui| {
let was = (d.top, d.by_definition, d.group_children);
let mut levels = usize::from(d.top);
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs
index 1f0c070895..0cab46dc92 100644
--- a/crates/ui-egui/src/browser.rs
+++ b/crates/ui-egui/src/browser.rs
@@ -758,16 +758,16 @@ fn row_rect(ui: &egui::Ui) -> Rect {
pub(crate) use crate::ui_kit::{Mark, Row};
fn compact_tree(ui: &egui::Ui) -> bool {
- ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::new("sc_compact_tree"))).unwrap_or(false)
+ ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::unique("sc_compact_tree"))).unwrap_or(false)
}
/// Where tree rows put their eye this frame (Preferences › Interface, #8718).
pub(crate) fn publish_row_prefs(app: &SolveApp, ctx: &egui::Context) {
- ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_tree_eye_left"), app.preferences.browser_eye_left));
+ ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_tree_eye_left"), app.preferences.browser_eye_left));
}
fn eye_left(ui: &egui::Ui) -> bool {
- ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::new("sc_tree_eye_left"))).unwrap_or(false)
+ ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::unique("sc_tree_eye_left"))).unwrap_or(false)
}
pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row<'_>) -> RowResp {
@@ -1134,7 +1134,7 @@ pub(crate) fn browser_width(remembered: f32) -> f32 {
pub(crate) fn resize_column(app: &mut SolveApp, ui: &egui::Ui, rect: Rect, width: f32, handle: &'static str) {
let rail = Rect::from_x_y_ranges(rect.right() - BROWSER_RAIL..=rect.right(), rect.y_range());
let response =
- ui.interact(rail, egui::Id::new(("sc_shared_column_rail", handle)), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
+ ui.interact(rail, egui::Id::unique(("sc_shared_column_rail", handle)), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
if response.dragged() {
let delta = ui.input(|input| input.pointer.delta().x);
if delta.is_finite() {
@@ -1173,7 +1173,7 @@ pub(crate) fn reveals(app: &SolveApp) -> bool {
/// text edit started while it showed keeps it shown. A drag started elsewhere (orbiting the view)
/// passes over it without showing it.
fn reveal_opacity(app: &SolveApp, ctx: &egui::Context, previous: Option<Rect>, edge: Rect) -> f32 {
- let card = egui::Id::new("sc_browser_card");
+ let card = egui::Id::unique("sc_browser_card");
let memory = card.with("reveal");
let was = ctx.data(|d| d.get_temp::<bool>(memory)).unwrap_or(false);
let over = ctx.input(|i| i.pointer.hover_pos()).is_some_and(|p| {
@@ -1245,7 +1245,7 @@ pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {
let frame = container.frame(ui.ctx(), fill, crate::frame::Side::Left).inner_margin(CARD_INSET as i8);
let inner_width = (bounds.width() - frame.total_margin().sum().x).max(0.0);
let inner_height = (bounds.height() - frame.total_margin().sum().y).max(0.0);
- let card = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("sc_browser_card")).fixed_pos(bounds.min).show(ui.ctx(), |ui| {
+ let card = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::unique("sc_browser_card")).fixed_pos(bounds.min).show(ui.ctx(), |ui| {
let limits = Rect::from_min_max(available.min, pos2(available.right(), bounds.bottom()));
let response = ui
.scope(|ui| {
@@ -1328,9 +1328,9 @@ fn render_card(app: &mut SolveApp, ui: &mut egui::Ui) {
let _ = app.run("view.render_browser", json!({"open":false}));
}
}
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_compact_tree"), true));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_compact_tree"), true));
browser_contents(app, ui, true);
- ui.ctx().data_mut(|d| d.remove::<bool>(egui::Id::new("sc_compact_tree")));
+ ui.ctx().data_mut(|d| d.remove::<bool>(egui::Id::unique("sc_compact_tree")));
},
);
if (lens == 1) != app.render_workspace.view.by_look {
@@ -1367,8 +1367,9 @@ fn browser_collapsed_rail(app: &mut SolveApp, ui: &mut egui::Ui) {
let height = title_top + t.space_24 * 4.0 + t.space_8;
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), height), Sense::hover());
// Include the card margin in the hit target; keep the tint inside that margin.
- let response =
- ui.interact(rect.expand(CARD_INSET + 1.0), ui.id().with("browser_header"), Sense::click()).on_hover_cursor(egui::CursorIcon::PointingHand);
+ let response = ui
+ .interact(rect.expand(CARD_INSET + 1.0), ui.scope_id().with("browser_header"), Sense::click())
+ .on_hover_cursor(egui::CursorIcon::PointingHand);
if response.hovered() || response.has_focus() {
crate::ui_kit::panel_header_hover(ui.painter(), rect);
}
@@ -1376,7 +1377,7 @@ fn browser_collapsed_rail(app: &mut SolveApp, ui: &mut egui::Ui) {
crate::ui_kit::disclosure(ui.painter(), disclosure.center(), false, t.text_dim);
crate::scenario::publish_handle("left-browser-toggle", disclosure.center());
crate::scenario::publish_target("browser:header", disclosure);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::tr("ui.browser_title")));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::tr("ui.browser_title")));
if response.backing_on_hover_text(crate::i18n::tr("ui.browser_expand")).clicked() {
app.preferences.timeline_left_browser_collapsed = false;
}
@@ -1436,7 +1437,7 @@ fn browser_header(app: &mut SolveApp, ui: &mut egui::Ui, collapsible: bool) {
let collapsible = collapsible && !reveals(app);
let t = Tokens::get();
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), HEADER_H), Sense::hover());
- let response = ui.interact(rect, ui.id().with("browser_header"), if collapsible { Sense::click() } else { Sense::hover() });
+ let response = ui.interact(rect, ui.scope_id().with("browser_header"), if collapsible { Sense::click() } else { Sense::hover() });
crate::scenario::publish_target("browser:header", rect);
let vertical = app.ui.show_timeline && app.preferences.timeline_left;
let stacked = crate::timeline_left::stacked(app);
@@ -1449,7 +1450,7 @@ fn browser_header(app: &mut SolveApp, ui: &mut egui::Ui, collapsible: bool) {
crate::ui_kit::panel_header_hover(ui.painter(), rect);
}
let title = crate::i18n::tr("ui.browser_title").to_string();
- let kind = if collapsible { egui::WidgetType::Button } else { egui::WidgetType::Label };
+ let kind = if collapsible { egui::Role::Button } else { egui::Role::Label };
response.widget_info(|| egui::WidgetInfo::labeled(kind, true, &title));
let galley = ui.painter().layout_no_wrap(title, crate::fonts::semibold(t.font_heading), t.text);
ui.painter().galley(pos2(rect.left() + t.space_6, rect.center().y - galley.size().y / 2.0), galley, t.text);
@@ -1750,7 +1751,7 @@ fn component_rows_inner(
mark: if id == 0 && acts.lit.any() { Mark::Branch } else { Mark::None },
..Default::default()
};
- let r = draw_row(ui, ui.id().with(("comp", id)), &row);
+ let r = draw_row(ui, ui.scope_id().with(("comp", id)), &row);
if r.fold {
toggle(app, key, true);
}
@@ -1897,7 +1898,7 @@ fn occurrence_rows_inner(
};
let r = draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row {
depth,
fold: Some(open),
@@ -2044,7 +2045,8 @@ fn occurrence_rows_inner(
fn doc_settings(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize) {
let key = "docsettings";
let open = is_open(app, key, false);
- let r = draw_row(ui, ui.id().with(key), &Row { depth, fold: Some(open), icon: "settings", label: "Document Settings", ..Default::default() });
+ let r =
+ draw_row(ui, ui.scope_id().with(key), &Row { depth, fold: Some(open), icon: "settings", label: "Document Settings", ..Default::default() });
if r.fold || r.clicked {
toggle(app, key, false);
}
@@ -2052,7 +2054,7 @@ fn doc_settings(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize) {
return;
}
let units = format!("Units: {}", app.session.doc.units);
- let r = draw_row(ui, ui.id().with("units"), &Row { depth: depth + 1, icon: "settings", label: &units, ..Default::default() });
+ let r = draw_row(ui, ui.scope_id().with("units"), &Row { depth: depth + 1, icon: "settings", label: &units, ..Default::default() });
if let Some(p) = r.secondary {
crate::context_menu::open_for(app, p, Target::Units);
} else if r.clicked
@@ -2066,7 +2068,7 @@ fn doc_settings(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize) {
crate::prefs::unit_scale(&app.session.doc.units).1,
format_args!("{:.*}", usize::from(app.preferences.angle_decimals), 0.0)
);
- if draw_row(ui, ui.id().with("precision"), &Row { depth: depth + 1, icon: "settings", label: &prec, ..Default::default() }).clicked {
+ if draw_row(ui, ui.scope_id().with("precision"), &Row { depth: depth + 1, icon: "settings", label: &prec, ..Default::default() }).clicked {
if app.prefs_window.open {
crate::prefs::close(app, true);
} else {
@@ -2074,15 +2076,19 @@ fn doc_settings(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize) {
}
}
let params = format!("Parameters ({})", app.session.doc.params.len());
- if draw_row(ui, ui.id().with("params"), &Row { depth: depth + 1, icon: "params", label: &params, ..Default::default() }).clicked {
+ if draw_row(ui, ui.scope_id().with("params"), &Row { depth: depth + 1, icon: "params", label: &params, ..Default::default() }).clicked {
if app.params.is_some() {
app.params = None;
} else {
app.start("parameters.change");
}
}
- if draw_row(ui, ui.id().with("design_properties"), &Row { depth: depth + 1, icon: "settings", label: "Design Properties", ..Default::default() })
- .clicked
+ if draw_row(
+ ui,
+ ui.scope_id().with("design_properties"),
+ &Row { depth: depth + 1, icon: "settings", label: "Design Properties", ..Default::default() },
+ )
+ .clicked
{
if app.design_properties.is_some() {
app.design_properties = None;
@@ -2113,7 +2119,7 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A
let items = origin_things();
let r = draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row {
depth,
fold: Some(open),
@@ -2149,7 +2155,7 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A
let (selected, mark) = lit_row(lit(&thing));
let r = draw_row(
ui,
- ui.id().with(("o", k)),
+ ui.scope_id().with(("o", k)),
// Faded when hidden itself or with the whole Origin. A renamed plane's label is already
// in the interface's language (`name`).
&Row {
@@ -2197,7 +2203,7 @@ pub const STANDARD_VIEWS: [(&str, &str); 4] = [("Top", "top"), ("Front", "front"
fn named_view_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut Actions) {
let key = "namedviews";
let open = is_open(app, key, false);
- let r = draw_row(ui, ui.id().with(key), &Row { depth, fold: Some(open), icon: "folder", label: "Named Views", ..Default::default() });
+ let r = draw_row(ui, ui.scope_id().with(key), &Row { depth, fold: Some(open), icon: "folder", label: "Named Views", ..Default::default() });
if r.fold || r.clicked {
toggle(app, key, false);
}
@@ -2208,7 +2214,7 @@ fn named_view_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &m
return;
}
for (label, view) in STANDARD_VIEWS {
- let r = draw_row(ui, ui.id().with(("stdview", view)), &Row { depth: depth + 1, icon: "home", label, ..Default::default() });
+ let r = draw_row(ui, ui.scope_id().with(("stdview", view)), &Row { depth: depth + 1, icon: "home", label, ..Default::default() });
if r.double {
app.animate_view(view);
}
@@ -2220,7 +2226,7 @@ fn named_view_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &m
for name in names {
let r = draw_row(
ui,
- ui.id().with(("view", &name)),
+ ui.scope_id().with(("view", &name)),
&Row { depth: depth + 1, icon: "perspective", label: &name, name: true, ..Default::default() },
);
if r.double {
@@ -2285,7 +2291,7 @@ fn analysis_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut
let open = is_open(app, key, start_open);
let r = draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row { depth, fold: Some(open), eye: Some(folder_shown), icon: "folder", label: "Analysis", dim: !folder_shown, ..Default::default() },
);
if r.fold || r.clicked {
@@ -2300,7 +2306,7 @@ fn analysis_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut
}
let r = draw_row(
ui,
- ui.id().with("section_analysis"),
+ ui.scope_id().with("section_analysis"),
&Row {
depth: depth + 1,
eye: Some(section_shown),
@@ -2378,7 +2384,7 @@ fn canvas_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A
let shown = !app.session.folder_hidden(CANVASES);
let r = draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row { depth, fold: Some(open), eye: Some(shown), icon: "folder", label: "Canvases", dim: !shown, ..Default::default() },
);
if r.fold || r.clicked {
@@ -2394,7 +2400,7 @@ fn canvas_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A
let selected = app.tree.picked_canvases.contains(&id);
let r = draw_row(
ui,
- ui.id().with(("canvas", id)),
+ ui.scope_id().with(("canvas", id)),
&Row {
depth: depth + 1,
eye: Some(visible),
@@ -2864,7 +2870,7 @@ fn folder_rows_at(
} else {
draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row {
depth,
fold: Some(open),
@@ -2975,7 +2981,7 @@ fn folder_level(
let count = if render && !gopen { crate::i18n::format("render.tree_more", &[("count", &group.count.to_string())]) } else { String::new() };
let r = draw_row(
ui,
- ui.id().with(gkey),
+ ui.scope_id().with(gkey),
&Row {
depth,
fold: Some(gopen),
@@ -3076,7 +3082,7 @@ fn inline_rename(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect, label_left: f
let Some(mut rename) = app.menu.rename.take() else { return };
let edit_rect = Rect::from_min_max(pos2(label_left, row.top() + 1.0), pos2(row.right() - 3.0, row.bottom() - 1.0));
ui.painter().rect_filled(edit_rect, 3.0, Tokens::get().field);
- let id = ui.id().with(("browser_rename", &e.row_key));
+ let id = ui.scope_id().with(("browser_rename", &e.row_key));
let response = crate::ui_kit::inline_name(ui, edit_rect, id, &mut rename.text);
crate::scenario::publish_handle(&format!("rename:{}", e.key), edit_rect.center());
let was_focused = rename.focused;
@@ -3148,7 +3154,7 @@ fn entry_row(
let state_tip = sketch_state.map(crate::sketch_state::SketchState::text);
let r = draw_row(
ui,
- ui.id().with(("item", &e.row_key)),
+ ui.scope_id().with(("item", &e.row_key)),
&Row {
depth,
fold: pattern_key.map(|_| patterns_open),
@@ -3543,7 +3549,7 @@ pub(crate) fn occurrence_triad(app: &mut SolveApp, ui: &mut egui::Ui, painter: &
let before = (m.translate, m.angles);
let Some(t) = occurrence_triad_model(app) else { return };
let step = crate::canvas::snap_step(app.cam.half_height());
- let Some(g) = gizmo::show(ui, painter, proj, egui::Id::new("sc_occ_triad"), &t, step) else { return };
+ let Some(g) = gizmo::show(ui, painter, proj, egui::Id::unique("sc_occ_triad"), &t, step) else { return };
if g.started || m.drag0.is_none() {
m.drag0 = Some((m.translate, m.angles));
}
diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rs
index aeda44b73f..3cce4d65f4 100644
--- a/crates/ui-egui/src/browser/features.rs
+++ b/crates/ui-egui/src/browser/features.rs
@@ -114,8 +114,11 @@ pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, component: u64, path:
.collect()
};
let (status, tip) = crate::timeline::worst_status(app, &ids);
- let r =
- draw_row(ui, ui.id().with(&key), &Row { depth, fold: Some(open), icon: "folder", label, status, tip: tip.as_deref(), ..Default::default() });
+ let r = draw_row(
+ ui,
+ ui.scope_id().with(&key),
+ &Row { depth, fold: Some(open), icon: "folder", label, status, tip: tip.as_deref(), ..Default::default() },
+ );
if r.fold || r.clicked {
toggle(app, &key, compact);
}
@@ -159,7 +162,7 @@ pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, component: u64, path:
let mut slots: Vec<(f32, usize)> = Vec::new();
// Where dragged rows can be dropped, as in the History at the left: these slots and one
// before the marker, each with the folder the rows join (#9565).
- let drag_id = ui.id().with(("sc_browser_history_drag", &scope));
+ let drag_id = ui.scope_id().with(("sc_browser_history_drag", &scope));
let mut dragged = app.tree.content.current_mut().feature_drags.get(&drag_id).cloned();
let mut drops: Vec<DropSlot> = Vec::new();
let mut marker_resp = None;
@@ -289,7 +292,7 @@ fn feature_row(
let cut = app.cut.features.contains(&id);
let r = draw_row(
ui,
- ui.id().with(("browser_feature", id)),
+ ui.scope_id().with(("browser_feature", id)),
&Row {
depth,
fold,
diff --git a/crates/ui-egui/src/browser/point_clouds.rs b/crates/ui-egui/src/browser/point_clouds.rs
index 19e80a2116..8fe9012916 100644
--- a/crates/ui-egui/src/browser/point_clouds.rs
+++ b/crates/ui-egui/src/browser/point_clouds.rs
@@ -214,7 +214,7 @@ pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &m
let shown = !app.session.folder_hidden(POINT_CLOUDS_FOLDER);
let r = draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row { depth, fold: Some(open), eye: Some(shown), icon: "folder", label: "Point Clouds", dim: !shown, ..Default::default() },
);
if r.fold || r.clicked {
@@ -229,7 +229,7 @@ pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &m
for (id, name, visible) in clouds {
let r = draw_row(
ui,
- ui.id().with(("point_cloud", id)),
+ ui.scope_id().with(("point_cloud", id)),
&Row { depth: depth + 1, eye: Some(visible), icon: "point", label: &name, name: true, dim: !visible || !shown, ..Default::default() },
);
if r.eye {
@@ -289,7 +289,7 @@ pub(crate) fn panel(app: &mut SolveApp, ctx: &egui::Context) {
};
let changes_of = c.colored_property().filter(|n| c.complex.integer(n)).map(str::to_string);
let at = panel_pos(app);
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_point_cloud_panel"), "point", &title)
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_point_cloud_panel"), "point", &title)
.placed(egui::Align2::LEFT_TOP, at)
.fields()
.actions("", crate::i18n::tr("ui.close"), None)
diff --git a/crates/ui-egui/src/browser/range_track.rs b/crates/ui-egui/src/browser/range_track.rs
index e399be4727..6349e79e56 100644
--- a/crates/ui-egui/src/browser/range_track.rs
+++ b/crates/ui-egui/src/browser/range_track.rs
@@ -109,7 +109,7 @@ const RULER: f32 = 14.0;
const BARS: f32 = 40.0;
fn id(key: &str) -> egui::Id {
- egui::Id::new(("sc_range_track", key))
+ egui::Id::unique(("sc_range_track", key))
}
fn state(ctx: &egui::Context, key: &str) -> State {
diff --git a/crates/ui-egui/src/browser_canvas.rs b/crates/ui-egui/src/browser_canvas.rs
index 20a3963f47..2d9292a140 100644
--- a/crates/ui-egui/src/browser_canvas.rs
+++ b/crates/ui-egui/src/browser_canvas.rs
@@ -26,7 +26,7 @@ pub(crate) fn panel(app: &mut SolveApp, ctx: &egui::Context) {
let at = panel_pos(app);
let (calibrate, name) = (m.calibrate, c.id);
let (ok, cancel) = if calibrate { (crate::i18n::tr_label("Calibrate"), crate::i18n::tr("ui.cancel")) } else { ("", crate::i18n::tr("ui.close")) };
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_canvas_panel"), "canvas", &title)
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_canvas_panel"), "canvas", &title)
.placed(egui::Align2::LEFT_TOP, at)
.fields()
.actions(ok, cancel, None)
diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rs
index ae5df4d437..e270b900de 100644
--- a/crates/ui-egui/src/browser_card_tests.rs
+++ b/crates/ui-egui/src/browser_card_tests.rs
@@ -323,7 +323,7 @@ fn selected_row_paints_tab_soft_fill_and_accent_text_in_both_layouts() {
let mut row_rect = Rect::NOTHING;
let out = crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
let row = Row { selected: true, label: "Selected body", dim: true, color: Some(Tokens::get().error), ..Default::default() };
- row_rect = draw_row(ui, egui::Id::new("selected-row"), &row).rect.unwrap();
+ row_rect = draw_row(ui, egui::Id::unique("selected-row"), &row).rect.unwrap();
});
assert_eq!(row_rect.height(), 26.0);
assert!(out.shapes.iter().any(|s| matches!(&s.shape, egui::Shape::Rect(r) if r.rect == row_rect && r.fill == accent.soft)));
@@ -1104,7 +1104,7 @@ fn semantic_frame_transitions(
semantic_content::finalize(&mut h.app, ui.ctx());
// App paths may converge after an early return; finalization must be idempotent.
semantic_content::finalize(&mut h.app, ui.ctx());
- if ui.ctx().data_mut(|data| data.remove_temp::<bool>(egui::Id::new("semantic-test-discard"))).unwrap_or(false) {
+ if ui.ctx().data_mut(|data| data.remove_temp::<bool>(egui::Id::unique("semantic-test-discard"))).unwrap_or(false) {
ui.ctx().request_discard("repeat semantic layout after input");
}
})
@@ -1516,7 +1516,7 @@ fn semantic_row_commands_are_consumed_once_across_layout_repeats() {
let undo = h.app.session.undo.len();
semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(at)], egui::Modifiers::NONE);
semantic_frame(&mut h, &owners, vec![semantic_button(at, egui::PointerButton::Primary, true, egui::Modifiers::NONE)], egui::Modifiers::NONE);
- h.ctx.data_mut(|data| data.insert_temp(egui::Id::new("semantic-test-discard"), true));
+ h.ctx.data_mut(|data| data.insert_temp(egui::Id::unique("semantic-test-discard"), true));
semantic_frame(&mut h, &owners, vec![semantic_button(at, egui::PointerButton::Primary, false, egui::Modifiers::NONE)], egui::Modifiers::NONE);
assert!(body_hidden(&h, "One"), "a repeated layout cannot toggle the eye back on");
assert_eq!(h.app.session.undo.len(), undo + 1);
@@ -1802,7 +1802,7 @@ fn switching_semantic_documents_preserves_unrelated_payload_and_capture() {
}
let from = semantic_at(ContentOwner::BROWSER, "One");
semantic_drag_start(&mut h, &owners, from);
- let external = egui::Id::new("external capture");
+ let external = egui::Id::unique("external capture");
egui::DragAndDrop::set_payload(&h.ctx, "external payload".to_string());
h.ctx.set_dragged_id(external);
crate::documents::switch(&mut h.app, tab);
diff --git a/crates/ui-egui/src/browser_prompts.rs b/crates/ui-egui/src/browser_prompts.rs
index 75341945d9..f66270d4e6 100644
--- a/crates/ui-egui/src/browser_prompts.rs
+++ b/crates/ui-egui/src/browser_prompts.rs
@@ -41,7 +41,7 @@ pub(crate) fn occurrence_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
let title = crate::i18n::format("browser.move_title", &[("name", &name)]);
let at = panel_pos(app);
let (units, decimals) = (app.session.doc.units.clone(), app.preferences.length_decimals);
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_occ_move"), "move", &title)
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_occ_move"), "move", &title)
.placed(egui::Align2::LEFT_TOP, at)
.fields()
.cards(2.0)
@@ -97,7 +97,7 @@ pub(crate) fn capture_prompt(app: &mut SolveApp, ctx: &egui::Context) {
return;
}
let n = app.session.pending_moves.len();
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_capture_prompt"), "capture", crate::i18n::tr_label("Capture Position"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_capture_prompt"), "capture", crate::i18n::tr_label("Capture Position"))
.anchor(egui::Align2::CENTER_CENTER, egui::vec2(0.0, -80.0))
.actions("Capture Position", "Cancel", Some("Revert"))
.show(ctx, true, |ui| {
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 4f05a53063..ec8e90ebbe 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -375,7 +375,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj
if matches!(d.kind, Kind::Move { .. }) {
let mut dragging = false;
if let Some(t) = crate::dialogs_move::triad(app, &d)
- && let Some(g) = crate::gizmo::show(ui, painter, proj, egui::Id::new("sc_move_triad"), &t, snap_step(app.cam.half_height()))
+ && let Some(g) = crate::gizmo::show(ui, painter, proj, egui::Id::unique("sc_move_triad"), &t, snap_step(app.cam.half_height()))
{
crate::dialogs_move::drag(app, &mut d, g);
dragging = true;
@@ -396,7 +396,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj
// Tab and Shift+Tab in the box show the next or previous value (Y after X; #4776),
// keeping the keyboard in the box.
// egui moves the keyboard on with Tab before this runs: the box had it last frame.
- let id = egui::Id::new("sc_canvas_value");
+ let id = egui::Id::unique("sc_canvas_value");
let boxed = ui.ctx().memory(|m| m.has_focus(id) || m.had_focus_last_frame(id));
let back = boxed && ui.input_mut(|i| i.consume_key(egui::Modifiers::SHIFT, egui::Key::Tab));
let tab = boxed && !back && ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Tab));
@@ -619,7 +619,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
-(n * sign),
l2,
true,
- egui::Id::new("sc_manipulator2"),
+ egui::Id::unique("sc_manipulator2"),
half_height,
0.0,
distance2,
@@ -630,7 +630,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
if let (Kind::Fillet { distance2, .. }, Some((_, t2))) = (&mut d.kind, faces)
&& let Some(l2) = crate::length_input::eval(&app.session.doc, distance2, ValueKind::Length).ok().filter(|v| v.is_finite())
{
- drag_arrow(&app.session.doc, ui, painter, proj, base, bs, t2, l2, false, egui::Id::new("sc_manipulator2"), half_height, 0.0, distance2);
+ drag_arrow(&app.session.doc, ui, painter, proj, base, bs, t2, l2, false, egui::Id::unique("sc_manipulator2"), half_height, 0.0, distance2);
}
// A rectangular pattern's second direction gets its own arrow for Spacing 2 (#2462), as the
// first direction's arrow sets Spacing.
@@ -642,7 +642,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
if let Some(spacing2) = spacing2
&& let Some(l2) = crate::length_input::eval(&app.session.doc, spacing2, ValueKind::Length).ok().filter(|v| v.is_finite())
{
- drag_arrow(&app.session.doc, ui, painter, proj, base, bs, n2, l2, true, egui::Id::new("sc_manipulator2"), half_height, 0.0, spacing2);
+ drag_arrow(&app.session.doc, ui, painter, proj, base, bs, n2, l2, true, egui::Id::unique("sc_manipulator2"), half_height, 0.0, spacing2);
}
}
// An offset plane shows where it will be: at the distance, or through the picked point.
@@ -700,7 +700,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
crate::length_input::eval(&app.session.doc, depth, ValueKind::Length).ok().filter(|v| v.is_finite()).unwrap_or(0.0)
};
let before = depth.clone();
- drag_arrow(&app.session.doc, ui, painter, proj, base, bs, -n, l, false, egui::Id::new("sc_manipulator_depth"), half_height, 0.0, depth);
+ drag_arrow(&app.session.doc, ui, painter, proj, base, bs, -n, l, false, egui::Id::unique("sc_manipulator_depth"), half_height, 0.0, depth);
// Dragging the depth turns "through all" into a distance.
if *depth != before {
opts.all = false;
@@ -735,7 +735,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
-n,
l2.abs(),
false,
- egui::Id::new("sc_manipulator_offset2"),
+ egui::Id::unique("sc_manipulator_offset2"),
half_height,
0.0,
distance2,
@@ -743,7 +743,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
// Its own area and field, so it does not share Distance's focus or text.
value_box_in(
ui,
- (egui::Id::new("sc_canvas_area2"), egui::Id::new("sc_canvas_value2")),
+ (egui::Id::unique("sc_canvas_area2"), egui::Id::unique("sc_canvas_value2")),
"Distance 2",
distance2,
(ts + vec2(14.0, 8.0), egui::Align2::LEFT_TOP),
@@ -785,7 +785,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
n,
half + baseline,
signed,
- egui::Id::new("sc_manipulator"),
+ egui::Id::unique("sc_manipulator"),
half_height,
clear,
dragged,
@@ -811,7 +811,7 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
// Clear of the command window first, then off the placement handles: the handles have the
// last word, as a box over a grip takes the press meant for it (#6608).
let place = box_place(app, proj);
- let size = box_size(ui, egui::Id::new("sc_canvas_area"), label, note.as_deref());
+ let size = box_size(ui, egui::Id::unique("sc_canvas_area"), label, note.as_deref());
let box_at = clear_of_dialog(rect_at(box_at, egui::Align2::LEFT_TOP, size), place).min;
let box_at = crate::place_gizmo::yield_box(ui, anchor, box_at);
value_box_noted(ui, label, value, box_at, focus || *value != before, note.as_deref(), BoxPlace { dialog: None, ..place });
@@ -841,7 +841,7 @@ pub(crate) fn box_place(app: &SolveApp, proj: &Proj) -> BoxPlace {
}
fn boxes_shown_id() -> egui::Id {
- egui::Id::new("sc_canvas_value_boxes")
+ egui::Id::unique("sc_canvas_value_boxes")
}
/// Show commands' values in boxes in the view or not, from the preference (the app calls this
@@ -878,13 +878,13 @@ fn value_box(ui: &mut egui::Ui, label: &str, value: &mut String, at: Pos2, selec
/// [`value_box`]; with `keep_tab` Tab stays in the box for the caller (the Move box steps
/// through its values with it).
fn value_box_with(ui: &mut egui::Ui, label: &str, value: &mut String, at: Pos2, select_all: bool, keep_tab: bool, place: BoxPlace) {
- let ids = (egui::Id::new("sc_canvas_area"), egui::Id::new("sc_canvas_value"));
+ let ids = (egui::Id::unique("sc_canvas_area"), egui::Id::unique("sc_canvas_value"));
value_box_in(ui, ids, label, value, (at, egui::Align2::LEFT_TOP), select_all, keep_tab, place);
}
/// [`value_box`] with a note after the field (a pull's step size).
fn value_box_noted(ui: &mut egui::Ui, label: &str, value: &mut String, at: Pos2, select_all: bool, note: Option<&str>, place: BoxPlace) {
- let ids = (egui::Id::new("sc_canvas_area"), egui::Id::new("sc_canvas_value"));
+ let ids = (egui::Id::unique("sc_canvas_area"), egui::Id::unique("sc_canvas_value"));
value_box_full(ui, ids, label, value, (at, egui::Align2::LEFT_TOP), (select_all, false), note, place);
}
@@ -1133,7 +1133,7 @@ fn drag_arrow(
}
// Paint the value just read from this frame's pointer, including the value box anchor.
// Using the old distance here made both trail the drag by another frame.
- crate::scenario::publish_handle(if id == egui::Id::new("sc_manipulator") { "arrow" } else { "arrow2" }, ts);
+ crate::scenario::publish_handle(if id == egui::Id::unique("sc_manipulator") { "arrow" } else { "arrow2" }, ts);
let hot = r.hovered() || r.dragged();
let col = if hot { t.accent } else { t.manipulator };
arrow(painter, start(ts), ts, col);
@@ -1264,7 +1264,8 @@ fn radius_spline_handles(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Pain
});
if let Some((p, u)) = near {
crate::scenario::publish_handle("fillet_curve", p);
- if ui.interact(egui::Rect::from_center_size(p, vec2(12.0, 12.0)), egui::Id::new("sc_fillet_curve"), egui::Sense::click()).double_clicked() {
+ if ui.interact(egui::Rect::from_center_size(p, vec2(12.0, 12.0)), egui::Id::unique("sc_fillet_curve"), egui::Sense::click()).double_clicked()
+ {
edit = Some(Edit::Insert(u));
}
}
@@ -1284,8 +1285,11 @@ fn radius_spline_handles(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Pain
for (k, (u, ts)) in g.iter().zip(&tips).enumerate() {
let Some(ts) = *ts else { continue };
crate::scenario::publish_handle(&if i == 0 { format!("fillet_r{k}") } else { format!("fillet_e{i}_r{k}") }, ts);
- let r =
- ui.interact(egui::Rect::from_center_size(ts, vec2(16.0, 16.0)), egui::Id::new(("sc_fillet_r", i, k)), egui::Sense::click_and_drag());
+ let r = ui.interact(
+ egui::Rect::from_center_size(ts, vec2(16.0, 16.0)),
+ egui::Id::unique(("sc_fillet_r", i, k)),
+ egui::Sense::click_and_drag(),
+ );
let hot = r.hovered() || r.dragged();
let col = if hot { t.accent } else { t.manipulator };
if let Some(fs) = proj.to_screen(at(*u)) {
@@ -1386,7 +1390,7 @@ fn drag_label(ui: &mut egui::Ui, labels: &mut MeasureLabels, i: usize, rect: egu
if let Some(drawn) = labels.drawn.get_mut(i) {
*drawn = Some(rect);
}
- let r = ui.interact(rect, egui::Id::new(("sc_measure_label", i)), egui::Sense::click_and_drag());
+ let r = ui.interact(rect, egui::Id::unique(("sc_measure_label", i)), egui::Sense::click_and_drag());
if r.dragged() {
ui.ctx().set_cursor_icon(egui::CursorIcon::Grabbing);
} else if r.hovered() {
@@ -1629,7 +1633,7 @@ fn taper_handle(
let l = span.len();
let end = foot + span + e * (l * angle.tan().clamp(-10.0, 10.0));
let (Some(fs), Some(es)) = (proj.to_screen(foot), proj.to_screen(end)) else { return };
- let r = ui.interact(egui::Rect::from_center_size(es, vec2(16.0, 16.0)), egui::Id::new("sc_taper"), egui::Sense::drag());
+ let r = ui.interact(egui::Rect::from_center_size(es, vec2(16.0, 16.0)), egui::Id::unique("sc_taper"), egui::Sense::drag());
crate::scenario::publish_handle("taper", es);
let hot = r.hovered() || r.dragged();
let col = if hot { t.accent } else { t.manipulator };
@@ -1811,7 +1815,7 @@ fn draw_revolve(
// This badge is read-only. Its placement follows the model and can overlap the
// command dialog, whose buttons must keep receiving clicks.
let area = Container::new(ui.ctx(), Surface::Canvas)
- .area(egui::Id::new("sc_canvas_area"))
+ .area(egui::Id::unique("sc_canvas_area"))
.fixed_pos(box_at)
.order(egui::Order::Background)
.interactable(false);
@@ -1911,7 +1915,7 @@ fn rotation_handle(
) -> Option<Pos2> {
let end = proj.to_screen(centre + (e1 * boundary.cos() + e2 * boundary.sin()) * radius)?;
crate::scenario::publish_handle(name, end);
- let response = ui.interact(egui::Rect::from_center_size(end, vec2(20.0, 20.0)), egui::Id::new(("sc_rotator", name)), egui::Sense::drag());
+ let response = ui.interact(egui::Rect::from_center_size(end, vec2(20.0, 20.0)), egui::Id::unique(("sc_rotator", name)), egui::Sense::drag());
let hot = response.hovered() || response.dragged();
let color = if hot { Tokens::get().accent } else { Tokens::get().manipulator };
painter.circle(end, if hot { 7.0 } else { 5.5 }, color, Stroke::new(1.5, Color32::WHITE));
@@ -2067,7 +2071,7 @@ mod tests {
h.app.session.selection = vec![Sel::Body { name: "Body1".into() }];
h.step(&serde_json::json!({"start": "solid.move"})).unwrap();
h.frames(6);
- let box_rect = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).expect("the value box");
+ let box_rect = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).expect("the value box");
let window = h.app.viewport.dialog_rect.expect("the command window");
// Drag the command window over the value box: the box must move out of it.
let title = crate::scenario::handle_at("dialog:title").expect("the window's title");
@@ -2076,7 +2080,7 @@ mod tests {
h.frames(6);
let window = h.app.viewport.dialog_rect.unwrap();
assert!(window.contains(box_rect.center()), "the window {window:?} did not reach the value box {box_rect:?}");
- let kept = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).expect("the value box");
+ let kept = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).expect("the value box");
assert!(!kept.intersects(window), "the value box {kept:?} covers the command window {window:?}");
}
@@ -2100,7 +2104,7 @@ mod tests {
{"click": {"world": [30, 15, 10]}}
]))
.unwrap();
- let box_rect = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).expect("the value box");
+ let box_rect = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).expect("the value box");
let handles = crate::scenario::handles("move_");
assert!(!handles.is_empty(), "the triad drew no handles");
for (name, p) in &handles {
@@ -2134,17 +2138,17 @@ mod tests {
h.step(&serde_json::json!({"start": "solid.move"})).unwrap();
h.frames(6);
let order = |h: &crate::scenario::Harness| {
- h.ctx.memory(|m| m.areas().visible_layer_ids().into_iter().find(|l| l.id == egui::Id::new("sc_canvas_area")).map(|l| l.order))
+ h.ctx.memory(|m| m.areas().visible_layer_ids().into_iter().find(|l| l.id == egui::Id::unique("sc_canvas_area")).map(|l| l.order))
};
assert_eq!(order(&h), Some(egui::Order::Background), "the value box belongs under system windows");
h.call("ui.prefs", serde_json::json!({"open": "General"}));
h.frames(3);
- let window = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).expect("Preferences");
- let box_rect = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).expect("the value box");
+ let window = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).expect("Preferences");
+ let box_rect = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).expect("the value box");
assert!(order(&h) < Some(egui::Order::Middle), "Preferences draws over the value box");
if window.intersects(box_rect) {
assert!(
- h.ctx.memory(|m| m.layer_id_at(box_rect.center())).is_some_and(|l| l.id == egui::Id::new("sc_prefs")),
+ h.ctx.memory(|m| m.layer_id_at(box_rect.center())).is_some_and(|l| l.id == egui::Id::unique("sc_prefs")),
"Preferences covers the Distance box where they overlap"
);
}
diff --git a/crates/ui-egui/src/colour_tokens_tests.rs b/crates/ui-egui/src/colour_tokens_tests.rs
index 15be6a9fa3..4dbc59d679 100644
--- a/crates/ui-egui/src/colour_tokens_tests.rs
+++ b/crates/ui-egui/src/colour_tokens_tests.rs
@@ -86,7 +86,7 @@ fn every_axis_is_drawn_in_one_set_of_colours() {
let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(rect), ..Default::default() }, |ui| {
let painter = ui.painter().clone();
- crate::gizmo::show(ui, &painter, &proj, egui::Id::new("one_set_gizmo"), &triad, 1.0);
+ crate::gizmo::show(ui, &painter, &proj, egui::Id::unique("one_set_gizmo"), &triad, 1.0);
});
out.textures_delta.clear();
let mut gizmo = stroke_colours(&out.shapes);
diff --git a/crates/ui-egui/src/configurations_ui.rs b/crates/ui-egui/src/configurations_ui.rs
index 108b990664..5945640f2e 100644
--- a/crates/ui-egui/src/configurations_ui.rs
+++ b/crates/ui-egui/src/configurations_ui.rs
@@ -190,7 +190,7 @@ pub(super) fn configurations_rows(
.unwrap_or_default()
});
let (kind, _) = column_parts(column);
- let (response, choice) = value_control(ui, ui.id().with(column), &mut value, kind, &material_names);
+ let (response, choice) = value_control(ui, ui.scope_id().with(column), &mut value, kind, &material_names);
let picked = choice.is_some();
if let Some(choice) = choice {
value = choice;
diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs
index e378ebce26..8628b0f521 100644
--- a/crates/ui-egui/src/context_menu.rs
+++ b/crates/ui-egui/src/context_menu.rs
@@ -2568,7 +2568,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
inside |= pointer.is_some_and(|p| area.contains(p));
let hot = pointer.and_then(|p| sector(p - c));
let resp = Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_marking_menu"))
+ .area(egui::Id::unique("sc_marking_menu"))
.fixed_pos(area.min)
.order(egui::Order::Foreground)
.show(ctx, |ui| {
@@ -2615,7 +2615,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let key_row = app.menu.key_row;
let mut seen: Vec<Seen> = Vec::new();
let resp = Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_context_menu"))
+ .area(egui::Id::unique("sc_context_menu"))
.fixed_pos(list_at)
.constrain(true)
.order(egui::Order::Foreground)
@@ -2632,7 +2632,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let Some(row) = seen.get(depth - 1).and_then(|s| s.anchor) else { break };
// One area per flyout and contents: an egui area keeps its last size, so a flyout sharing
// one with a shorter one would be squeezed into it and scroll.
- let id = egui::Id::new(("sc_context_submenu", depth)).with(rows.iter().map(|i| (&i.id, &i.label)).collect::<Vec<_>>());
+ let id = egui::Id::unique(("sc_context_submenu", depth)).with(rows.iter().map(|i| (&i.id, &i.label)).collect::<Vec<_>>());
let cursor = if depth == path.len() { app.menu.submenu_key } else { None };
let sub = crate::ui_kit::Menu::submenu(ctx, id, row, list_height(rows), leftward, |ui| {
egui::ScrollArea::vertical()
@@ -2823,7 +2823,7 @@ fn show_rename(app: &mut SolveApp, ctx: &egui::Context) {
let Some(mut r) = app.menu.rename.take() else { return };
let mut done: Option<bool> = None;
let resp =
- Container::new(ctx, Surface::Popup).area(egui::Id::new("sc_rename")).fixed_pos(r.at).constrain(true).order(egui::Order::Foreground).show(
+ Container::new(ctx, Surface::Popup).area(egui::Id::unique("sc_rename")).fixed_pos(r.at).constrain(true).order(egui::Order::Foreground).show(
ctx,
|ui| {
done = crate::ui_kit::rename_menu(ui, &mut r.text, &mut r.focused);
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs
index 8e4c661dce..87690cd590 100644
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@ -1282,7 +1282,13 @@ fn dispatch(app: &mut SolveApp, ctx: &egui::Context, method: &str, p: &Value) ->
if explicit {
app.synthetic.push(egui::Event::ModifiersChanged(modifiers));
}
- app.synthetic.push(egui::Event::MouseWheel { unit, delta: egui::vec2(0.0, delta), modifiers, phase: egui::TouchPhase::Move });
+ app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit,
+ delta: egui::vec2(0.0, delta),
+ modifiers,
+ phase: egui::TouchPhase::Move,
+ });
if explicit {
app.synthetic.push(egui::Event::ModifiersChanged(egui::Modifiers::NONE));
}
diff --git a/crates/ui-egui/src/crash_ui.rs b/crates/ui-egui/src/crash_ui.rs
index f09b3d7858..fe4d823072 100644
--- a/crates/ui-egui/src/crash_ui.rs
+++ b/crates/ui-egui/src/crash_ui.rs
@@ -76,7 +76,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
let mut report: Option<String> = None;
let mut delete: Option<Option<String>> = None;
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_crash_reports"), "bug_report", crate::i18n::tr_label("Crash Reports"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_crash_reports"), "bug_report", crate::i18n::tr_label("Crash Reports"))
.cards(2.0)
.actions("", crate::i18n::tr("ui.close"), None)
.show(ctx, true, |ui| {
@@ -281,7 +281,7 @@ mod tests {
h.app.crashes.folder = Some(d.clone());
super::open(&mut h.app);
h.frames(6);
- let window = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_crash_reports"))).unwrap();
+ let window = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_crash_reports"))).unwrap();
// The frame's margins come on top of the content's maximum width.
assert!(window.width() <= 760.0 + 40.0, "{} wide", window.width());
let _ = std::fs::remove_dir_all(&d);
diff --git a/crates/ui-egui/src/delete.rs b/crates/ui-egui/src/delete.rs
index cee70ad277..0553769f7f 100644
--- a/crates/ui-egui/src/delete.rs
+++ b/crates/ui-egui/src/delete.rs
@@ -185,7 +185,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
};
let (deleted, fails) = (list("deleted"), list("would_fail"));
let shared = shared_occurrences(app, &p.params);
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_delete_confirm"), "delete", crate::i18n::tr_label("Delete"))
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_delete_confirm"), "delete", crate::i18n::tr_label("Delete"))
.tone(ui_kit::Tone::Danger)
.actions("Delete", "Cancel", None)
.show(ctx, true, |ui| {
diff --git a/crates/ui-egui/src/design_properties.rs b/crates/ui-egui/src/design_properties.rs
index f774bf278d..cd813a6c76 100644
--- a/crates/ui-egui/src/design_properties.rs
+++ b/crates/ui-egui/src/design_properties.rs
@@ -87,12 +87,12 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let Some(mut d) = app.design_properties.take() else { return };
let metadata = app.session.doc.metadata.clone();
let title = crate::i18n::tr_label("Design Properties");
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_design_properties"), "settings", title).fields().show(ctx, true, |ui| {
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_design_properties"), "settings", title).fields().show(ctx, true, |ui| {
for (i, k) in keys(Owner::Design).enumerate() {
let (key, label) = (k.name, crate::i18n::tr(k.label));
let Some(field) = d.fields.get_mut(i) else { continue };
if key == DESCRIPTION {
- ui_kit::multiline_text_field(ui, label, egui::Id::new(("sc_design_properties", key)), field);
+ ui_kit::multiline_text_field(ui, label, egui::Id::unique(("sc_design_properties", key)), field);
} else {
ui_kit::row(ui, label, |ui| ui_kit::text_field(ui, field, ""));
}
@@ -253,7 +253,7 @@ fn show_measuring(app: &mut SolveApp, ctx: &egui::Context) {
Some((done, total)) => crate::i18n::format("ui.properties.measuring_bodies", &[("done", &done.to_string()), ("total", &total.to_string())]),
None => app.tr("ui.properties.measuring").to_string(),
};
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_props"), "settings", &heading).actions("", "Close", None).show(ctx, true, |ui| {
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_props"), "settings", &heading).actions("", "Close", None).show(ctx, true, |ui| {
ui.horizontal(|ui| {
ui.spinner();
ui_kit::text(ui, &text, ui_kit::Text::Note("measuring"));
@@ -435,7 +435,7 @@ pub fn show_object(app: &mut SolveApp, ctx: &egui::Context) {
let copy = shown_tensor(app, total).map(|t| tensor_text(&t));
let copy_label = app.tr("ui.properties.copy_matrix").to_string();
let heading = window_title(&title, &v);
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_props"), "settings", &heading).actions("", "Close", None).show(ctx, true, |ui| {
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_props"), "settings", &heading).actions("", "Close", None).show(ctx, true, |ui| {
for (label, value) in &rows {
ui_kit::row(ui, crate::i18n::tr_label(label), |ui| ui_kit::text(ui, value, ui_kit::Text::Cell));
}
@@ -738,7 +738,7 @@ mod tests {
crate::context_menu::run_item(&mut h.app, item, egui::pos2(0.0, 0.0));
assert!(h.app.design_properties.is_some());
h.app.design_properties = None;
- h.ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu"), true));
+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_file_menu"), true));
h.frames(2);
h.step(&json!({"widget": "Design Properties…"})).unwrap();
assert!(h.app.design_properties.is_some());
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 34c2177505..a76febed8f 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -2081,7 +2081,7 @@ pub(crate) fn fillet_least_setback(ctx: &egui::Context, s: &Session, items: &[Se
(&s.document_id, s.revision, radius.to_bits(), &bodies).hash(&mut key);
corners.iter().for_each(|c| [c.x, c.y, c.z].map(f64::to_bits).hash(&mut key));
let key = key.finish();
- let id = egui::Id::new("fillet_least_setback");
+ let id = egui::Id::unique("fillet_least_setback");
if let Some((k, least)) = ctx.data(|d| d.get_temp::<(u64, Option<f64>)>(id))
&& k == key
{
@@ -2539,7 +2539,7 @@ fn tr(text: &str) -> &str {
}
fn publish_check(ui: &egui::Ui, response: &egui::Response, selected: bool) {
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), selected, tr(crate::ui_kit::row_label(ui))));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::CheckBox, ui.is_enabled(), selected, tr(crate::ui_kit::row_label(ui))));
}
fn title(k: &Kind) -> &'static str {
@@ -3024,7 +3024,7 @@ pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, n
let chip = crate::ui_kit::selection_field(ui, prompt, crate::ui_kit::Selection { active, filled });
if matches!(d.kind, Kind::Shell { .. }) && i == 0 {
chip.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), tr(inp.label));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), tr(inp.label));
info.current_text_value = Some(prompt.to_string());
info
});
@@ -3196,13 +3196,13 @@ fn error_rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut
{
d.refuse(app, error);
}
- let shown_id = egui::Id::new("sc_dialog_refusal_shown");
+ let shown_id = egui::Id::unique("sc_dialog_refusal_shown");
if d.error.is_none() && app.preview.error.is_none() {
ui.data_mut(|m| m.remove::<String>(shown_id));
}
// A click the waiting pick field does not take: what that field is for, plainly (#10428).
// Under the fold in a short window, a new note scrolls into view once, as a refusal does.
- let note_shown_id = egui::Id::new("sc_dialog_pick_refused_shown");
+ let note_shown_id = egui::Id::unique("sc_dialog_pick_refused_shown");
if let Some(id) = d.pick_refused.filter(|_| d.error.is_none() && app.preview.error.is_none()) {
let note = crate::ui_kit::text(ui, crate::i18n::tr(id), crate::ui_kit::Text::Hint("pick_refused"));
crate::scenario::publish_rect("dialog:pick_refused", note.rect);
@@ -3837,9 +3837,9 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
| Kind::Sheet(crate::dialogs_sheet::Sm::Rules { .. })
| Kind::Plastic(crate::dialogs_plastic::Pl::Rules { .. })
);
- let grow_key = egui::Id::new(("sc_dialog_label_grow", raw_title));
+ let grow_key = egui::Id::unique(("sc_dialog_label_grow", raw_title));
let label_grow = ctx.data(|data| data.get_temp::<f32>(grow_key)).unwrap_or(0.0).min((vp.width() - t.space_24 - card_width(&d)).max(0.0));
- let panel = crate::ui_kit::Panel::new(&heading, egui::Id::new(("sc_dialog", title(&d.kind))), anchor, drag_bounds, side, frame)
+ let panel = crate::ui_kit::Panel::new(&heading, egui::Id::unique(("sc_dialog", title(&d.kind))), anchor, drag_bounds, side, frame)
.actions(ok_label, close_label);
let panel = if let Some(column) = column {
panel.width(column.width()).joined(crate::ui_kit::DockEdges { left: true, top: true, ..Default::default() })
@@ -3859,7 +3859,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
matches!(&d.kind, Kind::SketchModify(k) if crate::sketch_modify_ui::repeatable(k)) && d.editing.is_none() && !d.extra.contains_key("pattern");
if let Kind::ConfirmDelete { with, fail, .. } = &d.kind {
let detail = with.join(" · ");
- let (closed, action) = crate::ui_kit::Confirm::new(egui::Id::new(("sc_dialog", title(&d.kind))), "delete", &heading)
+ let (closed, action) = crate::ui_kit::Confirm::new(egui::Id::unique(("sc_dialog", title(&d.kind))), "delete", &heading)
.tone(crate::ui_kit::Tone::Danger)
.actions("Delete", "Cancel", None)
.detail(&detail)
@@ -3997,7 +3997,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
// Keyboard: Enter applies (from a value field, or with nothing focused), Esc cancels.
let (enter_free, esc) = ctx.input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape)));
let nothing_focused = ctx.memory(|m| m.focused().is_none());
- let canvas_enter = enter_free && ctx.memory(|m| m.had_focus_last_frame(egui::Id::new("sc_canvas_value")));
+ let canvas_enter = enter_free && ctx.memory(|m| m.had_focus_last_frame(egui::Id::unique("sc_canvas_value")));
// Tables (configurations, a study's keys) take Enter for their cells.
let enter_applies = !matches!(d.kind, Kind::Sketch | Kind::Measure { .. } | Kind::ConfirmDelete { .. })
&& !matches!(&d.kind, Kind::Motion(k) if k.wide())
diff --git a/crates/ui-egui/src/dialogs_appearance.rs b/crates/ui-egui/src/dialogs_appearance.rs
index 1acf870a1a..7bc164c0d0 100644
--- a/crates/ui-egui/src/dialogs_appearance.rs
+++ b/crates/ui-egui/src/dialogs_appearance.rs
@@ -485,7 +485,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Ap, inputs: &mut [Sel
ui_kit::swatch_grid(ui, &items, |ui, (i, (look, n))| {
if ui_kit::color_swatch(
ui,
- egui::Id::new(("ap_used", *i)),
+ egui::Id::unique(("ap_used", *i)),
c32(look.color, look.opacity),
k.color == look.color && k.opacity == look.opacity && k.pbr == look.pbr,
&format!("{} · {n} item(s)", look.name),
@@ -533,7 +533,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Ap, inputs: &mut [Sel
|p| format!("{}\n{}\n{}", l.name, p.preview_note, p.requirements.join(", ")),
);
ui.add_enabled_ui(available, |ui| {
- let response = ui_kit::color_swatch(ui, egui::Id::new(("ap_lib", *i)), c32(l.color, l.opacity), picked_look, &tip, (*l).clone());
+ let response = ui_kit::color_swatch(ui, egui::Id::unique(("ap_lib", *i)), c32(l.color, l.opacity), picked_look, &tip, (*l).clone());
if let Some(preset) = &l.preset {
crate::scenario::publish_handle(&format!("appearance:preset:{}", preset.id), response.rect.center());
}
diff --git a/crates/ui-egui/src/dialogs_assembly.rs b/crates/ui-egui/src/dialogs_assembly.rs
index f7c67d92dd..672cacc2d7 100644
--- a/crates/ui-egui/src/dialogs_assembly.rs
+++ b/crates/ui-egui/src/dialogs_assembly.rs
@@ -911,7 +911,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
form_row(ui, &capital(name), |ui| {
if i == 0 {
// Typing replaces the value at once, as in the other dialogs' value boxes.
- let id = egui::Id::new("sc_drive_value");
+ let id = egui::Id::unique("sc_drive_value");
let r = crate::ui_kit::cell_editor(ui, id, v, "", false);
crate::params_dialog::complete(ui, &r, v);
if std::mem::take(focus) {
@@ -1837,7 +1837,7 @@ pub(crate) fn timeline_joint_tiles(app: &mut SolveApp, ui: &mut egui::Ui, p: &eg
for (id, name, kind, suppressed) in joints {
let br = egui::Rect::from_min_size(egui::pos2(x, r.top() + 6.0), vec2(28.0, 28.0));
crate::scenario::publish_handle(&format!("timeline-joint:{name}"), br.center());
- let resp = ui.interact(br, ui.id().with(("joint", id)), egui::Sense::click());
+ let resp = ui.interact(br, ui.scope_id().with(("joint", id)), egui::Sense::click());
let bg = if app.tree.picked_joints.contains(&id) {
t.accent_soft
} else if resp.hovered() {
@@ -1961,7 +1961,7 @@ pub fn browser_joints(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize) {
let folder_shown = !app.session.folder_hidden(key);
let r = draw_row(
ui,
- ui.id().with(key),
+ ui.scope_id().with(key),
&Row { depth, fold: Some(open), eye: Some(folder_shown), icon: "folder", label: "Joints", dim: !folder_shown, ..Default::default() },
);
if r.eye {
@@ -1978,7 +1978,7 @@ pub fn browser_joints(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize) {
let selected = app.tree.picked_joints.contains(&id);
let r = draw_row(
ui,
- ui.id().with(("joint", id)),
+ ui.scope_id().with(("joint", id)),
&Row {
depth: depth + 1,
eye: Some(visible),
@@ -2050,7 +2050,7 @@ pub fn component_joints(app: &mut SolveApp, ui: &mut egui::Ui, path: &[u64], key
}
let key = format!("{key}/joints");
let open = is_open(app, &key, false);
- let r = draw_row(ui, ui.id().with(&key), &Row { depth, fold: Some(open), icon: "folder", label: "Joints", ..Default::default() });
+ let r = draw_row(ui, ui.scope_id().with(&key), &Row { depth, fold: Some(open), icon: "folder", label: "Joints", ..Default::default() });
if r.fold || r.clicked {
toggle(app, &key, false);
}
@@ -2066,7 +2066,7 @@ pub fn component_joints(app: &mut SolveApp, ui: &mut egui::Ui, path: &[u64], key
let selected = app.tree.picked_joints.contains(&id);
let r = draw_row(
ui,
- ui.id().with((&key, "joint", id)),
+ ui.scope_id().with((&key, "joint", id)),
&Row {
depth: depth + 1,
eye: Some(visible),
diff --git a/crates/ui-egui/src/dialogs_assembly_tests.rs b/crates/ui-egui/src/dialogs_assembly_tests.rs
index f0e8057f98..a3522409e4 100644
--- a/crates/ui-egui/src/dialogs_assembly_tests.rs
+++ b/crates/ui-egui/src/dialogs_assembly_tests.rs
@@ -873,7 +873,7 @@ fn slider_drag_does_not_open_suggestions_over_the_slider() {
.unwrap();
h.app.start("joint.drive");
h.frames(4);
- let editor = egui::Id::new("sc_drive_value");
+ let editor = egui::Id::unique("sc_drive_value");
let bounds = h
.output
.accesskit_update
diff --git a/crates/ui-egui/src/dialogs_hole.rs b/crates/ui-egui/src/dialogs_hole.rs
index e9e659e350..fbefe95b1e 100644
--- a/crates/ui-egui/src/dialogs_hole.rs
+++ b/crates/ui-egui/src/dialogs_hole.rs
@@ -466,7 +466,8 @@ mod tests {
(Dim::ThreadDepth, 145.0),
]
.map(|(dim, y)| (dim, Rect::from_min_size(pos2(150.0, y), vec2(100.0, 20.0)), false));
- let output = ctx.run_ui(egui::RawInput::default(), |ui| paint(ui.painter(), pic, &section, &slots));
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| paint(ui.painter(), pic, &section, &slots));
+ output.textures_delta.clear();
let mut dimensions: Vec<_> = output
.shapes
.iter()
diff --git a/crates/ui-egui/src/dialogs_library.rs b/crates/ui-egui/src/dialogs_library.rs
index 4d990e3ce6..05a09f8013 100644
--- a/crates/ui-egui/src/dialogs_library.rs
+++ b/crates/ui-egui/src/dialogs_library.rs
@@ -218,7 +218,13 @@ fn import_rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Ap, inputs: &[SelI
};
if let Some(look) = look {
let [r, g, b] = look.color;
- ui_kit::color_thumbnail(ui, ui.id().with((&entry.id, "sample")), egui::Color32::from_rgb(r, g, b), &look.name, ());
+ ui_kit::color_thumbnail(
+ ui,
+ ui.scope_id().with((&entry.id, "sample")),
+ egui::Color32::from_rgb(r, g, b),
+ &look.name,
+ (),
+ );
}
let button =
ui_kit::list_picker(ui, &entry.id, entry.definition.name(), k.local.selected.as_deref() == Some(entry.id.as_str()))
diff --git a/crates/ui-egui/src/dialogs_motion_plot.rs b/crates/ui-egui/src/dialogs_motion_plot.rs
index fe7d1c63b1..57897a2243 100644
--- a/crates/ui-egui/src/dialogs_motion_plot.rs
+++ b/crates/ui-egui/src/dialogs_motion_plot.rs
@@ -358,7 +358,7 @@ fn plot_rows(
if what != Plotted::Nothing {
choice_row(ui, "motion.plot_quantity", "ms_quantity", &mut a.quantity, &QUANTITIES);
form_row(ui, "Duration", |ui| {
- let r = crate::ui_kit::cell_editor(ui, ui.id().with("duration"), &mut a.duration, "motion.duration_hint", false);
+ let r = crate::ui_kit::cell_editor(ui, ui.scope_id().with("duration"), &mut a.duration, "motion.duration_hint", false);
crate::scenario::publish_handle("dialog:Duration", r.rect.center());
});
let params = study.clone().and_then(|st| plot_params(s, what, &st, &a.duration, inputs).map(|p| (st, p)));
diff --git a/crates/ui-egui/src/dialogs_parts.rs b/crates/ui-egui/src/dialogs_parts.rs
index 9fa4e65368..8c5d781300 100644
--- a/crates/ui-egui/src/dialogs_parts.rs
+++ b/crates/ui-egui/src/dialogs_parts.rs
@@ -225,7 +225,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Pt, inputs: &[SelInpu
text_row(ui, "Name", &mut k.name, crate::i18n::tr("parts.automatic_name"));
// The part, and its table values.
let key = (k.family, k.size, k.length);
- let tex_id = egui::Id::new("sc_part_picture");
+ let tex_id = egui::Id::unique("sc_part_picture");
if k.picture != Some(key) {
let tex = insert_params(&lib, k, &[])
.ok()
diff --git a/crates/ui-egui/src/dialogs_save_mesh.rs b/crates/ui-egui/src/dialogs_save_mesh.rs
index 61a9431a5e..de711a3b13 100644
--- a/crates/ui-egui/src/dialogs_save_mesh.rs
+++ b/crates/ui-egui/src/dialogs_save_mesh.rs
@@ -261,7 +261,7 @@ pub fn start_with_format(app: &mut SolveApp, format: &str) {
/// A popup with the slicer list is open (Delete belongs to it, not to the design's selection).
pub fn popup_open(ctx: &egui::Context) -> bool {
let frame = ctx.cumulative_frame_nr();
- let at = ctx.data(|d| d.get_temp::<u64>(egui::Id::new("sc_slicer_popup")));
+ let at = ctx.data(|d| d.get_temp::<u64>(egui::Id::unique("sc_slicer_popup")));
at.is_some_and(|n| n + 1 >= frame)
}
@@ -435,7 +435,7 @@ fn slicer_combo(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh) {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);
let r = crate::ui_kit::dropdown_menu(ui, "sm_slicer", &text, |ui| {
let frame = ctx.cumulative_frame_nr();
- ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_slicer_popup"), frame));
+ ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_slicer_popup"), frame));
for e in &entries {
let tex = icon(&mut app.slicer_menu, &ctx, e);
let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 22.0), Sense::click());
diff --git a/crates/ui-egui/src/dialogs_sheet.rs b/crates/ui-egui/src/dialogs_sheet.rs
index 6dda7c339d..4ea6729fcb 100644
--- a/crates/ui-egui/src/dialogs_sheet.rs
+++ b/crates/ui-egui/src/dialogs_sheet.rs
@@ -1050,7 +1050,7 @@ pub fn overlay(app: &mut SolveApp, painter: &egui::Painter, rect: Rect, d: &Dial
// to its width limit, so its actual edge, rather than a fixed reserve, bounds the view.
let panel_left = painter
.ctx()
- .memory(|m| m.area_rect(egui::Id::new(("sc_dialog", "FLAT PATTERN"))))
+ .memory(|m| m.area_rect(egui::Id::unique(("sc_dialog", "FLAT PATTERN"))))
.map(|panel| panel.left())
.unwrap_or(rect.right() - crate::frame::DIALOG_MAX_W);
let content = crate::shell::content_rect(app, rect);
diff --git a/crates/ui-egui/src/dialogs_sheet_tests.rs b/crates/ui-egui/src/dialogs_sheet_tests.rs
index c8f83c8640..7a97172f69 100644
--- a/crates/ui-egui/src/dialogs_sheet_tests.rs
+++ b/crates/ui-egui/src/dialogs_sheet_tests.rs
@@ -173,7 +173,7 @@ fn shallow_pocket_overlay_labels_depth_without_drawing_a_through_void() {
*data = Some(Ok(flat));
let ctx = crate::fonts::test_context();
let output = crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
- let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("flat-pocket-test")));
+ let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::unique("flat-pocket-test")));
assert!(overlay(&mut app, &painter, Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0)), &dialog));
});
let texts: Vec<_> = crate::test_support::text_shapes(&output).map(|text| text.galley.text()).collect();
@@ -251,7 +251,7 @@ fn flat_pattern_islands_fit_before_the_actual_command_panel() {
app.shell.content = Some(Rect::from_min_max(pos2(browser.right(), viewport.top()), pos2(viewport.right(), history.top())));
}
let ctx = crate::fonts::test_context();
- let id = egui::Id::new(("sc_dialog", "FLAT PATTERN"));
+ let id = egui::Id::unique(("sc_dialog", "FLAT PATTERN"));
let mut output = egui::FullOutput::default();
for _ in 0..3 {
output =
@@ -262,7 +262,7 @@ fn flat_pattern_islands_fit_before_the_actual_command_panel() {
.show(ui.ctx(), |ui| {
ui.label("Flat size: 50 × 10 × 2.5 mm");
});
- let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Background, egui::Id::new("island-fit")));
+ let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Background, egui::Id::unique("island-fit")));
assert!(overlay(
&mut app,
&painter,
@@ -314,7 +314,7 @@ fn coincident_top_and_bottom_pocket_depths_share_a_readable_annotation() {
*data = Some(Ok(flat));
let ctx = crate::fonts::test_context();
let output = crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
- let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("coincident-pocket-test")));
+ let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::unique("coincident-pocket-test")));
assert!(overlay(&mut app, &painter, Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0)), &dialog));
});
let labels: Vec<_> =
@@ -1049,8 +1049,13 @@ fn flat_pattern_pans_and_zooms_like_the_design_viewport() {
assert!(panned + zoomed >= 1, "{preset}: the preset has a pan or zoom drag");
// The wheel zooms (to the cursor when asked), identically.
let before = flat.flat_view.cam;
- let wheel =
- Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, 3.0), modifiers: none, phase: egui::TouchPhase::Move };
+ let wheel = Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Line,
+ delta: vec2(0.0, 3.0),
+ modifiers: none,
+ phase: egui::TouchPhase::Move,
+ };
for (app, ctx, t) in [(&mut flat, &flat_ctx, &mut ft), (&mut design, &design_ctx, &mut dt)] {
frame(app, ctx, t, none, vec![Event::PointerMoved(at)]);
frame(app, ctx, t, none, vec![wheel.clone()]);
@@ -1109,7 +1114,13 @@ fn design_camera_is_unchanged_while_the_flat_pattern_has_focus() {
frame(&mut app, &ctx, &mut t, mods, vec![Event::PointerButton { pos: at, button, pressed: false, modifiers: mods }]);
}
}
- let wheel = Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, 3.0), modifiers: none, phase: egui::TouchPhase::Move };
+ let wheel = Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Line,
+ delta: vec2(0.0, 3.0),
+ modifiers: none,
+ phase: egui::TouchPhase::Move,
+ };
frame(&mut app, &ctx, &mut t, none, vec![wheel]);
frame(&mut app, &ctx, &mut t, none, vec![Event::Zoom(1.3)]);
for _ in 0..30 {
@@ -1177,7 +1188,7 @@ fn flat_circles(app: &mut SolveApp, dialog: &Dialog, rect: Rect) -> Vec<egui::ep
let ctx = crate::fonts::test_context();
let input = egui::RawInput { screen_rect: Some(rect), ..Default::default() };
let output = crate::test_support::frame(&ctx, input, |ui| {
- let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("perforation-test")));
+ let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::unique("perforation-test")));
assert!(overlay(app, &painter, rect, dialog));
});
output.shapes.into_iter().filter_map(|s| if let egui::Shape::Circle(c) = s.shape { Some(c) } else { None }).collect()
diff --git a/crates/ui-egui/src/dialogs_thread.rs b/crates/ui-egui/src/dialogs_thread.rs
index 1bdb2b57e8..b8f18b111a 100644
--- a/crates/ui-egui/src/dialogs_thread.rs
+++ b/crates/ui-egui/src/dialogs_thread.rs
@@ -983,11 +983,13 @@ mod contribution_tests {
let mut designation = original.to_string();
let mut custom = None;
let doc = Document::default();
- let _ = ctx.run_ui(Default::default(), |ui| {
+ ctx.run_ui(Default::default(), |ui| {
egui::Grid::new("hole_catalogue").show(ui, |ui| {
hole_rows(ui, &doc, &mut designation, &mut custom, &mut None);
});
- });
+ })
+ .textures_delta
+ .clear();
assert_eq!(designation, original);
}
}
@@ -1134,11 +1136,14 @@ mod contribution_tests {
let mut hole = original.to_string();
let mut custom = None;
let doc = Document::default();
- let _ = context.run_ui(Default::default(), |ui| {
- egui::Grid::new("authored_hole").show(ui, |ui| {
- hole_rows(ui, &doc, &mut hole, &mut custom, &mut None);
- });
- });
+ context
+ .run_ui(Default::default(), |ui| {
+ egui::Grid::new("authored_hole").show(ui, |ui| {
+ hole_rows(ui, &doc, &mut hole, &mut custom, &mut None);
+ });
+ })
+ .textures_delta
+ .clear();
assert_eq!(hole, original);
}
}
diff --git a/crates/ui-egui/src/dim_view.rs b/crates/ui-egui/src/dim_view.rs
index e19bdc4522..f9b4889e09 100644
--- a/crates/ui-egui/src/dim_view.rs
+++ b/crates/ui-egui/src/dim_view.rs
@@ -1014,7 +1014,7 @@ fn is_plain_value(text: &str) -> bool {
/// The cursor ends just after the name and the field keeps the keyboard.
fn insert_reference(ctx: &egui::Context, edit: &mut Edit, name: &str) {
edit.typed = true;
- let id = egui::Id::new("sc_dim_edit");
+ let id = egui::Id::unique("sc_dim_edit");
let mut state = egui::TextEdit::load_state(ctx, id).unwrap_or_default();
let len = edit.expr.chars().count();
let (start, end) = if is_plain_value(&edit.expr) {
@@ -1120,7 +1120,7 @@ fn edit_box(app: &mut SolveApp, ctx: &egui::Context) {
let (done, escaped) = window::show(app, ctx, &mut e, at);
return settle(app, e, done, escaped);
}
- let id = egui::Id::new("sc_dim_edit");
+ let id = egui::Id::unique("sc_dim_edit");
let mut done: Option<bool> = None;
let mut escaped = false;
// A type-first value sits beside its text, clear of the pointer and of the target a click
@@ -1129,74 +1129,78 @@ fn edit_box(app: &mut SolveApp, ctx: &egui::Context) {
let popup_width = drawable.map_or(220.0, |rect| (rect.width() - 8.0).clamp(24.0, 220.0));
let anchor = edit_anchor(at, e.live.is_some(), drawable, popup_width);
// Background: under Preferences and Report a bug (#9016), like canvas value boxes.
- Container::new(ctx, Surface::Canvas).area(egui::Id::new("sc_dim_edit_area")).fixed_pos(anchor).order(egui::Order::Background).show(ctx, |ui| {
- let frame = Container::popup_frame(ui.style()).fill(Tokens::get().dialog_body).inner_margin(Tokens::get().space_4);
- Container::show_backing(ui, frame, |ui| {
- crate::ui_kit::scope(ui, |ui| {
- ui.set_max_width(popup_width);
- crate::ui_kit::text(ui, &crate::i18n::format("dialog.dimension_name", &[("name", &e.param)]), crate::ui_kit::Text::Inline)
- .backing_on_hover_text(crate::i18n::tr("dialog.dimension_insert_hint"));
- if !e.owned {
- // The whole value is selected before the field reads its state, every frame
- // until the person takes it over, so typing replaces it (#11204). Only on the
- // first frame was not enough: a frame without the keyboard collapses the
- // field's selection to its caret, and the first digit went in beside the value.
- let n = e.expr.chars().count();
- let mut s = egui::text_edit::TextEditState::load(ui.ctx(), id).unwrap_or_default();
- s.cursor.set_char_range(Some(egui::text_selection::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(n))));
- e.selection = s.cursor.char_range();
- s.store(ui.ctx(), id);
- // A key this frame acts on the whole value (a digit replaces it, Home puts the
- // caret before it); from then on the caret is the person's.
- let focused = ui.memory(|m| m.has_focus(id));
- e.owned = focused && ui.input(|i| i.events.iter().any(|ev| matches!(ev, egui::Event::Key { pressed: true, .. })));
- }
- let r = crate::ui_kit::cell_editor(ui, id, &mut e.expr, "", false);
- // A press into the field puts the caret where it landed; not the press that placed
- // or pinned the value, which began before the box sat there.
- let settled = e.shown == Some(anchor);
- e.owned |= settled && r.hovered() && ui.input(|i| i.pointer.any_pressed());
- crate::theme::TabAccent::number_focus(ui, &r);
- if r.has_focus() {
- e.selection = egui::TextEdit::load_state(ctx, id).and_then(|s| s.cursor.char_range());
- }
- let completed = crate::params_dialog::complete(ui, &r, &mut e.expr);
- if completed {
- e.selection = egui::TextEdit::load_state(ctx, id).and_then(|s| s.cursor.char_range());
- }
- if let Some(live) = e.live.as_mut() {
- live.typed |= r.changed() || completed;
- }
- e.owned |= r.changed() || completed;
- e.typed |= r.changed() || completed;
- // Solved now, so the next frame draws the sketch at the new value from its start.
- if (r.changed() || completed)
- && let Some(draft) = e.draft.as_mut()
- {
- let expr = e.expr.clone();
- reevaluate(app, draft, &expr);
- }
- if let Some(error) = e.draft.as_ref().and_then(|d| d.error.as_ref()) {
- crate::ui_kit::text(ui, error, crate::ui_kit::Text::Report("dimension_error", true));
- }
- let enter = ui.input(|i| i.key_pressed(egui::Key::Enter));
- if r.lost_focus() && enter {
- done = Some(true);
- } else if e.fresh > 0 {
- if !r.has_focus() {
- r.request_focus();
+ Container::new(ctx, Surface::Canvas).area(egui::Id::unique("sc_dim_edit_area")).fixed_pos(anchor).order(egui::Order::Background).show(
+ ctx,
+ |ui| {
+ let frame = Container::popup_frame(ui.style()).fill(Tokens::get().dialog_body).inner_margin(Tokens::get().space_4);
+ Container::show_backing(ui, frame, |ui| {
+ crate::ui_kit::scope(ui, |ui| {
+ ui.set_max_width(popup_width);
+ crate::ui_kit::text(ui, &crate::i18n::format("dialog.dimension_name", &[("name", &e.param)]), crate::ui_kit::Text::Inline)
+ .backing_on_hover_text(crate::i18n::tr("dialog.dimension_insert_hint"));
+ if !e.owned {
+ // The whole value is selected before the field reads its state, every frame
+ // until the person takes it over, so typing replaces it (#11204). Only on the
+ // first frame was not enough: a frame without the keyboard collapses the
+ // field's selection to its caret, and the first digit went in beside the value.
+ let n = e.expr.chars().count();
+ let mut s = egui::text_edit::TextEditState::load(ui.ctx(), id).unwrap_or_default();
+ s.cursor
+ .set_char_range(Some(egui::text_selection::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(n))));
+ e.selection = s.cursor.char_range();
+ s.store(ui.ctx(), id);
+ // A key this frame acts on the whole value (a digit replaces it, Home puts the
+ // caret before it); from then on the caret is the person's.
+ let focused = ui.memory(|m| m.has_focus(id));
+ e.owned = focused && ui.input(|i| i.events.iter().any(|ev| matches!(ev, egui::Event::Key { pressed: true, .. })));
}
- } else if r.lost_focus() {
- done = Some(false);
- }
- if ui.input(|i| i.key_pressed(egui::Key::Escape)) {
- done = Some(false);
- // Esc cancels the whole dimension, picks included.
- escaped = true;
- }
+ let r = crate::ui_kit::cell_editor(ui, id, &mut e.expr, "", false);
+ // A press into the field puts the caret where it landed; not the press that placed
+ // or pinned the value, which began before the box sat there.
+ let settled = e.shown == Some(anchor);
+ e.owned |= settled && r.hovered() && ui.input(|i| i.pointer.any_pressed());
+ crate::theme::TabAccent::number_focus(ui, &r);
+ if r.has_focus() {
+ e.selection = egui::TextEdit::load_state(ctx, id).and_then(|s| s.cursor.char_range());
+ }
+ let completed = crate::params_dialog::complete(ui, &r, &mut e.expr);
+ if completed {
+ e.selection = egui::TextEdit::load_state(ctx, id).and_then(|s| s.cursor.char_range());
+ }
+ if let Some(live) = e.live.as_mut() {
+ live.typed |= r.changed() || completed;
+ }
+ e.owned |= r.changed() || completed;
+ e.typed |= r.changed() || completed;
+ // Solved now, so the next frame draws the sketch at the new value from its start.
+ if (r.changed() || completed)
+ && let Some(draft) = e.draft.as_mut()
+ {
+ let expr = e.expr.clone();
+ reevaluate(app, draft, &expr);
+ }
+ if let Some(error) = e.draft.as_ref().and_then(|d| d.error.as_ref()) {
+ crate::ui_kit::text(ui, error, crate::ui_kit::Text::Report("dimension_error", true));
+ }
+ let enter = ui.input(|i| i.key_pressed(egui::Key::Enter));
+ if r.lost_focus() && enter {
+ done = Some(true);
+ } else if e.fresh > 0 {
+ if !r.has_focus() {
+ r.request_focus();
+ }
+ } else if r.lost_focus() {
+ done = Some(false);
+ }
+ if ui.input(|i| i.key_pressed(egui::Key::Escape)) {
+ done = Some(false);
+ // Esc cancels the whole dimension, picks included.
+ escaped = true;
+ }
+ });
});
- });
- });
+ },
+ );
e.shown = Some(anchor);
settle(app, e, done, escaped);
}
diff --git a/crates/ui-egui/src/dim_view/window.rs b/crates/ui-egui/src/dim_view/window.rs
index 00d68744cb..077ee6d1d1 100644
--- a/crates/ui-egui/src/dim_view/window.rs
+++ b/crates/ui-egui/src/dim_view/window.rs
@@ -101,7 +101,7 @@ thread_local! {
/// Whether the open window is under `p`: the wheel there steps its value, so the camera under it
/// does not zoom (navigation asks).
pub(crate) fn covers(ctx: &egui::Context, p: Pos2) -> bool {
- super::editing() && ctx.memory(|m| m.area_rect(egui::Id::new(AREA))).is_some_and(|r| r.contains(p))
+ super::editing() && ctx.memory(|m| m.area_rect(egui::Id::unique(AREA))).is_some_and(|r| r.contains(p))
}
/// Forget the worked-out value (the edit closed).
@@ -183,13 +183,13 @@ fn place(app: &SolveApp, ctx: &egui::Context, param: &str, at: Pos2, size: egui:
/// the control channel. True when clicked.
fn button(ui: &mut egui::Ui, rect: Rect, key: &str, tip: &str, icon: &str) -> bool {
let t = Tokens::get();
- let response = ui.interact(rect, ui.id().with(key), egui::Sense::click());
+ let response = ui.interact(rect, ui.scope_id().with(key), egui::Sense::click());
if response.hovered() {
ui.painter().rect_filled(rect, t.control_radius, t.hover);
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
crate::icons::paint_icon(ui.painter(), rect.shrink(t.space_4), icon, 1.0);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, tip));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tip));
crate::scenario::publish_target(key, rect);
response.on_hover_text(tip).clicked()
}
@@ -199,8 +199,8 @@ fn button(ui: &mut egui::Ui, rect: Rect, key: &str, tip: &str, icon: &str) -> bo
/// whether a new dimension's picks go too (the cross, Esc), as Esc in the box does.
pub(super) fn show(app: &mut SolveApp, ctx: &egui::Context, e: &mut Edit, at: Pos2) -> (Option<bool>, bool) {
let t = Tokens::get();
- let id = egui::Id::new("sc_dim_edit");
- let area = egui::Id::new(AREA);
+ let id = egui::Id::unique("sc_dim_edit");
+ let area = egui::Id::unique(AREA);
let (kind, error) = match &e.draft {
Some(draft) => (kind(&draft.preview_doc, &e.param), draft.error.clone()),
None => (kind(&app.session.doc, &e.param), existing(app, &e.param, &e.expr).1),
diff --git a/crates/ui-egui/src/dimension_create_ui_tests.rs b/crates/ui-egui/src/dimension_create_ui_tests.rs
index 869b3585ba..a7bda9a1a1 100644
--- a/crates/ui-egui/src/dimension_create_ui_tests.rs
+++ b/crates/ui-egui/src/dimension_create_ui_tests.rs
@@ -23,7 +23,7 @@ fn place(h: &mut Harness, picks: &[[f64; 2]], at: [f64; 2]) {
}
h.step(&json!({"click":{"world":[at[0],at[1],0]}})).unwrap();
assert!(crate::dim_view::editing(), "placement opens an editor");
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
}
fn type_value(h: &mut Harness, text: &str) {
h.step(&json!({"key":"A","cmd":true})).unwrap();
@@ -85,7 +85,7 @@ fn click_d1_and_apply(h: &mut Harness) -> String {
h.step(&json!({"click":{"dimension":"d1"}})).unwrap();
assert!(crate::dim_view::editing(), "a reference click keeps the editor open");
h.frames(2);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")), "the value field keeps the keyboard");
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")), "the value field keeps the keyboard");
h.step(&json!({"key":"Enter"})).unwrap();
assert!(!crate::dim_view::editing(), "{}", h.call("ui.inspect", json!({})));
let expr = h.app.session.doc.param("d2").unwrap().expr.clone();
@@ -165,7 +165,7 @@ fn dimension_tool_click_on_an_existing_dimension_edits_its_value() {
h.step(&json!({"click":{"dimension":"d1"}})).unwrap();
assert!(crate::dim_view::editing(), "a click on the dimension opens its value");
h.frames(5);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")), "the value field takes the keyboard");
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")), "the value field takes the keyboard");
type_value(&mut h, "25");
h.step(&json!({"key":"Enter"})).unwrap();
assert!(!crate::dim_view::editing(), "{}", h.call("ui.inspect", json!({})));
@@ -221,7 +221,7 @@ fn a_new_dimension_in_the_window_steps_previews_and_applies_once() {
h.step(&json!({"click":{"world":[10,6,0]}})).unwrap();
h.frames(3);
assert!(crate::dim_view::editing(), "placing the text opens the window");
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")), "its field takes the keyboard");
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")), "its field takes the keyboard");
let window = crate::scenario::rect_of("dimwin").expect("the window is shown");
let drawable = h.app.viewport.layout.as_ref().unwrap().drawable;
assert!(drawable.contains_rect(window), "the window {window:?} stays in the view {drawable:?}");
@@ -238,7 +238,7 @@ fn a_new_dimension_in_the_window_steps_previews_and_applies_once() {
assert!(crate::scenario::count_of("dimwin:preview_curves").unwrap_or(0.0) > 0.0, "what the value moves is drawn");
assert_eq!(h.app.session.doc.to_json(), original, "nothing reaches the design before OK");
assert_eq!(h.app.session.undo.len(), undo);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")), "the arrows leave the keyboard with the field");
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")), "the arrows leave the keyboard with the field");
// The wheel over the field steps it instead of zooming the view.
let cam = h.app.cam;
let field = crate::scenario::rect_of("dimwin:value").unwrap();
@@ -922,7 +922,7 @@ fn dimension_count(h: &Harness) -> usize {
fn assert_live(h: &Harness) {
assert!(crate::dim_view::editing(), "the pick opens the value at once");
assert_eq!(crate::dim_view::live(), Some(false));
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
}
#[test]
@@ -1298,7 +1298,7 @@ fn type_first_keeps_the_place_first_flow() {
h.step(&json!({"click":{"world":[10,-7,0]}})).unwrap();
assert!(crate::dim_view::editing());
assert_eq!(crate::dim_view::live(), None, "the text is pinned");
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
h.step(&json!({"move":{"world":[0,12,0]}})).unwrap();
keys(&mut h, "18");
h.step(&json!({"key":"Enter"})).unwrap();
@@ -1321,7 +1321,7 @@ fn type_first_keeps_the_place_first_flow() {
assert_eq!(h.app.tool.as_ref().map(|t| t.picks.len()), Some(1));
h.step(&json!({"click":{"world":[10,6,0]}})).unwrap();
assert!(crate::dim_view::editing());
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
keys(&mut h, "21");
h.step(&json!({"key":"Enter"})).unwrap();
let new = added(&h, dims);
@@ -1332,7 +1332,7 @@ fn type_first_keeps_the_place_first_flow() {
/// Put the value field's caret at `at` with nothing selected, as the field itself does when it
/// misses the keyboard for a frame (a WebView2 showed the caret before the value, #11204).
fn caret_without_the_person(h: &Harness, at: usize) {
- let id = egui::Id::new("sc_dim_edit");
+ let id = egui::Id::unique("sc_dim_edit");
let mut state = egui::TextEdit::load_state(&h.ctx, id).unwrap_or_default();
state.cursor.set_char_range(Some(egui::text::CCursorRange::one(egui::text::CCursor::new(at))));
state.store(&h.ctx, id);
@@ -1352,7 +1352,7 @@ fn held_click(h: &mut Harness, at: [f64; 2], frames: usize) {
/// The value field's caret and selection end (characters).
fn caret(h: &Harness) -> Option<(usize, usize)> {
- egui::TextEdit::load_state(&h.ctx, egui::Id::new("sc_dim_edit"))
+ egui::TextEdit::load_state(&h.ctx, egui::Id::unique("sc_dim_edit"))
.and_then(|s| s.cursor.char_range())
.map(|r| (r.primary.index.0, r.secondary.index.0))
}
@@ -1373,7 +1373,7 @@ fn typed_digits_replace_the_proposed_value_whatever_moved_the_caret() {
h.frames(12);
caret_without_the_person(&h, 0);
h.frames(2);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")), "held {held}");
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")), "held {held}");
keys(&mut h, "400");
assert_eq!(crate::dim_view::draft_preview().map(|d| d.0).as_deref(), Some("400"), "held {held}");
h.step(&json!({"key":"Enter"})).unwrap();
@@ -1824,7 +1824,7 @@ fn double_clicking_a_shown_dimension_edits_it_without_editing_the_sketch() {
let at = model_text(&h, "d2");
h.step(&json!({"click":at,"double":true})).unwrap();
assert!(crate::dim_view::editing(), "the double-click opens the value");
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
assert_eq!(h.app.session.active_sketch, None, "the sketch is not edited");
type_value(&mut h, "14");
h.step(&json!({"key":"Enter"})).unwrap();
diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rs
index ed7c19478b..313851b7c9 100644
--- a/crates/ui-egui/src/documents.rs
+++ b/crates/ui-egui/src/documents.rs
@@ -943,7 +943,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
.collect();
let fit_all = shown == n && natural.iter().sum::<f32>() <= x1 - x0 - 34.0;
// A right-click on a tab opens its menu (#3055): the tab and where the menu opens.
- let menu_id = egui::Id::new("sc_doc_tab_menu");
+ let menu_id = egui::Id::unique("sc_doc_tab_menu");
let mut menu: Option<(usize, egui::Pos2)> = ui.ctx().data(|d| d.get_temp(menu_id));
// The shown tabs' widths, in strip order.
let widths: Vec<f32> = (first..first + shown).map(|i| if fit_all { natural.get(i).copied().unwrap_or(w) } else { w }).collect();
@@ -952,7 +952,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
let title_bar = app.custom_titlebar || app.integrated_titlebar;
// A tab being dragged to a new place follows the pointer and the others make room for it;
// Escape puts it back.
- let drag_id = egui::Id::new("sc_doc_tab_drag");
+ let drag_id = egui::Id::unique("sc_doc_tab_drag");
let (held_down, released, escape) = ui.input(|i| (i.pointer.primary_down(), i.pointer.primary_released(), i.key_pressed(egui::Key::Escape)));
let mut drag =
ui.ctx().data(|d| d.get_temp::<TabDrag>(drag_id)).filter(|d| (held_down || released) && !escape && (first..first + shown).contains(&d.from));
@@ -985,7 +985,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
};
let tr = Rect::from_min_size(pos2(left, r.top() + 4.0), vec2(w - 2.0, r.height() - 8.0));
let active = !app.home.open && (i == app.docs.active || app.docs.slots.is_empty());
- let resp = ui.interact(tr, ui.id().with(("doc_tab", i)), Sense::click_and_drag());
+ let resp = ui.interact(tr, ui.scope_id().with(("doc_tab", i)), Sense::click_and_drag());
crate::scenario::publish_target(&format!("tab:design:{i}"), tr);
// Dragging a tab along the strip moves it. The tabs are also part of the title bar:
// dragging the only tab, or one mostly up or down, moves the window, and a double click
@@ -1028,7 +1028,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
// ×
let xr = Rect::from_center_size(pos2(tr.right() - 13.0, tr.center().y), vec2(16.0, 16.0));
let show_close = active || resp.hovered() || ui.rect_contains_pointer(tr);
- let xresp = ui.interact(xr, ui.id().with(("doc_close", i)), if show_close { Sense::click() } else { Sense::hover() });
+ let xresp = ui.interact(xr, ui.scope_id().with(("doc_close", i)), if show_close { Sense::click() } else { Sense::hover() });
crate::scenario::publish_target(&format!("tab:close:{i}"), xr);
if show_close && (xresp.hovered() || xresp.has_focus()) {
ui.painter().rect_filled(xr, t.radius_sm.saturating_sub(1), t.app_bar_hover_strong);
@@ -1044,6 +1044,8 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
if resp.secondary_clicked() {
menu = Some((i, ui.ctx().pointer_interact_pos().unwrap_or(tr.left_bottom())));
}
+ // Named apart from a dialog's Close: egui 0.37 names an unnamed widget after its tooltip.
+ xresp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, show_close, crate::i18n::tr("ui.close_tab")));
if xresp.backing_on_hover_text("Close").clicked() {
shut = Some(i);
} else if (if held.is_some() { resp } else { resp.backing_on_hover_text(tip) }).clicked() {
@@ -1060,7 +1062,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
// More tabs than fit: a chevron lists them all.
if shown < n {
let mr = Rect::from_center_size(pos2(x + 12.0, r.center().y), vec2(20.0, 22.0));
- let mresp = ui.interact(mr, ui.id().with("doc_more"), Sense::click());
+ let mresp = ui.interact(mr, ui.scope_id().with("doc_more"), Sense::click());
crate::scenario::publish_handle("tab:overflow", mr.center());
if mresp.hovered() {
ui.painter().rect_filled(mr, t.radius_sm, t.app_bar_hover_button);
@@ -1072,7 +1074,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
FontId::proportional(crate::theme::Tokens::get().font_body),
t.app_bar_text,
);
- let id = egui::Id::new("sc_doc_more");
+ let id = egui::Id::unique("sc_doc_more");
if mresp.clone().backing_on_hover_text(crate::i18n::tr_label("All open designs")).clicked() {
ui.ctx().data_mut(|d| d.insert_temp(id, !d.get_temp::<bool>(id).unwrap_or(false)));
}
@@ -1142,7 +1144,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
});
// Choose a new design, open or sample from the File view before creating a tab.
let pr = Rect::from_center_size(pos2(x + 14.0, r.center().y), vec2(22.0, 22.0));
- let presp = ui.interact(pr, ui.id().with("doc_new"), Sense::click());
+ let presp = ui.interact(pr, ui.scope_id().with("doc_new"), Sense::click());
if presp.hovered() {
ui.painter().rect_filled(pr, t.radius_sm, t.app_bar_hover_button);
}
@@ -1260,7 +1262,7 @@ pub fn prompt(app: &mut SolveApp, ctx: &egui::Context) {
answer = Some(choice);
}
let title = crate::i18n::format("document.save_changes", &[("name", &name_display)]);
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_close_prompt"), "status_warning", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_close_prompt"), "status_warning", &title)
.tone(ui_kit::Tone::Warning)
.actions(crate::i18n::tr("ui.save"), crate::i18n::tr("ui.cancel"), Some(crate::i18n::tr("ui.don_t_save")))
.secondary_left()
diff --git a/crates/ui-egui/src/easyprint_ui.rs b/crates/ui-egui/src/easyprint_ui.rs
index 5bd9bad80c..b92492c6bb 100644
--- a/crates/ui-egui/src/easyprint_ui.rs
+++ b/crates/ui-egui/src/easyprint_ui.rs
@@ -108,11 +108,12 @@ pub fn tick(app: &mut SolveApp, ctx: &egui::Context) {
pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let Some(params) = app.easyprint.ask.clone() else { return };
let _language = crate::i18n::scope(&app.preferences.language);
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_easyprint_confirm"), "mesh_export", crate::i18n::tr_label("Open with EasyPrint"))
- .actions("Upload", "Cancel", None)
- .show(ctx, true, |ui| {
- ui_kit::text(ui, crate::i18n::tr("ui.easyprint_consent"), ui_kit::Text::Report("easyprint_consent", false));
- });
+ let (closed, action) =
+ ui_kit::Confirm::new(egui::Id::unique("sc_easyprint_confirm"), "mesh_export", crate::i18n::tr_label("Open with EasyPrint"))
+ .actions("Upload", "Cancel", None)
+ .show(ctx, true, |ui| {
+ ui_kit::text(ui, crate::i18n::tr("ui.easyprint_consent"), ui_kit::Text::Report("easyprint_consent", false));
+ });
match action {
ui_kit::Action::Ok => {
app.easyprint.ask = None;
diff --git a/crates/ui-egui/src/edit_clipboard_tests.rs b/crates/ui-egui/src/edit_clipboard_tests.rs
index e8202c6acb..a3c036dda7 100644
--- a/crates/ui-egui/src/edit_clipboard_tests.rs
+++ b/crates/ui-egui/src/edit_clipboard_tests.rs
@@ -50,7 +50,7 @@ fn start(h: &Harness, id: &str) -> Vec2 {
}
fn clipboard_frame(h: &mut Harness, ctx: &egui::Context, events: Vec<egui::Event>) {
- let _ = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| super::handle(&mut h.app, ui.ctx()));
+ ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| super::handle(&mut h.app, ui.ctx())).textures_delta.clear();
}
fn middle_button(pressed: bool) -> egui::Event {
diff --git a/crates/ui-egui/src/expression_complete.rs b/crates/ui-egui/src/expression_complete.rs
index cafdf46abb..2446ca4b50 100644
--- a/crates/ui-egui/src/expression_complete.rs
+++ b/crates/ui-egui/src/expression_complete.rs
@@ -43,7 +43,7 @@ struct Popup {
}
fn popup_id() -> egui::Id {
- egui::Id::new("expression_completion_keyboard")
+ egui::Id::unique("expression_completion_keyboard")
}
/// Run before any TextEdit or viewport shortcuts. Only the focused, recently drawn popup
@@ -322,7 +322,7 @@ mod tests {
app.run("parameters.add", json!({"name":name,"expression":format!("{value} mm")})).unwrap();
}
params_dialog::publish(&mut app, &ctx);
- let id = egui::Id::new("completion_test_editor");
+ let id = egui::Id::unique("completion_test_editor");
ctx.memory_mut(|m| m.request_focus(id));
let mut editor = Self { ctx, app, text: text.into(), id, accepted: false, leaked: Vec::new() };
editor.frame(Vec::new());
@@ -399,7 +399,7 @@ mod tests {
let long = "Driver_MountHole_to_Cover_Shared_Base_Layout_Angle";
app.run("parameters.add", json!({"name": long, "expression": "8 deg"})).unwrap();
params_dialog::publish(&mut app, &ctx);
- let id = egui::Id::new("long_name_completion");
+ let id = egui::Id::unique("long_name_completion");
ctx.memory_mut(|m| m.request_focus(id));
let mut text = "Driver".to_string();
let mut output = ctx.run_ui(
diff --git a/crates/ui-egui/src/extrude_edit_tests.rs b/crates/ui-egui/src/extrude_edit_tests.rs
index 66707fc2a3..85ee2ba167 100644
--- a/crates/ui-egui/src/extrude_edit_tests.rs
+++ b/crates/ui-egui/src/extrude_edit_tests.rs
@@ -378,7 +378,7 @@ fn rotated_second_occurrence_keeps_saved_from_and_to_points_exact() {
fn dragging_to_update_value_reselects_whole_value_box_text() {
let mut h = make(json!({"distance":"4 mm"}));
open(&mut h);
- let id = egui::Id::new("sc_canvas_value");
+ let id = egui::Id::unique("sc_canvas_value");
let selection = |h: &Harness| {
let range = egui::text_edit::TextEditState::load(&h.ctx, id).unwrap().cursor.char_range().unwrap();
let (a, b) = (range.primary.index, range.secondary.index);
@@ -604,15 +604,15 @@ fn without_value_boxes_in_the_view_the_distance_is_typed_in_the_window() {
let mut h = make(json!({"distance":"4 mm"}));
h.app.preferences.value_boxes_in_view = false;
open(&mut h);
- assert!(h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).is_none(), "a value box in the view");
+ assert!(h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).is_none(), "a value box in the view");
let focused = h.ctx.memory(|m| m.focused());
- assert!(focused.is_some() && focused != Some(egui::Id::new("sc_canvas_value")), "{focused:?}");
+ assert!(focused.is_some() && focused != Some(egui::Id::unique("sc_canvas_value")), "{focused:?}");
h.step(&json!({"text":"25 mm"})).unwrap();
h.frames(2);
assert!((dialog_distance(&h) - 25.0).abs() < 1e-9, "{}", dialog_distance(&h));
h.step(&json!({"drag":[{"handle":"arrow"},on_arrow(&h, 30.0)]})).unwrap();
assert!((dialog_distance(&h) - 30.0).abs() < 0.5, "{}", dialog_distance(&h));
- assert!(h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).is_none(), "a value box in the view");
+ assert!(h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).is_none(), "a value box in the view");
}
#[test]
diff --git a/crates/ui-egui/src/file_load.rs b/crates/ui-egui/src/file_load.rs
index efc53d4fb5..95e68c8d2c 100644
--- a/crates/ui-egui/src/file_load.rs
+++ b/crates/ui-egui/src/file_load.rs
@@ -1261,14 +1261,14 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
m.surrender_focus(id);
}
});
- let id = egui::Id::new("file_loading");
+ let id = egui::Id::unique("file_loading");
let card_id = id.with("card");
// Above the dialogs over the design; menus, tooltips and the resize edges stay above it.
ctx.move_to_top(egui::LayerId::new(egui::Order::Middle, id));
ctx.move_to_top(egui::LayerId::new(egui::Order::Middle, card_id));
Container::new(ctx, Surface::InputShield).area(id).order(egui::Order::Middle).fixed_pos(cover.min).interactable(true).show(ctx, |ui| {
ui.set_min_size(cover.size());
- ui.interact(cover, egui::Id::new("file_loading_block"), egui::Sense::click_and_drag());
+ ui.interact(cover, egui::Id::unique("file_loading_block"), egui::Sense::click_and_drag());
let shield = Container::new(ctx, Surface::InputShield);
shield.paint_background(ui.painter(), shield.frame(ctx, egui::Color32::from_black_alpha(70), crate::frame::Side::Left), cover);
});
diff --git a/crates/ui-egui/src/file_picker.rs b/crates/ui-egui/src/file_picker.rs
index 8faebac430..78ca176824 100644
--- a/crates/ui-egui/src/file_picker.rs
+++ b/crates/ui-egui/src/file_picker.rs
@@ -527,10 +527,11 @@ mod tests {
_ => false,
}
}
- let out = h.ctx.run_ui(
+ let mut out = h.ctx.run_ui(
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() },
|ui| h.app.ui(ui),
);
+ out.textures_delta.clear();
out.shapes.iter().any(|shape| contains(&shape.shape, hint))
}
diff --git a/crates/ui-egui/src/fonts.rs b/crates/ui-egui/src/fonts.rs
index 300f877e23..67e2f5dc1f 100644
--- a/crates/ui-egui/src/fonts.rs
+++ b/crates/ui-egui/src/fonts.rs
@@ -84,7 +84,7 @@ impl RichTextExt for RichText {
// Keep pending definitions too: set_fonts takes effect on the next frame, while the web
// fetch and preference update can both finish before that frame starts.
fn installed_fonts_id() -> egui::Id {
- egui::Id::new("solidcraft_interface_fonts")
+ egui::Id::unique("solidcraft_interface_fonts")
}
fn install(ctx: &egui::Context, fonts: FontDefinitions) {
@@ -1089,7 +1089,7 @@ mod tests {
fonts.families[&egui::FontFamily::Proportional]
.iter()
.filter_map(|name| fonts.font_data.get(name))
- .any(|data| ttf_parser::Face::parse(&data.font, data.index).unwrap().glyph_index(c).is_some())
+ .any(|data| ttf_parser::Face::parse(data.bytes(), data.index).unwrap().glyph_index(c).is_some())
}
/// The symbols the built-in Latin faces lack draw through the built-in Hack (#2955), which
@@ -1146,14 +1146,14 @@ mod tests {
assert_eq!(list[0], name);
assert_eq!(&list[1..], defaults.families[&FontFamily::Proportional]);
let data = &fonts.font_data[name];
- assert_eq!(data.font.as_ref(), PLEX_SANS);
+ assert_eq!(data.bytes(), PLEX_SANS);
assert_eq!(data.tweak.coords.as_ref()[0].1, weight);
assert!(data.variation_axes().iter().any(|a| a.tag == *b"wght"));
}
let mono = &fonts.families[&FontFamily::Monospace];
assert_eq!(mono[0], "plex-mono");
assert_eq!(&mono[1..], defaults.families[&FontFamily::Monospace]);
- assert_eq!(fonts.font_data["plex-mono"].font.as_ref(), PLEX_MONO);
+ assert_eq!(fonts.font_data["plex-mono"].bytes(), PLEX_MONO);
}
#[test]
@@ -1239,7 +1239,7 @@ mod tests {
fn latin_font_bytes() -> Vec<u8> {
let defaults = base_font_definitions();
let name = &defaults.families[&egui::FontFamily::Proportional][0];
- defaults.font_data[name].font.to_vec()
+ defaults.font_data[name].bytes().to_vec()
}
#[test]
diff --git a/crates/ui-egui/src/frame.rs b/crates/ui-egui/src/frame.rs
index 3035271a5a..9b20235272 100644
--- a/crates/ui-egui/src/frame.rs
+++ b/crates/ui-egui/src/frame.rs
@@ -33,14 +33,14 @@ impl Side {
/// How far a docked panel with this key was dragged.
pub fn dock_offset(ctx: &egui::Context, key: &str) -> egui::Vec2 {
- ctx.data(|d| d.get_temp::<egui::Vec2>(egui::Id::new(("sc_dock_offset", key)))).unwrap_or(egui::Vec2::ZERO)
+ ctx.data(|d| d.get_temp::<egui::Vec2>(egui::Id::unique(("sc_dock_offset", key)))).unwrap_or(egui::Vec2::ZERO)
}
/// A title drag owns the pointer even when it outruns the dialog's previous position.
pub(crate) fn dock_dragging(ctx: &egui::Context) -> bool {
let frame = ctx.cumulative_frame_nr();
// The viewport can draw before the dialog, so retain the preceding frame's marker.
- ctx.data(|d| d.get_temp::<u64>(egui::Id::new("sc_dock_drag_frame"))).is_some_and(|at| at >= frame.saturating_sub(1))
+ ctx.data(|d| d.get_temp::<u64>(egui::Id::unique("sc_dock_drag_frame"))).is_some_and(|at| at >= frame.saturating_sub(1))
&& ctx.input(|i| i.pointer.any_down())
}
@@ -62,14 +62,14 @@ pub fn offset_anchor(docked: Pos2, offset: egui::Vec2, vp: egui::Rect, side: Sid
/// it on screen). Called before the band's buttons are added, so they keep their clicks.
pub fn drag_dock(ui: &Ui, band: egui::Rect, key: &str, moved: egui::Vec2, applied: egui::Vec2) {
crate::scenario::publish_handle("dialog:title", band.center());
- let response = ui.interact(band, ui.id().with("sc_dock_drag"), egui::Sense::drag());
+ let response = ui.interact(band, ui.scope_id().with("sc_dock_drag"), egui::Sense::drag());
if response.dragged() {
let frame = ui.ctx().cumulative_frame_nr();
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_dock_drag_frame"), frame));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_dock_drag_frame"), frame));
}
// The drag runs from where the press started, so no movement is lost while egui decides
// it is a drag, nor on the frame it ends.
- let base = egui::Id::new("sc_dock_drag_base");
+ let base = egui::Id::unique("sc_dock_drag_base");
if response.drag_started()
&& let Some(origin) = ui.input(|i| i.pointer.press_origin())
{
@@ -82,12 +82,12 @@ pub fn drag_dock(ui: &Ui, band: egui::Rect, key: &str, moved: egui::Vec2, applie
(Some((start, from)), Some(now)) => start + (now - from),
_ => applied + response.drag_delta(),
};
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new(("sc_dock_offset", key)), to));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique(("sc_dock_offset", key)), to));
} else if response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::Grab);
} else if moved != applied {
// Kept on screen: remember where it is, not where it was dragged off to.
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new(("sc_dock_offset", key)), applied));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique(("sc_dock_offset", key)), applied));
}
}
@@ -174,7 +174,7 @@ mod tests {
h.step(&json!({"start": "parameters.change"})).unwrap();
h.frames(6);
let title = crate::scenario::handle_at("dialog:title").unwrap();
- assert!(!h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_params_dialog"))).unwrap().contains(p));
+ assert!(!h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_params_dialog"))).unwrap().contains(p));
h.call("ui.move", json!({"x": title.x, "y": title.y}));
h.app.synthetic.push(egui::Event::PointerButton {
pos: title,
@@ -186,7 +186,7 @@ mod tests {
h.app.synthetic.push(egui::Event::PointerMoved(p));
h.frame();
assert!(h.ctx.dragged_id().is_some(), "the title must own the drag");
- assert!(!h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_params_dialog"))).unwrap().contains(p), "the pointer must outrun the dialog");
+ assert!(!h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_params_dialog"))).unwrap().contains(p), "the pointer must outrun the dialog");
assert!(h.app.viewport.hover.is_none(), "dragging a dialog must block model highlights");
assert!(h.app.viewport.mouse.is_none(), "the viewport must not receive the drag pointer");
h.frames(2);
diff --git a/crates/ui-egui/src/frame_rate.rs b/crates/ui-egui/src/frame_rate.rs
index 0321697481..a45feb1268 100644
--- a/crates/ui-egui/src/frame_rate.rs
+++ b/crates/ui-egui/src/frame_rate.rs
@@ -192,7 +192,7 @@ pub(crate) fn paint(app: &mut SolveApp, ui: &egui::Ui, painter: &egui::Painter,
{
r = r.translate(vec2(0.0, nav.top() - 6.0 - r.bottom()));
}
- let id = egui::Id::new("sc_frame_rate");
+ let id = egui::Id::unique("sc_frame_rate");
let clicked = ui.interact(r, id, Sense::click()).backing_on_hover_text(tr("perf.click_for_details")).clicked();
if clicked {
app.preferences.frame_rate_details = !app.preferences.frame_rate_details;
diff --git a/crates/ui-egui/src/gpu.rs b/crates/ui-egui/src/gpu.rs
index d5a9a1e6d5..436a4b18d2 100644
--- a/crates/ui-egui/src/gpu.rs
+++ b/crates/ui-egui/src/gpu.rs
@@ -64,7 +64,7 @@ pub(crate) fn paint_background_picture(app: &mut crate::SolveApp, painter: &egui
return;
}
let ctx = painter.ctx().clone();
- let id = egui::Id::new("sc_background_picture");
+ let id = egui::Id::unique("sc_background_picture");
let mut picture = ctx.data(|d| d.get_temp::<BackgroundPicture>(id)).filter(|p| p.path == *path).unwrap_or_else(|| {
let picture = BackgroundPicture { path: path.clone(), decoded: Default::default(), texture: None };
let (path, slot, repaint) = (path.clone(), picture.decoded.clone(), ctx.clone());
@@ -829,7 +829,7 @@ mod tests {
time += 0.023;
let mut raw = egui::RawInput { time: Some(time), ..Default::default() };
raw.viewports.entry(egui::ViewportId::ROOT).or_default().occluded = Some(!visible);
- let _ = ctx.run_ui(raw, |ui| {
+ ctx.run_ui(raw, |ui| {
ui.ctx().request_repaint(); // Deterministic harness only; product never does this for sampling.
let paint = rendered.then(|| crate::blur::PaintedFrame {
frame: ui.ctx().cumulative_frame_nr().saturating_sub(1),
@@ -838,7 +838,9 @@ mod tests {
});
session.sample(ui.ctx(), revision, radius, available, paint);
session.sample(ui.ctx(), revision, radius, available, paint); // egui re-pass duplicate
- });
+ })
+ .textures_delta
+ .clear();
};
feed(&mut session, false, true, true, true, 1, 40.0);
feed(&mut session, false, true, true, true, 1, 40.0);
@@ -1250,7 +1252,7 @@ mod tests {
.is_some_and(|shape| matches!(shape, egui::Shape::Rect(_))),
"backing precedes native popup chrome"
);
- assert!(ctx.memory(|m| m.has_focus(egui::Id::new("blur_picker").with("search"))), "native search focus survives hover");
+ assert!(ctx.memory(|m| m.has_focus(egui::Id::unique("blur_picker").with("search"))), "native search focus survives hover");
}
}
diff --git a/crates/ui-egui/src/help.rs b/crates/ui-egui/src/help.rs
index 6de7e260c5..c4cc329ddd 100644
--- a/crates/ui-egui/src/help.rs
+++ b/crates/ui-egui/src/help.rs
@@ -106,7 +106,7 @@ fn connect(app: &mut SolveApp, ctx: &egui::Context) {
let Some(lines) = app.help.connect.clone() else {
return;
};
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_connect_assistants"), "help", crate::i18n::tr_label("Connect AI assistants"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_connect_assistants"), "help", crate::i18n::tr_label("Connect AI assistants"))
.cards(2.0)
.actions("", "Close", None)
.show(ctx, true, |ui| {
@@ -127,7 +127,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context, anchor: egui::Pos2) {
if app.help.menu {
let mut pick: Option<&str> = None;
let resp = Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_help_menu"))
+ .area(egui::Id::unique("sc_help_menu"))
.fixed_pos(anchor)
.constrain(true)
.order(egui::Order::Foreground)
@@ -165,11 +165,11 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context, anchor: egui::Pos2) {
run(app, ctx, p);
} else if ctx.input(|i| i.pointer.any_pressed() || i.key_pressed(egui::Key::Escape)) && !resp.response.contains_pointer() {
// Pressed elsewhere (the ? button toggles it itself).
- if !ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_help_opened")).unwrap_or(false)) {
+ if !ctx.data(|d| d.get_temp::<bool>(egui::Id::unique("sc_help_opened")).unwrap_or(false)) {
app.help.menu = false;
}
}
- ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_help_opened"), false));
+ ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_help_opened"), false));
}
about(app, ctx);
connect(app, ctx);
@@ -181,7 +181,7 @@ fn about(app: &mut SolveApp, ctx: &egui::Context) {
if !app.help.about {
return;
}
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_about"), "help", crate::i18n::tr_label("About SolidCraft"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_about"), "help", crate::i18n::tr_label("About SolidCraft"))
.cards(2.0)
.actions("", "Close", None)
.show(ctx, true, |ui| {
diff --git a/crates/ui-egui/src/hole_place.rs b/crates/ui-egui/src/hole_place.rs
index d89a20b29e..d2eb756217 100644
--- a/crates/ui-egui/src/hole_place.rs
+++ b/crates/ui-egui/src/hole_place.rs
@@ -278,7 +278,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painte
let mut removed: Option<usize> = None;
for (n, (i, at)) in places.into_iter().enumerate() {
let Some(mut c) = proj.to_screen(at) else { continue };
- let id = egui::Id::new(("sc_hole_place", i));
+ let id = egui::Id::unique(("sc_hole_place", i));
let r = ui.interact(egui::Rect::from_center_size(c, vec2(2.0 * HANDLE_REACH, 2.0 * HANDLE_REACH)), id, egui::Sense::click_and_drag());
// A click on the hole takes it out, as a pick of a picked face does.
if r.clicked() {
diff --git a/crates/ui-egui/src/hole_presets.rs b/crates/ui-egui/src/hole_presets.rs
index f6807d03a4..3fedaeb0fd 100644
--- a/crates/ui-egui/src/hole_presets.rs
+++ b/crates/ui-egui/src/hole_presets.rs
@@ -422,7 +422,7 @@ pub(crate) fn rows(ui: &mut egui::Ui, d: &mut Dialog, library: &mut Library, doc
if !matches!(d.kind, Kind::Hole { .. }) {
return;
}
- let id = egui::Id::new("personal_hole_presets_panel");
+ let id = egui::Id::unique("personal_hole_presets_panel");
let mut state = if reset { PanelState::default() } else { ui.ctx().data_mut(|data| data.get_temp::<PanelState>(id)).unwrap_or_default() };
ui_kit::section(ui, "personal_hole_presets", "hole_presets.title", false, |ui| {
ui.label(tr("hole_presets.scope"));
@@ -454,7 +454,7 @@ pub(crate) fn rows(ui: &mut egui::Ui, d: &mut Dialog, library: &mut Library, doc
}
});
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::ComboBox, ui.is_enabled(), tr("hole_presets.preset"));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::ComboBox, ui.is_enabled(), tr("hole_presets.preset"));
info.current_text_value = Some(display.clone());
info
});
@@ -521,7 +521,9 @@ pub(crate) fn rows(ui: &mut egui::Ui, d: &mut Dialog, library: &mut Library, doc
/// when Escape has already blurred its text field. Stale state cannot block other tools.
pub(crate) fn name_prompt_open(ctx: &egui::Context, dialog: Option<&Dialog>) -> bool {
dialog.is_some_and(|d| matches!(&d.kind, Kind::Hole { .. }))
- && ctx.data_mut(|data| data.get_temp::<PanelState>(egui::Id::new("personal_hole_presets_panel"))).is_some_and(|state| state.prompt.is_some())
+ && ctx
+ .data_mut(|data| data.get_temp::<PanelState>(egui::Id::unique("personal_hole_presets_panel")))
+ .is_some_and(|state| state.prompt.is_some())
}
/// Draw after the Hole card so the modal owns input and its footer handles. `true` also
@@ -530,11 +532,11 @@ pub(crate) fn name_prompt(ctx: &egui::Context, d: &mut Dialog, library: &mut Lib
if !matches!(d.kind, Kind::Hole { .. }) {
return false;
}
- let id = egui::Id::new("personal_hole_presets_panel");
+ let id = egui::Id::unique("personal_hole_presets_panel");
let mut state = ctx.data_mut(|data| data.get_temp::<PanelState>(id)).unwrap_or_default();
let Some(mut prompt) = state.prompt.take() else { return false };
let title = tr(if prompt.renaming { "hole_presets.rename" } else { "hole_presets.save" });
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("personal_hole_preset_name"), "save", title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("personal_hole_preset_name"), "save", title)
.actions(if prompt.renaming { tr("hole_presets.rename") } else { crate::i18n::tr_label("Save") }, "Cancel", None)
.show(ctx, true, |ui| {
ui_kit::row(ui, "hole_presets.name", |ui| ui_kit::focused_text_field(ui, &mut prompt.name, tr("hole_presets.name_hint")));
diff --git a/crates/ui-egui/src/hole_refs.rs b/crates/ui-egui/src/hole_refs.rs
index 833517436f..157d21c48f 100644
--- a/crates/ui-egui/src/hole_refs.rs
+++ b/crates/ui-egui/src/hole_refs.rs
@@ -413,7 +413,7 @@ pub(crate) fn canvas(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter,
let at = box_beyond(a, b);
let r = crate::canvas::value_box_in(
ui,
- (egui::Id::new(("sc_hole_ref_area", *k)), egui::Id::new(("sc_hole_ref", *k))),
+ (egui::Id::unique(("sc_hole_ref_area", *k)), egui::Id::unique(("sc_hole_ref", *k))),
label,
value,
at,
diff --git a/crates/ui-egui/src/hole_refs_ui_tests.rs b/crates/ui-egui/src/hole_refs_ui_tests.rs
index 3361ea2ec8..08d91bc358 100644
--- a/crates/ui-egui/src/hole_refs_ui_tests.rs
+++ b/crates/ui-egui/src/hole_refs_ui_tests.rs
@@ -227,7 +227,7 @@ fn without_value_boxes_a_number_typed_after_an_edge_pick_sets_its_distance() {
let left = screen(&mut h, Vec3::new(0.0, 20.0, 10.0));
h.step(&json!({"click": left})).unwrap();
h.frames(2);
- assert!(h.ctx.memory(|m| m.area_rect(egui::Id::new(("sc_hole_ref_area", 0usize)))).is_none(), "a distance box in the view");
+ assert!(h.ctx.memory(|m| m.area_rect(egui::Id::unique(("sc_hole_ref_area", 0usize)))).is_none(), "a distance box in the view");
h.step(&json!({"text": "7 mm"})).unwrap();
h.frames(2);
assert_eq!(distances(&h)[0], "7 mm");
@@ -367,7 +367,7 @@ fn a_pick_field_clicked_into_waits_for_its_pick_and_says_what_it_takes() {
/// nothing leaves the field waiting and the note shown. A new note scrolls into view once.
#[test]
fn a_pick_fields_note_goes_with_a_value_field_or_a_marquee_that_takes_something() {
- let note_shown = egui::Id::new("sc_dialog_pick_refused_shown");
+ let note_shown = egui::Id::unique("sc_dialog_pick_refused_shown");
let mut h = plate();
h.step(&json!({"start": "solid.cylinder"})).unwrap();
h.frames(2);
diff --git a/crates/ui-egui/src/home.rs b/crates/ui-egui/src/home.rs
index 574b6dccf4..a39295ec63 100644
--- a/crates/ui-egui/src/home.rs
+++ b/crates/ui-egui/src/home.rs
@@ -624,13 +624,13 @@ enum FileAction {
/// File view replaces the workspace while keeping the open design and its history intact.
pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
poll(app, ui.ctx());
- let file_menu_open = ui.ctx().data(|data| data.get_temp::<bool>(egui::Id::new("sc_file_menu"))).unwrap_or(false);
+ let file_menu_open = ui.ctx().data(|data| data.get_temp::<bool>(egui::Id::unique("sc_file_menu"))).unwrap_or(false);
let interactive = !app.file_picker_busy() && !app.file_load.busy() && !file_menu_open;
// Help windows draw before Home; remember their prior visibility so one Escape closes only the window.
let had_help_window = ui.ctx().memory(|memory| {
["sc_about", "sc_crash_reports"]
.iter()
- .any(|id| memory.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::new(id))))
+ .any(|id| memory.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::unique(id))))
});
if interactive
@@ -1503,7 +1503,7 @@ mod tests {
h.call("ui.click", serde_json::json!({"x": gear.x, "y": gear.y}));
assert!(h.app.prefs_window.open && h.app.home.open);
let shown = |h: &crate::scenario::Harness| {
- h.ctx.memory(|m| m.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::new("sc_prefs"))))
+ h.ctx.memory(|m| m.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::unique("sc_prefs"))))
};
assert!(shown(&h), "the Preferences window must be drawn on Home");
h.call("ui.prefs", serde_json::json!({"button": "cancel"}));
diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs
index 3478838e9e..3732cbdaf6 100644
--- a/crates/ui-egui/src/icons.rs
+++ b/crates/ui-egui/src/icons.rs
@@ -34,7 +34,7 @@ struct Cache(Arc<Mutex<CacheEntries>>);
/// Drop rasterised icon textures so the next paint uploads them again (wake from sleep, #8749).
pub(crate) fn clear_texture_cache(ctx: &egui::Context) {
- let cache = ctx.data_mut(|d| d.get_temp_mut_or_insert_with(egui::Id::new("sc_icon_cache"), Cache::default).clone());
+ let cache = ctx.data_mut(|d| d.get_temp_mut_or_insert_with(egui::Id::unique("sc_icon_cache"), Cache::default).clone());
if let Ok(mut entries) = cache.0.lock() {
entries.textures.clear();
}
@@ -118,7 +118,7 @@ fn paint_resolved(p: &Painter, r: Rect, resolved: icon_svg::Resolved, look: Look
let ppp = ctx.pixels_per_point().max(0.5);
let side = r.width().min(r.height());
let px = (side * ppp).round().clamp(8.0, 512.0) as u32;
- let cache = ctx.data_mut(|d| d.get_temp_mut_or_insert_with(egui::Id::new("sc_icon_cache"), Cache::default).clone());
+ let cache = ctx.data_mut(|d| d.get_temp_mut_or_insert_with(egui::Id::unique("sc_icon_cache"), Cache::default).clone());
let Ok(mut entries) = cache.0.lock() else { return };
let palette = crate::theme::Tokens::get().icon_palette;
if entries.palette != palette {
diff --git a/crates/ui-egui/src/insert_handles.rs b/crates/ui-egui/src/insert_handles.rs
index a941e6462f..4b457c3ae0 100644
--- a/crates/ui-egui/src/insert_handles.rs
+++ b/crates/ui-egui/src/insert_handles.rs
@@ -108,7 +108,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui, proj: &Proj) {
}
parts.push((egui::Rect::from_center_size(knob, Screen::splat(HANDLE * 3.0)), Part::Turn, egui::CursorIcon::Crosshair));
for (i, (rect, part, cursor)) in parts.into_iter().enumerate() {
- let response = ui.interact(rect, egui::Id::new(("sc_insert_handle", i)), Sense::drag()).on_hover_cursor(cursor);
+ let response = ui.interact(rect, egui::Id::unique(("sc_insert_handle", i)), Sense::drag()).on_hover_cursor(cursor);
crate::scenario::publish_handle(&format!("insert:handle:{i}"), rect.center());
if response.drag_started()
&& let Some(from) = response.interact_pointer_pos().and_then(|p| pointer_on_sketch(&plane, proj, p))
diff --git a/crates/ui-egui/src/install.rs b/crates/ui-egui/src/install.rs
index d9454d652d..dd53b9eae2 100644
--- a/crates/ui-egui/src/install.rs
+++ b/crates/ui-egui/src/install.rs
@@ -88,7 +88,7 @@ pub fn start(app: &mut SolveApp, offer: Offer) {
pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let Some(steps) = app.install_steps else { return };
let (lines, after) = steps.messages();
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_install_steps"), "web", crate::i18n::tr("install.title"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_install_steps"), "web", crate::i18n::tr("install.title"))
.actions("", crate::i18n::tr("install.done"), None)
.show(ctx, true, |ui| {
ui_kit::text(ui, crate::i18n::tr("install.steps_intro"), ui_kit::Text::Report("intro", false));
@@ -121,7 +121,7 @@ mod tests {
/// Open the File menu and look for Install app….
fn file_menu_item(h: &mut Harness) -> bool {
- h.ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu"), true));
+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_file_menu"), true));
h.frames(2);
h.widget(crate::i18n::tr(ITEM)).is_some()
}
diff --git a/crates/ui-egui/src/issue_report.rs b/crates/ui-egui/src/issue_report.rs
index 3a0e1818ef..a9afb01267 100644
--- a/crates/ui-egui/src/issue_report.rs
+++ b/crates/ui-egui/src/issue_report.rs
@@ -809,7 +809,7 @@ pub(crate) fn hold_input(app: &mut SolveApp, raw: &mut egui::RawInput) {
}
/// What [`hold_input`] keeps for the form.
-fn typing(event: &egui::Event) -> bool {
+pub(crate) fn typing(event: &egui::Event) -> bool {
matches!(
event,
egui::Event::Text(_) | egui::Event::Key { .. } | egui::Event::Paste(_) | egui::Event::Copy | egui::Event::Cut | egui::Event::Ime(_)
@@ -961,8 +961,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
crate::dim_view::drag_end();
crate::sketch3d::drag_end();
crate::drag_snap::clear();
- crate::gizmo::cancel(ctx, egui::Id::new("sc_move_triad"));
- crate::gizmo::cancel(ctx, egui::Id::new("sc_occ_triad"));
+ crate::gizmo::cancel(ctx, egui::Id::unique("sc_move_triad"));
+ crate::gizmo::cancel(ctx, egui::Id::unique("sc_occ_triad"));
if let Some(focus) = app.issue_report.cad_focus.take() {
ctx.memory_mut(|m| m.request_focus(focus));
}
@@ -1167,7 +1167,7 @@ mod tests {
h.app.home.open = false;
h.app.issue_report.draft = Some(draft_for(&h.app, None, None));
h.frames(16);
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("issue_report_body")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("issue_report_body")));
h.frames(1);
h.frame_with(vec![egui::Event::Paste("故障".repeat(1500))]);
h.frames(4);
@@ -1202,7 +1202,7 @@ mod tests {
let commands = open_commands(&mut h);
assert!(!commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(_))));
assert!(h.app.issue_report.draft.as_ref().unwrap().missing_description);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("issue_report_body")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("issue_report_body")));
h.step(&json!({"text":"The preview disappeared"})).unwrap();
let commands = open_commands(&mut h);
assert!(commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(url) if url.url.starts_with(ISSUE_URL))));
@@ -1219,11 +1219,11 @@ mod tests {
h.app.home.open = false;
h.app.issue_report.draft = Some(draft_for(&h.app, None, None));
h.frames(16);
- let description = Some(egui::Id::new("issue_report_body"));
+ let description = Some(egui::Id::unique("issue_report_body"));
open_commands(&mut h);
assert_eq!(h.ctx.memory(|m| m.focused()), description);
// Click the Summary field (found by its id: it has no label of its own) and type.
- let title = egui::Id::new("issue_report_title").accesskit_id();
+ let title = egui::Id::unique("issue_report_title").accesskit_id();
let tree = h.output.accesskit_update.as_ref().unwrap();
let b = tree.nodes.iter().find(|(id, _)| *id == title).and_then(|(_, n)| n.bounds()).unwrap();
h.step(&json!({"click":[(b.x0 + b.x1) / 2.0, (b.y0 + b.y1) / 2.0]})).unwrap();
@@ -1257,28 +1257,20 @@ mod tests {
h.step(&json!({"widget":"Technical details"})).unwrap();
h.call("ui.scroll", json!({"x":800,"y":600,"delta":-1000}));
}
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new(field)));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique(field)));
h.frames(1);
let [x, y] = h.widget("Open GitHub issue form").unwrap();
let pos = egui::pos2(x as f32, y as f32);
let modifiers = egui::Modifiers { ctrl: true, command: true, ..Default::default() };
- let raw = egui::RawInput {
- screen_rect: Some(h.ctx.content_rect()),
- focused: true,
- events: vec![
- egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers },
- egui::Event::Paste("Latest reviewed content".into()),
- egui::Event::PointerMoved(pos),
- egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() },
- egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() },
- ],
- ..Default::default()
- };
- let app = &mut h.app;
- let mut output = h.ctx.run_ui(raw, |ui| {
- app.logic(ui.ctx());
- app.ui(ui);
- });
+ h.frame_with(vec![
+ egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers },
+ egui::Event::Paste("Latest reviewed content".into()),
+ egui::Event::PointerMoved(pos),
+ egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() },
+ egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() },
+ ]);
+ // The click waits one frame for the typing before it.
+ h.frame();
let draft = h.app.issue_report.draft.as_ref().unwrap();
let edited = match field {
"issue_report_body" => &draft.description,
@@ -1291,13 +1283,12 @@ mod tests {
let body = draft.report_body();
let (url, copy_needed) = draft_url(&draft.report_title(), &body);
assert!(
- output.platform_output.commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(u) if u.url == url)),
- "handoff must use this frame's edits: {field}, clipboard={clipboard}"
+ h.output.commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(u) if u.url == url)),
+ "handoff must use the click frame's edits: {field}, clipboard={clipboard}"
);
if copy_needed {
- assert!(output.platform_output.commands.iter().any(|c| matches!(c, egui::OutputCommand::CopyText(text) if text == &body)));
+ assert!(h.output.commands.iter().any(|c| matches!(c, egui::OutputCommand::CopyText(text) if text == &body)));
}
- output.textures_delta.clear();
assert!(draft.opened_github && !draft.missing_description);
}
}
@@ -1666,7 +1657,8 @@ mod tests {
draft.image = Some(Arc::new(ColorImage::new([1600, 1000], vec![egui::Color32::GREEN; 1_600_000])));
h.app.issue_report.draft = Some(draft);
h.frames(20);
- let rect = |h: &crate::scenario::Harness| egui::containers::AreaState::load(&h.ctx, egui::Id::new("sc_issue_report")).unwrap().rect();
+ let rect =
+ |h: &crate::scenario::Harness| egui::containers::AreaState::load(&h.ctx, egui::Id::unique("sc_issue_report")).unwrap().rect();
let settled = rect(&h);
h.frames(120);
let idle = rect(&h);
@@ -1695,7 +1687,7 @@ mod tests {
}
h.app.issue_report.draft = Some(draft_for(&h.app, None, None));
h.frames(10);
- let rect = |h: &crate::scenario::Harness| egui::containers::AreaState::load(&h.ctx, egui::Id::new("sc_issue_report")).unwrap().rect();
+ let rect = |h: &crate::scenario::Harness| egui::containers::AreaState::load(&h.ctx, egui::Id::unique("sc_issue_report")).unwrap().rect();
let at = rect(&h);
assert!((at.center().x - h.ctx.content_rect().center().x).abs() < 1.0, "sketch={sketch}: it opens at the top middle: {at:?}");
// On the title, clear of the close button.
@@ -1748,7 +1740,7 @@ mod tests {
h.frames(4);
let before = (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision);
for field in ["issue_report_title", "issue_report_body"] {
- let id = egui::Id::new(field);
+ let id = egui::Id::unique(field);
h.ctx.memory_mut(|m| m.request_focus(id));
h.frames(1);
h.step(&json!({"text":"edited-report-marker"})).unwrap();
@@ -1787,7 +1779,7 @@ mod tests {
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(3);
for field in ["issue_report_title", "issue_report_body"] {
- let id = egui::Id::new(field);
+ let id = egui::Id::unique(field);
h.ctx.memory_mut(|m| m.request_focus(id));
h.frames(2);
assert_eq!(h.ctx.memory(|m| m.focused()), Some(id), "placed Text must not steal report focus");
@@ -1816,8 +1808,8 @@ mod tests {
fn issue_report_boundary_preserves_opacity_widget_state_and_real_focus() {
let mut app = app();
let ctx = crate::fonts::test_context();
- let focus = egui::Id::new("report-review-focus");
- let state = egui::Id::new("cad-layout-state");
+ let focus = egui::Id::unique("report-review-focus");
+ let state = egui::Id::unique("cad-layout-state");
begin(&mut app, &ctx, None, None);
let raw = egui::RawInput {
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0))),
@@ -1831,16 +1823,16 @@ mod tests {
ui.disable();
assert_eq!(ui.opacity(), 1.0, "capture must retain normal drawing opacity");
assert!(!ui.is_enabled());
- Container::new(&ctx, Surface::Popup).area(egui::Id::new("cad-boundary-proof")).fade_in(false).show(&ctx, |ui| {
+ Container::new(&ctx, Surface::Popup).area(egui::Id::unique("cad-boundary-proof")).fade_in(false).show(&ctx, |ui| {
assert!(!ui.is_enabled());
assert_eq!(ui.opacity(), 1.0);
ui.ctx().data_mut(|d| d.insert_temp(state, 42_u32));
- ui.ctx().memory_mut(|m| m.request_focus(egui::Id::new("underlying-editor")));
+ ui.ctx().memory_mut(|m| m.request_focus(egui::Id::unique("underlying-editor")));
});
drop(barrier);
assert_eq!(ctx.memory(|m| m.focused()), Some(focus));
assert_eq!(ctx.data(|d| d.get_temp::<u32>(state)), Some(42));
- assert!(Container::new(&ctx, Surface::Popup).area(egui::Id::new("report-boundary-proof")).is_enabled());
+ assert!(Container::new(&ctx, Surface::Popup).area(egui::Id::unique("report-boundary-proof")).is_enabled());
});
output.textures_delta.clear();
app.issue_report.draft = None;
@@ -1913,7 +1905,7 @@ mod tests {
let token = h.app.issue_report.pending.as_ref().unwrap().token;
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(3);
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("issue_report_body")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("issue_report_body")));
h.step(&json!({"text":"Typing here describes the bug, not a CAD dimension."})).unwrap();
h.step(&json!({"key":"Enter"})).unwrap();
h.step(&json!({"key":"Escape"})).unwrap();
@@ -1922,7 +1914,7 @@ mod tests {
assert!(h.app.issue_report.draft.as_ref().unwrap().description.contains("Typing here describes"));
h.step(&json!({"widget":"Close draft"})).unwrap();
h.frames(2);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
h.step(&json!({"key":"Enter"})).unwrap();
assert!(!crate::dim_view::editing());
assert_eq!(h.app.session.undo.len(), before.1 + 1);
@@ -1950,7 +1942,7 @@ mod tests {
let token = h.app.issue_report.pending.as_ref().unwrap().token;
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(3);
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("issue_report_body")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("issue_report_body")));
h.step(&json!({"text":"report only"})).unwrap();
h.step(&json!({"key":"Enter"})).unwrap();
h.step(&json!({"key":"Escape"})).unwrap();
diff --git a/crates/ui-egui/src/issue_report/form.rs b/crates/ui-egui/src/issue_report/form.rs
index 8aefacc4f3..2ebff5a9fb 100644
--- a/crates/ui-egui/src/issue_report/form.rs
+++ b/crates/ui-egui/src/issue_report/form.rs
@@ -15,7 +15,7 @@ const ALL_GUIDANCE: [&str; 4] = [
fn answer(ui: &mut Ui, label: &str, hint: &str, text: &mut String, id: &str, rows: usize) -> egui::Response {
ui_kit::text(ui, tr_label(label), ui_kit::Text::Heading(label));
ui_kit::text(ui, tr_label(hint), ui_kit::Text::Note(hint));
- let response = ui_kit::text_area(ui, tr_label(label), Id::new(id), text, rows, MAX_ANSWER);
+ let response = ui_kit::text_area(ui, tr_label(label), Id::unique(id), text, rows, MAX_ANSWER);
crate::scenario::publish_handle(id, response.rect.center());
super::truncate_chars(text, MAX_ANSWER);
// What doesn't fit is not added: near the limit, say how much room is left (#7191).
@@ -124,7 +124,7 @@ pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -
let compact = cards * t.form_card_width < actions_width + 2.0 * t.space_12 + 2.0 * t.space_6 + t.space_8;
let open_label = if compact { "Open GitHub" } else { "Open GitHub issue form" };
let close_label = if compact { "" } else { "Close draft" };
- let (closed, mut action) = ui_kit::Window::new(Id::new("sc_issue_report"), "bug_report", tr_label("Report a bug"))
+ let (closed, mut action) = ui_kit::Window::new(Id::unique("sc_issue_report"), "bug_report", tr_label("Report a bug"))
.cards(cards)
// Opens at the top middle, and its title band drags it off what the report is about
// (#9916).
@@ -184,7 +184,7 @@ pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -
ui_kit::text(ui, tr_label("Summary"), ui_kit::Text::Heading("Summary"));
let response = ui_kit::bounded_cell_editor(
ui,
- Id::new("issue_report_title"),
+ Id::unique("issue_report_title"),
&mut draft.title,
"A short title for the problem (optional)",
false,
@@ -232,8 +232,14 @@ pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -
ui_kit::Text::Note("private"),
);
ui_kit::section(ui, "issue-report-technical", "Technical details", false, |ui| {
- let response =
- ui_kit::text_area(ui, tr_label("Technical details"), Id::new("issue_report_technical"), &mut draft.body, 8, MAX_BODY);
+ let response = ui_kit::text_area(
+ ui,
+ tr_label("Technical details"),
+ Id::unique("issue_report_technical"),
+ &mut draft.body,
+ 8,
+ MAX_BODY,
+ );
if response.changed() {
draft.opened_github = false;
}
diff --git a/crates/ui-egui/src/joint_handles.rs b/crates/ui-egui/src/joint_handles.rs
index 64a2eb8835..ef3854f38c 100644
--- a/crates/ui-egui/src/joint_handles.rs
+++ b/crates/ui-egui/src/joint_handles.rs
@@ -263,16 +263,17 @@ pub(crate) fn show_warning(app: &mut SolveApp, ctx: &egui::Context) {
app.menu.joint_move_warning = None;
return;
}
- let (closed, action) = crate::ui_kit::Confirm::new(egui::Id::new("sc_joint_move_blocked"), "status_warning", app.tr("joint_move.blocked_title"))
- .tone(crate::ui_kit::Tone::Warning)
- .actions(app.tr("ui.heading_ok"), "", None)
- .show(ctx, true, |ui| {
- if !blocked.part.is_empty() {
- crate::ui_kit::text(ui, &blocked.part, crate::ui_kit::Text::Report("part", false));
- }
- crate::ui_kit::text(ui, &reason, crate::ui_kit::Text::Report("reason", false));
- crate::ui_kit::text(ui, app.tr(hint), crate::ui_kit::Text::Hint("remedy"));
- });
+ let (closed, action) =
+ crate::ui_kit::Confirm::new(egui::Id::unique("sc_joint_move_blocked"), "status_warning", app.tr("joint_move.blocked_title"))
+ .tone(crate::ui_kit::Tone::Warning)
+ .actions(app.tr("ui.heading_ok"), "", None)
+ .show(ctx, true, |ui| {
+ if !blocked.part.is_empty() {
+ crate::ui_kit::text(ui, &blocked.part, crate::ui_kit::Text::Report("part", false));
+ }
+ crate::ui_kit::text(ui, &reason, crate::ui_kit::Text::Report("reason", false));
+ crate::ui_kit::text(ui, app.tr(hint), crate::ui_kit::Text::Hint("remedy"));
+ });
app.viewport.dialog_rect = crate::scenario::rect_of("dialog:window");
if closed || action != crate::ui_kit::Action::None {
app.menu.joint_move_warning = None;
@@ -644,7 +645,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painte
if let Some(p) = pointer {
let at = (p + vec2(20.0, 22.0)).clamp(proj.rect.min, proj.rect.max - vec2(260.0, 82.0).min(proj.rect.size()));
let host = Container::new(ui.ctx(), Surface::Canvas);
- host.area(egui::Id::new("joint_move_readout")).interactable(false).fixed_pos(at).order(egui::Order::Foreground).show(ui.ctx(), |ui| {
+ host.area(egui::Id::unique("joint_move_readout")).interactable(false).fixed_pos(at).order(egui::Order::Foreground).show(ui.ctx(), |ui| {
let frame = host.frame(ui.ctx(), tk.overlay, crate::frame::Side::Right).inner_margin(tk.space_8);
Container::show_backing(ui, frame, |ui| {
let value = if d.axis.angular {
@@ -678,7 +679,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painte
}
let host = Container::new(ui.ctx(), Surface::Canvas);
let mut done = false;
- host.area(egui::Id::new("joint_move_help")).fixed_pos(proj.rect.left_bottom() + vec2(16.0, -148.0)).show(ui.ctx(), |ui| {
+ host.area(egui::Id::unique("joint_move_help")).fixed_pos(proj.rect.left_bottom() + vec2(16.0, -148.0)).show(ui.ctx(), |ui| {
let frame = host.frame(ui.ctx(), tk.overlay, crate::frame::Side::Right).inner_margin(tk.space_8);
Container::show_backing(ui, frame, |ui| {
ui.label(app.tr("joint_move.help"));
diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs
index 6f9d6d20fc..f64dd74b43 100644
--- a/crates/ui-egui/src/keymap.rs
+++ b/crates/ui-egui/src/keymap.rs
@@ -565,7 +565,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
// A Preferences search lists the matching shortcuts too, and one recorded from there takes
// the key like one on this page (#10043). Only a search field that has the keyboard keeps
// its keys: going back to it to type stops the recording.
- if ctx.memory(|m| m.has_focus(egui::Id::new("prefs_search"))) && app.keymap.capturing.is_some() {
+ if ctx.memory(|m| m.has_focus(egui::Id::unique("prefs_search"))) && app.keymap.capturing.is_some() {
stop_capture(app);
}
// Keep a pending chord until it has settled and all keys are released. Modifier-only
@@ -631,7 +631,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
.allocate_ui_with_layout(egui::vec2(width, t.control_height), egui::Layout::left_to_right(egui::Align::Center), |ui| {
ui_kit::search_field(
ui,
- egui::Id::new("sc_keymap_filter"),
+ egui::Id::unique("sc_keymap_filter"),
&mut app.keymap.filter,
crate::i18n::tr_label("Filter commands or keys"),
)
@@ -911,8 +911,8 @@ fn shortcut_row(
let name =
egui::Rect::from_min_size(rect.min + egui::vec2(0.0, t.space_4), egui::vec2(if beside { name_width } else { width }, label_height));
ui.painter().galley(egui::pos2(name.left(), name.center().y - label_galley.size().y / 2.0), label_galley, t.form_ink);
- let response = ui.interact(name, ui.id().with("command"), egui::Sense::hover()).backing_on_hover_text(command.id);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{label} ({})", command.id)));
+ let response = ui.interact(name, ui.scope_id().with("command"), egui::Sense::hover()).backing_on_hover_text(command.id);
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), format!("{label} ({})", command.id)));
let top = if beside { name.top() } else { name.bottom() + t.space_4 };
let total = widths.iter().sum::<f32>() + widths.len().saturating_sub(1) as f32 * t.space_8;
let left = if beside { rect.right() - actions_width - t.space_8 - total.min(controls_width) } else { rect.left() };
@@ -1099,7 +1099,7 @@ mod tests {
assert!(!h.app.agent_chat.open, "extra modifiers do not match");
h.step(&json!({"key":"J", "cmd":true, "shift":true})).unwrap();
assert!(h.app.agent_chat.open);
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("sc_agent_chat_input")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("sc_agent_chat_input")));
h.frames(2);
h.step(&json!({"key":"J", "cmd":true, "shift":true})).unwrap();
assert!(!h.app.agent_chat.open, "a chord can hide Assistant from its input field");
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 211d911765..827690ca59 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -743,6 +743,8 @@ pub struct SolveApp {
pub synthetic: Vec<egui::Event>,
/// The modifiers of the synthetic press in progress (a Ctrl-drag keeps Ctrl while it moves).
pub synthetic_mods: egui::Modifiers,
+ /// A click that came in the same frame as typing before it, held for the next frame.
+ held_click: Vec<egui::Event>,
control_rx: Option<Receiver<ControlRequest>>,
/// Control requests that change the design, held while a file loads or an agent's design
/// change computes.
@@ -760,6 +762,9 @@ pub struct SolveApp {
pending_shots: Vec<(u64, Option<String>, std::sync::mpsc::Sender<Value>, f64)>,
shot_chat_turns: std::collections::HashMap<u64, std::sync::Arc<std::sync::atomic::AtomicBool>>,
queued_shots: Vec<(u64, f64, u32)>,
+ /// Screenshots egui hands back, by token; egui calls back, `collect_screenshots` reads them.
+ shot_tx: std::sync::mpsc::Sender<(u64, std::sync::Arc<egui::ColorImage>)>,
+ shot_rx: std::sync::mpsc::Receiver<(u64, std::sync::Arc<egui::ColorImage>)>,
shot_token: u64,
styled: bool,
fitted: bool,
@@ -815,6 +820,7 @@ impl SolveApp {
#[cfg(not(target_arch = "wasm32"))]
solidcraft_engine::slicer_files::clean_old();
let tree = browser::TreeState::for_session(session.uid);
+ let (shot_tx, shot_rx) = std::sync::mpsc::channel();
let mut app = SolveApp {
panel_runtime: None,
viewport_status: Default::default(),
@@ -926,6 +932,7 @@ impl SolveApp {
frame_rate: frame_rate::FrameRate::default(),
synthetic: Vec::new(),
synthetic_mods: egui::Modifiers::default(),
+ held_click: Vec::new(),
control_rx: None,
agent_chat: Default::default(),
ai_connect: Default::default(),
@@ -936,6 +943,8 @@ impl SolveApp {
pending_shots: Vec::new(),
shot_chat_turns: Default::default(),
queued_shots: Vec::new(),
+ shot_tx,
+ shot_rx,
shot_token: 0,
styled: false,
fitted: false,
@@ -2988,7 +2997,7 @@ impl SolveApp {
self.return_from_extrude_view();
agent_cursor::step(self, ctx);
browser::eye_drag_frame(self, ctx);
- if !self.synthetic.is_empty() {
+ if !self.synthetic.is_empty() || !self.held_click.is_empty() {
ctx.request_repaint();
}
issue_report::tick(self, ctx);
@@ -3028,9 +3037,28 @@ impl SolveApp {
/// capture hides the report waits for it (the control channel's typing too).
pub fn raw_input_hook(&mut self, raw: &mut egui::RawInput) {
self.synthetic_input(raw);
+ finite_input(raw);
+ self.hold_click_after_typing(raw);
issue_report::hold_input(self, raw);
}
+ /// A pointer button after typing in the same frame (a slow frame) waits for the next frame,
+ /// with the events after it. egui 0.37 drops a field's focus on a click elsewhere before the
+ /// field reads the frame's typing, which lost what was typed. Drop once emilk/egui#8763 is fixed.
+ fn hold_click_after_typing(&mut self, raw: &mut egui::RawInput) {
+ if !self.held_click.is_empty() {
+ let mut events = std::mem::take(&mut self.held_click);
+ events.append(&mut raw.events);
+ raw.events = events;
+ }
+ let button = raw.events.iter().position(|e| matches!(e, egui::Event::PointerButton { .. }));
+ if let Some(i) = button
+ && raw.events[..i].iter().any(issue_report::typing)
+ {
+ self.held_click = raw.events.split_off(i);
+ }
+ }
+
/// Inject synthetic events (one pointer event per frame).
fn synthetic_input(&mut self, raw: &mut egui::RawInput) {
if self.synthetic.is_empty() {
@@ -3420,10 +3448,15 @@ impl SolveApp {
// A view that just moved is drawn with fewer AO samples: shoot the full-quality frame
// that follows (#7165), or after half a second a view that keeps moving as it is.
let settled = viewport::ao_settled(self, ctx);
+ let shot_tx = &self.shot_tx;
self.queued_shots.retain_mut(|(token, at, frames)| {
*frames += 1;
if now >= *at && *frames >= 3 && (settled || now >= *at + 500.0) {
- ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(egui::UserData::new(*token)));
+ let (token, tx, ctx2) = (*token, shot_tx.clone(), ctx.clone());
+ ctx.request_screenshot(move |image| {
+ let _ = tx.send((token, image));
+ ctx2.request_repaint();
+ });
false
} else {
true
@@ -3448,23 +3481,13 @@ impl SolveApp {
true
}
});
+ // Drained every frame: a shot that comes after its request was cancelled or timed out
+ // is dropped here instead of waiting in the channel.
+ let shots: Vec<_> = self.shot_rx.try_iter().collect();
if self.pending_shots.is_empty() && !issue_report::pending(self) {
return;
}
- let events: Vec<_> = ctx.input(|i| {
- i.raw
- .events
- .iter()
- .filter_map(|e| match e {
- egui::Event::Screenshot { user_data, image, .. } => {
- let token = user_data.data.as_ref().and_then(|d| d.downcast_ref::<u64>()).copied()?;
- Some((token, image.clone()))
- }
- _ => None,
- })
- .collect()
- });
- for (token, image) in events {
+ for (token, image) in shots {
issue_report::receive(self, token, image.clone());
if let Some(i) = self.pending_shots.iter().position(|(t, ..)| *t == token) {
let (_, path, reply, _) = self.pending_shots.remove(i);
@@ -3486,6 +3509,17 @@ impl SolveApp {
}
}
+/// Drop pointer, wheel and gesture events that carry a non-finite number: egui 0.37 asserts on them.
+fn finite_input(raw: &mut egui::RawInput) {
+ raw.events.retain(|event| match event {
+ egui::Event::PointerMoved(pos) | egui::Event::PointerButton { pos, .. } | egui::Event::MiddleClickPaste { pos, .. } => pos.is_finite(),
+ egui::Event::MouseMoved(delta) | egui::Event::MouseWheel { delta, .. } => delta.is_finite(),
+ egui::Event::Zoom(amount) | egui::Event::Rotate(amount) => amount.is_finite(),
+ egui::Event::Touch { pos, force, .. } => pos.is_finite() && force.is_none_or(f32::is_finite),
+ _ => true,
+ });
+}
+
/// The window is minimised or fully covered, so it presents no frames (#1677). Unknown counts as
/// shown: the screenshot deadline still ends a wait for a frame that never comes.
fn window_hidden(ctx: &egui::Context) -> bool {
diff --git a/crates/ui-egui/src/linked_source.rs b/crates/ui-egui/src/linked_source.rs
index 0d2a636698..563baf223f 100644
--- a/crates/ui-egui/src/linked_source.rs
+++ b/crates/ui-egui/src/linked_source.rs
@@ -251,7 +251,7 @@ pub fn link_copies(app: &mut SolveApp, accept: bool) -> bool {
pub fn show_copies(app: &mut SolveApp, ctx: &egui::Context) {
let Some(c) = app.menu.link_copies.clone() else { return };
let name = app.session.doc.components.iter().find(|x| x.id == c.linked).map(|x| x.name.clone()).unwrap_or_default();
- let (closed, action) = crate::ui_kit::Confirm::new(egui::Id::new("sc_link_copies"), "help", crate::i18n::tr_label("Link Identical Copies"))
+ let (closed, action) = crate::ui_kit::Confirm::new(egui::Id::unique("sc_link_copies"), "help", crate::i18n::tr_label("Link Identical Copies"))
.actions("Link", "Keep", None)
.show(ctx, true, |ui| {
let text = crate::i18n::format("ui.link_copies_text", &[("name", &name)]);
diff --git a/crates/ui-egui/src/manage_dialogs_tests.rs b/crates/ui-egui/src/manage_dialogs_tests.rs
index 0aede818e1..dfebca1f18 100644
--- a/crates/ui-egui/src/manage_dialogs_tests.rs
+++ b/crates/ui-egui/src/manage_dialogs_tests.rs
@@ -379,7 +379,7 @@ fn appearance_card_keeps_the_approved_width_with_no_preselection() {
h.app.start("appearance.assign");
h.frames(4);
let header = scenario::rect_of("dialog:header").unwrap();
- let card = h.ctx.memory(|m| m.area_rect(egui::Id::new(("sc_dialog", "APPEARANCE")))).unwrap();
+ let card = h.ctx.memory(|m| m.area_rect(egui::Id::unique(("sc_dialog", "APPEARANCE")))).unwrap();
let t = Tokens::get();
let approved = t.form_card_width + t.form_label_width + t.space_6;
assert!((card.width() - approved).abs() <= t.space_2, "card {card:?}, header {header:?}");
diff --git a/crates/ui-egui/src/material_card_review.rs b/crates/ui-egui/src/material_card_review.rs
index f517ed34fd..57fc626d5c 100644
--- a/crates/ui-egui/src/material_card_review.rs
+++ b/crates/ui-egui/src/material_card_review.rs
@@ -65,7 +65,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let anchor = crate::frame::offset_anchor(docked, moved, drag_bounds, side);
let panel = ui_kit::Panel::new(
title,
- egui::Id::new("sc_material_card_review"),
+ egui::Id::unique("sc_material_card_review"),
anchor,
drag_bounds,
side,
@@ -95,8 +95,14 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
|ui| {
ui_kit::text(ui, tr("ui.material_review.scope"), ui_kit::Text::Hint("manage"));
ui_kit::text(ui, tr("ui.material_review.input"), ui_kit::Text::Report("material_input_label", false));
- let response =
- ui_kit::text_area(ui, tr("ui.material_review.input"), egui::Id::new("sc_material_card_input"), &mut window.input, 5, MAX_BYTES);
+ let response = ui_kit::text_area(
+ ui,
+ tr("ui.material_review.input"),
+ egui::Id::unique("sc_material_card_input"),
+ &mut window.input,
+ 5,
+ MAX_BYTES,
+ );
crate::scenario::publish_handle("review:input", response.rect.center());
if response.changed() {
window.reviewed = None;
@@ -272,7 +278,7 @@ mod tests {
assert!(h.widget("Original synthetic candidate").is_some());
assert!(h.widget("Density: Unknown").is_some());
assert!(h.widget("E: 1.2e10 Pa").is_some());
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("sc_material_card_input")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("sc_material_card_input")));
h.step(&json!({"text":" "})).unwrap();
assert!(h.app.material_card_review.as_ref().unwrap().reviewed.is_none(), "editing invalidates the old report");
h.step(&json!({"click":{"handle":"dialog:close"}})).unwrap();
diff --git a/crates/ui-egui/src/material_editor.rs b/crates/ui-egui/src/material_editor.rs
index 8342941ecd..3f480fb7e1 100644
--- a/crates/ui-egui/src/material_editor.rs
+++ b/crates/ui-egui/src/material_editor.rs
@@ -301,8 +301,9 @@ fn number(value: &str, field: &str) -> Result<f64, String> {
fn field(ui: &mut egui::Ui, label: &str, id: &str, value: &mut String, unit: &str) {
let label = if unit.is_empty() { label.to_string() } else { format!("{label} ({unit})") };
- let response =
- ui_kit::row(ui, &label, |ui| ui_kit::cell_editor(ui, egui::Id::new(("physical_editor", id)), value, tr("ui.material_review.unknown"), false));
+ let response = ui_kit::row(ui, &label, |ui| {
+ ui_kit::cell_editor(ui, egui::Id::unique(("physical_editor", id)), value, tr("ui.material_review.unknown"), false)
+ });
crate::scenario::publish_handle(&format!("material:field:{id}"), response.rect.center());
}
diff --git a/crates/ui-egui/src/menu_tests.rs b/crates/ui-egui/src/menu_tests.rs
index 08dc5f618f..edc34dd8a4 100644
--- a/crates/ui-egui/src/menu_tests.rs
+++ b/crates/ui-egui/src/menu_tests.rs
@@ -1486,7 +1486,7 @@ fn menus_near_the_window_corner_open_inward() {
assert_eq!(h.call("ui.menu", json!({}))["result"]["open"], true, "{scale} {target:?}");
// An auto-sized menu takes a few frames to settle its size.
h.frames(3);
- let r = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_context_menu"))).unwrap();
+ let r = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_context_menu"))).unwrap();
assert!(screen.contains_rect(r), "{scale} {target:?}: {r:?} outside {screen:?}");
// Below and right of the cursor where it fits, else ending at it.
let x = if at.x + r.width() <= screen.right() { at.x } else { at.x - r.width() };
diff --git a/crates/ui-egui/src/messages.rs b/crates/ui-egui/src/messages.rs
index 48285e0760..ecea56b376 100644
--- a/crates/ui-egui/src/messages.rs
+++ b/crates/ui-egui/src/messages.rs
@@ -109,8 +109,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
let t = Tokens::get();
let now = crate::now_ms();
- let (closed, _) =
- crate::ui_kit::Window::new(egui::Id::new("sc_messages"), "list", tr("messages.title")).fields().actions("", "", None).show(ctx, true, |ui| {
+ let (closed, _) = crate::ui_kit::Window::new(egui::Id::unique("sc_messages"), "list", tr("messages.title")).fields().actions("", "", None).show(
+ ctx,
+ true,
+ |ui| {
ui.horizontal(|ui| {
let copy = crate::ui_kit::button(ui, tr("messages.copy_all"), crate::ui_kit::Button::Enabled(app.messages.iter().len() > 0));
crate::scenario::publish_handle("messages:copy", copy.rect.center());
@@ -137,7 +139,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
});
}
});
- });
+ },
+ );
if closed {
app.messages.open = false;
}
diff --git a/crates/ui-egui/src/mouse_gesture.rs b/crates/ui-egui/src/mouse_gesture.rs
index 478d9c2a76..9593c84f52 100644
--- a/crates/ui-egui/src/mouse_gesture.rs
+++ b/crates/ui-egui/src/mouse_gesture.rs
@@ -521,10 +521,13 @@ fn paint_open(app: &SolveApp, ctx: &egui::Context) {
let t = Tokens::get();
let pointer = ctx.input(|i| i.pointer.latest_pos());
let area = Rect::from_center_size(wheel.centre, vec2(2.0 * (RING + 6.0), 2.0 * (RING + 6.0)));
- Container::new(ctx, Surface::Canvas).area(egui::Id::new("sc_mouse_gesture")).fixed_pos(area.min).order(egui::Order::Foreground).show(ctx, |ui| {
- let (r, _) = ui.allocate_exact_size(area.size(), Sense::hover());
- paint(&ui.painter_at(r.expand(4.0)), wheel.centre, 1.0, wheel.studio, &list, pointer, t);
- });
+ Container::new(ctx, Surface::Canvas).area(egui::Id::unique("sc_mouse_gesture")).fixed_pos(area.min).order(egui::Order::Foreground).show(
+ ctx,
+ |ui| {
+ let (r, _) = ui.allocate_exact_size(area.size(), Sense::hover());
+ paint(&ui.painter_at(r.expand(4.0)), wheel.centre, 1.0, wheel.studio, &list, pointer, t);
+ },
+ );
}
// ---------------------------------------------------------------------------------------------
@@ -632,7 +635,7 @@ fn editor(app: &mut SolveApp, ctx: &egui::Context) {
let t = Tokens::get();
let mut studio = app.gesture.editor.studio;
let mut config = app.preferences.mouse_gestures.clone();
- let closed = crate::ui_kit::Window::new(egui::Id::new("sc_gesture_editor"), "settings", crate::i18n::tr_label("Mouse gestures"))
+ let closed = crate::ui_kit::Window::new(egui::Id::unique("sc_gesture_editor"), "settings", crate::i18n::tr_label("Mouse gestures"))
.cards(3.0)
.show_body(ctx, |ui| {
crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Ring of tools on the right button"), &mut config.enabled);
@@ -688,7 +691,7 @@ fn editor(app: &mut SolveApp, ctx: &egui::Context) {
&shown,
egui::PopupCloseBehavior::CloseOnClickOutside,
|ui| {
- let filter_id = ui.id().with("filter");
+ let filter_id = ui.scope_id().with("filter");
let mut filter: String = ui.data_mut(|d| d.get_temp(filter_id).unwrap_or_default());
crate::ui_kit::text_field(ui, &mut filter, crate::i18n::tr_label("Filter…"));
ui.data_mut(|d| d.insert_temp(filter_id, filter.clone()));
diff --git a/crates/ui-egui/src/navigation.rs b/crates/ui-egui/src/navigation.rs
index 13a2e777a8..9aaf7323a5 100644
--- a/crates/ui-egui/src/navigation.rs
+++ b/crates/ui-egui/src/navigation.rs
@@ -55,7 +55,13 @@ impl WebWheelGestures {
use egui::{Event, Modifiers, MouseWheelUnit, TouchPhase, Vec2};
const IDLE: f64 = 0.1;
const WHEEL_STEP_MIN: f32 = 40.0;
- let phase_event = |phase| Event::MouseWheel { unit: MouseWheelUnit::Point, delta: Vec2::ZERO, modifiers: Modifiers::NONE, phase };
+ let phase_event = |phase| Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: MouseWheelUnit::Point,
+ delta: Vec2::ZERO,
+ modifiers: Modifiers::NONE,
+ phase,
+ };
let valid_time = now.is_finite() && now >= 0.0;
let events = std::mem::take(&mut raw.events);
if self.last_scroll.is_some_and(|last| !valid_time || now < last || now - last >= IDLE) {
@@ -190,7 +196,7 @@ pub(crate) fn immediate_wheel(
mouse_pan: egui::Vec2::ZERO,
};
for event in &input.events {
- let egui::Event::MouseWheel { unit, delta, modifiers, phase } = event else { continue };
+ let egui::Event::MouseWheel { unit, delta, modifiers, phase, .. } = event else { continue };
let modifier_zoom = claims_scroll(*modifiers, zoom_modifier);
if !modifier_zoom && modifiers.matches_any(options.zoom_modifier) {
continue;
@@ -218,11 +224,7 @@ pub(crate) fn immediate_wheel(
}
egui::TouchPhase::Move => {}
}
- let points = match unit {
- egui::MouseWheelUnit::Point => *delta,
- egui::MouseWheelUnit::Line => *delta * options.line_scroll_speed,
- egui::MouseWheelUnit::Page => *delta * page_height,
- };
+ let points = wheel_points(*unit, *delta, options, page_height);
if !points.is_finite() {
continue;
}
@@ -256,6 +258,16 @@ pub(crate) fn immediate_wheel(
out
}
+/// A wheel event's movement in points, in egui's units: lines at its line scroll speed, pages at
+/// `page_height`.
+fn wheel_points(unit: egui::MouseWheelUnit, delta: egui::Vec2, options: egui::InputOptions, page_height: f32) -> egui::Vec2 {
+ match unit {
+ egui::MouseWheelUnit::Point => delta,
+ egui::MouseWheelUnit::Line => delta * options.line_scroll_speed,
+ egui::MouseWheelUnit::Page => delta * page_height,
+ }
+}
+
/// Whether the chosen trackpad zoom modifier (Preferences › Navigation, #8322) claims a wheel
/// event: that key held alone. egui aliases Ctrl/Command on Windows/Linux; macOS can hold both.
pub(crate) fn claims_scroll(modifiers: egui::Modifiers, zoom_modifier: Option<egui::Modifiers>) -> bool {
@@ -277,14 +289,10 @@ pub(crate) fn pinch_factor(input: &egui::InputState, options: egui::InputOptions
}
}
// A wheel the chosen zoom modifier already turns into zoom is not also a pinch.
- egui::Event::MouseWheel { unit, delta, modifiers, phase: egui::TouchPhase::Move }
+ egui::Event::MouseWheel { unit, delta, modifiers, phase: egui::TouchPhase::Move, .. }
if modifiers.matches_any(options.zoom_modifier) && !claims_scroll(*modifiers, zoom_modifier) =>
{
- let points = match unit {
- egui::MouseWheelUnit::Point => *delta,
- egui::MouseWheelUnit::Line => *delta * options.line_scroll_speed,
- egui::MouseWheelUnit::Page => *delta * page_height,
- };
+ let points = wheel_points(*unit, *delta, options, page_height);
let f = (options.scroll_zoom_speed * (points.x + points.y)).exp();
if f.is_finite() && f > 0.0 {
factor *= f;
@@ -305,15 +313,11 @@ pub(crate) fn axis_wheel(ctx: &egui::Context, page_height: f32) -> (f32, f32, f3
let (zoom, sideways, pinch) = ctx.input(|i| {
let (mut zoom, mut sideways) = (0.0, 0.0);
for event in &i.events {
- let egui::Event::MouseWheel { unit, delta, modifiers, phase } = event else { continue };
+ let egui::Event::MouseWheel { unit, delta, modifiers, phase, .. } = event else { continue };
if *phase != egui::TouchPhase::Move || modifiers.matches_any(options.zoom_modifier) {
continue;
}
- let points = match unit {
- egui::MouseWheelUnit::Point => *delta,
- egui::MouseWheelUnit::Line => *delta * options.line_scroll_speed,
- egui::MouseWheelUnit::Page => *delta * page_height,
- };
+ let points = wheel_points(*unit, *delta, options, page_height);
let up = route_wheel_vertical(points, *modifiers, options);
zoom += up;
sideways += if up == 0.0 { points.x + points.y } else { points.x };
@@ -425,7 +429,7 @@ fn view_keys_blocked(app: &SolveApp, ctx: &egui::Context) -> bool {
|| app.viewport.context_menu.is_some()
|| app.ui.palette_open
|| ctx.memory(|m| m.focused().is_some())
- || ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open")).is_some())
+ || ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::unique("sc_panel_open")).is_some())
}
/// View keys (#1541): the arrows turn the view 15° (with Shift a quarter turn, as the navigation
@@ -1250,7 +1254,7 @@ fn orbit_camera(app: &mut SolveApp, dx: f64, dy: f64) {
mod tests {
use solidcraft_engine::geom::prelude::*;
fn web_wheel(unit: egui::MouseWheelUnit, delta: egui::Vec2, modifiers: egui::Modifiers) -> egui::Event {
- egui::Event::MouseWheel { unit, delta, modifiers, phase: egui::TouchPhase::Move }
+ egui::Event::MouseWheel { source: egui::MouseWheelSource::Unknown, unit, delta, modifiers, phase: egui::TouchPhase::Move }
}
fn web_frame(
@@ -1297,7 +1301,13 @@ mod tests {
] {
for unit in [U::Point, U::Line, U::Page] {
for bracket in [false, true] {
- let event = |phase| egui::Event::MouseWheel { unit, delta: vec2(8.0, 12.0), modifiers: held, phase };
+ let event = |phase| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit,
+ delta: vec2(8.0, 12.0),
+ modifiers: held,
+ phase,
+ };
let mut input = egui::InputState::default();
input.events = if bracket { vec![event(P::Start), event(P::Move), event(P::End)] } else { vec![event(P::Move)] };
let raw = super::immediate_wheel(&input, options, 600.0, &mut false, &mut Default::default(), true, chosen);
@@ -1452,7 +1462,7 @@ mod tests {
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
app.viewport.rect = Some(rect);
- let response = ui.interact(rect, ui.id().with("touchpad-setting"), egui::Sense::click_and_drag());
+ let response = ui.interact(rect, ui.scope_id().with("touchpad-setting"), egui::Sense::click_and_drag());
super::handle(app, ui, rect, &response, caps);
});
out.textures_delta.clear();
@@ -1973,7 +1983,7 @@ mod tests {
};
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
- let resp = ui.interact(rect, ui.id().with("drag-zoom"), egui::Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("drag-zoom"), egui::Sense::click_and_drag());
super::handle(&mut app, ui, rect, &resp, caps);
});
out.textures_delta.clear();
@@ -2026,13 +2036,14 @@ mod tests {
};
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
- let resp = ui.interact(rect, ui.id().with("wheel-speed"), egui::Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("wheel-speed"), egui::Sense::click_and_drag());
super::handle(&mut app, ui, rect, &resp, caps);
});
out.textures_delta.clear();
};
frame(vec![Event::PointerMoved(pos2(200.0, 300.0))]);
frame(vec![Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: MouseWheelUnit::Point,
delta: vec2(0.0, 40.0),
modifiers: Modifiers::NONE,
@@ -2109,7 +2120,7 @@ mod tests {
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
app.viewport.rect = Some(rect);
- let resp = ui.interact(rect, ui.id().with("spin"), egui::Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("spin"), egui::Sense::click_and_drag());
super::handle(app, ui, rect, &resp, super::NavCaps::MODEL);
});
out.textures_delta.clear();
@@ -2179,7 +2190,7 @@ mod tests {
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
app.viewport.rect = Some(rect);
- let resp = ui.interact(rect, ui.id().with("flat"), egui::Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("flat"), egui::Sense::click_and_drag());
super::handle(app, ui, rect, &resp, flat);
});
out.textures_delta.clear();
@@ -2210,7 +2221,13 @@ mod tests {
frame(
&mut app,
modifiers,
- vec![Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(20.0, -10.0), modifiers, phase }],
+ vec![Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(20.0, -10.0),
+ modifiers,
+ phase,
+ }],
);
}
assert_eq!(app.cam.back(), before.back(), "{preset}: trackpad turned a flat page");
@@ -2220,6 +2237,7 @@ mod tests {
}
let before = app.cam;
let wheel = Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Line,
delta: vec2(0.0, 3.0),
modifiers: Modifiers::NONE,
@@ -2255,7 +2273,7 @@ mod tests {
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
app.viewport.rect = Some(rect);
- let resp = ui.interact(rect, ui.id().with("native-pinch"), egui::Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("native-pinch"), egui::Sense::click_and_drag());
super::handle(app, ui, rect, &resp, super::NavCaps::MODEL);
});
out.textures_delta.clear();
@@ -2267,7 +2285,13 @@ mod tests {
vec![
Event::ModifiersChanged(Modifiers::CTRL),
Event::PointerMoved(at),
- Event::MouseWheel { unit: MouseWheelUnit::Point, delta: vec2(0.0, 50.0), modifiers: Modifiers::CTRL, phase: TouchPhase::Move },
+ Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: MouseWheelUnit::Point,
+ delta: vec2(0.0, 50.0),
+ modifiers: Modifiers::CTRL,
+ phase: TouchPhase::Move,
+ },
],
);
assert!(app.cam.distance < before.distance, "a positive Ctrl+wheel pinch zooms in: {} -> {}", before.distance, app.cam.distance);
@@ -2281,7 +2305,13 @@ mod tests {
&mut plain,
vec![
Event::PointerMoved(at),
- Event::MouseWheel { unit: MouseWheelUnit::Point, delta: vec2(0.0, 50.0), modifiers: Modifiers::NONE, phase: TouchPhase::Move },
+ Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: MouseWheelUnit::Point,
+ delta: vec2(0.0, 50.0),
+ modifiers: Modifiers::NONE,
+ phase: TouchPhase::Move,
+ },
],
);
let pinched = before.distance / app.cam.distance;
@@ -2337,6 +2367,7 @@ mod tests {
for phase in [egui::TouchPhase::Start, egui::TouchPhase::End, egui::TouchPhase::Cancel] {
let mut input = egui::InputState::default();
input.events = vec![egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, 40.0),
modifiers: egui::Modifiers::CTRL,
@@ -2357,7 +2388,8 @@ mod tests {
input.events = events;
super::pinch_factor(&input, options, 600.0, None)
};
- let wheel = |unit, delta, modifiers| Event::MouseWheel { unit, delta, modifiers, phase: TouchPhase::Move };
+ let wheel =
+ |unit, delta, modifiers| Event::MouseWheel { source: egui::MouseWheelSource::Unknown, unit, delta, modifiers, phase: TouchPhase::Move };
let close = |a: f32, b: f32| (a - b).abs() < 1e-4;
let point = factor(vec![wheel(MouseWheelUnit::Point, vec2(0.0, 40.0), Modifiers::CTRL)]);
assert!(close(point, (options.scroll_zoom_speed * 40.0).exp()), "point pinch {point}");
@@ -2394,7 +2426,7 @@ mod tests {
let mut out = ctx.run_ui(raw, |ui| {
let rect = ui.max_rect();
app.viewport.rect = Some(rect);
- let resp = ui.interact(rect, ui.id().with("page"), egui::Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("page"), egui::Sense::click_and_drag());
super::handle(&mut app, ui, rect, &resp, caps);
});
out.textures_delta.clear();
diff --git a/crates/ui-egui/src/navigation_bar_view.rs b/crates/ui-egui/src/navigation_bar_view.rs
index 8b44a180bc..094caf0e0b 100644
--- a/crates/ui-egui/src/navigation_bar_view.rs
+++ b/crates/ui-egui/src/navigation_bar_view.rs
@@ -211,7 +211,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
return;
}
crate::scenario::publish_rect("nav:outer", bar.rect);
- let menu_id = ui.id().with("navigation_bar_menu");
+ let menu_id = ui.scope_id().with("navigation_bar_menu");
let mut open = ui.data(|d| d.get_temp::<String>(menu_id)).unwrap_or_default();
let active = ui.rect_contains_pointer(bar.rect)
|| ui.rect_contains_pointer(crate::viewport::axis_rect(app, rect))
@@ -223,7 +223,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
|| app.viewport.spin
|| !open.is_empty();
let opacity = ui_kit::navigation_opacity(app.preferences.navigation_bar.idle, active);
- let background = ui.interact(bar.rect, ui.id().with("navigation_bar_context"), egui::Sense::click());
+ let background = ui.interact(bar.rect, ui.scope_id().with("navigation_bar_context"), egui::Sense::click());
let opacity = if app.preferences.navigation_bar.idle == Idle::Hide {
ui.ctx().animate_value_with_time(menu_id.with("opacity"), opacity, if active { ui_kit::NAV_FADE_SECONDS } else { 0.0 })
} else {
@@ -355,7 +355,7 @@ pub(crate) fn paint_row(
ui_kit::navigation_separator(ui, *bounds);
ui.interact(
*bounds,
- ui.id().with("separator"),
+ ui.scope_id().with("separator"),
if editing.is_some() { egui::Sense::click_and_drag() } else { egui::Sense::click() },
)
} else {
@@ -386,15 +386,14 @@ pub(crate) fn paint_row(
.inner;
let mut hidden = None;
if let Some((selected, caps, render)) = editing {
- response
- .widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), selected == Some(index), app.tr(slot.label)));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), selected == Some(index), app.tr(slot.label)));
ui_kit::navigation_edit_outline(ui, *bounds, !slot.available(caps), selected == Some(index));
if !slot.available(caps) {
hidden = Some(if render { "navbar.custom.hidden_render" } else { "navbar.custom.hidden_design" });
}
} else {
response.widget_info(|| {
- egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), selected(app, slot.id) || open == slot.id, app.tr(slot.label))
+ egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), selected(app, slot.id) || open == slot.id, app.tr(slot.label))
});
}
// The settings' preview keeps its tips above, wherever the bar sits in the view.
diff --git a/crates/ui-egui/src/navigation_cube.rs b/crates/ui-egui/src/navigation_cube.rs
index b8d80aef24..32b2c8871b 100644
--- a/crates/ui-egui/src/navigation_cube.rs
+++ b/crates/ui-egui/src/navigation_cube.rs
@@ -173,7 +173,7 @@ pub(super) fn navigate(app: &mut SolveApp, action: Option<&str>, dir: Option<Vec
fn control(app: &mut SolveApp, ui: &mut egui::Ui, bounds: Rect, action: &str, tooltip: &str) -> bool {
crate::scenario::publish_handle(&format!("navigation_cube:control:{action}"), bounds.center());
- let response = ui.interact(bounds, ui.id().with(("navigation_cube", action)), Sense::click()).backing_on_hover_text(tooltip);
+ let response = ui.interact(bounds, ui.scope_id().with(("navigation_cube", action)), Sense::click()).backing_on_hover_text(tooltip);
let hover = response.hovered();
if response.clicked() {
navigate(app, Some(action), None);
@@ -259,7 +259,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
crate::scenario::publish_count("axis_view_highlights", f64::from(u8::from(hovered.is_some())));
if let Some(face) = hovered.and_then(|i| faces.get(i)) {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
- ui.interact(Rect::from_center_size(hover.unwrap_or(face.centre), vec2(2.0, 2.0)), ui.id().with("navigation_cube_tip"), Sense::hover())
+ ui.interact(Rect::from_center_size(hover.unwrap_or(face.centre), vec2(2.0, 2.0)), ui.scope_id().with("navigation_cube_tip"), Sense::hover())
.backing_on_hover_text(format!(
"{} view. Drag to orbit{}.",
face.label,
diff --git a/crates/ui-egui/src/network_prompt.rs b/crates/ui-egui/src/network_prompt.rs
index 8784a50c5c..5bf818576e 100644
--- a/crates/ui-egui/src/network_prompt.rs
+++ b/crates/ui-egui/src/network_prompt.rs
@@ -118,7 +118,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let _language = crate::i18n::scope(&app.preferences.language);
let hosts = prompt.hosts.iter().map(|h| format!("\\\\{h}")).collect::<Vec<_>>().join(", ");
let detail = crate::i18n::format("network.prompt_detail", &[("host", &hosts)]);
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_network_prompt"), "status_warning", crate::i18n::tr("network.prompt_title"))
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_network_prompt"), "status_warning", crate::i18n::tr("network.prompt_title"))
.tone(ui_kit::Tone::Warning)
.actions(crate::i18n::tr("network.allow_once"), crate::i18n::tr("ui.cancel"), Some(crate::i18n::tr("network.always_allow")))
.selected(ui_kit::Action::Cancel)
diff --git a/crates/ui-egui/src/op_auto.rs b/crates/ui-egui/src/op_auto.rs
index 4104720166..25ce09e834 100644
--- a/crates/ui-egui/src/op_auto.rs
+++ b/crates/ui-egui/src/op_auto.rs
@@ -270,7 +270,7 @@ pub fn update(app: &mut SolveApp, d: &mut Dialog, ctx: &egui::Context) {
/// Where a pick in an Operation row is noted for the next [`update`].
pub(crate) fn picked_id() -> egui::Id {
- egui::Id::new("op_auto_picked")
+ egui::Id::unique("op_auto_picked")
}
/// The Operation row of a window that chooses by itself: any pick there, the shown option
diff --git a/crates/ui-egui/src/open_elsewhere.rs b/crates/ui-egui/src/open_elsewhere.rs
index 0724e0b1b6..b5b4475d62 100644
--- a/crates/ui-egui/src/open_elsewhere.rs
+++ b/crates/ui-egui/src/open_elsewhere.rs
@@ -149,7 +149,7 @@ fn show_lock_prompt(app: &mut SolveApp, ctx: &egui::Context) {
"document.open_elsewhere_detail",
&[("name", &name), ("who", &who), ("when", &crate::recovery_ui::ago(lock.opened)), ("app", &lock.app)],
);
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_open_elsewhere"), "status_warning", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_open_elsewhere"), "status_warning", &title)
.tone(ui_kit::Tone::Warning)
.actions(crate::i18n::tr("document.open_read_only"), crate::i18n::tr("ui.cancel"), Some(crate::i18n::tr("document.open_anyway")))
.selected(ui_kit::Action::Ok)
@@ -219,7 +219,7 @@ fn show_disk_prompt(app: &mut SolveApp, ctx: &egui::Context) {
let name = app.session.path.as_deref().map(file_name).unwrap_or_default();
let title = crate::i18n::format("document.changed_on_disk", &[("name", &name)]);
let detail = crate::i18n::format("document.changed_on_disk_detail", &[("name", &name)]);
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_changed_on_disk"), "status_warning", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_changed_on_disk"), "status_warning", &title)
.tone(ui_kit::Tone::Warning)
.actions(crate::i18n::tr("document.save_copy"), crate::i18n::tr("ui.cancel"), Some(crate::i18n::tr("document.overwrite")))
.selected(ui_kit::Action::Ok)
diff --git a/crates/ui-egui/src/open_meshing.rs b/crates/ui-egui/src/open_meshing.rs
index b0e7730f1a..f1da259c45 100644
--- a/crates/ui-egui/src/open_meshing.rs
+++ b/crates/ui-egui/src/open_meshing.rs
@@ -165,7 +165,7 @@ pub(crate) fn show(app: &SolveApp, ctx: &egui::Context) {
let t = crate::theme::Tokens::get();
let at = egui::pos2(view.left() + 12.0, view.bottom() - 12.0);
Container::new(ctx, Surface::Toast)
- .area(egui::Id::new("open_meshing"))
+ .area(egui::Id::unique("open_meshing"))
.order(egui::Order::Foreground)
.pivot(egui::Align2::LEFT_BOTTOM)
.fixed_pos(at)
diff --git a/crates/ui-egui/src/panel_runtime/host.rs b/crates/ui-egui/src/panel_runtime/host.rs
index d4c8917cf4..2208bba888 100644
--- a/crates/ui-egui/src/panel_runtime/host.rs
+++ b/crates/ui-egui/src/panel_runtime/host.rs
@@ -270,7 +270,7 @@ impl PanelHost for EguiPanelHost<'_> {
if let Some(status) = &presentation.status {
response = response.backing_on_hover_text(status);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &presentation.title));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, &presentation.title));
}
if slot == ContentSlot::Footer && !presentation.actions.is_empty() {
egui::ScrollArea::horizontal().id_salt("panel_actions").show(ui, |ui| {
diff --git a/crates/ui-egui/src/params_dialog.rs b/crates/ui-egui/src/params_dialog.rs
index c99efc04af..8d22feb087 100644
--- a/crates/ui-egui/src/params_dialog.rs
+++ b/crates/ui-egui/src/params_dialog.rs
@@ -226,7 +226,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let title = crate::i18n::tr_label("Parameters");
let panel = ui_kit::Panel::new(
title,
- egui::Id::new("sc_params_dialog"),
+ egui::Id::unique("sc_params_dialog"),
anchor,
drag_bounds,
side,
@@ -363,7 +363,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
/// Where the chosen order is kept: egui's persisted memory, like a section's open state.
fn sort_id() -> egui::Id {
- egui::Id::new("sc_params_sort")
+ egui::Id::unique("sc_params_sort")
}
/// The dialog's sections, each in the chosen order.
@@ -862,7 +862,7 @@ struct Cache {
}
fn cache_id() -> egui::Id {
- egui::Id::new("sc_param_completions")
+ egui::Id::unique("sc_param_completions")
}
/// Keep the completion list (parameters, functions, constants, units) for this revision of the
diff --git a/crates/ui-egui/src/personal_sheet_rules.rs b/crates/ui-egui/src/personal_sheet_rules.rs
index 365d942e7e..d91a84c5b8 100644
--- a/crates/ui-egui/src/personal_sheet_rules.rs
+++ b/crates/ui-egui/src/personal_sheet_rules.rs
@@ -308,7 +308,7 @@ struct PanelState {
}
fn panel_id() -> egui::Id {
- egui::Id::new("personal_sheet_rules_panel")
+ egui::Id::unique("personal_sheet_rules_panel")
}
fn rule_manager(d: &mut Dialog) -> Option<&mut Sm> {
@@ -357,7 +357,7 @@ pub(crate) fn rows(ui: &mut egui::Ui, d: &mut Dialog, library: &mut Library, doc
}
});
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::ComboBox, ui.is_enabled(), tr("sheet.personal_rules.rule"));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::ComboBox, ui.is_enabled(), tr("sheet.personal_rules.rule"));
info.current_text_value = Some(display.clone());
info
});
@@ -442,7 +442,7 @@ pub(crate) fn name_prompt(ctx: &egui::Context, d: &mut Dialog, library: &mut Lib
let mut state = ctx.data_mut(|data| data.get_temp::<PanelState>(id)).unwrap_or_default();
let Some(mut prompt) = state.prompt.take() else { return false };
let title = tr(if prompt.renaming { "sheet.personal_rules.rename" } else { "sheet.personal_rules.save" });
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("personal_sheet_rule_name"), "save", title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("personal_sheet_rule_name"), "save", title)
.actions(if prompt.renaming { tr("sheet.personal_rules.rename") } else { crate::i18n::tr_label("Save") }, "Cancel", None)
.show(ctx, true, |ui| {
ui_kit::row(ui, "sheet.personal_rules.name", |ui| ui_kit::focused_text_field(ui, &mut prompt.name, tr("sheet.personal_rules.name_hint")));
diff --git a/crates/ui-egui/src/place_gizmo.rs b/crates/ui-egui/src/place_gizmo.rs
index 3c3d5ea194..251cf75a65 100644
--- a/crates/ui-egui/src/place_gizmo.rs
+++ b/crates/ui-egui/src/place_gizmo.rs
@@ -244,7 +244,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, painter: &egui::Painte
let Some(bs) = proj.to_screen(base) else { return };
let t = Tokens::get();
let area = |c: Pos2| egui::Rect::from_center_size(c, vec2(2.0 * REACH, 2.0 * REACH));
- let id = |what: &str| egui::Id::new(("sc_place", sp.name, what));
+ let id = |what: &str| egui::Id::unique(("sc_place", sp.name, what));
// The crosshair that moves the feature. The press lands where the finger is, not always the
// centre: the drag keeps that gap.
@@ -384,7 +384,7 @@ fn ring_radius(proj: &Proj, base: Vec3, x: Vec3, y: Vec3) -> Option<f64> {
/// `anchor` (the arrow's tip) or above it, whichever is clear first. Seen straight down the arrow
/// collapses onto the place and the box sits just right of it, where the ring's grip often is.
pub(crate) fn yield_box(ui: &egui::Ui, anchor: Pos2, at: Pos2) -> Pos2 {
- let Some(size) = ui.ctx().memory(|m| m.area_rect(egui::Id::new("sc_canvas_area"))).map(|r| r.size()) else { return at };
+ let Some(size) = ui.ctx().memory(|m| m.area_rect(egui::Id::unique("sc_canvas_area"))).map(|r| r.size()) else { return at };
let target = match RING_ABOUT.with(|c| c.get()) {
// With a ring, the box keeps out of the whole circle the ring, its grip, the compass and
// the readout sweep, whatever the turn: one place per view, nothing moves when a turn
@@ -403,7 +403,7 @@ pub(crate) fn yield_box(ui: &egui::Ui, anchor: Pos2, at: Pos2) -> Pos2 {
};
// The step aside slides, as an offset from where the box would be, so the box still follows
// the arrow's tip at once when the view moves.
- at + motion::slide(ui.ctx(), egui::Id::new("sc_place_box"), target - at, DIM_S)
+ at + motion::slide(ui.ctx(), egui::Id::unique("sc_place_box"), target - at, DIM_S)
}
/// What the ring needs around it beyond its radius (pixels): the grip, the compass and the
diff --git a/crates/ui-egui/src/plugins.rs b/crates/ui-egui/src/plugins.rs
index 6915a8ab9b..2a57e45c9c 100644
--- a/crates/ui-egui/src/plugins.rs
+++ b/crates/ui-egui/src/plugins.rs
@@ -160,7 +160,12 @@ fn page_in_dir(app: &mut SolveApp, ui: &mut egui::Ui, dir: Option<&Path>) {
let searching = crate::prefs_search::querying(ui);
// The page's own box is for browsing Plugins. The dialog search is the filter while it is active.
if !searching {
- crate::ui_kit::search_field(ui, ui.id().with("plugins_search"), &mut app.prefs_window.plugin_query, crate::i18n::tr("ui.plugins_search"));
+ crate::ui_kit::search_field(
+ ui,
+ ui.scope_id().with("plugins_search"),
+ &mut app.prefs_window.plugin_query,
+ crate::i18n::tr("ui.plugins_search"),
+ );
ui.add_space(8.0);
}
let (plugins, skipped) = scan(dir);
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index c25af97abc..7a11fc3c12 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -459,9 +459,9 @@ fn page_path(index: usize) -> String {
fn search_header(ui: &mut egui::Ui, app: &mut SolveApp) {
let typed = drive_search(ui, app);
- let field = ui_kit::preferences_search_field(ui, egui::Id::new("prefs_search"), &mut app.prefs_window.filter, crate::i18n::tr("prefs.search"));
+ let field = ui_kit::preferences_search_field(ui, egui::Id::unique("prefs_search"), &mut app.prefs_window.filter, crate::i18n::tr("prefs.search"));
if typed {
- place_search_cursor(ui.ctx(), egui::Id::new("prefs_search"), app.prefs_window.filter.chars().count());
+ place_search_cursor(ui.ctx(), egui::Id::unique("prefs_search"), app.prefs_window.filter.chars().count());
}
crate::scenario::publish_handle("prefs:search", field.rect.center());
if field.has_focus() {
@@ -478,7 +478,7 @@ fn drive_search(ui: &mut egui::Ui, app: &mut SolveApp) -> bool {
if crate::keymap::capturing(app) {
return false;
}
- let id = egui::Id::new("prefs_search");
+ let id = egui::Id::unique("prefs_search");
if ctx.input_mut(|input| input.consume_key(egui::Modifiers::COMMAND, egui::Key::F)) {
ctx.memory_mut(|memory| memory.request_focus(id));
}
@@ -2737,7 +2737,7 @@ impl SettingReset {
/// when a font was picked, and egui keeps that in the saved window state: it then opened as its
/// title bar alone, for good (#1800). Unfold it.
fn unfold(ctx: &egui::Context) {
- if let Some(mut body) = egui::collapsing_header::CollapsingState::load(ctx, egui::Id::new("sc_prefs").with("collapsing"))
+ if let Some(mut body) = egui::collapsing_header::CollapsingState::load(ctx, egui::Id::unique("sc_prefs").with("collapsing"))
&& !body.is_open()
{
body.set_open(true);
@@ -2782,7 +2782,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let before = app.preferences.clone();
let capturing = crate::keymap::capturing(app);
let pending = apply_pending(app);
- let window = ui_kit::Window::new(egui::Id::new("sc_prefs"), "settings", app.tr("ui.preferences"))
+ let window = ui_kit::Window::new(egui::Id::unique("sc_prefs"), "settings", app.tr("ui.preferences"))
.cards(10.0 / 3.0)
.page_rows(24.0)
.page_header_in_titlebar()
@@ -3198,7 +3198,7 @@ fn button_job_picker(
[None, Some(ButtonJob::Settings)].into_iter().chain(views.into_iter().chain(keys).chain(commands).map(Some)).collect();
let entries: Vec<(String, String)> = jobs.iter().map(|job| (button_job_value(job.as_ref()), button_job_label(app, job.as_ref()))).collect();
let options: Vec<_> = entries.iter().map(|(value, label)| ui_kit::SearchOption { value, label, handle: None }).collect();
- let filter_id = egui::Id::new(("sc_space_mouse_button_filter", number));
+ let filter_id = egui::Id::unique(("sc_space_mouse_button_filter", number));
let mut filter: String = ui.data_mut(|data| data.get_temp(filter_id).unwrap_or_default());
let id = format!("sc_space_mouse_button_{number}");
let chosen = ui_kit::searchable_dropdown(ui, &id, &button_job_label(app, current), &mut filter, &options, None, None);
@@ -5017,7 +5017,7 @@ mod tests {
assert!(h.app.space_mouse.calibrating.is_some() && h.app.prefs_window.open);
let window = crate::scenario::rect_of("dialog:window").expect("the calibration window is the last window drawn");
let top = h.ctx.layer_id_at(window.center());
- assert!(top.is_some_and(|layer| layer.id == egui::Id::new("sc_space_mouse_calibration")), "top is {top:?}");
+ assert!(top.is_some_and(|layer| layer.id == egui::Id::unique("sc_space_mouse_calibration")), "top is {top:?}");
}
/// Scrolls vertically to the handle, then clicks after the wheel animation settles.
@@ -5040,6 +5040,7 @@ mod tests {
}
h.app.synthetic.push(egui::Event::PointerMoved(body.center()));
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, if target.is_some_and(|at| at.y < body.top()) { 60.0 } else { -60.0 }),
modifiers: egui::Modifiers::NONE,
@@ -6681,10 +6682,11 @@ mod tests {
..Default::default()
};
let app = &mut h.app;
- let out = h.ctx.run_ui(raw, |ui| {
+ let mut out = h.ctx.run_ui(raw, |ui| {
app.logic(ui.ctx());
app.ui(ui);
});
+ out.textures_delta.clear();
let commands = out.viewport_output.get(&egui::ViewportId::ROOT).map(|v| v.commands.clone()).unwrap_or_default();
commands.into_iter().filter_map(|c| if let egui::ViewportCommand::SetTheme(t) = c { Some(t) } else { None }).collect::<Vec<_>>()
};
@@ -8282,7 +8284,7 @@ mod tests {
fn picking_a_font_keeps_the_preferences_window_unfolded() {
use egui::collapsing_header::CollapsingState;
use serde_json::json;
- let body = egui::Id::new("sc_prefs").with("collapsing");
+ let body = egui::Id::unique("sc_prefs").with("collapsing");
let folded = |h: &crate::scenario::Harness| CollapsingState::load(&h.ctx, body).is_some_and(|s| !s.is_open());
let mut h = crate::scenario::Harness::new();
h.call("ui.prefs", json!({"open":"Interface"}));
diff --git a/crates/ui-egui/src/prefs/mouse3d.rs b/crates/ui-egui/src/prefs/mouse3d.rs
index 5ebc4d4c4d..17b25618d5 100644
--- a/crates/ui-egui/src/prefs/mouse3d.rs
+++ b/crates/ui-egui/src/prefs/mouse3d.rs
@@ -216,7 +216,7 @@ fn axes(app: &mut SolveApp, ui: &mut egui::Ui) {
let enabled = app.preferences.space_mouse_enabled;
let raw: [i16; 6] = app.space_mouse.raw.into();
// Frames come on input, so a reading that moved since the last one gets a frame to show it.
- let seen = ui.id().with("space_mouse_meter_raw");
+ let seen = ui.scope_id().with("space_mouse_meter_raw");
let before = ui.data_mut(|data| data.get_temp::<[i16; 6]>(seen));
ui.data_mut(|data| data.insert_temp(seen, raw));
if before.is_some_and(|before| before != raw) {
diff --git a/crates/ui-egui/src/prefs/navbar.rs b/crates/ui-egui/src/prefs/navbar.rs
index 80d0d46bd2..13963e85e0 100644
--- a/crates/ui-egui/src/prefs/navbar.rs
+++ b/crates/ui-egui/src/prefs/navbar.rs
@@ -245,8 +245,8 @@ fn slot_count(app: &SolveApp, ui: &mut egui::Ui, stage: Rect, bar: Rect) {
};
let rect = Rect::from_min_size(egui::pos2(x, y), size);
ui.painter().with_clip_rect(stage).galley(rect.min, galley, view.text_dim);
- let response = ui.interact(rect, ui.id().with("navbar_slot_count"), Sense::hover());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text.as_str()));
+ let response = ui.interact(rect, ui.scope_id().with("navbar_slot_count"), Sense::hover());
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text.as_str()));
scenario::publish_rect("prefs:navbar:count", rect);
}
@@ -393,7 +393,7 @@ fn inspector_header(app: &mut SolveApp, ui: &mut egui::Ui, state: &mut State, in
})
.inner
.backing_on_hover_text(label);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled && ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled && ui.is_enabled(), label));
scenario::publish_target(&format!("prefs:navbar:{key}"), response.rect);
if response.clicked() {
edit(app, state, index, key);
diff --git a/crates/ui-egui/src/prefs_notice.rs b/crates/ui-egui/src/prefs_notice.rs
index 71212e7ca3..d3de853189 100644
--- a/crates/ui-egui/src/prefs_notice.rs
+++ b/crates/ui-egui/src/prefs_notice.rs
@@ -10,7 +10,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
if app.settings_reset.is_empty() {
return;
}
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_settings_reset"), "settings", app.tr("settings.reset_title"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_settings_reset"), "settings", app.tr("settings.reset_title"))
.actions(app.tr("ui.open_preferences"), app.tr("ui.heading_ok"), None)
.show(ctx, true, |ui| {
ui_kit::text(ui, app.tr("settings.reset_intro"), ui_kit::Text::Report("intro", false));
diff --git a/crates/ui-egui/src/prefs_search.rs b/crates/ui-egui/src/prefs_search.rs
index 198c992122..359cf5f773 100644
--- a/crates/ui-egui/src/prefs_search.rs
+++ b/crates/ui-egui/src/prefs_search.rs
@@ -100,7 +100,7 @@ impl Drop for SearchFrame {
pub(crate) fn begin(ui: &Ui, filter: &str) -> SearchFrame {
let query: String = filter.trim().chars().take(256).collect::<String>().to_lowercase();
ui.ctx().data_mut(|data| {
- let state = data.get_temp_mut_or_insert_with(Id::new(STATE), State::default);
+ let state = data.get_temp_mut_or_insert_with(Id::unique(STATE), State::default);
let changed = state.memory_query != query;
if changed {
state.memory_query = query.clone();
@@ -131,7 +131,7 @@ pub(crate) fn begin(ui: &Ui, filter: &str) -> SearchFrame {
fn finish(ctx: &Context) -> bool {
let mut dirty = false;
ctx.data_mut(|data| {
- let state = data.get_temp_mut_or_default::<State>(Id::new(STATE));
+ let state = data.get_temp_mut_or_default::<State>(Id::unique(STATE));
dirty = state.live && state.dirty;
state.live = false;
});
@@ -141,7 +141,7 @@ fn finish(ctx: &Context) -> bool {
fn with<R>(ui: &Ui, f: impl FnOnce(&mut State) -> R) -> Option<R> {
let mut out = None;
ui.ctx().data_mut(|data| {
- let state = data.get_temp_mut_or_default::<State>(Id::new(STATE));
+ let state = data.get_temp_mut_or_default::<State>(Id::unique(STATE));
if state.live {
out = Some(f(state));
}
@@ -251,11 +251,11 @@ pub(crate) fn pop_passthrough(ui: &Ui) {
}
pub(crate) fn set_force_scroll(ctx: &Context, on: bool) {
- ctx.data_mut(|data| data.insert_temp(Id::new(SCROLL), on));
+ ctx.data_mut(|data| data.insert_temp(Id::unique(SCROLL), on));
}
pub(crate) fn force_scroll(ctx: &Context) -> bool {
- ctx.data(|data| data.get_temp(Id::new(SCROLL))).unwrap_or(false)
+ ctx.data(|data| data.get_temp(Id::unique(SCROLL))).unwrap_or(false)
}
pub(crate) fn begin_page(ui: &Ui, index: usize, label: &str) {
@@ -726,34 +726,34 @@ fn english_hit(query: &str, shown: &str) -> bool {
/// A text field or drag value had the keyboard on the previous frame.
pub(crate) fn shift_key_sink(ctx: &Context) -> bool {
- let held = ctx.data(|data| data.get_temp::<bool>(Id::new(SINK_NOW))).unwrap_or(false);
- ctx.data_mut(|data| data.insert_temp(Id::new(SINK_NOW), false));
+ let held = ctx.data(|data| data.get_temp::<bool>(Id::unique(SINK_NOW))).unwrap_or(false);
+ ctx.data_mut(|data| data.insert_temp(Id::unique(SINK_NOW), false));
held
}
pub(crate) fn key_sink(ctx: &Context) -> bool {
- ctx.data(|data| data.get_temp::<bool>(Id::new(SINK_PREV))).unwrap_or(false)
+ ctx.data(|data| data.get_temp::<bool>(Id::unique(SINK_PREV))).unwrap_or(false)
}
pub(crate) fn note_key_sink(ctx: &Context) {
- ctx.data_mut(|data| data.insert_temp(Id::new(SINK_NOW), true));
+ ctx.data_mut(|data| data.insert_temp(Id::unique(SINK_NOW), true));
}
pub(crate) fn set_key_sink_prev(ctx: &Context, held: bool) {
- ctx.data_mut(|data| data.insert_temp(Id::new(SINK_PREV), held));
+ ctx.data_mut(|data| data.insert_temp(Id::unique(SINK_PREV), held));
}
/// The matches drawn last frame, for Up/Down and Enter before this pass rebuilds them.
pub(crate) fn nav(ctx: &Context) -> (String, usize, Vec<NavHit>) {
ctx.data(|data| {
- let store = data.get_temp::<NavStore>(Id::new(NAV)).unwrap_or_default();
+ let store = data.get_temp::<NavStore>(Id::unique(NAV)).unwrap_or_default();
(store.query, store.cursor, store.hits)
})
}
pub(crate) fn set_cursor(ctx: &Context, cursor: usize) {
ctx.data_mut(|data| {
- let store = data.get_temp_mut_or_default::<NavStore>(Id::new(NAV));
+ let store = data.get_temp_mut_or_default::<NavStore>(Id::unique(NAV));
store.scroll = store.cursor != cursor;
store.cursor = cursor;
});
@@ -765,7 +765,7 @@ pub(crate) fn store_nav(ui: &Ui) {
with(ui, |state| (state.query.clone(), state.nav.iter().map(|hit| NavHit { page: hit.page, label: hit.label.clone() }).collect::<Vec<_>>()))
.unwrap_or_default();
ui.ctx().data_mut(|data| {
- let store = data.get_temp_mut_or_default::<NavStore>(Id::new(NAV));
+ let store = data.get_temp_mut_or_default::<NavStore>(Id::unique(NAV));
store.query = query;
store.hits = hits;
if store.cursor >= store.hits.len() {
@@ -783,7 +783,7 @@ pub(crate) fn remember(ui: &mut Ui, label: &str, rect: Rect) {
return;
}
let (cursor, scroll) = ui.ctx().data(|data| {
- let store = data.get_temp::<NavStore>(Id::new(NAV)).unwrap_or_default();
+ let store = data.get_temp::<NavStore>(Id::unique(NAV)).unwrap_or_default();
(store.cursor, store.scroll)
});
let selected = with(ui, |state| {
@@ -807,9 +807,9 @@ pub(crate) fn remember(ui: &mut Ui, label: &str, rect: Rect) {
pub(crate) fn set_reveal(ctx: &Context, reveal: Option<Reveal>) {
ctx.data_mut(|data| {
if let Some(reveal) = reveal {
- data.insert_temp(Id::new(REVEAL_ID), reveal);
+ data.insert_temp(Id::unique(REVEAL_ID), reveal);
} else {
- data.remove::<Reveal>(Id::new(REVEAL_ID));
+ data.remove::<Reveal>(Id::unique(REVEAL_ID));
}
});
}
@@ -820,7 +820,7 @@ pub(crate) fn reveal_for(page: usize, label: &str) -> Reveal {
/// Scroll the opened setting into view and outline it until [`Reveal::until`].
pub(crate) fn follow(ui: &Ui, label: &str, rect: Rect) {
- let Some(reveal) = ui.data(|data| data.get_temp::<Reveal>(Id::new(REVEAL_ID))) else { return };
+ let Some(reveal) = ui.data(|data| data.get_temp::<Reveal>(Id::unique(REVEAL_ID))) else { return };
if crate::now_ms() > reveal.until || fold(label) != fold(&reveal.label) {
return;
}
@@ -1213,7 +1213,7 @@ mod tests {
h.frames(2);
h.step(&serde_json::json!({"key": "F", "cmd": true})).expect("find");
h.frames(1);
- assert!(h.ctx.memory(|memory| memory.has_focus(egui::Id::new("prefs_search"))), "Cmd+F focuses search");
+ assert!(h.ctx.memory(|memory| memory.has_focus(egui::Id::unique("prefs_search"))), "Cmd+F focuses search");
h.step(&serde_json::json!({"text": "zo"})).expect("type");
h.frames(20);
assert!(h.widget("Reverse zoom direction").is_some(), "typed letters search from the open page");
@@ -1402,6 +1402,7 @@ mod tests {
h.frames(20);
let first = crate::scenario::handle_at("prefs:search:current").expect("first match");
let wheel = egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, -400.0),
modifiers: egui::Modifiers::NONE,
diff --git a/crates/ui-egui/src/quick_measure.rs b/crates/ui-egui/src/quick_measure.rs
index f2e82a04ff..7c1560e979 100644
--- a/crates/ui-egui/src/quick_measure.rs
+++ b/crates/ui-egui/src/quick_measure.rs
@@ -252,7 +252,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &egui::Ui, view: egui::Rect, taken: &
return None;
}
let response =
- ui.interact(r, egui::Id::new("sc_quick_measure"), egui::Sense::click()).backing_on_hover_text(crate::i18n::tr("measure.quick_copy"));
+ ui.interact(r, egui::Id::unique("sc_quick_measure"), egui::Sense::click()).backing_on_hover_text(crate::i18n::tr("measure.quick_copy"));
crate::scenario::publish_rect("measure:quick", r);
painter.rect_filled(r, t.radius_sm, if response.hovered() { t.hover } else { t.overlay });
painter.rect_stroke(r, t.radius_sm, egui::Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
diff --git a/crates/ui-egui/src/recent_colors.rs b/crates/ui-egui/src/recent_colors.rs
index f77376b8c9..0bc0e76a39 100644
--- a/crates/ui-egui/src/recent_colors.rs
+++ b/crates/ui-egui/src/recent_colors.rs
@@ -14,7 +14,7 @@ struct RecentColors {
}
fn recent_id() -> egui::Id {
- egui::Id::new("color_recent_colors")
+ egui::Id::unique("color_recent_colors")
}
/// The recently picked colours, newest first.
diff --git a/crates/ui-egui/src/recovery_ui.rs b/crates/ui-egui/src/recovery_ui.rs
index 02305b428f..8ce0e46267 100644
--- a/crates/ui-egui/src/recovery_ui.rs
+++ b/crates/ui-egui/src/recovery_ui.rs
@@ -140,7 +140,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
let mut act: Option<(Entry, bool)> = None;
let mut discard_all = false;
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_recover_prompt"), "restore", crate::i18n::tr_label("Recover unsaved design?"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_recover_prompt"), "restore", crate::i18n::tr_label("Recover unsaved design?"))
.actions("", crate::i18n::tr_label("Later"), None)
.show_with_left(
ctx,
@@ -216,7 +216,7 @@ pub fn browser_copies_window(ctx: &egui::Context, language: &str, copies: &[Brow
_ => crate::i18n::tr("recovery.restore_title").to_string(),
};
let mut act = None;
- let _ = ui_kit::Window::new(egui::Id::new("sc_browser_keep_restore"), "restore", &title).required().show_body(ctx, |ui| {
+ let _ = ui_kit::Window::new(egui::Id::unique("sc_browser_keep_restore"), "restore", &title).required().show_body(ctx, |ui| {
ui_kit::text(ui, crate::i18n::tr("recovery.restore_intro"), ui_kit::Text::Report("intro", false));
for (index, c) in copies.iter().enumerate() {
if copies.len() > 1 {
@@ -249,7 +249,7 @@ fn confirm_discard_all(app: &mut SolveApp, ctx: &egui::Context) {
} else {
crate::i18n::format("recovery.discard_all_title", &[("count", &count.to_string())])
};
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("sc_recover_discard_all"), "delete", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("sc_recover_discard_all"), "delete", &title)
.tone(ui_kit::Tone::Danger)
.actions(crate::i18n::tr("recovery.discard_all"), crate::i18n::tr("ui.cancel"), None)
.show(ctx, true, |ui| {
diff --git a/crates/ui-egui/src/render_ui/assign.rs b/crates/ui-egui/src/render_ui/assign.rs
index 1de2823998..0411f88a8d 100644
--- a/crates/ui-egui/src/render_ui/assign.rs
+++ b/crates/ui-egui/src/render_ui/assign.rs
@@ -533,7 +533,7 @@ pub(crate) fn selection_bar(app: &mut SolveApp, ui: &mut egui::Ui, free: egui::R
crate::shell::within(screen.top() - crate::theme::Tokens::get().space_12, free.top(), free.bottom()),
);
let ctx = ui.ctx().clone();
- let pill = ui_kit::Container::selection_card(&ctx, egui::Id::new("render_selection"), anchor, free, |ui| {
+ let pill = ui_kit::Container::selection_card(&ctx, egui::Id::unique("render_selection"), anchor, free, |ui| {
ui_kit::selection_actions(ui, &selection_name(app, &sel), &actions)
});
crate::scenario::publish_rect("render:selection", pill.response.rect);
@@ -572,7 +572,7 @@ pub(crate) fn replacement_dialog(app: &mut SolveApp, ctx: &egui::Context) {
let entries: Vec<_> = entries.into_iter().filter(|entry| entry["available"] != false).collect();
let mut selected = app.render_workspace.view.assign.replacement_index;
let title = app.tr("render.replace_all").to_string();
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("render_replace_look"), "reorder", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("render_replace_look"), "reorder", &title)
.actions(&title, app.tr_label("Cancel"), None)
.show(ctx, !entries.is_empty(), |ui| {
ui_kit::text(ui, from["name"].as_str().unwrap_or(""), ui_kit::Text::Inline);
diff --git a/crates/ui-egui/src/render_ui/mod.rs b/crates/ui-egui/src/render_ui/mod.rs
index df191da9de..649d76eb76 100644
--- a/crates/ui-egui/src/render_ui/mod.rs
+++ b/crates/ui-egui/src/render_ui/mod.rs
@@ -36,7 +36,7 @@ pub(crate) fn canvas(app: &SolveApp, viewport: Rect) -> Rect {
pub(crate) fn stage_bar(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
use crate::render_workspace::Stage;
crate::scenario::publish_rect("render:stage_bar", rect);
- ui.ctx().data_mut(|d| d.remove::<Rect>(egui::Id::new("sc_ribbon_search")));
+ ui.ctx().data_mut(|d| d.remove::<Rect>(egui::Id::unique("sc_ribbon_search")));
let labels: Vec<_> = Stage::ALL.iter().map(|stage| app.tr(stage.label()).to_string()).collect();
let selected = Stage::ALL.iter().position(|s| *s == app.render_workspace.view.stage).unwrap_or(0);
let ready = [crate::render_workspace::job_ready(app, "render.start"), crate::render_workspace::job_ready(app, "render.cancel")];
@@ -187,7 +187,7 @@ pub(crate) fn overlays(app: &mut SolveApp, ui: &mut egui::Ui) {
return;
}
if crate::render_workspace::job_busy(app) {
- let pill = Container::navigation_card(ui.ctx(), egui::Id::new("sc_render_progress"), free.center_top(), egui::Align2::CENTER_TOP, |ui| {
+ let pill = Container::navigation_card(ui.ctx(), egui::Id::unique("sc_render_progress"), free.center_top(), egui::Align2::CENTER_TOP, |ui| {
// Bound the row by the canvas, not by the card's size last frame: a longer status or
// name would otherwise squeeze Cancel or cut a name that has room (#11222).
let t = Tokens::get();
@@ -207,7 +207,7 @@ pub(crate) fn overlays(app: &mut SolveApp, ui: &mut egui::Ui) {
if !crate::render_workspace::result_active(app) && app.session.render_selected_result().is_some() {
let free = if crate::render_workspace::job_busy(app) { Container::below_navigation_row(free) } else { free };
let card =
- Container::navigation_card(ui.ctx(), egui::Id::new("sc_render_compare_controls"), free.center_top(), egui::Align2::CENTER_TOP, |ui| {
+ Container::navigation_card(ui.ctx(), egui::Id::unique("sc_render_compare_controls"), free.center_top(), egui::Align2::CENTER_TOP, |ui| {
crate::render_workspace::comparison_controls(app, ui)
});
crate::shell::register_panel(app, "render:compare-controls", Some(card.response.rect), None);
@@ -229,7 +229,7 @@ pub(crate) fn dock_chip(app: &mut SolveApp, ui: &mut egui::Ui, id: &'static str,
let position = if left { bounds.left_top() + vec2(t.space_8, 0.0) } else { bounds.right_top() - vec2(t.space_8, 0.0) };
let ctx = ui.ctx().clone();
let chip =
- Container::navigation_card(&ctx, egui::Id::new(id), position, if left { egui::Align2::LEFT_TOP } else { egui::Align2::RIGHT_TOP }, |ui| {
+ Container::navigation_card(&ctx, egui::Id::unique(id), position, if left { egui::Align2::LEFT_TOP } else { egui::Align2::RIGHT_TOP }, |ui| {
let response = ui_kit::choice_chip(ui, id, app.tr(label), false);
crate::scenario::publish_target(id, response.rect);
if response.clicked() {
@@ -247,7 +247,7 @@ fn shots_pill(app: &mut SolveApp, ui: &mut egui::Ui, free: Rect) {
let ctx = ui.ctx().clone();
let pill = Container::navigation_card(
&ctx,
- egui::Id::new("sc_render_shots_pill"),
+ egui::Id::unique("sc_render_shots_pill"),
free.left_bottom() + vec2(Tokens::get().space_8, -Tokens::get().space_8),
egui::Align2::LEFT_BOTTOM,
|ui| {
diff --git a/crates/ui-egui/src/render_ui/scene.rs b/crates/ui-egui/src/render_ui/scene.rs
index adcf63abd5..3af41122f2 100644
--- a/crates/ui-egui/src/render_ui/scene.rs
+++ b/crates/ui-egui/src/render_ui/scene.rs
@@ -80,7 +80,7 @@ fn section(app: &mut SolveApp, ui: &mut egui::Ui, key: &str) -> bool {
}];
let row = browser::draw_row(
ui,
- ui.id().with(&id),
+ ui.scope_id().with(&id),
&Row {
label: &label,
name: true,
@@ -180,7 +180,7 @@ pub(crate) fn sections(app: &mut SolveApp, ui: &mut egui::Ui) {
let environment_label = app.tr("render.tree_environment").to_string();
let row = browser::draw_row(
ui,
- ui.id().with("render_environment"),
+ ui.scope_id().with("render_environment"),
&Row {
label: &environment_label,
name: true,
@@ -212,7 +212,7 @@ pub(crate) fn sections(app: &mut SolveApp, ui: &mut egui::Ui) {
let actions = [ui_kit::TreeAction { icon: "lookat", hover_only: true, label: &solo_label, reason: None, target: &solo_target }];
let row = browser::draw_row(
ui,
- ui.id().with(("render_light", id)),
+ ui.scope_id().with(("render_light", id)),
&Row {
depth: 1,
label: &label,
@@ -251,7 +251,7 @@ pub(crate) fn sections(app: &mut SolveApp, ui: &mut egui::Ui) {
let active = name == app.render_workspace.view.name;
let row = browser::draw_row(
ui,
- ui.id().with(("render_shot", &name)),
+ ui.scope_id().with(("render_shot", &name)),
&Row {
depth: 1,
label: &name,
@@ -300,7 +300,7 @@ pub(crate) fn output(app: &mut SolveApp, ui: &mut egui::Ui) {
let subtitle = format!("{size} · {format}");
let row = browser::draw_row(
ui,
- ui.id().with("render_output"),
+ ui.scope_id().with("render_output"),
&Row {
label: app.tr("render.tree_output"),
icon: "render_image",
@@ -324,7 +324,7 @@ pub(crate) fn output(app: &mut SolveApp, ui: &mut egui::Ui) {
let subtitle = crate::render_workspace::output_child_summary(app, kind);
let row = browser::draw_row(
ui,
- ui.id().with(("render_output_child", kind)),
+ ui.scope_id().with(("render_output_child", kind)),
&Row {
depth: 1,
label: app.tr(key),
@@ -377,7 +377,7 @@ fn wear(app: &mut SolveApp, ui: &mut egui::Ui) {
let subtitle = wear_subtitle(app);
let row = browser::draw_row(
ui,
- ui.id().with("render_wear"),
+ ui.scope_id().with("render_wear"),
&Row {
depth: 1,
label: app.tr("render.wear_title"),
@@ -421,7 +421,7 @@ pub(crate) fn objects(app: &mut SolveApp, ui: &mut egui::Ui, hover_bodies: &mut
);
let row = browser::draw_row(
ui,
- ui.id().with(("render_look", &key)),
+ ui.scope_id().with(("render_look", &key)),
&Row {
depth: 1,
label: &label,
@@ -479,7 +479,7 @@ pub(crate) fn objects(app: &mut SolveApp, ui: &mut egui::Ui, hover_bodies: &mut
});
let row = browser::draw_row(
ui,
- ui.id().with((&key, &name)),
+ ui.scope_id().with((&key, &name)),
&Row {
depth: 2,
label: &name,
diff --git a/crates/ui-egui/src/render_ui/wear.rs b/crates/ui-egui/src/render_ui/wear.rs
index 90f5c55c3f..8aed39ca6d 100644
--- a/crates/ui-egui/src/render_ui/wear.rs
+++ b/crates/ui-egui/src/render_ui/wear.rs
@@ -52,7 +52,7 @@ fn layer_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
}];
let row = ui_kit::tree_row(
ui,
- ui.id().with(("aging-layer", index)),
+ ui.scope_id().with(("aging-layer", index)),
&ui_kit::Row { label: &label, name: true, selected: index == editor.selected_aging, actions: &actions, ..Default::default() },
);
if let Some(rect) = row.rect {
@@ -120,7 +120,7 @@ fn layer_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
}
}
let search_label = app.tr("render.aging_target_search").to_string();
- ui_kit::bounded_cell_editor(ui, ui.id().with("aging_target_search"), &mut editor.search, &search_label, false, 128);
+ ui_kit::bounded_cell_editor(ui, ui.scope_id().with("aging_target_search"), &mut editor.search, &search_label, false, 128);
let selected = layer.target.as_ref().map_or_else(
|| app.tr("render.aging_all_bodies").to_string(),
|identity| {
diff --git a/crates/ui-egui/src/render_workspace.rs b/crates/ui-egui/src/render_workspace.rs
index df77a1c285..aebab4f88c 100644
--- a/crates/ui-egui/src/render_workspace.rs
+++ b/crates/ui-egui/src/render_workspace.rs
@@ -991,7 +991,7 @@ pub(crate) fn browser_mode(app: &mut SolveApp, ui: &mut egui::Ui) -> bool {
if app.render_workspace.view.search_objects {
let mut query = app.render_workspace.view.object_query.clone();
crate::ui_kit::scope(ui, |ui| {
- if crate::ui_kit::search_field(ui, ui.id().with("render:tree:query"), &mut query, crate::i18n::tr("render.tree_search")).changed() {
+ if crate::ui_kit::search_field(ui, ui.scope_id().with("render:tree:query"), &mut query, crate::i18n::tr("render.tree_search")).changed() {
let _ = app.run("view.render_browser", json!({"query":query}));
}
});
@@ -2243,7 +2243,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
// Framing uses the output camera's own aspect, including navigation and picking.
let rect = shot::preview_rect(app, viewport).unwrap_or(viewport);
crate::viewport::refresh_layout(app, ui.ctx());
- let response = ui.interact(rect, ui.id().with("render_preview"), Sense::click_and_drag());
+ let response = ui.interact(rect, ui.scope_id().with("render_preview"), Sense::click_and_drag());
if !environment::ring_input(app, ui, rect, &response) {
let input = crate::navigation::handle(app, ui, rect, &response, crate::navigation::NavCaps::RENDER);
let navigating = input.scroll != 0.0
diff --git a/crates/ui-egui/src/render_workspace_cpu.rs b/crates/ui-egui/src/render_workspace_cpu.rs
index ac1dd90092..35d9b7df92 100644
--- a/crates/ui-egui/src/render_workspace_cpu.rs
+++ b/crates/ui-egui/src/render_workspace_cpu.rs
@@ -432,7 +432,7 @@ pub(super) fn reflection_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
crate::scenario::publish_handle(&format!("render:cpu-reflection-mode:{}", entry.body), mode_control.rect.center());
}
let hint = app.tr("render.cpu_body_filter").to_string();
- ui_kit::bounded_cell_editor(ui, ui.id().with("cpu_body_filter"), &mut app.render_workspace.view.cpu.body_filter, &hint, false, 128);
+ ui_kit::bounded_cell_editor(ui, ui.scope_id().with("cpu_body_filter"), &mut app.render_workspace.view.cpu.body_filter, &hint, false, 128);
let selected = app.render_workspace.view.cpu.selected_body.clone();
let label = selected.clone().unwrap_or_else(|| app.tr("render.cpu_body_choose").to_string());
let world = crate::open_meshing::session_world(&app.session);
diff --git a/crates/ui-egui/src/render_workspace_environment.rs b/crates/ui-egui/src/render_workspace_environment.rs
index b1cbc28045..7c13402581 100644
--- a/crates/ui-egui/src/render_workspace_environment.rs
+++ b/crates/ui-egui/src/render_workspace_environment.rs
@@ -204,7 +204,7 @@ pub(super) fn ring_overlay(app: &mut SolveApp, ui: &mut egui::Ui, viewport: egui
crate::scenario::publish_target("render:environment:ring-handle", egui::Rect::from_center_size(handle, egui::Vec2::splat(t.space_16)));
let chip = ui_kit::Container::navigation_card(
ui.ctx(),
- egui::Id::new("render_environment_rotation"),
+ egui::Id::unique("render_environment_rotation"),
ring.center + egui::vec2(0.0, ring.radius - t.control_height - t.space_8),
egui::Align2::CENTER_BOTTOM,
|ui| ui_kit::text(ui, &format!("{angle:.0}°"), ui_kit::Text::Inline).backing_on_hover_text(app.tr("render.env_ring_help")),
@@ -461,7 +461,7 @@ fn source_name(app: &mut SolveApp, ctx: &egui::Context) -> String {
};
if let Some(source) = source {
type Names = std::sync::Arc<std::collections::BTreeMap<String, String>>;
- let cache = egui::Id::new("render_environment_catalog_names");
+ let cache = egui::Id::unique("render_environment_catalog_names");
let names = ctx.data_mut(|data| data.get_temp::<Names>(cache)).unwrap_or_else(|| {
let mut names = std::collections::BTreeMap::new();
if let Ok(reply) = app.run("render.library.list", json!({"kind":"hdr","limit":128})) {
@@ -542,8 +542,13 @@ fn edit<T: Clone + PartialEq + Send + Sync + 'static>(
current: T,
draw: impl FnOnce(&mut egui::Ui, &mut T) -> egui::Response,
) -> Option<T> {
- let id =
- ui.id().with(("render-environment", key, &app.render_workspace.view.name, std::sync::Arc::as_ptr(&app.session.doc), app.session.revision));
+ let id = ui.scope_id().with((
+ "render-environment",
+ key,
+ &app.render_workspace.view.name,
+ std::sync::Arc::as_ptr(&app.session.doc),
+ app.session.revision,
+ ));
let (_, mut value, mut pending) = ui
.data_mut(|data| data.get_temp::<(T, T, bool)>(id))
.filter(|(original, _, _)| original == &current)
@@ -750,7 +755,7 @@ pub(super) fn request_stage_removal(app: &SolveApp, ctx: &egui::Context) {
if let Ok(set) = setups::snapshot(app) {
ctx.data_mut(|data| {
data.insert_temp(
- egui::Id::new("render_remove_stage"),
+ egui::Id::unique("render_remove_stage"),
StageRemoval {
document: Arc::downgrade(&app.session.doc),
revision: app.session.revision,
@@ -763,7 +768,7 @@ pub(super) fn request_stage_removal(app: &SolveApp, ctx: &egui::Context) {
}
pub(super) fn stage_confirmation(app: &mut SolveApp, ctx: &egui::Context) {
- let id = egui::Id::new("render_remove_stage");
+ let id = egui::Id::unique("render_remove_stage");
let Some(pending) = ctx.data_mut(|data| data.get_temp::<StageRemoval>(id)) else { return };
if pending.revision != app.session.revision
|| pending.name != app.render_workspace.view.name
@@ -797,7 +802,7 @@ fn ground(app: &mut SolveApp, ui: &mut egui::Ui) {
let title = app.tr("render.environment.ground").to_string();
ui_kit::section(ui, "render_environment_ground", &title, true, |ui| {
let snapshot = setups::snapshot(app);
- let id = ui.id().with(("ground-form", Arc::as_ptr(&app.session.doc), app.session.revision, &app.render_workspace.view.name));
+ let id = ui.scope_id().with(("ground-form", Arc::as_ptr(&app.session.doc), app.session.revision, &app.render_workspace.view.name));
let mut form = ui.data_mut(|data| data.get_temp::<GroundForm>(id)).unwrap_or_else(|| GroundForm {
value: snapshot.as_ref().map(|set| ground_values(app, set)).unwrap_or(Ground { margin: 1.0, gap: 0.1, color: [0.18; 3] }),
replace: false,
diff --git a/crates/ui-egui/src/render_workspace_hdr.rs b/crates/ui-egui/src/render_workspace_hdr.rs
index 651894a6d4..ea4b5b0606 100644
--- a/crates/ui-egui/src/render_workspace_hdr.rs
+++ b/crates/ui-egui/src/render_workspace_hdr.rs
@@ -175,7 +175,7 @@ pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui, target: Target) {
let mut path = input(app, target).path().to_string();
let hint = app.tr("render.studio_hdr_required").to_string();
let field = ui_kit::row(ui, app.tr("render.environment.file"), |ui| {
- ui_kit::bounded_cell_editor(ui, ui.id().with("hdr_source_path"), &mut path, &hint, false, 4096)
+ ui_kit::bounded_cell_editor(ui, ui.scope_id().with("hdr_source_path"), &mut path, &hint, false, 4096)
});
if field.changed() {
set_input(app, target, Input::FilePending { path });
diff --git a/crates/ui-egui/src/render_workspace_library.rs b/crates/ui-egui/src/render_workspace_library.rs
index 7d241160ef..48c2e9c2c1 100644
--- a/crates/ui-egui/src/render_workspace_library.rs
+++ b/crates/ui-egui/src/render_workspace_library.rs
@@ -228,7 +228,7 @@ fn target_controls(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut View) {
ui.label(app.tr("render.library_target"));
ui_kit::bounded_cell_editor(
ui,
- ui.id().with("render_library_target_search"),
+ ui.scope_id().with("render_library_target_search"),
&mut view.target_query,
app.tr("render.material_filter"),
false,
@@ -626,7 +626,7 @@ fn light_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
}
if view.light_scope == 4 {
ui.add_enabled_ui(false, |ui| {
- ui_kit::search_field(ui, ui.id().with("render_mine_search"), &mut view.query, app.tr("render.stage_panels.search_studios"));
+ ui_kit::search_field(ui, ui.scope_id().with("render_mine_search"), &mut view.query, app.tr("render.stage_panels.search_studios"));
ui_kit::button(ui, app.tr("render.stage_panels.apply"), ui_kit::Button::Normal);
});
ui_kit::text(ui, app.tr("render.stage_panels.mine_pending"), ui_kit::Text::Note("render:mine:reason"));
@@ -685,7 +685,7 @@ fn light_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
}
fn catalog_search(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut View, hint: &str) {
- let search = ui_kit::search_field(ui, ui.id().with("render_stage_catalog_search"), &mut view.query, app.tr(hint));
+ let search = ui_kit::search_field(ui, ui.scope_id().with("render_stage_catalog_search"), &mut view.query, app.tr(hint));
crate::scenario::publish_target("render:library-search", search.rect);
let end = view.query.char_indices().nth(128).map_or(view.query.len(), |(at, _)| at);
view.query.truncate(end);
@@ -976,7 +976,7 @@ fn browse_contents(app: &mut SolveApp, ui: &mut egui::Ui, stage_card: bool) {
};
let hint = crate::i18n::format("render.search_appearances", &[("count", &count.to_string())]);
let query = if view.collection == 0 { &mut view.query } else { &mut view.collection_query };
- let search = ui_kit::search_field(ui, ui.id().with("render_library_search"), query, &hint);
+ let search = ui_kit::search_field(ui, ui.scope_id().with("render_library_search"), query, &hint);
query.truncate(query.char_indices().nth(128).map_or(query.len(), |(at, _)| at));
crate::scenario::publish_target("render:library-search", search.rect);
if search.changed() {
@@ -1631,7 +1631,7 @@ fn physical_controls(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut View, id:
}
}
ui.label(app.tr("render.physical_material_name"));
- ui_kit::bounded_cell_editor(ui, ui.id().with("physical_reference_name"), &mut view.physical_name, "", false, 128);
+ ui_kit::bounded_cell_editor(ui, ui.scope_id().with("physical_reference_name"), &mut view.physical_name, "", false, 128);
if ui_kit::button(ui, app.tr("render.stage_panels.prepare_plan"), ui_kit::Button::Normal).clicked() {
let result =
app.run("render.library.physical.prepare", json!({"id":id,"name":view.physical_name,"acknowledge_reference":true})).and_then(|plan| {
diff --git a/crates/ui-egui/src/render_workspace_library_review.rs b/crates/ui-egui/src/render_workspace_library_review.rs
index bef7e78188..95840b9b7f 100644
--- a/crates/ui-egui/src/render_workspace_library_review.rs
+++ b/crates/ui-egui/src/render_workspace_library_review.rs
@@ -300,7 +300,7 @@ pub(in crate::render_workspace) fn confirmation(app: &mut SolveApp, ctx: &egui::
let title = app.tr(if stage { "render.stage_panels.remove_stage_title" } else { "render.stage_panels.remove_optics_title" }).to_string();
let message = app.tr(if stage { "render.stage_panels.remove_stage_help" } else { "render.stage_panels.remove_optics_help" }).to_string();
let label = app.tr(if stage { "render.stage_panels.remove_stage" } else { "render.stage_panels.remove_optics" }).to_string();
- let (closed, answer) = ui_kit::Confirm::new(egui::Id::new("render_resource_removal"), "delete", &title)
+ let (closed, answer) = ui_kit::Confirm::new(egui::Id::unique("render_resource_removal"), "delete", &title)
.tone(ui_kit::Tone::Danger)
.actions(&label, app.tr("render.stage_panels.keep"), None)
.show(ctx, true, |ui| {
diff --git a/crates/ui-egui/src/render_workspace_light.rs b/crates/ui-egui/src/render_workspace_light.rs
index 1c8ef8eaeb..dd804d2964 100644
--- a/crates/ui-egui/src/render_workspace_light.rs
+++ b/crates/ui-egui/src/render_workspace_light.rs
@@ -593,7 +593,7 @@ pub(super) fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {
let title = app.tr("render.lighting_review_title").to_string();
let apply = app.tr("render.lighting_apply").to_string();
let cancel = app.tr("render.keep_editing").to_string();
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("render_lighting_review"), "render_scene", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("render_lighting_review"), "render_scene", &title)
.actions(&apply, &cancel, None)
.selected(ui_kit::Action::Cancel)
.show(ctx, review.consent, |ui| {
diff --git a/crates/ui-egui/src/render_workspace_materials.rs b/crates/ui-egui/src/render_workspace_materials.rs
index 5e1f29d84f..687975841d 100644
--- a/crates/ui-egui/src/render_workspace_materials.rs
+++ b/crates/ui-egui/src/render_workspace_materials.rs
@@ -369,7 +369,7 @@ pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui) {
&& !app.session.model.is_stale();
ui_kit::bounded_cell_editor(
ui,
- ui.id().with("render_material_search"),
+ ui.scope_id().with("render_material_search"),
&mut view.target_search,
app.tr("render.material_filter"),
false,
@@ -943,7 +943,7 @@ pub(super) fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {
return;
}
let title = app.tr("render.appearance_editor.remove_title").to_owned();
- let (closed, action) = ui_kit::Confirm::new(egui::Id::new("render_remove_optics"), "delete", &title)
+ let (closed, action) = ui_kit::Confirm::new(egui::Id::unique("render_remove_optics"), "delete", &title)
.tone(ui_kit::Tone::Danger)
.actions(app.tr("render.appearance_editor.remove"), app.tr("render.keep_editing"), None)
.selected(ui_kit::Action::Cancel)
diff --git a/crates/ui-egui/src/render_workspace_output.rs b/crates/ui-egui/src/render_workspace_output.rs
index 04b65ac1f7..2d33bf9b2f 100644
--- a/crates/ui-egui/src/render_workspace_output.rs
+++ b/crates/ui-egui/src/render_workspace_output.rs
@@ -181,7 +181,7 @@ pub(super) fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {
let primary = app.tr(if removing { "render.stage_panels.remove_shot" } else { "render.save_continue" }).to_string();
let discard = app.tr("render.discard_continue").to_string();
let message = app.tr(if removing { "render.shot_remove_help" } else { "render.draft_confirm_help" }).to_string();
- let (closed, answer) = ui_kit::Confirm::new(egui::Id::new("render_pending_shot"), if removing { "delete" } else { "save" }, &title)
+ let (closed, answer) = ui_kit::Confirm::new(egui::Id::unique("render_pending_shot"), if removing { "delete" } else { "save" }, &title)
.tone(if removing { ui_kit::Tone::Danger } else { ui_kit::Tone::Warning })
.actions(&primary, &keep, (!removing).then_some(discard.as_str()))
.selected(ui_kit::Action::Cancel)
@@ -240,7 +240,7 @@ pub(super) fn scene_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
] {
let response = ui_kit::tree_row(
ui,
- ui.id().with(("scene_stage", stage.key())),
+ ui.scope_id().with(("scene_stage", stage.key())),
&ui_kit::Row { compact: true, label: app.tr(stage.label()), secondary: &summary, icon, ..Default::default() },
);
if let Some(rect) = response.rect {
diff --git a/crates/ui-egui/src/render_workspace_shot.rs b/crates/ui-egui/src/render_workspace_shot.rs
index 10697806f8..4ce4513914 100644
--- a/crates/ui-egui/src/render_workspace_shot.rs
+++ b/crates/ui-egui/src/render_workspace_shot.rs
@@ -190,7 +190,7 @@ pub(super) fn editor(app: &mut SolveApp, ui: &mut egui::Ui, shot: &str) {
let mut name = app.render_workspace.view.frame.name.as_ref().map(|(_, text)| text.clone()).unwrap_or_else(|| shot.into());
let invalid = RenderSettings::validate_name(&name).is_err();
let response = ui_kit::row(ui, app.tr("render.frame_name"), |ui| {
- ui_kit::bounded_cell_editor(ui, ui.id().with(("shot_name", shot)), &mut name, "", invalid, 128)
+ ui_kit::bounded_cell_editor(ui, ui.scope_id().with(("shot_name", shot)), &mut name, "", invalid, 128)
});
crate::scenario::publish_target("render:shot:name", response.rect);
let commit = response.lost_focus() || (response.has_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)));
@@ -482,7 +482,7 @@ pub(crate) fn overlay(app: &mut SolveApp, ui: &mut egui::Ui, viewport: Rect) {
let label = format!("{aspect} · {} × {}", saved.width, saved.height);
ui_kit::Container::navigation_card(
ui.ctx(),
- egui::Id::new("render_frame_size_chip"),
+ egui::Id::unique("render_frame_size_chip"),
frame.left_top() + vec2(t.space_8, t.space_8),
egui::Align2::LEFT_TOP,
|ui| {
@@ -498,7 +498,7 @@ pub(crate) fn overlay(app: &mut SolveApp, ui: &mut egui::Ui, viewport: Rect) {
};
ui_kit::Container::navigation_card(
ui.ctx(),
- egui::Id::new("render_frame_lens_chip"),
+ egui::Id::unique("render_frame_lens_chip"),
pos2(frame.left() + t.space_8, frame.bottom() - t.space_8),
egui::Align2::LEFT_BOTTOM,
|ui| {
diff --git a/crates/ui-egui/src/render_workspace_shots.rs b/crates/ui-egui/src/render_workspace_shots.rs
index b115b3c86a..daafeecfda 100644
--- a/crates/ui-egui/src/render_workspace_shots.rs
+++ b/crates/ui-egui/src/render_workspace_shots.rs
@@ -130,7 +130,7 @@ pub(super) fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {
let title = app.tr("render.shots_save").to_string();
let cancel = app.tr("ui.cancel").to_string();
let (closed, answer) =
- ui_kit::Confirm::new(egui::Id::new("render_save_shot"), "save", &title).actions(&title, &cancel, None).show(ctx, valid, |ui| {
+ ui_kit::Confirm::new(egui::Id::unique("render_save_shot"), "save", &title).actions(&title, &cancel, None).show(ctx, valid, |ui| {
ui_kit::text(ui, app.tr("render.shots_name_help"), ui_kit::Text::Note("render.shots_name_help"));
ui_kit::row(ui, app.tr("render.shot_new_name"), |ui| {
ui_kit::focused_text_field(ui, &mut name, "");
diff --git a/crates/ui-egui/src/render_workspace_surface_import.rs b/crates/ui-egui/src/render_workspace_surface_import.rs
index 98b77d65cb..ee5455a16d 100644
--- a/crates/ui-egui/src/render_workspace_surface_import.rs
+++ b/crates/ui-egui/src/render_workspace_surface_import.rs
@@ -250,7 +250,7 @@ pub(super) fn controls(app: &mut SolveApp, ui: &mut egui::Ui, view: &mut super::
("render.surface_import.license", &mut view.imported.license, 4096),
] {
ui_kit::row(ui, app.tr(key), |ui| {
- ui_kit::bounded_cell_editor(ui, ui.id().with(key), value, "", false, maximum);
+ ui_kit::bounded_cell_editor(ui, ui.scope_id().with(key), value, "", false, maximum);
});
}
ui_kit::row(ui, app.tr("render.stage_panels.plane"), |ui| {
diff --git a/crates/ui-egui/src/render_workspace_tests.rs b/crates/ui-egui/src/render_workspace_tests.rs
index cd4d193cbf..cecac02d5f 100644
--- a/crates/ui-egui/src/render_workspace_tests.rs
+++ b/crates/ui-egui/src/render_workspace_tests.rs
@@ -2209,6 +2209,7 @@ fn result_navigation_uses_shared_pan_zoom_and_leaves_product_camera_unchanged()
&mut time,
Modifiers::NONE,
vec![Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Line,
delta: vec2(0.0, 3.0),
modifiers: Modifiers::NONE,
@@ -2663,7 +2664,13 @@ fn render_preview_navigates_like_the_modelling_viewport_in_every_preset() {
// Wheel over the model, then modifier-only motion (Touchpad: Shift pans, Alt orbits).
let before = design.cam;
both(vec![Event::PointerMoved(model)], none, &mut design, &mut render);
- let wheel = Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, 3.0), modifiers: none, phase: egui::TouchPhase::Move };
+ let wheel = Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Line,
+ delta: vec2(0.0, 3.0),
+ modifiers: none,
+ phase: egui::TouchPhase::Move,
+ };
both(vec![wheel], none, &mut design, &mut render);
for _ in 0..30 {
both(vec![], none, &mut design, &mut render);
@@ -7019,7 +7026,13 @@ fn render_results_compare_divider_drag_clamps_and_blocks_all_camera_input() {
let end = egui::pos2(canvas.right() + 100.0, start.y);
h.frame_with(vec![
Event::PointerMoved(end),
- Event::MouseWheel { unit: MouseWheelUnit::Point, delta: vec2(0.0, -300.0), modifiers: Modifiers::ALT, phase: egui::TouchPhase::Move },
+ Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: MouseWheelUnit::Point,
+ delta: vec2(0.0, -300.0),
+ modifiers: Modifiers::ALT,
+ phase: egui::TouchPhase::Move,
+ },
]);
assert!(
(h.app.render_workspace.view.compare.as_ref().unwrap().position - 0.95).abs() < 1e-6,
diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs
index 874aee74cc..4328e54574 100644
--- a/crates/ui-egui/src/scenario.rs
+++ b/crates/ui-egui/src/scenario.rs
@@ -218,6 +218,12 @@ impl Harness {
crate::recovery_ui::start(&mut self.app, &self.dir.join("recovery"), std::time::Duration::ZERO);
}
+ /// The next frame's time, 1/60 s on. A frame run without a time (the control channel's) moves
+ /// the context's clock by egui's f32 `predicted_dt`, so follow it: time never goes backwards.
+ fn tick(&mut self) {
+ self.time = self.time.max(self.ctx.input(|i| i.time)) + 1.0 / 60.0;
+ }
+
/// Lay out and draw one frame (feeding queued pointer and key events).
pub fn frame(&mut self) {
self.frame_with(Vec::new());
@@ -226,7 +232,7 @@ impl Harness {
/// One frame that receives all these events at once (a quick tap, or input queued during a
/// slow frame), before any queued ones.
pub fn frame_with(&mut self, events: Vec<egui::Event>) {
- self.time += 1.0 / 60.0;
+ self.tick();
let mut raw = egui::RawInput {
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, self.size)),
time: Some(self.time),
@@ -261,7 +267,7 @@ impl Harness {
/// One frame in which files are dragged over the window (`hovered`) or dropped, the pointer
/// last seen at `at`.
pub fn drag_files(&mut self, at: egui::Pos2, hovered: Vec<egui::HoveredFile>, dropped: Vec<egui::DroppedFileHandle>) {
- self.time += 1.0 / 60.0;
+ self.tick();
let raw = egui::RawInput {
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, self.size)),
time: Some(self.time),
@@ -387,7 +393,7 @@ impl Harness {
}
/// Centres of the visible widgets whose label or value is `text`, last drawn first.
- fn widgets(&self, text: &str) -> Vec<[f64; 2]> {
+ pub fn widgets(&self, text: &str) -> Vec<[f64; 2]> {
let Some(tree) = self.output.accesskit_update.as_ref() else { return Vec::new() };
let centre =
|n: &egui::accesskit::Node| n.bounds().filter(|b| b.x1 > b.x0 && b.y1 > b.y0).map(|b| [(b.x0 + b.x1) / 2.0, (b.y0 + b.y1) / 2.0]);
diff --git a/crates/ui-egui/src/select_other.rs b/crates/ui-egui/src/select_other.rs
index f9102fbec3..590bcf5636 100644
--- a/crates/ui-egui/src/select_other.rs
+++ b/crates/ui-egui/src/select_other.rs
@@ -640,7 +640,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let scroll_height = (screen.height() - overhead).max(0.0);
let size = vec2(width, overhead + rows_height.min(scroll_height));
let resp = Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_select_other"))
+ .area(egui::Id::unique("sc_select_other"))
.fixed_pos(crate::context_menu::place(at, gap, size, screen))
.constrain(true)
.order(egui::Order::Foreground)
diff --git a/crates/ui-egui/src/select_other_tests.rs b/crates/ui-egui/src/select_other_tests.rs
index 1783c01fa2..f9a514f22d 100644
--- a/crates/ui-egui/src/select_other_tests.rs
+++ b/crates/ui-egui/src/select_other_tests.rs
@@ -335,7 +335,7 @@ fn long_names_stay_inside_the_popup_and_remain_available_on_hover() {
_ => None,
})
.expect("the body label is painted");
- let popup = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_select_other"))).unwrap();
+ let popup = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_select_other"))).unwrap();
let text_rect = egui::Rect::from_min_size(text.pos, text.galley.size());
assert!(popup.contains_rect(text_rect), "{text_rect:?} spills outside {popup:?}");
assert!(h.ctx.content_rect().contains_rect(popup));
@@ -861,6 +861,7 @@ fn popup_uses_window_height_and_flips_above_the_pointer() {
assert!(!rect.contains(crate::scenario::handle_at(&format!("select_other:{}", count - 1)).unwrap()), "overflow needs scrolling");
h.app.synthetic.push(egui::Event::PointerMoved(rect.center()));
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, -2000.0),
phase: egui::TouchPhase::Move,
diff --git a/crates/ui-egui/src/semantic_content.rs b/crates/ui-egui/src/semantic_content.rs
index 826d04f0cc..cbfcca45a9 100644
--- a/crates/ui-egui/src/semantic_content.rs
+++ b/crates/ui-egui/src/semantic_content.rs
@@ -118,15 +118,15 @@ impl Frame {
}
fn active_id() -> egui::Id {
- egui::Id::new("sc_semantic_content_owner")
+ egui::Id::unique("sc_semantic_content_owner")
}
fn output_id(owner: ContentOwner) -> egui::Id {
- egui::Id::new(("sc_semantic_content_output", owner))
+ egui::Id::unique(("sc_semantic_content_output", owner))
}
fn capture_id() -> egui::Id {
- egui::Id::new("sc_semantic_content_eye_owner")
+ egui::Id::unique("sc_semantic_content_eye_owner")
}
#[derive(Clone, Copy)]
@@ -153,7 +153,7 @@ struct InputClaims {
pub(crate) fn claim_action(ui: &Ui, widget: egui::Id) -> bool {
let frame = ui.ctx().cumulative_frame_nr();
ui.ctx().data_mut(|data| {
- let claims = data.get_temp_mut_or_default::<InputClaims>(egui::Id::new("sc_semantic_content_input_claims"));
+ let claims = data.get_temp_mut_or_default::<InputClaims>(egui::Id::unique("sc_semantic_content_input_claims"));
if claims.frame != frame {
claims.frame = frame;
claims.actions.clear();
@@ -163,7 +163,7 @@ pub(crate) fn claim_action(ui: &Ui, widget: egui::Id) -> bool {
}
fn row_capture_id() -> egui::Id {
- egui::Id::new("sc_semantic_content_row_capture")
+ egui::Id::unique("sc_semantic_content_row_capture")
}
pub(crate) fn current_source(app: &SolveApp) -> Option<ContentSource> {
diff --git a/crates/ui-egui/src/settings_profiles.rs b/crates/ui-egui/src/settings_profiles.rs
index fec648185e..2d38cde5be 100644
--- a/crates/ui-egui/src/settings_profiles.rs
+++ b/crates/ui-egui/src/settings_profiles.rs
@@ -742,7 +742,7 @@ pub(crate) fn rename_popup(app: &mut SolveApp, ctx: &egui::Context) {
crate::prefs_search::note_key_sink(ctx);
let mut done = None;
let popup = ui_kit::Container::new(ctx, ui_kit::Surface::Popup)
- .area(egui::Id::new("sc_profile_rename"))
+ .area(egui::Id::unique("sc_profile_rename"))
.fixed_pos(rename.at)
.constrain(true)
.order(egui::Order::Foreground)
diff --git a/crates/ui-egui/src/shell.rs b/crates/ui-egui/src/shell.rs
index 1cdf328cd3..e59681d5c0 100644
--- a/crates/ui-egui/src/shell.rs
+++ b/crates/ui-egui/src/shell.rs
@@ -17,11 +17,11 @@ pub enum LayoutMode {
impl LayoutMode {
pub(crate) fn publish(self, ctx: &egui::Context) {
- ctx.data_mut(|data| data.insert_temp(egui::Id::new("sc_container_layout"), self));
+ ctx.data_mut(|data| data.insert_temp(egui::Id::unique("sc_container_layout"), self));
}
pub(crate) fn current(ctx: &egui::Context) -> Self {
- ctx.data(|data| data.get_temp(egui::Id::new("sc_container_layout"))).unwrap_or_default()
+ ctx.data(|data| data.get_temp(egui::Id::unique("sc_container_layout"))).unwrap_or_default()
}
}
diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rs
index f5cfd1ad85..3ab417e93a 100644
--- a/crates/ui-egui/src/shell_tests.rs
+++ b/crates/ui-egui/src/shell_tests.rs
@@ -515,7 +515,7 @@ fn tool_sheets_drag_over_browser_and_history_but_clear_protected_panels() {
if target == browser.center() {
assert!(sheet.intersect(browser).is_positive(), "sheet can cover Browser");
let layer = h.ctx.layer_id_at(sheet.intersect(browser).center()).unwrap();
- assert_eq!(layer.id, egui::Id::new(("sc_dialog", "CREATE SKETCH")), "sheet receives input above Browser");
+ assert_eq!(layer.id, egui::Id::unique(("sc_dialog", "CREATE SKETCH")), "sheet receives input above Browser");
} else if target == history.center() {
assert!(sheet.intersect(history).is_positive(), "sheet can cover History");
}
@@ -546,7 +546,7 @@ fn tool_sheets_stay_above_browser_and_history_after_panel_clicks() {
assert!(!sheet.contains(exposed), "the panel click is outside the dialog");
h.call("ui.click", json!({"x":exposed.x,"y":exposed.y}));
let layer = h.ctx.layer_id_at(overlap.center()).unwrap();
- assert_eq!(layer.id, egui::Id::new(("sc_dialog", "EXTRUDE")), "{dock}: clicking a panel must not cover the dialog");
+ assert_eq!(layer.id, egui::Id::unique(("sc_dialog", "EXTRUDE")), "{dock}: clicking a panel must not cover the dialog");
let panel_layer = h.ctx.layer_id_at(exposed).unwrap();
h.call("ui.click", json!({"x":1700,"y":500}));
assert_eq!(h.ctx.layer_id_at(exposed), Some(panel_layer), "clicking the model view must not cover the panel");
@@ -575,9 +575,9 @@ fn tool_sheet_dropdowns_and_preferences_still_open_above_the_sheet() {
let preferences = rect_of("dialog:window").unwrap();
let overlap = sheet.intersect(preferences);
assert!(overlap.is_positive(), "Preferences overlaps the feature dialog");
- assert_eq!(h.ctx.layer_id_at(overlap.center()).unwrap().id, egui::Id::new("sc_prefs"), "Preferences receives input above the sheet");
+ assert_eq!(h.ctx.layer_id_at(overlap.center()).unwrap().id, egui::Id::unique("sc_prefs"), "Preferences receives input above the sheet");
let cancel = rect_of("prefs:cancel").expect("Preferences Cancel");
- assert_eq!(h.ctx.layer_id_at(cancel.center()).unwrap().id, egui::Id::new("sc_prefs"), "Preferences owns its Cancel target");
+ assert_eq!(h.ctx.layer_id_at(cancel.center()).unwrap().id, egui::Id::unique("sc_prefs"), "Preferences owns its Cancel target");
h.step(&json!({"click":{"handle":"prefs:cancel"}})).unwrap();
assert!(!h.app.prefs_window.open && h.app.dialog.is_some(), "Cancel closes Preferences, leaving the feature dialog open");
h.step(&json!({"widget":"Cancel"})).unwrap();
@@ -1186,7 +1186,7 @@ fn status_bar_units_open_the_units_menu_above_the_bar_and_change_units_in_one_un
let labels: Vec<_> = menu["items"].as_array().unwrap().iter().map(|i| i["label"].as_str().unwrap().to_string()).collect();
assert_eq!(labels, crate::prefs::UNITS);
// The list opens above the bar, inside the window.
- let list = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_context_menu"))).unwrap();
+ let list = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_context_menu"))).unwrap();
assert!(list.bottom() <= button.top() + 0.5 && list.top() >= 0.0, "{list:?} {button:?}");
assert_eq!(h.app.session.undo.len(), undo, "opening the menu changes nothing");
h.call("ui.menuPick", json!({"item":"in"}));
@@ -1230,7 +1230,7 @@ fn status_bar_mouse_mapping_opens_the_mappings_and_picks_one_as_the_preferences_
let labels: Vec<_> = menu.iter().map(|item| item.label.as_str()).collect();
assert_eq!(labels, crate::prefs::NAV_PRESETS.iter().map(|preset| preset.translated_label()).collect::<Vec<_>>());
assert_eq!(menu.iter().filter(|item| item.shortcut == "current").map(|item| item.label.as_str()).collect::<Vec<_>>(), ["Fusion"]);
- let list = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_context_menu"))).unwrap();
+ let list = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_context_menu"))).unwrap();
assert!(list.bottom() <= button.top() + 0.5 && list.top() >= 0.0, "{list:?} {button:?}");
// Each mapping, picked from the menu, sets what Preferences › Navigation sets for it.
for preset in crate::prefs::NAV_PRESETS {
diff --git a/crates/ui-egui/src/shortcut_box.rs b/crates/ui-egui/src/shortcut_box.rs
index 91eee66c92..0083c84fc2 100644
--- a/crates/ui-egui/src/shortcut_box.rs
+++ b/crates/ui-egui/src/shortcut_box.rs
@@ -375,15 +375,15 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let open = app.ui.palette_open;
// Respect egui's instant/reduced animation policy, with a 120 ms upper bound.
let progress = ctx.animate_bool_with_time_and_easing(
- egui::Id::new("sc_search_expansion"),
+ egui::Id::unique("sc_search_expansion"),
open,
ctx.global_style().animation_time.clamp(0.0, 0.12),
egui::emath::easing::cubic_out,
);
- let ribbon = ctx.data(|d| d.get_temp::<Rect>(egui::Id::new("sc_ribbon_search")));
+ let ribbon = ctx.data(|d| d.get_temp::<Rect>(egui::Id::unique("sc_ribbon_search")));
if !open {
app.sbox.focus = false;
- ctx.memory_mut(|m| m.surrender_focus(egui::Id::new("sc_sbox_text")));
+ ctx.memory_mut(|m| m.surrender_focus(egui::Id::unique("sc_sbox_text")));
if progress == 0.0 {
app.sbox.at = None;
}
@@ -438,7 +438,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
// folded ribbon's panels, open over the view (#10112), keep it on top of them too.
let floating = open || progress > 0.0 || app.ui.ribbon_open;
let response = Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_sbox"))
+ .area(egui::Id::unique("sc_sbox"))
.fixed_pos(pos)
.order(if floating { egui::Order::Foreground } else { egui::Order::Background })
.fade_in(false)
@@ -467,7 +467,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
);
if !open && progress == 0.0 {
if field.clicked()
- || ui.interact(Rect::from_min_size(pos, field_size), ui.id().with("search_open"), egui::Sense::click()).clicked()
+ || ui.interact(Rect::from_min_size(pos, field_size), ui.scope_id().with("search_open"), egui::Sense::click()).clicked()
{
app.start("ui.palette");
ctx.request_repaint();
@@ -730,7 +730,7 @@ mod tests {
fn the_search_field_asks_for_focus_once_per_opening() {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
let ctx = crate::fonts::test_context();
- let field = egui::Id::new("sc_sbox_text");
+ let field = egui::Id::unique("sc_sbox_text");
open(&mut app, None);
frame(&mut app, &ctx);
frame(&mut app, &ctx);
@@ -819,7 +819,7 @@ mod tests {
let row = rect_of("ribbon:reveal").expect("the revealed row");
assert!(rect_of("toolbar_dropdown").unwrap().contains_rect(row), "{row:?}");
assert!(rect_of("ribbon:reveal_tooltip").is_some_and(|tip| tip.left() >= row.right()), "the row's tooltip beside it");
- assert_eq!(h.ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open"))), None, "the preview doesn't open it for good");
+ assert_eq!(h.ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::unique("sc_panel_open"))), None, "the preview doesn't open it for good");
// Starting it from the box: the section label pulses, then stays marked while it runs.
h.call("ui.key", json!({"key": "Enter"}));
@@ -993,7 +993,7 @@ mod tests {
assert_eq!(h.app.session.doc.features.len(), 1, "{:?}", h.app.status);
assert!(h.app.ui.palette_open);
assert_eq!(h.app.sbox.text, query);
- assert!(h.ctx.memory(|m| m.has_focus(egui::Id::new("sc_sbox_text"))));
+ assert!(h.ctx.memory(|m| m.has_focus(egui::Id::unique("sc_sbox_text"))));
h.step(&json!({"key":"Enter"})).unwrap();
h.frames(2);
assert_eq!(h.app.session.doc.features.len(), 2);
@@ -1063,17 +1063,17 @@ mod tests {
h.app.home.open = false;
h.frames(3);
let order = |h: &crate::scenario::Harness| {
- h.ctx.memory(|m| m.areas().visible_layer_ids().into_iter().find(|l| l.id == egui::Id::new("sc_sbox")).map(|l| l.order))
+ h.ctx.memory(|m| m.areas().visible_layer_ids().into_iter().find(|l| l.id == egui::Id::unique("sc_sbox")).map(|l| l.order))
};
// Closed, the field is ribbon chrome: Preferences and the other system windows cover it.
assert_eq!(order(&h), Some(egui::Order::Background), "the closed field belongs to the ribbon");
h.call("ui.prefs", json!({"open": "General"}));
h.frames(3);
- let window = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).unwrap();
+ let window = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).unwrap();
let field = crate::scenario::rect_of("ribbon:search").unwrap();
assert!(order(&h) < Some(egui::Order::Middle), "a system window draws over the closed field");
assert!(
- !window.contains(field.center()) || h.ctx.memory(|m| m.layer_id_at(field.center())).is_some_and(|l| l.id == egui::Id::new("sc_prefs"))
+ !window.contains(field.center()) || h.ctx.memory(|m| m.layer_id_at(field.center())).is_some_and(|l| l.id == egui::Id::unique("sc_prefs"))
);
h.call("ui.prefs", json!({"button": "cancel"}));
// Open, the sheet is a popup again and floats over every window.
@@ -1121,7 +1121,7 @@ mod tests {
assert_eq!(footer, Rect::from_min_max(pos2(sheet.left(), footer.top()), sheet.right_bottom()));
// Inspect native accessibility widgets, not just aliases or painted labels.
let nodes = &h.output.accesskit_update.as_ref().unwrap().nodes;
- let search_edit = h.ctx.read_response(egui::Id::new("sc_sbox_text")).unwrap().rect;
+ let search_edit = h.ctx.read_response(egui::Id::unique("sc_sbox_text")).unwrap().rect;
let fields: Vec<_> = nodes
.iter()
.filter(|(_, n)| n.role() == egui::accesskit::Role::TextInput)
diff --git a/crates/ui-egui/src/sketch_attachment_ui.rs b/crates/ui-egui/src/sketch_attachment_ui.rs
index 714e37066c..a21ef2dee3 100644
--- a/crates/ui-egui/src/sketch_attachment_ui.rs
+++ b/crates/ui-egui/src/sketch_attachment_ui.rs
@@ -178,7 +178,7 @@ pub fn panel(app: &mut SolveApp, ctx: &egui::Context) {
let spec = solidcraft_engine::find_command("sketch.redefine");
let command = spec.as_ref().map_or("", |s| crate::i18n::tr_label(s.label));
let title = crate::i18n::format("sketch_panel.redefine_title", &[("command", command), ("name", name)]);
- let panel = ui_kit::Panel::new(&title, egui::Id::new("sc_redefine"), anchor, drag_bounds, side, frame);
+ let panel = ui_kit::Panel::new(&title, egui::Id::unique("sc_redefine"), anchor, drag_bounds, side, frame);
let response = panel.window(ctx).show(ctx, |ui| {
let (closed, action) = panel.feature(
ui,
diff --git a/crates/ui-egui/src/sketch_construction.rs b/crates/ui-egui/src/sketch_construction.rs
index 7eccebb199..c6be7ffaf4 100644
--- a/crates/ui-egui/src/sketch_construction.rs
+++ b/crates/ui-egui/src/sketch_construction.rs
@@ -60,7 +60,7 @@ pub fn line_type_switch(ui: &mut egui::Ui, t: &mut Tool) {
return;
}
let Some(i) = t.dims.iter().position(|b| b.label == "Length") else { return };
- let Some(length_box) = ui.ctx().memory(|m| m.area_rect(egui::Id::new(("sc_dim_area", i)))) else { return };
+ let Some(length_box) = ui.ctx().memory(|m| m.area_rect(egui::Id::unique(("sc_dim_area", i)))) else { return };
let tokens = crate::theme::Tokens::get();
let has_length = typed_length(t).is_some();
let reason = crate::i18n::tr("ui.construction.normal_needs_length");
@@ -70,7 +70,7 @@ pub fn line_type_switch(ui: &mut egui::Ui, t: &mut Tool) {
let mut selected = usize::from(has_length && t.normal);
let frame = crate::ui_kit::Container::popup_frame(ui.style()).inner_margin(egui::Margin::same(1)).fill(tokens.panel);
crate::ui_kit::Container::new(ui.ctx(), crate::ui_kit::Surface::Canvas)
- .area(egui::Id::new("sc_construction_switch"))
+ .area(egui::Id::unique("sc_construction_switch"))
.fixed_pos(length_box.left_bottom() + egui::vec2(0.0, tokens.space_2))
.order(egui::Order::Background)
.show(ui.ctx(), |ui| {
diff --git a/crates/ui-egui/src/sketch_dims.rs b/crates/ui-egui/src/sketch_dims.rs
index 859bcbc9ea..ff83751b9a 100644
--- a/crates/ui-egui/src/sketch_dims.rs
+++ b/crates/ui-egui/src/sketch_dims.rs
@@ -206,7 +206,7 @@ fn construction_length(t: &Tool, b: &DimBox) -> bool {
/// The id of the `i`th value box of the tool being drawn.
pub(crate) fn box_id(i: usize) -> egui::Id {
- egui::Id::new(("sc_dim", i))
+ egui::Id::unique(("sc_dim", i))
}
/// Where the preview and the value boxes put the tool's next point for the hover `p`: for a
@@ -543,7 +543,7 @@ pub(crate) fn locked_expression<'a>(t: &'a Tool, label: &str) -> Option<&'a str>
/// still show its boxes, so a finished or restarted shape is left alone.
pub fn restore_box_focus(app: &SolveApp, ctx: &egui::Context) {
let Some(count) = app.tool.as_ref().map(|t| t.dims.len()) else { return };
- let holder = ctx.memory(|memory| (0..count).map(|i| egui::Id::new(("sc_dim", i))).find(|id| memory.had_focus_last_frame(*id)));
+ let holder = ctx.memory(|memory| (0..count).map(|i| egui::Id::unique(("sc_dim", i))).find(|id| memory.had_focus_last_frame(*id)));
if let Some(id) = holder {
ctx.memory_mut(|memory| memory.request_focus(id));
}
@@ -553,7 +553,7 @@ pub fn restore_box_focus(app: &SolveApp, ctx: &egui::Context) {
pub fn show(app: &mut SolveApp, ui: &mut egui::Ui, proj: &Proj) {
// Esc in a box ends the shape (the box had the keyboard, so the shortcut didn't see it).
let in_box =
- app.tool.as_ref().is_some_and(|t| (0..t.dims.len()).any(|i| ui.ctx().memory(|m| m.had_focus_last_frame(egui::Id::new(("sc_dim", i))))));
+ app.tool.as_ref().is_some_and(|t| (0..t.dims.len()).any(|i| ui.ctx().memory(|m| m.had_focus_last_frame(egui::Id::unique(("sc_dim", i))))));
if in_box && !app.esc_handled && ui.input(|i| i.key_pressed(egui::Key::Escape)) {
app.esc_handled = true;
crate::tools::finish(app);
@@ -595,8 +595,8 @@ fn boxes(app: &SolveApp, ui: &mut egui::Ui, proj: &Proj, t: &mut Tool) -> Option
let source = tab.and_then(|_| {
ui.ctx().memory(|memory| {
(0..t.dims.len())
- .find(|i| memory.had_focus_last_frame(egui::Id::new(("sc_dim", i))))
- .or_else(|| (0..t.dims.len()).find(|i| memory.has_focus(egui::Id::new(("sc_dim", i)))))
+ .find(|i| memory.had_focus_last_frame(egui::Id::unique(("sc_dim", i))))
+ .or_else(|| (0..t.dims.len()).find(|i| memory.has_focus(egui::Id::unique(("sc_dim", i)))))
})
});
if source.is_some() {
@@ -635,7 +635,7 @@ fn boxes(app: &SolveApp, ui: &mut egui::Ui, proj: &Proj, t: &mut Tool) -> Option
for (i, b) in t.dims.iter_mut().enumerate() {
let Some((_, at)) = lv.get(i).copied() else { continue };
let Some(sp) = proj.to_screen(plane.to_world(at)) else { continue };
- let id = egui::Id::new(("sc_dim", i));
+ let id = egui::Id::unique(("sc_dim", i));
let has_focus = ui.ctx().memory(|m| m.has_focus(id));
// While a box follows the cursor its whole text is selected, so typing replaces it.
if (has_focus || (focus && i == 0)) && !b.locked {
@@ -649,7 +649,7 @@ fn boxes(app: &SolveApp, ui: &mut egui::Ui, proj: &Proj, t: &mut Tool) -> Option
.and_then(|positions| positions.get(i).copied())
.unwrap_or_else(|| in_view(sp + vec2(-34.0, -11.0), view, ui.ctx().pointer_latest_pos()));
// Background: under Preferences and Report a bug (#9016), like canvas value boxes.
- Container::new(ui.ctx(), Surface::Canvas).area(egui::Id::new(("sc_dim_area", i))).fixed_pos(pos).order(egui::Order::Background).show(
+ Container::new(ui.ctx(), Surface::Canvas).area(egui::Id::unique(("sc_dim_area", i))).fixed_pos(pos).order(egui::Order::Background).show(
ui.ctx(),
|ui| {
let fill = if b.locked { tk.accent_soft } else { tk.panel };
@@ -675,7 +675,7 @@ fn boxes(app: &SolveApp, ui: &mut egui::Ui, proj: &Proj, t: &mut Tool) -> Option
&& !completed
{
let next = if tab == Some(true) { (source + t.dims.len() - 1) % t.dims.len() } else { (source + 1) % t.dims.len() };
- let id = egui::Id::new(("sc_dim", next));
+ let id = egui::Id::unique(("sc_dim", next));
if let Some(dimension) = t.dims.get(next) {
let mut state = egui::TextEdit::load_state(ui.ctx(), id).unwrap_or_default();
state.cursor.set_char_range(Some(egui::text::CCursorRange::two(
@@ -728,8 +728,8 @@ pub(crate) const BOX: egui::Vec2 = egui::vec2(76.0, 24.0);
/// sketch point, so the viewport asks before letting one take the click.
pub(crate) fn over_tool_boxes(app: &SolveApp, ctx: &egui::Context, p: egui::Pos2) -> bool {
let Some(t) = app.tool.as_ref() else { return false };
- (0..t.dims.len()).any(|i| ctx.memory(|m| m.area_rect(egui::Id::new(("sc_dim_area", i)))).is_some_and(|r| r.contains(p)))
- || ctx.memory(|m| m.area_rect(egui::Id::new("sc_construction_switch"))).is_some_and(|r| r.contains(p))
+ (0..t.dims.len()).any(|i| ctx.memory(|m| m.area_rect(egui::Id::unique(("sc_dim_area", i)))).is_some_and(|r| r.contains(p)))
+ || ctx.memory(|m| m.area_rect(egui::Id::unique("sc_construction_switch"))).is_some_and(|r| r.contains(p))
}
/// Where a value box whose top left would be `pos` goes so it stays in the drawing area `view`:
diff --git a/crates/ui-egui/src/sketch_dims_tests.rs b/crates/ui-egui/src/sketch_dims_tests.rs
index f1b338339e..c8214d571d 100644
--- a/crates/ui-egui/src/sketch_dims_tests.rs
+++ b/crates/ui-egui/src/sketch_dims_tests.rs
@@ -17,7 +17,7 @@ fn drawing(command: &str) -> Harness {
}
fn assert_focus(h: &Harness, index: usize) {
- let expected = egui::Id::new(("sc_dim", index));
+ let expected = egui::Id::unique(("sc_dim", index));
assert_eq!(h.ctx.memory(|memory| memory.focused()), Some(expected), "focus must stay in inline dimension {index}");
}
@@ -628,7 +628,7 @@ fn polygon_inputs_clear_each_other_and_the_preview() {
let boxes: Vec<_> = (0..2usize)
.map(|i| {
h.ctx
- .memory(|m| m.area_rect(egui::Id::new(("sc_dim_area", i))))
+ .memory(|m| m.area_rect(egui::Id::unique(("sc_dim_area", i))))
.unwrap_or_else(|| panic!("{command}, {view}, {corner:?}: input {i} missing"))
})
.collect();
@@ -740,7 +740,7 @@ fn a_second_circle_on_the_same_centre_keeps_its_diameter_box_after_release() {
h.app.status
);
assert!(
- h.ctx.memory(|m| m.area_rect(egui::Id::new(("sc_dim_area", 0usize)))).is_some(),
+ h.ctx.memory(|m| m.area_rect(egui::Id::unique(("sc_dim_area", 0usize)))).is_some(),
"{label}: Diameter field missing; focused={:?} hover={:?}",
h.ctx.memory(|m| m.focused()),
tool.hover
@@ -770,7 +770,7 @@ fn a_typed_first_circle_then_same_centre_keeps_the_diameter_box() {
assert_eq!(tool.pts.len(), 1, "pts={:?} status={:?}", tool.pts, h.app.status);
assert_eq!(tool.dims.iter().map(|d| d.label).collect::<Vec<_>>(), ["Diameter"]);
assert!(
- h.ctx.memory(|m| m.area_rect(egui::Id::new(("sc_dim_area", 0usize)))).is_some(),
+ h.ctx.memory(|m| m.area_rect(egui::Id::unique(("sc_dim_area", 0usize)))).is_some(),
"Diameter field gone; focused={:?} hover={:?} dims={:?}",
h.ctx.memory(|m| m.focused()),
tool.hover,
diff --git a/crates/ui-egui/src/sketch_palette.rs b/crates/ui-egui/src/sketch_palette.rs
index ce960b8381..e36a5fa135 100644
--- a/crates/ui-egui/src/sketch_palette.rs
+++ b/crates/ui-egui/src/sketch_palette.rs
@@ -377,7 +377,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let selected_types = if has_curves { selected_linetypes(app) } else { std::array::from_fn(|i| mode(app) == i as u8) };
let panel = crate::ui_kit::Panel::new(
app.tr_label("ui.palette_sketch_options"),
- egui::Id::new("sc_sketch_palette"),
+ egui::Id::unique("sc_sketch_palette"),
anchor,
vp,
crate::frame::Side::Right,
diff --git a/crates/ui-egui/src/sketch_pattern_tree.rs b/crates/ui-egui/src/sketch_pattern_tree.rs
index 19b086b0c5..6938601ba7 100644
--- a/crates/ui-egui/src/sketch_pattern_tree.rs
+++ b/crates/ui-egui/src/sketch_pattern_tree.rs
@@ -45,7 +45,7 @@ pub(crate) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, sketch: u64, depth: us
let selected = active && !copies.is_empty() && copies.iter().all(|copy| app.session.selection.contains(copy));
let response = draw_row(
ui,
- ui.id().with(("sketch_pattern", sketch, &pattern.id)),
+ ui.scope_id().with(("sketch_pattern", sketch, &pattern.id)),
&Row { depth, icon, label: &label, name: true, selected, dim, ..Default::default() },
);
if let Some(rect) = response.rect {
diff --git a/crates/ui-egui/src/sketch_report.rs b/crates/ui-egui/src/sketch_report.rs
index 77ad74bff6..aed602e201 100644
--- a/crates/ui-egui/src/sketch_report.rs
+++ b/crates/ui-egui/src/sketch_report.rs
@@ -74,7 +74,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
r.result = read(app, r.sketch);
}
let title = crate::i18n::tr_label("Sketch Report");
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_sketch_report"), "inspect", title)
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_sketch_report"), "inspect", title)
.fields()
.actions("", crate::i18n::tr("ui.close"), None)
.show(ctx, true, |ui| match &r.result {
diff --git a/crates/ui-egui/src/sketch_text.rs b/crates/ui-egui/src/sketch_text.rs
index 2da4ca6e9c..ca5adce71c 100644
--- a/crates/ui-egui/src/sketch_text.rs
+++ b/crates/ui-egui/src/sketch_text.rs
@@ -506,7 +506,7 @@ fn font_has_bold_face(name: &str) -> bool {
/// starts a new line there). `inputs` and `active`: the dialog's Path input.
pub(crate) fn rows(ui: &mut egui::Ui, k: &mut Tx, inputs: &mut [SelInput], active: &mut usize) -> bool {
let mut enter = false;
- let id = egui::Id::new("sketch_text_content");
+ let id = egui::Id::unique("sketch_text_content");
if ui.memory(|m| m.has_focus(id)) {
enter |= ui.input_mut(|i| !i.modifiers.shift && i.consume_key(egui::Modifiers::NONE, egui::Key::Enter));
}
@@ -1094,7 +1094,7 @@ mod tests {
let token = h.app.shot_token;
crate::issue_report::receive(&mut h.app, token, std::sync::Arc::new(egui::ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(3);
- let focus = egui::Id::new("issue_report_title");
+ let focus = egui::Id::unique("issue_report_title");
h.ctx.memory_mut(|memory| memory.request_focus(focus));
h.frames(2);
assert_eq!(h.ctx.memory(|memory| memory.focused()), Some(focus));
diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs
index 7e595582ee..a3a7220b34 100644
--- a/crates/ui-egui/src/sketch_tools.rs
+++ b/crates/ui-egui/src/sketch_tools.rs
@@ -450,7 +450,7 @@ fn comb_options_card(app: &mut SolveApp, ctx: &egui::Context, proj: &Proj) {
let mut options = comb_options();
let (length_tip, teeth_tip) = (app.tr("ui.comb_length_tip").to_string(), app.tr("ui.comb_teeth_tip").to_string());
let shown = crate::ui_kit::Container::new(ctx, crate::ui_kit::Surface::Canvas)
- .area(egui::Id::new("sc_comb_options"))
+ .area(egui::Id::unique("sc_comb_options"))
.fixed_pos(available.left_top() + egui::vec2(tk.space_16, tk.space_16))
.order(egui::Order::Foreground)
.show(ctx, |ui| {
diff --git a/crates/ui-egui/src/sketch_transform_ui.rs b/crates/ui-egui/src/sketch_transform_ui.rs
index 07fe04aa3e..8328cdc6cd 100644
--- a/crates/ui-egui/src/sketch_transform_ui.rs
+++ b/crates/ui-egui/src/sketch_transform_ui.rs
@@ -240,7 +240,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui, proj: &Proj) {
return;
}
for (i, (rect, part, cursor)) in parts.into_iter().enumerate() {
- let response = ui.interact(rect, egui::Id::new(("sc_transform_handle", i)), Sense::drag()).on_hover_cursor(cursor);
+ let response = ui.interact(rect, egui::Id::unique(("sc_transform_handle", i)), Sense::drag()).on_hover_cursor(cursor);
crate::scenario::publish_handle(&format!("transform:handle:{i}"), rect.center());
if response.drag_started()
&& let Some(from) = response.interact_pointer_pos().and_then(|p| pointer_on_sketch(&plane, proj, p))
diff --git a/crates/ui-egui/src/sketch_typed_intent_tests.rs b/crates/ui-egui/src/sketch_typed_intent_tests.rs
index 93a2256e53..107c681cd6 100644
--- a/crates/ui-egui/src/sketch_typed_intent_tests.rs
+++ b/crates/ui-egui/src/sketch_typed_intent_tests.rs
@@ -308,7 +308,7 @@ fn the_arc_end_pick_snaps_to_a_point_under_the_value_box() {
h.step(&json!({"move":{"world":[end[0], end[1], 0]}})).unwrap();
let cursor = h.at(&json!({"world":[end[0], end[1], 0]})).unwrap();
let cursor = egui::pos2(cursor[0] as f32, cursor[1] as f32);
- let blocking = h.ctx.memory(|m| m.area_rect(egui::Id::new(("sc_dim_area", 0usize)))).filter(|r| r.expand(2.0).contains(cursor));
+ let blocking = h.ctx.memory(|m| m.area_rect(egui::Id::unique(("sc_dim_area", 0usize)))).filter(|r| r.expand(2.0).contains(cursor));
assert!(blocking.is_none(), "{command}: the value box {blocking:?} sits under the cursor {cursor:?}");
h.step(&json!({"click":{"world":[end[0], end[1], 0]}})).unwrap();
// A slot's third pick sets its width only; the arc's end takes the point it lands on.
diff --git a/crates/ui-egui/src/space_mouse.rs b/crates/ui-egui/src/space_mouse.rs
index 975475a48d..d1623562b1 100644
--- a/crates/ui-egui/src/space_mouse.rs
+++ b/crates/ui-egui/src/space_mouse.rs
@@ -1160,6 +1160,7 @@ mod tests {
fn wheel(dy: f32) -> egui::Event {
egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, dy),
modifiers: egui::Modifiers::NONE,
diff --git a/crates/ui-egui/src/space_mouse_calibration.rs b/crates/ui-egui/src/space_mouse_calibration.rs
index 7378d39eb8..139358830b 100644
--- a/crates/ui-egui/src/space_mouse_calibration.rs
+++ b/crates/ui-egui/src/space_mouse_calibration.rs
@@ -187,83 +187,84 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let mut chosen = None;
let done = matches!(result, Some(Ok(_)));
let text = |ui: &mut egui::Ui, text: &str, key: &str| crate::ui_kit::text(ui, text, crate::ui_kit::Text::Report(key, false));
- let (closed, action) = crate::ui_kit::Window::new(egui::Id::new("sc_space_mouse_calibration"), "settings", app.tr("ui.3d_mouse_calibrate_title"))
- .actions(if done { app.tr("ui.save") } else { "" }, app.tr("ui.cancel"), None)
- .show_with_left(
- ctx,
- done,
- |ui| {
- text(ui, app.tr(prompt), "prompt");
- if let Some(axis) = weak {
- crate::ui_kit::text(ui, app.tr(axis), crate::ui_kit::Text::Heading("weak_axis"));
- }
- // The device doesn't behave like the kind picked: say so, and offer the other.
- if let Some(other) = mismatch {
- let (hint, switch) = match other {
- Kind::Trackball => ("ui.3d_mouse_looks_like_trackball", "ui.3d_mouse_switch_trackball"),
- Kind::ReturnToCenter => ("ui.3d_mouse_looks_like_cap", "ui.3d_mouse_switch_cap"),
- };
- crate::ui_kit::text(ui, app.tr(hint), crate::ui_kit::Text::Hint("space_mouse_kind_mismatch"));
- if crate::ui_kit::button(ui, app.tr(switch), crate::ui_kit::Button::Normal).clicked() {
- chosen = Some(other);
+ let (closed, action) =
+ crate::ui_kit::Window::new(egui::Id::unique("sc_space_mouse_calibration"), "settings", app.tr("ui.3d_mouse_calibrate_title"))
+ .actions(if done { app.tr("ui.save") } else { "" }, app.tr("ui.cancel"), None)
+ .show_with_left(
+ ctx,
+ done,
+ |ui| {
+ text(ui, app.tr(prompt), "prompt");
+ if let Some(axis) = weak {
+ crate::ui_kit::text(ui, app.tr(axis), crate::ui_kit::Text::Heading("weak_axis"));
}
- }
- if stage == Stage::Choose {
- // Side by side where they fit, one under the other where the window is narrow.
- ui.horizontal_wrapped(|ui| {
- for (kind, label) in KINDS {
- ui.vertical(|ui| {
- crate::space_mouse_model::rest(ui, kind);
- if crate::ui_kit::button(ui, app.tr(label), crate::ui_kit::Button::Normal).clicked() {
- chosen = Some(kind);
- }
- });
+ // The device doesn't behave like the kind picked: say so, and offer the other.
+ if let Some(other) = mismatch {
+ let (hint, switch) = match other {
+ Kind::Trackball => ("ui.3d_mouse_looks_like_trackball", "ui.3d_mouse_switch_trackball"),
+ Kind::ReturnToCenter => ("ui.3d_mouse_looks_like_cap", "ui.3d_mouse_switch_cap"),
+ };
+ crate::ui_kit::text(ui, app.tr(hint), crate::ui_kit::Text::Hint("space_mouse_kind_mismatch"));
+ if crate::ui_kit::button(ui, app.tr(switch), crate::ui_kit::Button::Normal).clicked() {
+ chosen = Some(other);
}
- });
- } else {
- crate::ui_kit::progress(ui, "space_mouse_calibration", progress as f32);
- crate::ui_kit::text(ui, &counter, crate::ui_kit::Text::Note("space_mouse_counter"));
- // Each step shows the motion it asks for; once calibrated, the device's picture follows it.
- let step = match stage {
- Stage::Step(index) => solidcraft_space_mouse::STEPS.get(index).copied(),
- _ => None,
- };
- match (step, result) {
- (Some(step), _) => crate::space_mouse_model::demo(ui, step, kind),
- (_, Some(Ok(calibration))) => {
- let calibration = Calibration { dead_zone_share: dead_zone, ..calibration };
- crate::space_mouse_model::live(ui, &calibration, raw);
- dead_zone_pads(ui, &calibration, raw, true, &Default::default());
+ }
+ if stage == Stage::Choose {
+ // Side by side where they fit, one under the other where the window is narrow.
+ ui.horizontal_wrapped(|ui| {
+ for (kind, label) in KINDS {
+ ui.vertical(|ui| {
+ crate::space_mouse_model::rest(ui, kind);
+ if crate::ui_kit::button(ui, app.tr(label), crate::ui_kit::Button::Normal).clicked() {
+ chosen = Some(kind);
+ }
+ });
+ }
+ });
+ } else {
+ crate::ui_kit::progress(ui, "space_mouse_calibration", progress as f32);
+ crate::ui_kit::text(ui, &counter, crate::ui_kit::Text::Note("space_mouse_counter"));
+ // Each step shows the motion it asks for; once calibrated, the device's picture follows it.
+ let step = match stage {
+ Stage::Step(index) => solidcraft_space_mouse::STEPS.get(index).copied(),
+ _ => None,
+ };
+ match (step, result) {
+ (Some(step), _) => crate::space_mouse_model::demo(ui, step, kind),
+ (_, Some(Ok(calibration))) => {
+ let calibration = Calibration { dead_zone_share: dead_zone, ..calibration };
+ crate::space_mouse_model::live(ui, &calibration, raw);
+ dead_zone_pads(ui, &calibration, raw, true, &Default::default());
+ }
+ _ => crate::space_mouse_model::rest(ui, kind),
}
- _ => crate::space_mouse_model::rest(ui, kind),
}
- }
- // The device's six raw axes as they come, so the jitter at rest is there to see.
- crate::ui_kit::text(ui, app.tr("ui.3d_mouse_reading"), crate::ui_kit::Text::Note("space_mouse_reading"));
- reading_grid(ui, raw);
- // A reassignment made in Preferences stays on top of whatever this records.
- if app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES {
- crate::ui_kit::text(ui, app.tr("ui.3d_mouse_axes_reassigned"), crate::ui_kit::Text::Note("space_mouse_axes_reassigned"));
- }
- crate::ui_kit::row(ui, app.tr("ui.3d_mouse_dead_zone"), |ui| {
- dead_zone_slider(ui, &mut dead_zone).backing_on_hover_text(app.tr("ui.3d_mouse_dead_zone_tip"));
- });
- },
- |ui| {
- ui.horizontal(|ui| {
- back = ui
- .add_enabled_ui(stage != Stage::Choose, |ui| crate::ui_kit::button(ui, app.tr("ui.back"), crate::ui_kit::Button::Normal))
- .inner
- .clicked();
- skip = can_skip
- && crate::ui_kit::button(ui, app.tr("ui.3d_mouse_skip"), crate::ui_kit::Button::Normal)
- .backing_on_hover_text(app.tr("ui.3d_mouse_skip_tip"))
+ // The device's six raw axes as they come, so the jitter at rest is there to see.
+ crate::ui_kit::text(ui, app.tr("ui.3d_mouse_reading"), crate::ui_kit::Text::Note("space_mouse_reading"));
+ reading_grid(ui, raw);
+ // A reassignment made in Preferences stays on top of whatever this records.
+ if app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES {
+ crate::ui_kit::text(ui, app.tr("ui.3d_mouse_axes_reassigned"), crate::ui_kit::Text::Note("space_mouse_axes_reassigned"));
+ }
+ crate::ui_kit::row(ui, app.tr("ui.3d_mouse_dead_zone"), |ui| {
+ dead_zone_slider(ui, &mut dead_zone).backing_on_hover_text(app.tr("ui.3d_mouse_dead_zone_tip"));
+ });
+ },
+ |ui| {
+ ui.horizontal(|ui| {
+ back = ui
+ .add_enabled_ui(stage != Stage::Choose, |ui| crate::ui_kit::button(ui, app.tr("ui.back"), crate::ui_kit::Button::Normal))
+ .inner
.clicked();
- over =
- matches!(result, Some(Err(_))) && crate::ui_kit::button(ui, app.tr("ui.start_over"), crate::ui_kit::Button::Normal).clicked();
- });
- },
- );
+ skip = can_skip
+ && crate::ui_kit::button(ui, app.tr("ui.3d_mouse_skip"), crate::ui_kit::Button::Normal)
+ .backing_on_hover_text(app.tr("ui.3d_mouse_skip_tip"))
+ .clicked();
+ over = matches!(result, Some(Err(_)))
+ && crate::ui_kit::button(ui, app.tr("ui.start_over"), crate::ui_kit::Button::Normal).clicked();
+ });
+ },
+ );
let cancel = closed || action == crate::ui_kit::Action::Cancel;
let save = action == crate::ui_kit::Action::Ok;
if cancel {
diff --git a/crates/ui-egui/src/space_mouse_model.rs b/crates/ui-egui/src/space_mouse_model.rs
index da4f489a02..27f48009fd 100644
--- a/crates/ui-egui/src/space_mouse_model.rs
+++ b/crates/ui-egui/src/space_mouse_model.rs
@@ -173,7 +173,7 @@ fn rolled(ui: &egui::Ui, site: &str, travel: [f32; 6], repaint: bool) -> ball::B
ui.ctx().request_repaint_after(std::time::Duration::from_millis(16));
}
ui.data_mut(|data| {
- let ball = data.get_temp_mut_or_insert_with(ui.id().with(("sc_space_mouse_ball", site)), ball::Ball::new);
+ let ball = data.get_temp_mut_or_insert_with(ui.scope_id().with(("sc_space_mouse_ball", site)), ball::Ball::new);
ball.roll(rate, seconds);
*ball
})
@@ -291,7 +291,7 @@ pub(crate) fn demo_swing(seconds: f32) -> f32 {
/// rest again whenever the step changes.
pub(crate) fn demo(ui: &mut egui::Ui, step: Step, kind: Kind) {
let now = ui.input(|i| i.time);
- let id = egui::Id::new("sc_space_mouse_demo");
+ let id = egui::Id::unique("sc_space_mouse_demo");
let key = (step.axis, step.positive);
let started = ui.data_mut(|data| {
let (shown, started) = data.get_temp_mut_or_insert_with(id, || (key, now));
diff --git a/crates/ui-egui/src/space_mouse_offer.rs b/crates/ui-egui/src/space_mouse_offer.rs
index 1effc7b7db..6162a69fcd 100644
--- a/crates/ui-egui/src/space_mouse_offer.rs
+++ b/crates/ui-egui/src/space_mouse_offer.rs
@@ -375,7 +375,10 @@ mod preferences_tests {
let window = crate::scenario::rect_of("dialog:window");
let centre = window.map(|r| r.center());
let top = centre.and_then(|c| h.ctx.layer_id_at(c));
- assert!(top.is_some_and(|layer| layer.id == egui::Id::new("sc_prefs")), "{device:?}: the layer on top at the window centre is {top:?}");
+ assert!(
+ top.is_some_and(|layer| layer.id == egui::Id::unique("sc_prefs")),
+ "{device:?}: the layer on top at the window centre is {top:?}"
+ );
assert!(h.app.prefs_window.open, "{device:?}: still open");
assert!(crate::scenario::rect_of("dialog:window").is_some_and(|r| r.is_positive()), "{device:?}: the window is drawn");
}
@@ -417,7 +420,10 @@ mod preferences_tests {
let at = window.min + egui::vec2(window.width() * f, window.height() * g);
let top = h.ctx.layer_id_at(at);
let order = h.ctx.memory(|m| m.areas().visible_layer_ids());
- assert!(top.is_some_and(|l| l.id == egui::Id::new("sc_prefs")), "frame {frame} at {at:?}: top is {top:?}; order {order:?}");
+ assert!(
+ top.is_some_and(|l| l.id == egui::Id::unique("sc_prefs")),
+ "frame {frame} at {at:?}: top is {top:?}; order {order:?}"
+ );
}
}
}
@@ -445,7 +451,7 @@ mod preferences_tests {
if frame > 4 {
let window = crate::scenario::rect_of("dialog:window").expect("drawn");
let top = h.ctx.layer_id_at(window.center());
- assert!(top.is_some_and(|l| l.id == egui::Id::new("sc_prefs")), "{device:?} frame {frame}: top is {top:?}");
+ assert!(top.is_some_and(|l| l.id == egui::Id::unique("sc_prefs")), "{device:?} frame {frame}: top is {top:?}");
}
}
}
@@ -717,8 +723,11 @@ mod preferences_tests {
run(&mut h, 2.0);
assert!(card_up(&h), "{widget}");
let before = h.app.preferences.clone();
+ // Where the button was: once the guard hides the card, a name finds nothing (or another
+ // control), so a click by name would not test the click behind it.
+ let at = h.widget(widget).unwrap();
crate::issue_report::set_cad_input_blocked_for_test(true);
- h.step(&serde_json::json!({"widget": widget})).ok();
+ h.step(&serde_json::json!({"click": at})).unwrap();
h.frames(3);
crate::issue_report::set_cad_input_blocked_for_test(false);
assert!(h.app.space_mouse.calibrating.is_none() && !h.app.prefs_window.open, "{widget}: no wizard, no Preferences");
diff --git a/crates/ui-egui/src/stand_up.rs b/crates/ui-egui/src/stand_up.rs
index 08e553162e..76bcb70b5a 100644
--- a/crates/ui-egui/src/stand_up.rs
+++ b/crates/ui-egui/src/stand_up.rs
@@ -296,7 +296,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
return;
}
let title = if app.stand_up_assembly { "Stand this assembly up?" } else { "Stand this part up?" };
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_stand_up"), "move", crate::i18n::tr_label(title))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_stand_up"), "move", crate::i18n::tr_label(title))
.anchor(egui::Align2::CENTER_TOP, egui::vec2(0.0, 140.0))
.actions("Stand it up", "Leave it", Some("Don't ask again"))
.show(ctx, true, |ui| {
diff --git a/crates/ui-egui/src/status_bar.rs b/crates/ui-egui/src/status_bar.rs
index 82f32d7f97..939458e77a 100644
--- a/crates/ui-egui/src/status_bar.rs
+++ b/crates/ui-egui/src/status_bar.rs
@@ -170,7 +170,7 @@ fn paint(app: &mut SolveApp, ui: &mut egui::Ui, contents: &Contents) {
painter.circle_filled(pos2(item.left() + t.space_4, item.center().y), t.space_3 + 0.5, dot);
}
painter.galley(pos2(item.left() + dot_width, item.center().y - galley.size().y / 2.0), galley, colour);
- ui.interact(item, egui::Id::new(handle), Sense::hover()).widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &text));
+ ui.interact(item, egui::Id::unique(handle), Sense::hover()).widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, &text));
crate::scenario::publish_target(handle, item);
right = item.left();
}
@@ -187,7 +187,7 @@ fn menu_button(app: &mut SolveApp, ui: &mut egui::Ui, right: f32, target: Target
let chevron = t.space_10;
let width = t.space_6 + galley.size().x + t.space_4 + chevron + t.space_6;
let button = Rect::from_min_max(pos2(right - width, r.top() + t.space_3), pos2(right, r.bottom() - t.space_3));
- let response = ui.interact(button, egui::Id::new(("sc_status_menu", handle)), Sense::click());
+ let response = ui.interact(button, egui::Id::unique(("sc_status_menu", handle)), Sense::click());
let open = app.viewport.context_menu.is_some() && app.menu.target == target;
if response.hovered() || open {
painter.rect_filled(button, t.control_radius, t.hover);
@@ -197,7 +197,7 @@ fn menu_button(app: &mut SolveApp, ui: &mut egui::Ui, right: f32, target: Target
painter.galley(text_at, galley, t.text);
let chevron_rect = Rect::from_center_size(pos2(button.right() - t.space_6 - chevron / 2.0, button.center().y), vec2(chevron, chevron));
crate::ui_kit::dropdown_indicator(&painter, chevron_rect, t.text_dim);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, label));
crate::scenario::publish_target(handle, button);
if response.backing_on_hover_text(tip).clicked() {
crate::context_menu::toggle_for(app, button, button.right_top(), target);
diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs
index 6191ff0b23..0bb5ba41cf 100644
--- a/crates/ui-egui/src/theme.rs
+++ b/crates/ui-egui/src/theme.rs
@@ -231,7 +231,7 @@ pub(crate) struct BlurIntent {
}
pub(crate) fn blur_intent(ctx: &egui::Context) -> BlurIntent {
- ctx.data_mut(|data| data.get_temp_mut_or_default::<TabThemeState>(egui::Id::new(TAB_STATE)).blur)
+ ctx.data_mut(|data| data.get_temp_mut_or_default::<TabThemeState>(egui::Id::unique(TAB_STATE)).blur)
}
/// Cache the authored theme and raw saved values before any effective-value normalization.
@@ -244,7 +244,7 @@ pub(crate) fn prepare_tabs(
values: impl FnOnce() -> BTreeMap<String, crate::theme_files::OptionValue>,
) -> Option<Custom> {
ctx.data_mut(|data| {
- let state = data.get_temp_mut_or_default::<TabThemeState>(egui::Id::new(TAB_STATE));
+ let state = data.get_temp_mut_or_default::<TabThemeState>(egui::Id::unique(TAB_STATE));
let same = match (&state.prepared, file) {
(Some(old), Some(file)) => old.file == *file && old.raw.as_ref() == raw,
(None, None) => true,
@@ -403,7 +403,7 @@ impl Bevel {
let mut rounding: egui::epaint::CornerRadiusF32 = radius.into();
rounding -= inset;
let mut path = Vec::new();
- egui::epaint::tessellator::path::rounded_rectangle(&mut path, edge, rounding);
+ egui::epaint::tessellator::path::rounded_rectangle(&mut path, egui::epaint::RoundedRect::new(edge, rounding));
if let Some(first) = path.first().copied() {
path.push(first);
}
@@ -676,17 +676,17 @@ impl TabAccent {
}
pub fn current(ctx: &egui::Context) -> Self {
- ctx.data(|d| d.get_temp::<Self>(egui::Id::new("sc_tab_accent"))).unwrap_or_else(|| Self::for_tab(&Tokens::get(), "MODEL"))
+ ctx.data(|d| d.get_temp::<Self>(egui::Id::unique("sc_tab_accent"))).unwrap_or_else(|| Self::for_tab(&Tokens::get(), "MODEL"))
}
pub fn current_icon_accent(ctx: &egui::Context) -> Option<&'static str> {
- ctx.data(|d| d.get_temp::<Option<&'static str>>(egui::Id::new("sc_tab_icon_accent"))).flatten()
+ ctx.data(|d| d.get_temp::<Option<&'static str>>(egui::Id::unique("sc_tab_icon_accent"))).flatten()
}
pub fn publish(app: &crate::SolveApp, ctx: &egui::Context) {
let now = ctx.input(|i| i.time);
let (published, accent, fading, style_surfaces) = ctx.data_mut(|data| {
- let state = data.get_temp_mut_or_default::<TabThemeState>(egui::Id::new(TAB_STATE));
+ let state = data.get_temp_mut_or_default::<TabThemeState>(egui::Id::unique(TAB_STATE));
let (published, accent, fading) = state.publish(&app.ui.tab, now);
let style_surfaces = published.tab_surfaces || state.styled_surfaces;
state.styled_surfaces = published.tab_surfaces;
@@ -709,18 +709,18 @@ impl TabAccent {
ctx.request_repaint();
}
ctx.data_mut(|d| {
- d.insert_temp(egui::Id::new("sc_tab_accent"), accent);
- d.insert_temp(egui::Id::new("sc_tab_icon_accent"), icon_accent_for_tab(&app.ui.tab));
- d.insert_temp(egui::Id::new("sc_sketch_open"), app.session.active_sketch.is_some());
- d.insert_temp(egui::Id::new("sc_tool_accent"), app.tool.is_some() || app.dialog.is_some());
+ d.insert_temp(egui::Id::unique("sc_tab_accent"), accent);
+ d.insert_temp(egui::Id::unique("sc_tab_icon_accent"), icon_accent_for_tab(&app.ui.tab));
+ d.insert_temp(egui::Id::unique("sc_sketch_open"), app.session.active_sketch.is_some());
+ d.insert_temp(egui::Id::unique("sc_tool_accent"), app.tool.is_some() || app.dialog.is_some());
});
}
/// Paint only the focused numeric editor, without changing sibling buttons or checkboxes.
pub fn number_focus(ui: &egui::Ui, response: &egui::Response) {
- let active = ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::new("sc_tool_accent"))).unwrap_or(false);
+ let active = ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::unique("sc_tool_accent"))).unwrap_or(false);
let t = Tokens::get();
- let sketch = ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::new("sc_sketch_open"))).unwrap_or(false);
+ let sketch = ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::unique("sc_sketch_open"))).unwrap_or(false);
let color = if sketch { t.sketch_accent } else { Self::current(ui.ctx()).color };
if active && response.has_focus() && color != t.accent {
ui.painter().rect_stroke(response.rect, t.radius_sm, Stroke::new(1.0, color), egui::StrokeKind::Inside);
@@ -1816,7 +1816,7 @@ mod tests {
set_dark(file.base.is_dark());
set_custom(custom);
};
- let publish = || ctx.data_mut(|d| d.get_temp_mut_or_default::<TabThemeState>(egui::Id::new(TAB_STATE)).publish("SKETCH", 1.0));
+ let publish = || ctx.data_mut(|d| d.get_temp_mut_or_default::<TabThemeState>(egui::Id::unique(TAB_STATE)).publish("SKETCH", 1.0));
set_vision(ColorVision::Off);
set_viewport_dark(None);
set_viewport_background(None);
@@ -1851,7 +1851,7 @@ mod tests {
let ctx = crate::fonts::test_context();
let mut state = tabs_state("dark", BTreeMap::new());
state.publish("MODEL", 0.0);
- ctx.data_mut(|d| d.insert_temp(egui::Id::new(TAB_STATE), state));
+ ctx.data_mut(|d| d.insert_temp(egui::Id::unique(TAB_STATE), state));
app.ui.tab = "SKETCH".into();
let frame = |time| {
let mut out = ctx.run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| {
@@ -1878,7 +1878,7 @@ mod tests {
frame(time);
}
assert_eq!(frame(2.0), std::time::Duration::MAX);
- let (end, _, _) = ctx.data_mut(|d| d.get_temp_mut_or_default::<TabThemeState>(egui::Id::new(TAB_STATE)).publish("SKETCH", 2.0));
+ let (end, _, _) = ctx.data_mut(|d| d.get_temp_mut_or_default::<TabThemeState>(egui::Id::unique(TAB_STATE)).publish("SKETCH", 2.0));
assert_eq!(Tokens::get(), end.tokens);
let mut instant = tabs_state("dark", BTreeMap::from([("tab_fade_ms".into(), OptionValue::Num(0.0))]));
instant.publish("MODEL", 0.0);
@@ -1899,14 +1899,15 @@ mod tests {
let actual = visuals(dark);
let original = if dark { egui::Visuals::dark() } else { egui::Visuals::light() };
assert_eq!(actual.menu_corner_radius, original.menu_corner_radius);
+ // egui 0.37 rounds its widgets 4 points; ours keep the 2 and 3 points egui used before.
for (a, b) in [
- (actual.widgets.noninteractive, original.widgets.noninteractive),
- (actual.widgets.inactive, original.widgets.inactive),
- (actual.widgets.hovered, original.widgets.hovered),
- (actual.widgets.active, original.widgets.active),
- (actual.widgets.open, original.widgets.open),
+ (actual.widgets.noninteractive, 2),
+ (actual.widgets.inactive, 2),
+ (actual.widgets.hovered, 3),
+ (actual.widgets.active, 2),
+ (actual.widgets.open, 2),
] {
- assert_eq!(a.corner_radius, b.corner_radius);
+ assert_eq!(a.corner_radius, egui::CornerRadius::same(b));
}
let tokens = Tokens { radius_sm: 0, radius_md: 0, ..Tokens::dark() };
set_custom(Some(Custom { dark, tokens }));
diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rs
index f26a99c870..1a2101dba4 100644
--- a/crates/ui-egui/src/timeline.rs
+++ b/crates/ui-egui/src/timeline.rs
@@ -937,7 +937,7 @@ fn folder_tile(app: &mut SolveApp, ui: &mut egui::Ui, p: &egui::Painter, x: f32,
let br = Rect::from_min_size(pos2(x, r.top() + 6.0), vec2(28.0, 28.0));
let key = format!("timeline_group:{id}");
let open = !app.tree.collapsed.contains(&key);
- let resp = ui.interact(br, ui.id().with(("folder", id)), Sense::click());
+ let resp = ui.interact(br, ui.scope_id().with(("folder", id)), Sense::click());
p.rect(
br,
t.radius_sm.saturating_sub(1),
@@ -993,7 +993,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
drag_rect = drag_rect.union(title_rect);
x += heading.width();
}
- let response = ui.interact(drag_rect, egui::Id::new("sc_history_dock_grip"), Sense::drag());
+ let response = ui.interact(drag_rect, egui::Id::unique("sc_history_dock_grip"), Sense::drag());
crate::scenario::publish_handle("history:grip", drag_rect.center());
crate::timeline_left::dock_drag(app, ui, &response);
let controls = crate::ui_kit::HistoryTransport::shown(app.preferences.history_play_button);
@@ -1027,7 +1027,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
let galley = ui.painter().layout_no_wrap(label.clone(), egui::FontId::proportional(t.font_label), t.text);
let br = Rect::from_min_size(pos2(x, r.top() + 9.0), vec2(galley.size().x + 12.0, 22.0));
crate::scenario::publish_handle("timeline:components", br.center());
- let resp = ui.interact(br, ui.id().with("tl_components"), Sense::click());
+ let resp = ui.interact(br, ui.scope_id().with("tl_components"), Sense::click());
p.rect(br, 3.0, if resp.hovered() { t.hover } else { t.timeline_item }, egui::Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
p.galley(br.left_center() + vec2(6.0, -galley.size().y * 0.5), galley, t.text);
let tip = if show_all {
@@ -1053,7 +1053,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
let reveal = app.tree.timeline_reveal;
// The feature that made what is under the cursor or picked in the viewport.
let from_view = [hovered_feature(app), picked_feature(app)];
- let drag_id = ui.id().with("tl_drag");
+ let drag_id = ui.scope_id().with("tl_drag");
let mut drag: Option<Drag> = ui.data(|d| d.get_temp(drag_id));
let pointer = ui.input(|i| i.pointer.hover_pos());
let mut xs: Vec<f32> = vec![x; feats.len()];
@@ -1127,7 +1127,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
// A chip scrolled out of the strip is neither drawn nor interactive: a long
// history drew every chip each frame. Its slot above still places the marker and drops.
// One being dragged or focused, or under an open menu, stays alive until that ends.
- let chip_id = ui.id().with(("feat", *id));
+ let chip_id = ui.scope_id().with(("feat", *id));
if !ui.clip_rect().intersects(br)
&& drag != Some(Drag::Feature(*id))
&& !ui.memory(|m| m.has_focus(chip_id))
@@ -1225,7 +1225,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
// The history marker: drag it to roll the model back or forward.
if let Some(mr) = marker_rect {
crate::scenario::publish_rect("history:marker", mr);
- let resp = ui.interact(mr.expand2(vec2(3.0, 0.0)), ui.id().with("tl_marker"), Sense::drag());
+ let resp = ui.interact(mr.expand2(vec2(3.0, 0.0)), ui.scope_id().with("tl_marker"), Sense::drag());
if resp.drag_started() {
drag = Some(Drag::Marker);
}
@@ -1794,9 +1794,12 @@ mod tests {
// Model a rebuild that held the window thread for ten seconds. Its first visible
// frame must still show the first feature; elapsed compute time is not playback.
let time = h.ctx.input(|i| i.time) + 10.0;
- let _ = h.ctx.run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| {
- super::tick_playback(&mut h.app, ui.ctx());
- });
+ h.ctx
+ .run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| {
+ super::tick_playback(&mut h.app, ui.ctx());
+ })
+ .textures_delta
+ .clear();
assert_eq!(h.app.session.doc.marker, Some(1));
assert_eq!(h.app.session.model.state().bodies.len(), 1);
}
diff --git a/crates/ui-egui/src/timeline_left.rs b/crates/ui-egui/src/timeline_left.rs
index c3331ffbf0..fd40c792cb 100644
--- a/crates/ui-egui/src/timeline_left.rs
+++ b/crates/ui-egui/src/timeline_left.rs
@@ -189,11 +189,11 @@ fn split_handle(app: &mut SolveApp, ui: &egui::Ui, available: Rect) {
return;
}
let rail = Rect::from_x_y_ranges(browser.x_range(), browser.bottom() - SPLIT_RAIL / 2.0..=history.top() + SPLIT_RAIL / 2.0);
- let overlay = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("sc_column_split")).fixed_pos(rail.min);
+ let overlay = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::unique("sc_column_split")).fixed_pos(rail.min);
ui.ctx().set_sublayer(ui.layer_id(), overlay.layer());
overlay.show(ui.ctx(), |ui| {
ui.set_min_size(rail.size());
- let response = ui.interact(rail, egui::Id::new("sc_column_split_rail"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeVertical);
+ let response = ui.interact(rail, egui::Id::unique("sc_column_split_rail"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeVertical);
if response.dragged() {
let delta = ui.input(|input| input.pointer.delta().y);
if delta.is_finite() {
@@ -246,19 +246,20 @@ pub fn left_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
let fill = card_fill(app, container.floating());
let frame = container.frame(ui.ctx(), fill, crate::frame::Side::Left).inner_margin(t.space_4);
let inner = (bounds.size() - frame.total_margin().sum()).max(egui::Vec2::ZERO);
- let card = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("sc_timeline_left_card")).fixed_pos(bounds.min).show(ui.ctx(), |ui| {
- let response = container.show_frame(ui, frame, available, |ui| {
- ui.set_min_size(inner);
- ui.set_max_size(inner);
- ui.set_clip_rect(ui.clip_rect().intersect(Rect::from_min_size(ui.max_rect().min, inner)));
- left_timeline(app, ui);
+ let card =
+ Container::new(ui.ctx(), Surface::Panel).area(egui::Id::unique("sc_timeline_left_card")).fixed_pos(bounds.min).show(ui.ctx(), |ui| {
+ let response = container.show_frame(ui, frame, available, |ui| {
+ ui.set_min_size(inner);
+ ui.set_max_size(inner);
+ ui.set_clip_rect(ui.clip_rect().intersect(Rect::from_min_size(ui.max_rect().min, inner)));
+ left_timeline(app, ui);
+ });
+ if stacked(app) {
+ let width = crate::browser::browser_width(app.preferences.browser_width);
+ crate::browser::resize_column(app, ui, response.response.rect, width, "left-history-rail");
+ split_handle(app, ui, available);
+ }
});
- if stacked(app) {
- let width = crate::browser::browser_width(app.preferences.browser_width);
- crate::browser::resize_column(app, ui, response.response.rect, width, "left-history-rail");
- split_handle(app, ui, available);
- }
- });
app.shell.history = Some(card.response.rect);
crate::scenario::publish_rect("history:vertical", card.response.rect);
if !stacked(app) {
@@ -297,7 +298,7 @@ fn names_fit(width: f32) -> bool {
fn seam_handle(app: &mut SolveApp, ui: &mut egui::Ui, card: Rect, parent: egui::LayerId) {
let seam = crate::ui_kit::HistorySeam::new(card);
let bounds = seam.edge.union(seam.pill);
- let overlay = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("history_seam_overlay")).fixed_pos(bounds.min);
+ let overlay = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::unique("history_seam_overlay")).fixed_pos(bounds.min);
// The grip follows its panel when clicked, while remaining below movable dialogs.
ui.ctx().set_sublayer(parent, overlay.layer());
overlay.show(ui.ctx(), |ui| {
@@ -387,7 +388,7 @@ fn timeline_transport(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {
} else {
handle
};
- let drag = ui.interact(drag_rect, egui::Id::new("sc_history_dock_grip"), Sense::drag());
+ let drag = ui.interact(drag_rect, egui::Id::unique("sc_history_dock_grip"), Sense::drag());
crate::scenario::publish_handle("history:grip", drag_rect.center());
dock_drag(app, ui, &drag);
}
@@ -471,7 +472,7 @@ pub(crate) fn dock_drag(app: &mut SolveApp, ui: &egui::Ui, drag: &egui::Response
Dock::UnderBrowser => column_rects(app, available, false, false).1,
};
let t = Tokens::get();
- let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Foreground, egui::Id::new("history_dock_preview")));
+ let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Foreground, egui::Id::unique("history_dock_preview")));
painter.rect(zone, t.radius_lg, t.accent.gamma_multiply(0.18), Stroke::new(t.space_2, t.accent), egui::StrokeKind::Inside);
crate::scenario::publish_rect("history:dock_preview", zone);
crate::scenario::publish_rect(&format!("history:dock:{}", target.id()), zone);
@@ -1053,7 +1054,7 @@ fn timeline_group_name(
let Some(mut rename) = app.menu.rename.take() else { return false };
let left = rect.left() + 38.0 + offset;
let edit_rect = Rect::from_min_max(pos2(left, rect.top() + 1.0), pos2(rect.right() - 3.0, rect.bottom() - 1.0));
- let edit_id = ui.id().with(("timeline_group_rename", group.id));
+ let edit_id = ui.scope_id().with(("timeline_group_rename", group.id));
let response = crate::ui_kit::inline_name(ui, edit_rect, edit_id, &mut rename.text);
crate::scenario::publish_handle(&format!("timeline-folder-rename:{}", group.name), edit_rect.center());
if !rename.focused {
@@ -1148,7 +1149,7 @@ fn vertical_group_row(
crate::scenario::publish_handle(&format!("timeline-folder:{}", group.name), rect.center());
let fold_rect = Rect::from_min_max(pos2(rect.left() + offset, rect.top()), pos2(rect.left() + offset + 18.0, rect.bottom()));
crate::scenario::publish_handle(&format!("timeline-folder-fold:{}", group.name), fold_rect.center());
- let fold = ui.interact(fold_rect, ui.id().with(("timeline_group_fold", group.id)), Sense::click());
+ let fold = ui.interact(fold_rect, ui.scope_id().with(("timeline_group_fold", group.id)), Sense::click());
if fold.clicked() {
if open {
app.tree.collapsed.insert(key.clone());
@@ -1265,7 +1266,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {
let n = features.len();
let marker = app.session.doc.marker.unwrap_or(n);
let from_view = [crate::timeline::hovered_feature(app), crate::timeline::picked_feature(app)];
- let drag_id = ui.id().with("tl_vertical_drag");
+ let drag_id = ui.scope_id().with("tl_vertical_drag");
let mut rows = Rows {
sketch_states: crate::sketch_state::SketchStates::of(app),
names,
diff --git a/crates/ui-egui/src/timeline_left/plan.rs b/crates/ui-egui/src/timeline_left/plan.rs
index 5eefcce74e..b3ddc42e14 100644
--- a/crates/ui-egui/src/timeline_left/plan.rs
+++ b/crates/ui-egui/src/timeline_left/plan.rs
@@ -106,7 +106,7 @@ pub(super) struct RowPlan {
impl RowPlan {
/// The plan for the design as it is, kept until it changes.
pub(super) fn cached(app: &SolveApp, ui: &egui::Ui, under_feature: bool) -> Arc<Self> {
- let id = egui::Id::new("sc_history_row_plan");
+ let id = egui::Id::unique("sc_history_row_plan");
let key = PlanKey::of(app, under_feature);
if let Some(plan) = ui.data(|data| data.get_temp::<Arc<Self>>(id)).filter(|plan| plan.key == key) {
return plan;
@@ -376,7 +376,7 @@ impl RowPlan {
/// closes.
pub(super) fn order(&self, ui: &egui::Ui, folds: &Folds) -> Arc<Vec<TimelineItem>> {
type Kept = (PlanKey, Folds, Arc<Vec<TimelineItem>>);
- let id = egui::Id::new("sc_history_row_order");
+ let id = egui::Id::unique("sc_history_row_order");
if let Some(kept) = ui.data(|data| data.get_temp::<Arc<Kept>>(id)).filter(|kept| kept.0 == self.key && kept.1 == *folds) {
return kept.2.clone();
}
@@ -447,6 +447,6 @@ impl RowPlan {
/// The plan the History drew with last, from the egui context.
pub(super) fn kept(ctx: &egui::Context) -> Option<Arc<Self>> {
- ctx.data(|data| data.get_temp::<Arc<Self>>(egui::Id::new("sc_history_row_plan")))
+ ctx.data(|data| data.get_temp::<Arc<Self>>(egui::Id::unique("sc_history_row_plan")))
}
}
diff --git a/crates/ui-egui/src/timeline_marks_tests.rs b/crates/ui-egui/src/timeline_marks_tests.rs
index add4853682..334990fe53 100644
--- a/crates/ui-egui/src/timeline_marks_tests.rs
+++ b/crates/ui-egui/src/timeline_marks_tests.rs
@@ -118,7 +118,7 @@ fn fresh_frame(h: &mut crate::scenario::Harness) -> (Vec<egui::epaint::ClippedSh
let mut shapes = Vec::new();
for _ in 0..2 {
let app = &mut h.app;
- let out = h.ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| {
+ let mut out = h.ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| {
app.logic(ui.ctx());
app.ui(ui);
});
@@ -129,6 +129,7 @@ fn fresh_frame(h: &mut crate::scenario::Harness) -> (Vec<egui::epaint::ClippedSh
colours.dedup();
textures.insert(*id, colours);
}
+ out.textures_delta.clear();
shapes = out.shapes;
}
(shapes, textures)
diff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rs
index f777a3f7a0..ad0e293b55 100644
--- a/crates/ui-egui/src/titlebar.rs
+++ b/crates/ui-egui/src/titlebar.rs
@@ -42,7 +42,7 @@ pub const CAPTIONS: [Caption; 3] = [Caption::Minimize, Caption::Maximize, Captio
/// Caption button ids (stable, so tests and agents can find them).
pub fn caption_id(c: Caption) -> Id {
- Id::new(("titlebar-caption", c as u8))
+ Id::unique(("titlebar-caption", c as u8))
}
fn maximized(ctx: &egui::Context) -> bool {
@@ -78,7 +78,7 @@ pub fn window_action(app: &mut SolveApp, ctx: &egui::Context, action: &str) -> R
/// their clicks.
pub fn drag_area(ui: &Ui, rect: Rect) {
let ctx = ui.ctx();
- let resp = ui.interact(rect, Id::new("titlebar-drag"), Sense::click_and_drag());
+ let resp = ui.interact(rect, Id::unique("titlebar-drag"), Sense::click_and_drag());
// egui hands a drag that starts on a click-only widget to the drag-sensing background below
// it, so remember whether the press itself landed on bare background.
if ctx.input(|i| i.pointer.any_pressed()) {
@@ -191,10 +191,10 @@ pub fn resize_zones(ui: &mut Ui) {
let w = ctx.content_rect();
let ppp = ctx.pixels_per_point();
let edge = resize_border_px(ctx.input(|i| i.viewport().native_pixels_per_point).unwrap_or(ppp)) / ppp;
- let layer = LayerId::new(Order::Foreground, Id::new("titlebar-resize"));
+ let layer = LayerId::new(Order::Foreground, Id::unique("titlebar-resize"));
let zui = ui.new_child(egui::UiBuilder::new().layer_id(layer).max_rect(w));
for (i, (r, dir, cursor)) in zones(w, edge).into_iter().enumerate() {
- let resp = zui.interact(r, Id::new(("titlebar-resize", i)), Sense::drag()).on_hover_cursor(cursor);
+ let resp = zui.interact(r, Id::unique(("titlebar-resize", i)), Sense::drag()).on_hover_cursor(cursor);
if resp.drag_started_by(PointerButton::Primary) {
ctx.send_viewport_cmd(ViewportCommand::BeginResize(dir));
}
diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs
index 1b2995a34b..6ebc18be1a 100644
--- a/crates/ui-egui/src/toolbar.rs
+++ b/crates/ui-egui/src/toolbar.rs
@@ -315,9 +315,9 @@ pub(crate) fn offer_pill(
return None;
}
let rect = Rect::from_min_size(pos2(span.right() - width, span.center().y - PILL_HEIGHT / 2.0), vec2(width, PILL_HEIGHT));
- let response = ui.interact(rect, ui.id().with(("sc_offer_pill", handle)), Sense::click());
+ let response = ui.interact(rect, ui.scope_id().with(("sc_offer_pill", handle)), Sense::click());
let name = label.map(|(text, _)| text).or(labels.first().copied()).unwrap_or_default().to_string();
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), &name));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), &name));
crate::scenario::publish_target(handle, rect);
let hot = response.hovered() || response.has_focus();
let fill = if hot { t.app_bar_hover_button } else { t.accent };
@@ -430,9 +430,9 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
let mut x = left + if compact_actions { 56.0 } else { 128.0 };
let home = Rect::from_center_size(pos2(x - 4.0, r.center().y), vec2(32.0, 32.0));
let idle = !app.file_load.busy();
- let home_response = ui.interact(home, ui.id().with("appbar_home"), if idle { Sense::click() } else { Sense::hover() });
+ let home_response = ui.interact(home, ui.scope_id().with("appbar_home"), if idle { Sense::click() } else { Sense::hover() });
let home_tip = app.tr("ui.start_page");
- home_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, idle, home_tip));
+ home_response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, idle, home_tip));
crate::scenario::publish_handle("appbar:home", home.center());
crate::scenario::publish_handle("titlebar:home", home.center());
// Compatibility for scenarios that used the former Home tab.
@@ -456,25 +456,25 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
let galley = ui.painter().layout_no_wrap(label.clone(), FontId::proportional(t.font_button), t.app_bar_text);
let br = Rect::from_min_size(pos2(x - 13.0, r.center().y - 13.0), vec2(galley.size().x + 16.0, 26.0));
x = br.right() + 17.0;
- let resp = ui.interact(br, ui.id().with(("ab", "file")), if idle { Sense::click() } else { Sense::hover() });
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, idle, &label));
+ let resp = ui.interact(br, ui.scope_id().with(("ab", "file")), if idle { Sense::click() } else { Sense::hover() });
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, idle, &label));
crate::scenario::publish_handle("appbar:file", br.center());
crate::scenario::publish_target_as("appbar:folder", "appbar:file", br);
- let open = ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::new("sc_file_menu")).unwrap_or(false));
+ let open = ui.ctx().data(|d| d.get_temp::<bool>(egui::Id::unique("sc_file_menu")).unwrap_or(false));
if idle && (resp.hovered() || resp.has_focus() || open) {
ui.painter().rect_filled(br, t.radius_sm, t.app_bar_hover);
}
let ink = if idle { t.app_bar_text } else { t.app_bar_text.gamma_multiply(0.35) };
ui.painter().galley(pos2(br.left() + 8.0, br.center().y - galley.size().y / 2.0), galley, ink);
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu_x"), br.left()));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_file_menu_x"), br.left()));
idle && resp.clicked()
};
// A disabled button is dimmed and ignores clicks (its tooltip still shows).
let click = |ui: &mut egui::Ui, at: f32, icon: &str, tip: &str, enabled: bool| -> bool {
let width = if compact_actions && matches!(icon, "save" | "undo" | "redo") { 22.0 } else { 32.0 };
let br = Rect::from_center_size(pos2(at, r.center().y), vec2(width, 32.0));
- let resp = ui.interact(br, ui.id().with(("ab", icon)), if enabled { Sense::click() } else { Sense::hover() });
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, tip));
+ let resp = ui.interact(br, ui.scope_id().with(("ab", icon)), if enabled { Sense::click() } else { Sense::hover() });
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, tip));
crate::scenario::publish_target(&format!("appbar:{icon}"), br);
crate::scenario::publish_target(&format!("titlebar:{icon}"), br);
if enabled && (resp.hovered() || resp.has_focus()) {
@@ -511,13 +511,13 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
if file {
app.ui.palette_open = false;
let ctx = ui.ctx().clone();
- let open = ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_file_menu")).unwrap_or(false));
+ let open = ctx.data(|d| d.get_temp::<bool>(egui::Id::unique("sc_file_menu")).unwrap_or(false));
let pass = ctx.cumulative_pass_nr();
// The File button toggles the menu. Remember the pass it opened on so the same
// click isn't also treated as a click outside the menu (which would close it at once).
ctx.data_mut(|d| {
- d.insert_temp(egui::Id::new("sc_file_menu"), !open);
- d.insert_temp(egui::Id::new("sc_file_menu_opened"), pass);
+ d.insert_temp(egui::Id::unique("sc_file_menu"), !open);
+ d.insert_temp(egui::Id::unique("sc_file_menu_opened"), pass);
});
}
// Document tabs follow the file actions; the house opens the start page.
@@ -540,7 +540,7 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
let search_shift = search.map_or(0.0, |s| s.width() + HEADER_SEARCH_GAP);
if let Some(search) = search {
// shortcut_box::show draws the one search editor wherever this rectangle is.
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_ribbon_search"), search));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_ribbon_search"), search));
crate::scenario::publish_target("titlebar:search", search);
}
// Assistant, Settings, Help and Report a bug form the right-hand cluster.
@@ -548,8 +548,8 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
app.help.menu = !app.help.menu;
let at = help_x(report);
ui.ctx().data_mut(|d| {
- d.insert_temp(egui::Id::new("sc_help_opened"), true);
- d.insert_temp(egui::Id::new("sc_help_anchor"), at);
+ d.insert_temp(egui::Id::unique("sc_help_opened"), true);
+ d.insert_temp(egui::Id::unique("sc_help_anchor"), at);
});
}
// A newer release: its Update button stays before the right cluster, in the space up to
@@ -566,8 +566,8 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
let mut tabs_ui = ui.new_child(egui::UiBuilder::new().max_rect(tabs_rect));
tabs_ui.set_clip_rect(tabs_rect.intersect(ui.clip_rect()));
crate::documents::tabs(app, &mut tabs_ui, r, tabs_start, tabs_end);
- let response = ui.interact(report, ui.id().with("sc_report_button"), Sense::click());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), report_text));
+ let response = ui.interact(report, ui.scope_id().with("sc_report_button"), Sense::click());
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), report_text));
crate::scenario::publish_target("titlebar:report", report);
let hot = response.hovered() || response.has_focus();
let tip = if app.header.report == ReportButton::Icon {
@@ -598,7 +598,7 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
}
// Settings sits immediately left of Help (also Ctrl+,).
let gear = Rect::from_center_size(pos2(report.left() - 52.0, r.center().y), vec2(32.0, 32.0));
- let gresp = ui.interact(gear, ui.id().with("sc_prefs_button"), Sense::click());
+ let gresp = ui.interact(gear, ui.scope_id().with("sc_prefs_button"), Sense::click());
if gresp.hovered() || gresp.has_focus() {
ui.painter().rect_filled(gear.shrink(3.0), t.radius_sm, t.app_bar_hover_button);
}
@@ -621,7 +621,7 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
let vrect = Align2::RIGHT_CENTER.anchor_size(pos2(r.right() - 12.0 - captions, r.center().y), galley.size());
let vresp = ui.interact(
vrect.expand2(vec2(2.0, 4.0)).intersect(Rect::everything_right_of(report.right())),
- ui.id().with("sc_version_link"),
+ ui.scope_id().with("sc_version_link"),
Sense::click(),
);
let url = crate::update::release_notes_url(crate::update::current_version(), crate::update::release_build());
@@ -640,7 +640,7 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
}
});
file_menu(app, ui.ctx());
- let help_x = ui.ctx().data(|d| d.get_temp::<f32>(egui::Id::new("sc_help_anchor")).unwrap_or(300.0));
+ let help_x = ui.ctx().data(|d| d.get_temp::<f32>(egui::Id::unique("sc_help_anchor")).unwrap_or(300.0));
crate::help::show(app, &ui.ctx().clone(), pos2(help_x - 14.0, APP_BAR_HEIGHT));
}
@@ -743,14 +743,14 @@ impl FileAction {
}
fn file_menu(app: &mut SolveApp, ctx: &egui::Context) {
- let id = egui::Id::new("sc_file_menu");
+ let id = egui::Id::unique("sc_file_menu");
if !ctx.data(|d| d.get_temp::<bool>(id).unwrap_or(false)) {
return;
}
let mut close = false;
let resp = Container::new(ctx, Surface::Popup)
- .area(egui::Id::new("sc_file_area"))
- .fixed_pos(pos2(ctx.data(|d| d.get_temp::<f32>(egui::Id::new("sc_file_menu_x"))).unwrap_or(100.0), APP_BAR_HEIGHT))
+ .area(egui::Id::unique("sc_file_area"))
+ .fixed_pos(pos2(ctx.data(|d| d.get_temp::<f32>(egui::Id::unique("sc_file_menu_x"))).unwrap_or(100.0), APP_BAR_HEIGHT))
.order(egui::Order::Foreground)
.show(ctx, |ui| {
crate::ui_kit::Menu::show_frame(ui, crate::ui_kit::Menu::frame(), |ui| {
@@ -896,7 +896,7 @@ fn file_menu(app: &mut SolveApp, ctx: &egui::Context) {
}
});
});
- let just_opened = ctx.data(|d| d.get_temp::<u64>(egui::Id::new("sc_file_menu_opened"))) == Some(ctx.cumulative_pass_nr());
+ let just_opened = ctx.data(|d| d.get_temp::<u64>(egui::Id::unique("sc_file_menu_opened"))) == Some(ctx.cumulative_pass_nr());
if close || (!just_opened && resp.response.clicked_elsewhere()) {
ctx.data_mut(|d| d.insert_temp(id, false));
}
@@ -1261,10 +1261,10 @@ fn paint_persistent_ribbon(app: &SolveApp, ui: &egui::Ui, paints: Vec<Persistent
}
paint.response.widget_info(|| {
if app.preferences.persistent_ribbon_pressed && persistent_available(app, paint.command.id) {
- egui::WidgetInfo::selected(egui::WidgetType::Button, paint.enabled, selected, persistent_button_name(app, paint.command))
+ egui::WidgetInfo::selected(egui::Role::Button, paint.enabled, selected, persistent_button_name(app, paint.command))
} else {
let info = crate::render_workspace::interactive_command_info(app, paint.command);
- egui::WidgetInfo::labeled(egui::WidgetType::Button, paint.enabled, app.tr_label(info.label))
+ egui::WidgetInfo::labeled(egui::Role::Button, paint.enabled, app.tr_label(info.label))
}
});
let _ = ribbon_tooltip(app, paint.response, paint.command, paint.disabled.as_deref());
@@ -1415,10 +1415,10 @@ fn ribbon_tabs(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect) -> Option<bool>
// The single editor is drawn on the foreground layer by shortcut_box::show, so it
// can grow over the ribbon without being clipped to the tab row.
if in_ribbon {
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_ribbon_search"), search));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_ribbon_search"), search));
}
let changed = ui.ctx().data_mut(|d| {
- let id = egui::Id::new("sc_ribbon_visible_tab");
+ let id = egui::Id::unique("sc_ribbon_visible_tab");
let state = (app.ui.tab.clone(), row.width());
let changed = d.get_temp::<(String, f32)>(id) != Some(state.clone());
d.insert_temp(id, state);
@@ -1447,8 +1447,8 @@ fn ribbon_tabs(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect) -> Option<bool>
if active && changed {
ui.scroll_to_rect(tr, Some(egui::Align::Center));
}
- let response = ui.interact(tr, ui.id().with(("tab", tab)), Sense::click());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, ribbon_label(app, tab)));
+ let response = ui.interact(tr, ui.scope_id().with(("tab", tab)), Sense::click());
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, ribbon_label(app, tab)));
let style = ribbon_tab_style(&t, tab, contextual, active, response.hovered());
ui.painter().rect(tr, corner, style.fill, Stroke::new(1.0, style.outline), egui::StrokeKind::Inside);
ribbon_text(ui, tr.center(), &ribbon_label(app, tab), t.font_button, style.ink, active || contextual);
@@ -1608,7 +1608,7 @@ fn open_ribbon(app: &mut SolveApp, ui: &mut egui::Ui, available: Rect, folded: R
let ws = if floating { cards.workspace } else { Rect::from_min_size(r.left_top(), vec2(WORKSPACE_WIDTH, full - 1.0)) };
let host = Container::for_layout(layout, Surface::Chrome);
let mut tab_click = None;
- host.area(egui::Id::new("sc_ribbon_open")).fixed_pos(r.min).show(ui.ctx(), |ui| {
+ host.area(egui::Id::unique("sc_ribbon_open")).fixed_pos(r.min).show(ui.ctx(), |ui| {
ui.set_min_size(r.size());
if !floating {
let frame = host.frame(ui.ctx(), t.toolbar, crate::frame::Side::Left);
@@ -1617,7 +1617,7 @@ fn open_ribbon(app: &mut SolveApp, ui: &mut egui::Ui, available: Rect, folded: R
tab_click = ribbon_contents(app, ui, RibbonShape { floating, cards, r, ws, folded: false });
if tab_click.is_some() {
// The other tab's panels are drawn now; the old tab's open drop-down is gone with them.
- ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
+ ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::unique("sc_panel_open")));
}
if floating {
let frame = host.frame(ui.ctx(), t.toolbar, crate::frame::Side::Left);
@@ -1630,7 +1630,7 @@ fn open_ribbon(app: &mut SolveApp, ui: &mut egui::Ui, available: Rect, folded: R
let ctx = ui.ctx().clone();
// A panel's drop-down, a menu or a dragged button keep the panels open while the pointer is
// on them, away from the panels.
- let busy = ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open")).is_some())
+ let busy = ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::unique("sc_panel_open")).is_some())
|| app.viewport.context_menu.is_some()
|| egui::DragAndDrop::payload::<ToolbarDrag>(&ctx).is_some();
let left = ctx.input(|i| i.pointer.latest_pos()).is_none_or(|p| !r.expand(t.space_4).contains(p));
@@ -1660,7 +1660,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
let frame = host.frame(ui.ctx(), fill, crate::frame::Side::Left);
host.paint_background(ui.painter(), frame, card);
// Blank card space owns clicks as well as its buttons.
- ui.interact(card, ui.id().with(("shell_card", card.left().to_bits())), Sense::click_and_drag());
+ ui.interact(card, ui.scope_id().with(("shell_card", card.left().to_bits())), Sense::click_and_drag());
}
if !crate::render_workspace::active(app) {
crate::scenario::publish_rect("ribbon:card", cards.ribbon);
@@ -1671,11 +1671,11 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
ui.set_clip_rect(ui.clip_rect().intersect(r));
}
let painter = ui.painter().clone();
- let bg = ui.interact(if floating { cards.ribbon } else { r }, ui.id().with("toolbar_bg"), Sense::click());
+ let bg = ui.interact(if floating { cards.ribbon } else { r }, ui.scope_id().with("toolbar_bg"), Sense::click());
if bg.secondary_clicked() {
crate::context_menu::open_for(app, bg.interact_pointer_pos().unwrap_or(r.left_bottom()), crate::context_menu::Target::Toolbar);
}
- let wresp = ui.interact(ws, ui.id().with("workspace_switcher"), Sense::click());
+ let wresp = ui.interact(ws, ui.scope_id().with("workspace_switcher"), Sense::click());
let open = app.viewport.context_menu.is_some() && app.menu.target == crate::context_menu::Target::Workspace;
if wresp.hovered() || open {
painter.rect_filled(ws, if floating { t.radius_lg } else { 0 }, t.hover);
@@ -1886,7 +1886,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
let enabled_panel = !cmds.is_empty() || *panel == "SELECT";
// Per tab: panels of the same name on other tabs (MODIFY, CREATE…) list other commands,
// and the drop-down's area remembers its size by this id (#874).
- let popup_id = ui.id().with(("panel_menu", &tab, panel));
+ let popup_id = ui.scope_id().with(("panel_menu", &tab, panel));
// Dropped on the panel's free space (all of a collapsed panel): the button goes to
// its end.
let gallery: Vec<_> = shown.iter().copied().filter(|c| app.toolbar_custom.in_gallery(&tab, panel, c.id)).collect();
@@ -1902,7 +1902,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
let bx = px + 4.0 + inset;
let free_x = bx + buttons_width + BUTTON_GAP;
let free = Rect::from_min_size(pos2(free_x, top + 2.0), vec2((px + width - 4.0 - free_x).max(0.0), button_height));
- let fresp = ui.interact(free, ui.id().with(("panel_free", panel)), if collapsed { Sense::click() } else { Sense::hover() });
+ let fresp = ui.interact(free, ui.scope_id().with(("panel_free", panel)), if collapsed { Sense::click() } else { Sense::hover() });
let collapsed_hovered = collapsed && fresp.hovered();
let mut opened = false;
if collapsed {
@@ -1925,7 +1925,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
dropdown_arrow(&painter, pos2(br.center().x, br.bottom() - 3.0), t.text_dim);
let tip = format!("{} ({})", app.tr_label(panel), shown.len().max(cmds.len()));
if fresp.backing_on_hover_text(tip).clicked() && enabled_panel {
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_panel_open"), popup_id));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_panel_open"), popup_id));
opened = true;
}
}
@@ -1946,7 +1946,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
}
}
let info = crate::render_workspace::interactive_command_info(app, selected);
- let resp = ui.interact(br, ui.id().with(("cmd", c.id)), Sense::click_and_drag());
+ let resp = ui.interact(br, ui.scope_id().with(("cmd", c.id)), Sense::click_and_drag());
crate::scenario::publish_handle(&format!("toolbar:{}", c.id), br.center());
// The button itself (`toolbar:<id>` is also a drop-down row's while one is open).
crate::scenario::publish_handle(&format!("button:{}", c.id), br.center());
@@ -1973,7 +1973,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
let persistent = persistent_available(app, selected.id);
let background_slot = painter.add(egui::Shape::Noop);
let accent = crate::theme::TabAccent::for_tab(&t, &tab);
- let family_open = family.is_some_and(|f| egui::Popup::is_id_open(ui.ctx(), ui.id().with(("family", f.label)).with("popup")));
+ let family_open = family.is_some_and(|f| egui::Popup::is_id_open(ui.ctx(), ui.scope_id().with(("family", f.label)).with("popup")));
// The buttons that leave the sketch or the edit (Finish, Finish with AutoConstrain,
// Cancel, Finish Edit) never show pressed; a tool pinned into their group does.
let exit =
@@ -2016,7 +2016,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
icons::paint_icon(&painter, icon_rect, icon, if info.enabled { 1.0 } else { 0.35 });
let tr_label = app.tr_label(info.label).to_string();
if !persistent {
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled() && info.enabled, &tr_label));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled() && info.enabled, &tr_label));
}
let clicked = resp.clicked();
if !persistent {
@@ -2051,7 +2051,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
} else {
Rect::from_min_max(pos2(br.right(), whole.top()), whole.right_bottom())
};
- let arrow = ui.interact(ar, ui.id().with(("family", f.label)), Sense::click());
+ let arrow = ui.interact(ar, ui.scope_id().with(("family", f.label)), Sense::click());
crate::scenario::publish_handle(&format!("family:{}", f.label), ar.center());
if arrow.hovered() {
painter.rect_filled(ar, t.radius_sm, t.hover);
@@ -2066,7 +2066,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
} else {
dropdown_arrow(&painter, ar.center(), t.text_dim);
}
- arrow.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, app.tr_label(f.label)));
+ arrow.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, app.tr_label(f.label)));
Container::new(ui.ctx(), Surface::Popup).menu(&arrow).show(|ui| {
let variants: Vec<_> = f.commands.iter().filter_map(|id| solidcraft_engine::find_command(id)).collect();
dropdown_keys(app, ui, &variants);
@@ -2097,7 +2097,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
vec2(24.0, 20.0),
);
let info = crate::render_workspace::interactive_command_info(app, c);
- let resp = ui.interact(cell, ui.id().with(("cmd", c.id)), Sense::click_and_drag());
+ let resp = ui.interact(cell, ui.scope_id().with(("cmd", c.id)), Sense::click_and_drag());
let active = ribbon_shows_pressed(app, c.id);
let accent = crate::theme::TabAccent::for_tab(&t, &tab);
painter.rect(
@@ -2132,7 +2132,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
for prefix in ["toolbar", "button", "ribbon:constraint"] {
crate::scenario::publish_target(&format!("{prefix}:{}", c.id), cell);
}
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, info.enabled, app.tr_label(info.label)));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, info.enabled, app.tr_label(info.label)));
if resp.drag_started() {
resp.dnd_set_drag_payload(ToolbarDrag { id: c.id, from_menu: false });
}
@@ -2157,7 +2157,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
pos2(px + RIBBON_TAB_INSET, top + group_height - SECTION_HEIGHT - (RIBBON_TAB_INSET - 1.0)),
vec2((width - 2.0 * RIBBON_TAB_INSET).max(0.0), SECTION_HEIGHT),
);
- let lresp = ui.interact(lr, ui.id().with(("panel", panel)), Sense::click());
+ let lresp = ui.interact(lr, ui.scope_id().with(("panel", panel)), Sense::click());
crate::scenario::publish_handle(&format!("panel:{tab}:{panel}"), lr.center());
crate::scenario::publish_target(&format!("ribbon:section:{tab}:{panel}"), lr);
// Commands this panel has only in its drop-down (not drawn as a button or cell).
@@ -2170,7 +2170,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
let hidden = |id: &str| cmds.iter().any(|c| c.id == id) && !drawn_ids.contains(&id);
let hidden_running = app.preferences.ribbon_reveal && running.as_deref().is_some_and(hidden);
let hidden_reveal = reveal.as_ref().filter(|r| hidden(r.id));
- let panel_open = ui.ctx().data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open"))) == Some(popup_id);
+ let panel_open = ui.ctx().data(|d| d.get_temp::<egui::Id>(egui::Id::unique("sc_panel_open"))) == Some(popup_id);
let accent = crate::theme::TabAccent::for_tab(&t, &tab);
let hot = lresp.hovered() && enabled_panel;
if follow_panel_hover && enabled_panel && !finish && (hot || collapsed_hovered) {
@@ -2202,7 +2202,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
}
if lresp.clicked() && enabled_panel {
ui.ctx().data_mut(|d| {
- let key = egui::Id::new("sc_panel_open");
+ let key = egui::Id::unique("sc_panel_open");
if d.get_temp::<egui::Id>(key) == Some(popup_id) {
d.remove::<egui::Id>(key);
} else {
@@ -2230,7 +2230,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
drop = Some((d.id, *panel, None));
}
}
- let open = ui.ctx().data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open"))) == Some(popup_id);
+ let open = ui.ctx().data(|d| d.get_temp::<egui::Id>(egui::Id::unique("sc_panel_open"))) == Some(popup_id);
// A hovered search result in this drop-down opens it on its row, under the search sheet.
let previewed = hidden_reveal.is_some_and(|r| r.preview && !open);
if open || previewed {
@@ -2314,7 +2314,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
RowAction::TogglePin => toggle = Some(c.id),
RowAction::Start(rect) => {
app.start_at(c.id, Some(rect));
- ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
+ ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::unique("sc_panel_open")));
}
}
}
@@ -2333,7 +2333,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
&& ((area.response.clicked_elsewhere() && !lresp.clicked() && !opened && !dragging)
|| ui.input(|i| i.key_pressed(egui::Key::Escape)))
{
- ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
+ ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::unique("sc_panel_open")));
}
}
px += width;
@@ -2392,7 +2392,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
let ribbon = Rect::from_min_max(pos2(ribbon_left, r.top()), r.max);
let pointer = ui.input(|i| i.pointer.hover_pos());
let changed = ui.ctx().data_mut(|d| {
- let key = egui::Id::new("sc_panel_open");
+ let key = egui::Id::unique("sc_panel_open");
let Some(open) = d.get_temp::<egui::Id>(key) else { return false };
let menu = open_panel_menu.filter(|(id, _)| *id == open).map(|(_, rect)| rect);
let stays_open =
@@ -2435,7 +2435,7 @@ fn ribbon_contents(app: &mut SolveApp, ui: &mut egui::Ui, shape: RibbonShape) ->
crate::toolbar_custom::toggle(app, &tab, id);
}
if let Some((at, id)) = menu {
- ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
+ ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::unique("sc_panel_open")));
crate::context_menu::open_for(app, at, crate::context_menu::Target::ToolbarCommand { id: id.to_string() });
}
tab_click
@@ -2468,9 +2468,9 @@ fn quick_access_bar(app: &mut SolveApp, ui: &mut egui::Ui, bar: Rect, mut x: f32
x += step;
let info = c.info(&app.session);
let enabled = shown && info.enabled;
- let resp = ui.interact(br, ui.id().with(("quick_access", c.id)), Sense::click_and_drag());
+ let resp = ui.interact(br, ui.scope_id().with(("quick_access", c.id)), Sense::click_and_drag());
let label = app.tr_label(info.label).to_string();
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, &label));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, &label));
crate::scenario::publish_target(&format!("appbar:quick:{}", c.id), br);
if enabled && (resp.hovered() || resp.has_focus()) {
ui.painter().rect_filled(br.shrink(3.0), t.radius_sm, t.app_bar_hover_button);
@@ -2533,11 +2533,11 @@ fn app_bar_separator(ui: &egui::Ui, bar: Rect, x: f32, group: &str) {
/// The chat panel's compact entry point. State stays in agent_chat; the bar only paints it.
fn assistant_button(app: &mut SolveApp, ui: &mut egui::Ui, at: Rect) {
use crate::agent_chat::AssistantMark;
- let resp = ui.interact(at, ui.id().with("assistant_button"), Sense::click());
+ let resp = ui.interact(at, ui.scope_id().with("assistant_button"), Sense::click());
crate::scenario::publish_target("titlebar:assistant", at);
let mark = crate::agent_chat::assistant_mark(app);
let tip = crate::agent_chat::assistant_tip(app, mark);
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), &tip));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), &tip));
let state = match mark {
AssistantMark::Quiet => crate::ui_kit::AssistantEntryState::Quiet,
AssistantMark::Ready => crate::ui_kit::AssistantEntryState::Ready,
@@ -2644,7 +2644,7 @@ fn paint_reveal(painter: &egui::Painter, rect: Rect, accent: &crate::theme::TabA
/// A revealed command's tooltip, open without the pointer on it (#7287).
fn reveal_tooltip(app: &SolveApp, ui: &egui::Ui, rect: Rect, command: &solidcraft_engine::CommandSpec, align: egui::RectAlign) {
- let mut tip = egui::Tooltip::always_open(ui.ctx().clone(), ui.layer_id(), egui::Id::new(("ribbon_reveal", command.id)), rect);
+ let mut tip = egui::Tooltip::always_open(ui.ctx().clone(), ui.layer_id(), egui::Id::unique(("ribbon_reveal", command.id)), rect);
tip.popup = tip.popup.align(align);
// The same text as a drop-down row's own tooltip: name and shortcut, its help, and why it is
// disabled when it is.
@@ -2652,7 +2652,7 @@ fn reveal_tooltip(app: &SolveApp, ui: &egui::Ui, rect: Rect, command: &solidcraf
let label = app.tr_label(info.label);
let shortcut = crate::keymap::display_for(app, command.id).map(|k| format!(" ({k})")).unwrap_or_default();
let help = crate::command_help::help(command.id);
- if let Some(shown) = crate::ui_kit::Container::show_tooltip(egui::Id::new(("ribbon_reveal", command.id)), tip, |ui| {
+ if let Some(shown) = crate::ui_kit::Container::show_tooltip(egui::Id::unique(("ribbon_reveal", command.id)), tip, |ui| {
ui.set_max_width(300.0);
ui.label(egui::RichText::new(format!("{label}{shortcut}")).strong());
if let Some(help) = help {
@@ -2698,7 +2698,7 @@ fn section_footer(ui: &mut egui::Ui, message: &str) {
/// Stable row id inside and outside the scrolling list, for keyboard focus.
fn dropdown_row_id(id: &str) -> egui::Id {
- egui::Id::new(("dropdown_row", id))
+ egui::Id::unique(("dropdown_row", id))
}
/// How wide a panel drop-down's rows are: the widest label and shortcut, at least 200.
@@ -2778,10 +2778,10 @@ mod dropdown_tip_tests {
let mut shown: Vec<(usize, Rect)> = Vec::new();
crate::test_support::frame(ctx, raw, |ui| {
let ctx = ui.ctx();
- egui::Area::new(egui::Id::new("test_dropdown")).fixed_pos(menu.min).show(ctx, |ui| {
+ egui::Area::new(egui::Id::unique("test_dropdown")).fixed_pos(menu.min).show(ctx, |ui| {
for row in 0..2 {
let rect = Rect::from_min_size(menu.min + vec2(0.0, row as f32 * 32.0), vec2(menu.width(), 32.0));
- let resp = ui.interact(rect, egui::Id::new(("test_row", row)), Sense::hover());
+ let resp = ui.interact(rect, egui::Id::unique(("test_row", row)), Sense::hover());
let tip = if row == 0 {
dropdown_tip(ui, menu, &resp, |ui| {
ui.label("first row");
@@ -2863,7 +2863,7 @@ fn dropdown_row(
}
// The pin at the row's end (above the row, so it takes its own clicks).
let pr = Rect::from_center_size(pos2(rect.right() - 13.0, rect.center().y), vec2(20.0, 20.0));
- let pin = ui.interact(pr, ui.id().with(("dropdown_pin", c.id)), Sense::click());
+ let pin = ui.interact(pr, ui.scope_id().with(("dropdown_pin", c.id)), Sense::click());
let pointer_on = (resp.hovered() || pin.hovered()) && !egui::DragAndDrop::has_any_payload(ui.ctx());
let label = app.tr_label(info.label).to_string();
let mut checked = None;
@@ -2875,8 +2875,8 @@ fn dropdown_row(
}
// A checkable row announces its on/off state, since its label no longer says it.
resp.widget_info(|| match checked {
- Some(on) => egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled() && info.enabled, on, &label),
- None => egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled() && info.enabled, &label),
+ Some(on) => egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled() && info.enabled, on, &label),
+ None => egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled() && info.enabled, &label),
});
crate::scenario::publish_handle(&format!("toolbar:{}", c.id), rect.center());
crate::scenario::publish_handle(&format!("dropdown:{}", c.id), rect.center());
@@ -2956,7 +2956,7 @@ fn grid_action(
Some((id, RowAction::TogglePin)) => *toggle = Some(id),
Some((id, RowAction::Start(rect))) => {
app.start_at(id, Some(rect));
- ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
+ ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::unique("sc_panel_open")));
}
Some((_, RowAction::None)) | None => {}
}
@@ -3209,7 +3209,7 @@ const PIN_DELAY: f64 = 2.0;
/// Whether the corner pin of grid icon `id` takes clicks: the pointer (`on`) has rested on the
/// icon for [`PIN_DELAY`]. One icon is timed at a time; the window redraws when the pin is due.
fn pin_armed(ui: &egui::Ui, id: &'static str, on: bool) -> bool {
- let key = egui::Id::new("sc_grid_pin_hover");
+ let key = egui::Id::unique("sc_grid_pin_hover");
let now = ui.input(|i| i.time);
let since = ui.ctx().data_mut(|d| {
let rest = d.get_temp::<(&'static str, f64)>(key).filter(|(at, _)| *at == id);
@@ -3261,12 +3261,12 @@ fn dropdown_cell(
let pr = Rect::from_min_size(pos2(rect.right() - 15.0, rect.top()), vec2(15.0, 15.0));
let dragging = egui::DragAndDrop::has_any_payload(ui.ctx());
let armed = pin_armed(ui, c.id, ui.rect_contains_pointer(rect) && !dragging);
- let pin = armed.then(|| ui.interact(pr, ui.id().with(("dropdown_pin", c.id)), Sense::click()));
+ let pin = armed.then(|| ui.interact(pr, ui.scope_id().with(("dropdown_pin", c.id)), Sense::click()));
let pin_hovered = pin.as_ref().is_some_and(egui::Response::hovered);
let persistent = app.preferences.persistent_ribbon_pressed && persistent_available(app, c.id);
if !persistent {
let label = app.tr_label(c.label).to_string();
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled() && info.enabled, &label));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled() && info.enabled, &label));
}
crate::scenario::publish_handle(&format!("toolbar:{}", c.id), rect.center());
crate::scenario::publish_handle(&format!("dropdown:{}", c.id), rect.center());
@@ -3367,7 +3367,7 @@ fn dropdown_keys(app: &SolveApp, ui: &egui::Ui, cmds: &[&'static solidcraft_engi
}
// A submenu renders before the remaining rows of its parent. Handle a key once, but
// leave the event available for the focused row's scroll-into-view behaviour.
- let handled = egui::Id::new("sketch_menu_key_pass");
+ let handled = egui::Id::unique("sketch_menu_key_pass");
let pass = ui.ctx().cumulative_pass_nr();
if ui.ctx().data(|d| d.get_temp::<u64>(handled)) == Some(pass) {
return;
@@ -3412,7 +3412,7 @@ fn sketch_menu_rows(
RowAction::TogglePin => *toggle = Some(c.id),
RowAction::Start(rect) => {
app.start_at(c.id, Some(rect));
- ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
+ ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::unique("sc_panel_open")));
ui.close();
}
}
@@ -3425,7 +3425,7 @@ type ToolbarDrag = ui_kit::ReorderPayload<&'static str>;
fn drag_ghost(app: &SolveApp, ctx: &egui::Context, id: &str, at: egui::Pos2, removing: bool) {
let t = Tokens::get();
let Some(c) = solidcraft_engine::find_command(id) else { return };
- let p = ctx.layer_painter(egui::LayerId::new(egui::Order::Tooltip, egui::Id::new("sc_toolbar_drag")));
+ let p = ctx.layer_painter(egui::LayerId::new(egui::Order::Tooltip, egui::Id::unique("sc_toolbar_drag")));
let r = Rect::from_center_size(at + vec2(14.0, 16.0), vec2(30.0, 30.0));
p.rect(r, t.radius_sm, t.toolbar.gamma_multiply(0.92), Stroke::new(1.0, if removing { t.error } else { t.accent }), egui::StrokeKind::Inside);
let info = c.info(&app.session);
@@ -3539,7 +3539,7 @@ pub fn shortcuts(app: &mut SolveApp, ctx: &egui::Context) {
}
// File is a custom Area, so it must claim Escape before the underlying editors and
// sketch shortcuts. Clear raw events too: egui may replay them on a layout pass.
- let file_menu_id = egui::Id::new("sc_file_menu");
+ let file_menu_id = egui::Id::unique("sc_file_menu");
if !app.native_file_menu
&& ctx.data(|d| d.get_temp::<bool>(file_menu_id).unwrap_or(false))
&& ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape))
@@ -3776,7 +3776,7 @@ mod header_report_tests {
h.frames(3);
let sketch = h.app.session.active_sketch;
let before = h.app.session.doc.to_json();
- let menu_open = |h: &crate::scenario::Harness| h.ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_file_menu")).unwrap_or(false));
+ let menu_open = |h: &crate::scenario::Harness| h.ctx.data(|d| d.get_temp::<bool>(egui::Id::unique("sc_file_menu")).unwrap_or(false));
h.step(&json!({"click":{"handle":"appbar:file"}})).unwrap();
assert!(menu_open(&h));
h.app.last_escape = Some(h.ctx.input(|i| i.time));
@@ -3799,9 +3799,9 @@ mod header_report_tests {
h.step(&json!({"start":"parameters.change"})).unwrap();
let before = (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.selection.clone());
h.step(&json!({"click":{"handle":"appbar:file"}})).unwrap();
- assert!(h.ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_file_menu")).unwrap_or(false)));
+ assert!(h.ctx.data(|d| d.get_temp::<bool>(egui::Id::unique("sc_file_menu")).unwrap_or(false)));
h.step(&json!({"key":"Escape"})).unwrap();
- assert!(!h.ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_file_menu")).unwrap_or(false)));
+ assert!(!h.ctx.data(|d| d.get_temp::<bool>(egui::Id::unique("sc_file_menu")).unwrap_or(false)));
assert!(h.app.params.is_some(), "the first Escape belongs to File");
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.selection.clone()));
h.step(&json!({"key":"Escape"})).unwrap();
@@ -3841,7 +3841,7 @@ mod header_report_tests {
h.step(&json!({"click":{"handle":"appbar:file"}})).unwrap();
assert!(h.widget("Save As JSON…").is_some(), "the in-window File menu still opens");
h.step(&json!({"click":{"handle":"appbar:file"}})).unwrap();
- assert!(!h.ctx.data(|data| data.get_temp::<bool>(egui::Id::new("sc_file_menu")).unwrap_or(false)));
+ assert!(!h.ctx.data(|data| data.get_temp::<bool>(egui::Id::unique("sc_file_menu")).unwrap_or(false)));
h.step(&json!({"click":{"handle":"appbar:help"}})).unwrap();
assert!(h.app.help.menu);
h.step(&json!({"key":"Escape"})).unwrap();
@@ -4639,13 +4639,13 @@ mod header_report_tests {
h.frames(3);
assert!(h.app.issue_report.draft.is_some() && crate::dim_view::editing());
captured_frame(&mut h);
- h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("issue_report_body")));
+ h.ctx.memory_mut(|m| m.request_focus(egui::Id::unique("issue_report_body")));
h.step(&json!({"text":"Describe this dimension problem."})).unwrap();
h.step(&json!({"key":"Enter"})).unwrap();
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.revision));
h.step(&json!({"widget":"Close draft"})).unwrap();
h.frames(2);
- assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+ assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::unique("sc_dim_edit")));
h.step(&json!({"key":"Enter"})).unwrap();
assert!(!crate::dim_view::editing());
assert_eq!(h.app.session.undo.len(), before.1 + 1);
@@ -4713,7 +4713,7 @@ mod home_tests {
actions.push((
format!("File › {item}"),
Box::new(move |h| {
- h.ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu"), false));
+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_file_menu"), false));
click(h, "appbar:folder");
// A same-named File navigation action is now present: target the menu row explicitly.
if let Some(at) = crate::scenario::handle_at(&format!("menu:{item}")) {
@@ -4743,7 +4743,7 @@ mod home_tests {
h.call("ui.key", json!({"key": "Z", "cmd": true}));
h.settle();
assert_eq!(h.app.session.redo.len(), 1, "Ctrl+Z works once Home is closed");
- h.ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu"), false));
+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_file_menu"), false));
click(&mut h, "appbar:file");
h.step(&json!({"widget": "Save"})).unwrap();
h.settle();
@@ -4757,7 +4757,7 @@ mod home_tests {
h.app.home.open = false;
h.app.run("solid.box", json!({"length": 10, "width": 10, "height": 10})).unwrap();
h.frames(2);
- h.ctx.data_mut(|d| d.insert_temp(egui::Id::new("sc_file_menu"), false));
+ h.ctx.data_mut(|d| d.insert_temp(egui::Id::unique("sc_file_menu"), false));
let at = crate::scenario::handle_at("appbar:folder").unwrap();
h.call("ui.click", json!({"x": at.x, "y": at.y}));
let _ = h.step(&json!({"widget": "Export URDF…"}));
@@ -5501,7 +5501,7 @@ mod dropdown_toggle_tests {
h.frames(2);
h.step(&json!({"click": {"handle": "panel:MODEL:MODIFY"}})).unwrap();
h.frames(2);
- let key = egui::Id::new("sc_panel_open");
+ let key = egui::Id::unique("sc_panel_open");
assert!(h.app.ui.ribbon_open);
assert!(h.ctx.data(|d| d.get_temp::<egui::Id>(key)).is_some(), "the panel menu is open");
let other = rect_of("toolbar_tab:SURFACE").unwrap().center();
@@ -5822,6 +5822,25 @@ mod ribbon_label_tests {
let lines = ribbon_button_lines(&painter, "長い日本語のラベル 続き", 50.0);
assert_eq!(lines.len(), 2);
assert!(lines[0].ends_with('…'));
+ // Hebrew comes in display order (`bidi::visual`): the reader starts at the right end,
+ // so "סקיצה חדשה" (New Sketch, stored as "חדשה סקיצה") puts סקיצה on the first line.
+ let label = crate::bidi::visual("סקיצה חדשה").into_owned();
+ let width = ribbon_label_width(&painter, "סקיצה").max(ribbon_label_width(&painter, "חדשה")) + 1.0;
+ assert!(ribbon_label_width(&painter, &label) > width);
+ assert_eq!(ribbon_button_lines(&painter, &label, width), vec!["סקיצה", "חדשה"]);
+ let lines = ribbon_button_lines(&painter, &crate::bidi::visual("אחת שתיים שלוש ארבע חמש"), 50.0);
+ assert_eq!(lines.len(), 2);
+ assert!(lines[1].starts_with('…'), "{lines:?}");
+ });
+ output.textures_delta.clear();
+ // Japanese is measured with the bundled Japanese face, as a Japanese UI draws it: without it
+ // the glyphs are missing and their width says nothing.
+ let ctx = crate::fonts::test_context();
+ let cjk = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf"));
+ assert!(crate::fonts::install_cjk_font_for(&ctx, cjk.to_vec(), "ja"));
+ ctx.run_ui(egui::RawInput::default(), |_| {}).textures_delta.clear();
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ let painter = ui.painter().clone();
let ja = crate::i18n::Locale::for_language("ja");
for (id, expected) in [
("sketch.create", vec!["新規", "スケッチ"]),
@@ -5831,7 +5850,7 @@ mod ribbon_label_tests {
("mesh.convert", vec!["メッシュを", "変換"]),
("component.create", vec!["新規", "コンポ"]),
("joint.origin", vec!["ジョイント", "原点"]),
- ("joint.drive", vec!["ジョイント", "を駆動"]),
+ ("joint.drive", vec!["ジョイントを", "駆動"]),
] {
let command = solidcraft_engine::find_command(id).unwrap();
let label = ja.label(crate::workspace::ribbon_button_label(command));
@@ -5840,15 +5859,6 @@ mod ribbon_label_tests {
}
let comp = solidcraft_engine::find_command("component.create").unwrap();
assert_eq!(ja.label(comp.label), "新規コンポーネント");
- // Hebrew comes in display order (`bidi::visual`): the reader starts at the right end,
- // so "סקיצה חדשה" (New Sketch, stored as "חדשה סקיצה") puts סקיצה on the first line.
- let label = crate::bidi::visual("סקיצה חדשה").into_owned();
- let width = ribbon_label_width(&painter, "סקיצה").max(ribbon_label_width(&painter, "חדשה")) + 1.0;
- assert!(ribbon_label_width(&painter, &label) > width);
- assert_eq!(ribbon_button_lines(&painter, &label, width), vec!["סקיצה", "חדשה"]);
- let lines = ribbon_button_lines(&painter, &crate::bidi::visual("אחת שתיים שלוש ארבע חמש"), 50.0);
- assert_eq!(lines.len(), 2);
- assert!(lines[1].starts_with('…'), "{lines:?}");
});
output.textures_delta.clear();
}
diff --git a/crates/ui-egui/src/toolbar_custom.rs b/crates/ui-egui/src/toolbar_custom.rs
index 68b485965d..b7feeff0e0 100644
--- a/crates/ui-egui/src/toolbar_custom.rs
+++ b/crates/ui-egui/src/toolbar_custom.rs
@@ -487,7 +487,7 @@ pub fn window(app: &mut SolveApp, ctx: &egui::Context) {
// published positions instead of shifting them after egui measures the taller content.
let origin =
egui::pos2((ctx.content_rect().center().x - t.form_card_width).max(ctx.content_rect().left()), ctx.content_rect().top() + t.space_24 * 2.0);
- let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_toolbar_customize"), "settings", crate::i18n::tr_label("Customize Toolbar"))
+ let (closed, action) = ui_kit::Window::new(egui::Id::unique("sc_toolbar_customize"), "settings", crate::i18n::tr_label("Customize Toolbar"))
.placed(egui::Align2::LEFT_TOP, origin)
.cards(2.0)
.actions("", "Close", None)
diff --git a/crates/ui-egui/src/ui_kit/actions.rs b/crates/ui-egui/src/ui_kit/actions.rs
index 3c178ea8d0..ea8fbfc8cd 100644
--- a/crates/ui-egui/src/ui_kit/actions.rs
+++ b/crates/ui-egui/src/ui_kit/actions.rs
@@ -112,7 +112,7 @@ fn styled_button(ui: &Ui, label: egui::WidgetText, tone: ButtonTone) -> egui::Bu
// Native button padding already accounts for this state's border. Preserve its width
// when changing the colour, or buttons outside a form grow and make toast actions wrap.
let state = response.as_ref().map(Response::widget_state).unwrap_or_default();
- appearance.stroke.width = ui.style().button_style(&Default::default(), state).frame.stroke.width;
+ appearance.stroke.width = ui.style().visuals.widgets.state(state).bg_stroke.width;
}
egui::Button::new(label.color(appearance.ink)).fill(appearance.fill).stroke(appearance.stroke)
}
@@ -166,7 +166,7 @@ fn icon_button_presentation(
t.form_dim
}),
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::tr_label(label)));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::tr_label(label)));
pointer_on_hover(ui, &response);
response.backing_on_hover_text(crate::i18n::tr_label(label))
}
@@ -493,7 +493,7 @@ pub(crate) fn button_pair(ui: &mut egui::Ui, key: &str, states: [bool; 2], butto
);
}
painter.galley(egui::pos2(left + icon_width, rect.center().y - galley.size().y / 2.0), galley, t.form_ink);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), on, label));
t.button_bevel(ui, &response, on);
pointer_on_hover(ui, &response);
crate::scenario::publish_target(&format!("{key}:{}", button.key), rect);
@@ -681,7 +681,7 @@ pub(crate) fn compact_button(ui: &mut Ui, glyph: &str, tooltip: &str, enabled: b
} else {
ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, glyph, egui::FontId::proportional(t.font_label), ink);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), glyph));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), glyph));
response
})
.inner;
@@ -699,7 +699,7 @@ pub(crate) fn icon_label_button(ui: &mut Ui, label: &str, icon: &str, enabled: b
/// geometry, enabled state and optional danger ink. Tokens: icon-label action tokens.
pub(crate) fn icon_action(ui: &mut Ui, label: &str, icon: &str, enabled: bool, danger: bool) -> Response {
let response = icon_label_button(ui, "", icon, enabled, danger).backing_on_hover_text(label);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled && ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled && ui.is_enabled(), label));
response
}
@@ -737,7 +737,7 @@ pub(crate) fn selection_actions(ui: &mut Ui, name: &str, actions: &[super::Stage
let font = crate::fonts::semibold(t.font_small);
let width = ui.painter().layout_no_wrap(name.into(), font.clone(), accent.ink).size().x.min(t.form_label_width) + t.space_12;
let (rect, name_response) = ui.allocate_exact_size(vec2(width, t.control_height - t.space_2), egui::Sense::click());
- name_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), name));
+ name_response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), name));
super::text::paint_text(ui, rect.shrink2(vec2(t.space_6, 0.0)), name, font, accent.ink, false);
scenario::publish_target("selection:name", rect);
let mut clicked = name_response.clicked().then_some(actions.len());
@@ -812,7 +812,7 @@ fn icon_label_presentation(ui: &mut Ui, label: &str, icon: Option<&str>, enabled
ink,
false,
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
pointer_on_hover(ui, &response);
response
};
diff --git a/crates/ui-egui/src/ui_kit/actions_tests.rs b/crates/ui-egui/src/ui_kit/actions_tests.rs
index e3c60a8a7d..09cf54e957 100644
--- a/crates/ui-egui/src/ui_kit/actions_tests.rs
+++ b/crates/ui-egui/src/ui_kit/actions_tests.rs
@@ -166,7 +166,7 @@ fn positioned_shared_buttons_center_text_and_respect_disabled_clicks_in_both_the
[Rect::from_min_size(egui::pos2(20.0, 30.0), vec2(108.0, 32.0)), Rect::from_min_size(egui::pos2(140.0, 30.0), vec2(108.0, 32.0))];
let mut clicks = [0_usize; 2];
let mut draw = |events| {
- ctx.run_ui(
+ let mut output = ctx.run_ui(
RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(320.0, 200.0))), events, focused: true, ..Default::default() },
|ui| {
ui.add_enabled_ui(enabled, |ui| {
@@ -186,7 +186,9 @@ fn positioned_shared_buttons_center_text_and_respect_disabled_clicks_in_both_the
}
});
},
- )
+ );
+ output.textures_delta.clear();
+ output
};
let output = draw(vec![]);
for (index, label) in ["Recover", "Discard"].into_iter().enumerate() {
diff --git a/crates/ui-egui/src/ui_kit/assistant.rs b/crates/ui-egui/src/ui_kit/assistant.rs
index 4aee088c6b..da18c62b23 100644
--- a/crates/ui-egui/src/ui_kit/assistant.rs
+++ b/crates/ui-egui/src/ui_kit/assistant.rs
@@ -45,7 +45,7 @@ fn badge(ui: &mut Ui, label: &str, ink: egui::Color32, fill: egui::Color32) -> R
let (rect, response) = ui.allocate_exact_size(vec2(width, t.form_close_size - t.space_4), egui::Sense::hover());
ui.painter().rect_filled(rect, t.radius_xl, fill);
ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, label, font, ink);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), label));
response
}
@@ -339,7 +339,7 @@ pub(crate) fn assistant_send(ui: &mut Ui, enabled: bool, busy: bool, label: &str
if response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
response.backing_on_hover_text(label)
})
.inner
diff --git a/crates/ui-egui/src/ui_kit/checks.rs b/crates/ui-egui/src/ui_kit/checks.rs
index 8d93e05333..4fcb7ba56e 100644
--- a/crates/ui-egui/src/ui_kit/checks.rs
+++ b/crates/ui-egui/src/ui_kit/checks.rs
@@ -93,7 +93,7 @@ pub(crate) fn checkbox_indeterminate(ui: &mut Ui, label: &str, value: &mut bool,
}
response.widget_info(|| {
let accessible = if label.is_empty() { crate::i18n::tr_label(super::row_label(ui)) } else { label };
- let mut info = egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), *value, accessible);
+ let mut info = egui::WidgetInfo::selected(egui::Role::CheckBox, ui.is_enabled(), *value, accessible);
if mixed && !response.changed() {
info.selected = None;
}
@@ -115,6 +115,6 @@ pub(crate) fn checkbox_at(ui: &mut Ui, rect: Rect, label: &str, value: &mut bool
response.mark_changed();
}
paint_box(ui, rect, &response, *value, false);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), *value, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::CheckBox, ui.is_enabled(), *value, label));
response.backing_on_hover_text(label)
}
diff --git a/crates/ui-egui/src/ui_kit/checks_tests.rs b/crates/ui-egui/src/ui_kit/checks_tests.rs
index 2e9835b4dd..31f3151aa5 100644
--- a/crates/ui-egui/src/ui_kit/checks_tests.rs
+++ b/crates/ui-egui/src/ui_kit/checks_tests.rs
@@ -461,11 +461,11 @@ fn checkbox_accessibility_preserves_label_checked_and_mixed_metadata() {
}
}
let before = before.expect("checkbox gains keyboard focus");
- assert_eq!(before.typ, egui::WidgetType::Checkbox);
+ assert_eq!(before.role, egui::Role::CheckBox);
assert_eq!(before.label.as_deref(), Some("Enabled"));
assert_eq!(before.selected, if mixed { None } else { Some(false) });
let after = after.expect("activation publishes the changed checked state");
- assert_eq!(after.typ, egui::WidgetType::Checkbox);
+ assert_eq!(after.role, egui::Role::CheckBox);
assert_eq!(after.label.as_deref(), Some("Enabled"));
assert_eq!(after.selected, Some(true));
}
diff --git a/crates/ui-egui/src/ui_kit/choice.rs b/crates/ui-egui/src/ui_kit/choice.rs
index 04fb80bc06..721f3679c4 100644
--- a/crates/ui-egui/src/ui_kit/choice.rs
+++ b/crates/ui-egui/src/ui_kit/choice.rs
@@ -193,7 +193,7 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
false,
);
t.button_bevel_with_radius(ui, &response, on, rounding);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, segment_enabled, on, *text));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, segment_enabled, on, *text));
scenario::publish_target(&format!("dialog:{}:{option}", label(ui)), segment);
if let Some(target) = targets.get(index) {
let visible = segment.intersect(ui.clip_rect());
@@ -279,7 +279,7 @@ pub(crate) fn segmented_icons(ui: &mut Ui, selected: &mut usize, options: &[Icon
crate::icons::paint_icon(ui.painter(), icon_rect, option.icon, f32::from(t.icon.a()) / 255.0);
}
t.button_bevel_with_radius(ui, &response, on, rounding);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, option.key));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), on, option.key));
scenario::publish_handle(&format!("dialog:{}:{}", label(ui), option.key), segment.center());
scenario::publish_target(option.key, segment);
let response = response.backing_on_hover_text(&option.tip);
@@ -315,7 +315,7 @@ pub(crate) fn checkbox_grid(ui: &mut Ui, items: &mut [(&str, &mut bool)], column
let text = if translated == "Tangent Chain" { "Tangent chain" } else { translated };
let text_rect = egui::Rect::from_min_max(egui::pos2((square.right() + t.space_6).min(rect.right()), rect.top()), rect.max);
paint_text(ui, text_rect, text, egui::FontId::proportional(t.font_body), t.form_ink, false);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), **value, translated));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::CheckBox, ui.is_enabled(), **value, translated));
scenario::publish_target_as(&format!("dialog:{label}"), &format!("dialog:checkbox:{label}"), rect);
}
});
@@ -343,7 +343,7 @@ pub(crate) fn checkbox_row(ui: &mut egui::Ui, key: &str, label: &str, on: bool)
.painter()
.with_clip_rect(ui.clip_rect().intersect(egui::Rect::from_min_max(rect.min, egui::pos2(square.left() - t.space_6, rect.bottom()))));
painter.text(rect.left_center(), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(t.font_label), t.form_ink);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), on, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::CheckBox, ui.is_enabled(), on, label));
crate::scenario::publish_target(&format!("sketch_palette:toggle:{key}"), rect);
response.backing_on_hover_text(label).clicked()
}
@@ -363,7 +363,7 @@ pub(crate) fn text_emphasis(ui: &mut Ui, bold: &mut bool, italic: &mut bool, bol
if !enabled {
response = response.backing_on_disabled_hover_text(crate::i18n::tr("sketch_text.no_bold"));
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled() && enabled, *value, crate::i18n::tr(id)));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled() && enabled, *value, crate::i18n::tr(id)));
scenario::publish_target_as(&format!("dialog:{key}"), &format!("dialog:emphasis:{key}"), response.rect);
}
}
@@ -399,7 +399,7 @@ pub(crate) fn tool_choices<'a>(ui: &mut Ui, label: &str, current: &str, choices:
crate::icons::paint_icon(ui.painter(), response.rect.shrink(t.space_6), choice.icon, f32::from(t.icon.a()) / 255.0);
t.button_bevel(ui, &response, on);
scenario::publish_target(&format!("sketch_palette:feature:{}", choice.key), response.rect);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, enabled, on, choice.label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, enabled, on, choice.label));
if response.backing_on_hover_text(choice.label).clicked() && enabled {
start = Some(choice.key);
}
@@ -416,7 +416,7 @@ pub(crate) fn toggle_icon(ui: &mut Ui, row: &str, label: &str, selected: &mut bo
let response =
ui.add(egui::Button::new("").selected(*selected).min_size(vec2(t.space_24 + t.space_4, t.control_height)).sense(egui::Sense::CLICK));
crate::icons::paint_icon(ui.painter(), response.rect.shrink(t.space_3), icon, f32::from(t.icon.a()) / 255.0);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, true, *selected, crate::i18n::tr_label(label)));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, true, *selected, crate::i18n::tr_label(label)));
t.button_bevel(ui, &response, *selected);
crate::scenario::publish_handle(&format!("dialog:{row}:{label}"), response.rect.center());
if response.clone().backing_on_hover_text(crate::i18n::tr_label(label)).clicked() {
@@ -474,7 +474,7 @@ pub(crate) fn choice_chip(ui: &mut Ui, key: &str, text: &str, selected: bool) ->
if selected { accent.ink } else { t.form_ink },
false,
);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), selected, text));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), selected, text));
crate::scenario::publish_target(&format!("dialog:list:{key}"), rect);
return response;
}
@@ -575,7 +575,7 @@ pub(crate) fn thumbnail_choice(ui: &mut Ui, key: &str, text: &str, state: Thumbn
ui.painter().add(egui::Shape::line(points, egui::Stroke::new(t.space_2, accent.ink)));
crate::scenario::publish_rect(&format!("dialog:list:{key}:progress"), thumb);
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, ui.is_enabled(), state.selected, text));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), state.selected, text));
crate::scenario::publish_target(&format!("dialog:list:{key}"), response.rect);
response.backing_on_hover_text(text)
}
@@ -595,7 +595,7 @@ pub(crate) fn add_choice(ui: &mut Ui, label: &str) -> egui::Response {
}
ui.painter().add(egui::Shape::dashed_line(&outline, egui::Stroke::new(1.0, t.control_border), t.space_3, t.space_3));
ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, "+", egui::FontId::proportional(t.font_subtitle), t.form_dim);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
response.backing_on_hover_text(label)
}
@@ -741,7 +741,7 @@ pub(crate) fn popup_list(
);
super::text::paint_text(ui, text_rect, option.text, mono.clone(), if picked { t.form_primary } else { option.color }, false);
ui.painter().text(inner.right_center(), egui::Align2::RIGHT_CENTER, kind, kind_font.clone(), t.form_dim);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, ui.is_enabled(), picked, option.text));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), picked, option.text));
// Tip the full name first: long identifiers still clip inside a capped popup.
let tip = if option.detail.is_empty() { option.text.to_owned() } else { format!("{}\n{}", option.text, option.detail) };
let response = response.backing_on_hover_text(tip);
diff --git a/crates/ui-egui/src/ui_kit/choice_tests.rs b/crates/ui-egui/src/ui_kit/choice_tests.rs
index 16e7c48a4f..a4870718b8 100644
--- a/crates/ui-egui/src/ui_kit/choice_tests.rs
+++ b/crates/ui-egui/src/ui_kit/choice_tests.rs
@@ -241,7 +241,7 @@ fn stage_chips_reserve_the_selected_weight_for_complete_labels_in_all_five_catal
StageBar::row(ui, bounds, false, |ui| StageBar::header(ui, selected, &labels.iter().map(String::as_str).collect::<Vec<_>>(), &[]));
});
output.textures_delta.clear();
- let search = ctx.data(|d| d.get_temp::<egui::Rect>(egui::Id::new("sc_ribbon_search"))).unwrap();
+ let search = ctx.data(|d| d.get_temp::<egui::Rect>(egui::Id::unique("sc_ribbon_search"))).unwrap();
assert!((search.right() - (bounds.right() - crate::theme::Tokens::get().space_6)).abs() < 1.0);
for label in &labels {
assert!(
diff --git a/crates/ui-egui/src/ui_kit/color.rs b/crates/ui-egui/src/ui_kit/color.rs
index 9b6155ce10..650a191070 100644
--- a/crates/ui-egui/src/ui_kit/color.rs
+++ b/crates/ui-egui/src/ui_kit/color.rs
@@ -74,7 +74,7 @@ fn color_field_inner(ui: &mut Ui, rgb: &mut [u8; 3], opacity: Option<&mut f64>,
t.control_border_stroke(t.control_border),
egui::StrokeKind::Inside,
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ColorButton, ui.is_enabled(), i18n::tr("color.edit")));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::ColorWell, ui.is_enabled(), i18n::tr("color.edit")));
publish(&format!("dialog:color:{}", label(ui)), &response);
let mut edited = false;
let popup = Container::new(ui.ctx(), Surface::Popup)
@@ -112,7 +112,7 @@ pub(crate) fn color_popover(ui: &mut Ui, rgb: &mut [u8; 3]) -> bool {
fn color_popover_with_opacity(ui: &mut Ui, rgb: &mut [u8; 3], mut opacity: Option<&mut f64>, mixed: bool) -> bool {
let t = Tokens::get();
ui.style_mut().drag_value_text_style = egui::TextStyle::Monospace;
- let id = ui.id().with("color_hsv");
+ let id = ui.scope_id().with("color_hsv");
let color = crate::theme::srgb(rgb.map(|c| f32::from(c) / 255.0));
// Retain hue for black/grey, and sub-byte precision while dragging.
let (saved, hsv) = ui.ctx().data(|d| d.get_temp::<([u8; 3], HsvaGamma)>(id)).unwrap_or((*rgb, color.into()));
@@ -120,10 +120,10 @@ fn color_popover_with_opacity(ui: &mut Ui, rgb: &mut [u8; 3], mut opacity: Optio
let before = hsv;
let before_rgb = *rgb;
let before_opacity = opacity.as_deref().copied();
- let hex_id = ui.id().with("color_hex");
+ let hex_id = ui.scope_id().with("color_hex");
let mut hex = ui.ctx().data(|d| d.get_temp::<HexEdit>(hex_id)).unwrap_or_else(|| HexEdit::new(*rgb, before_opacity));
hex.sync(*rgb, before_opacity);
- let format_id = egui::Id::new("color_hex_format");
+ let format_id = egui::Id::unique("color_hex_format");
let mut hexadecimal = ui.ctx().data(|d| d.get_temp::<bool>(format_id)).unwrap_or(false);
let mut linear = ui.global_style().visuals.numeric_color_space == egui::style::NumericColorSpace::Linear;
let mut accepted_mixed = false;
@@ -143,7 +143,7 @@ fn color_popover_with_opacity(ui: &mut Ui, rgb: &mut [u8; 3], mut opacity: Optio
for (index, (key, name)) in [("color.gamma", "U8"), ("color.linear", "F"), ("color.hex_help", "Hex")].iter().enumerate() {
let rect =
egui::Rect::from_min_size(rect.min + vec2(index as f32 * rect.width() / 3.0, 0.0), vec2(rect.width() / 3.0, rect.height()));
- ui.interact(rect, ui.id().with(("format_tip", index)), Sense::hover()).backing_on_hover_text(i18n::tr(key));
+ ui.interact(rect, ui.scope_id().with(("format_tip", index)), Sense::hover()).backing_on_hover_text(i18n::tr(key));
scenario::publish_handle(&format!("color:format:{name}"), rect.center());
}
});
@@ -257,7 +257,7 @@ fn color_popover_with_opacity(ui: &mut Ui, rgb: &mut [u8; 3], mut opacity: Optio
}
gradient(ui, square, |x, y| Color32::from(HsvaGamma { h: hsv.h, s: x, v: 1.0 - y, a: 1.0 }));
marker(ui, pos2(square.left() + hsv.s * square.width(), square.bottom() - hsv.v * square.height()), t.space_6);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), i18n::tr("color.saturation_value")));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Unknown, ui.is_enabled(), i18n::tr("color.saturation_value")));
publish("color:sv", &response);
response.backing_on_hover_text(i18n::tr("color.saturation_value"));
let (hue, response) = ui.allocate_exact_size(vec2(width, t.space_14), Sense::click_and_drag());
@@ -442,12 +442,12 @@ fn spin_buttons(ui: &mut Ui, key: &str, height: f32) -> i32 {
let (top, bottom) = rect.split_top_bottom_at_fraction(0.5);
let mut steps = 0;
for (direction, half, label, end) in [(1, top, "color.step_up", "up"), (-1, bottom, "color.step_down", "down")] {
- let id = ui.id().with(("color_spin", key, end));
+ let id = ui.scope_id().with(("color_spin", key, end));
// Sensing drags too keeps a long press down on the button: a press that senses clicks
// only stops counting once it outlasts egui's longest click (0.8 s), and the repeat with
// it, after 8 steps (#10201).
let response = ui.interact(half, id, Sense::click_and_drag());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), i18n::tr(label)));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), i18n::tr(label)));
publish(&format!("color:spin:{key}:{end}"), &response);
let held = response.is_pointer_button_down_on();
if response.hovered() || held {
@@ -517,11 +517,11 @@ fn recent_row(ui: &mut Ui, width: f32) -> Option<[u8; 3]> {
ui.painter().rect_stroke(rect, t.control_radius, t.control_border_stroke(t.border), egui::StrokeKind::Inside);
continue;
};
- let response = ui.interact(rect, ui.id().with(("color_recent", slot)), Sense::click());
+ let response = ui.interact(rect, ui.scope_id().with(("color_recent", slot)), Sense::click());
let stroke = if response.hovered() { t.control_border_stroke(t.form_ink) } else { t.control_border_stroke(t.control_border) };
ui.painter().rect(rect, t.control_radius, crate::theme::srgb([r, g, b].map(|c| f32::from(c) / 255.0)), stroke, egui::StrokeKind::Inside);
let hex = format!("#{r:02x}{g:02x}{b:02x}");
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &hex));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &hex));
publish(&format!("color:recent:{slot}"), &response);
let response = response.on_hover_cursor(egui::CursorIcon::PointingHand).backing_on_hover_text(&hex);
if response.clicked() {
diff --git a/crates/ui-egui/src/ui_kit/compare.rs b/crates/ui-egui/src/ui_kit/compare.rs
index e28c3d98f1..17ca812c82 100644
--- a/crates/ui-egui/src/ui_kit/compare.rs
+++ b/crates/ui-egui/src/ui_kit/compare.rs
@@ -12,7 +12,7 @@ pub(crate) fn comparison_divider(ui: &mut Ui, canvas: Rect, position: &mut f32,
*position = comparison_position(*position);
let x = canvas.left() + canvas.width() * *position;
let rail = Rect::from_center_size(pos2(x, canvas.center().y), vec2(t.space_16, canvas.height()));
- let mut response = ui.interact(rail, ui.id().with("comparison_divider"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
+ let mut response = ui.interact(rail, ui.scope_id().with("comparison_divider"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
if response.dragged()
&& let Some(pointer) = response.interact_pointer_pos()
{
@@ -20,7 +20,7 @@ pub(crate) fn comparison_divider(ui: &mut Ui, canvas: Rect, position: &mut f32,
response.mark_changed();
}
comparison_divider_chrome(ui, canvas, *position);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Slider, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Slider, ui.is_enabled(), label));
scenario::publish_target("render:compare:divider", rail);
response
}
diff --git a/crates/ui-egui/src/ui_kit/confirm.rs b/crates/ui-egui/src/ui_kit/confirm.rs
index c28e235c8b..f99c279a4e 100644
--- a/crates/ui-egui/src/ui_kit/confirm.rs
+++ b/crates/ui-egui/src/ui_kit/confirm.rs
@@ -114,8 +114,8 @@ impl<'a> Confirm<'a> {
);
let title = egui::Rect::from_min_max(heading.min, egui::pos2(close.left(), heading.bottom()));
paint_text(ui, title, self.title, crate::fonts::semibold(t.font_subtitle), t.form_ink, false);
- ui.interact(title, ui.id().with("title"), egui::Sense::hover())
- .widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), self.title));
+ ui.interact(title, ui.scope_id().with("title"), egui::Sense::hover())
+ .widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), self.title));
let response = super::icon_button_at(ui, close, "close", "Close");
closed = response.clicked();
scenario::publish_target("dialog:close", response.rect);
diff --git a/crates/ui-egui/src/ui_kit/container.rs b/crates/ui-egui/src/ui_kit/container.rs
index 47eb8b4f1b..b34d7eb730 100644
--- a/crates/ui-egui/src/ui_kit/container.rs
+++ b/crates/ui-egui/src/ui_kit/container.rs
@@ -734,12 +734,13 @@ impl Container {
egui::Area::new(id).enabled(self.input_enabled()).order(order)
}
- pub fn edge(self, id: impl Into<Id>, edge: Edge) -> egui::Panel {
+ /// A panel on `edge`, keyed by `salt` within the Ui it is shown in.
+ pub fn edge(self, salt: impl egui::AsIdSalt, edge: Edge) -> egui::Panel {
let panel = match edge {
- Edge::Left => egui::Panel::left(id),
- Edge::Right => egui::Panel::right(id),
- Edge::Top => egui::Panel::top(id),
- Edge::Bottom => egui::Panel::bottom(id),
+ Edge::Left => egui::Panel::left(salt),
+ Edge::Right => egui::Panel::right(salt),
+ Edge::Top => egui::Panel::top(salt),
+ Edge::Bottom => egui::Panel::bottom(salt),
};
if self.adaptive() && !self.floating() { panel.show_separator_line(false) } else { panel }
}
diff --git a/crates/ui-egui/src/ui_kit/details.rs b/crates/ui-egui/src/ui_kit/details.rs
index 4ee6cbfee6..3e80d49c69 100644
--- a/crates/ui-egui/src/ui_kit/details.rs
+++ b/crates/ui-egui/src/ui_kit/details.rs
@@ -7,7 +7,7 @@ const FIELD_FOCUS: &str = "details_field_focus";
const CONTROL_FOCUS: &str = "details_control_focus";
const OWNED_POPUPS: &str = "details_owned_popups";
pub(crate) fn dismiss_details_popups(ctx: &egui::Context) {
- let popups = ctx.data(|data| data.get_temp::<Vec<egui::Id>>(egui::Id::new(OWNED_POPUPS))).unwrap_or_default();
+ let popups = ctx.data(|data| data.get_temp::<Vec<egui::Id>>(egui::Id::unique(OWNED_POPUPS))).unwrap_or_default();
for popup in popups {
egui::Popup::close_id(ctx, popup);
}
@@ -17,18 +17,18 @@ fn remember_control(ui: &Ui, id: egui::Id) {
return;
}
ui.ctx().data_mut(|data| {
- let key = egui::Id::new(CONTROL_FOCUS);
+ let key = egui::Id::unique(CONTROL_FOCUS);
let mut ids = data.get_temp::<Vec<egui::Id>>(key).unwrap_or_default();
ids.push(id);
data.insert_temp(key, ids);
});
}
pub(crate) fn details_control_owns_focus(ctx: &egui::Context) -> bool {
- let ids = ctx.data(|data| data.get_temp::<Vec<egui::Id>>(egui::Id::new(CONTROL_FOCUS))).unwrap_or_default();
+ let ids = ctx.data(|data| data.get_temp::<Vec<egui::Id>>(egui::Id::unique(CONTROL_FOCUS))).unwrap_or_default();
ctx.memory(|memory| memory.focused().is_some_and(|id| ids.contains(&id)))
}
pub(crate) fn details_field_owns_focus(ctx: &egui::Context) -> bool {
- let fields = ctx.data(|data| data.get_temp::<Vec<(egui::Id, egui::Rect)>>(egui::Id::new(FIELD_FOCUS))).unwrap_or_default();
+ let fields = ctx.data(|data| data.get_temp::<Vec<(egui::Id, egui::Rect)>>(egui::Id::unique(FIELD_FOCUS))).unwrap_or_default();
let focused = ctx.memory(|memory| memory.focused());
focused.is_some_and(|id| {
fields.iter().any(|(field, rect)| *field == id || ctx.read_response(id).is_some_and(|response| rect.contains(response.rect.center())))
@@ -38,7 +38,7 @@ pub(crate) fn details_field_owned_escape(ctx: &egui::Context) -> bool {
if details_field_owns_focus(ctx) {
return true;
}
- let fields = ctx.data(|data| data.get_temp::<Vec<(egui::Id, egui::Rect)>>(egui::Id::new(FIELD_FOCUS))).unwrap_or_default();
+ let fields = ctx.data(|data| data.get_temp::<Vec<(egui::Id, egui::Rect)>>(egui::Id::unique(FIELD_FOCUS))).unwrap_or_default();
// egui blurs native value editors before global shortcuts see Escape. The
// preceding visible frame still owns that press, just as a text editor does.
ctx.memory(|memory| memory.focused().is_none() && fields.iter().any(|(id, _)| memory.had_focus_last_frame(*id)))
@@ -190,7 +190,7 @@ fn setting(ui: &mut Ui, field: &DetailSetting, focus: bool) -> Option<DetailEven
}
});
ui.ctx().data_mut(|data| {
- let key = egui::Id::new(OWNED_POPUPS);
+ let key = egui::Id::unique(OWNED_POPUPS);
let mut popups = data.get_temp::<Vec<egui::Id>>(key).unwrap_or_default();
// ComboBox's native popup is keyed by the returned button response.
popups.push(response.id.with("popup"));
@@ -217,7 +217,7 @@ fn setting(ui: &mut Ui, field: &DetailSetting, focus: bool) -> Option<DetailEven
*id == response.id || ui.ctx().read_response(*id).is_some_and(|native| response.rect.contains(native.rect.center()))
});
ui.ctx().data_mut(|data| {
- let key = egui::Id::new(FIELD_FOCUS);
+ let key = egui::Id::unique(FIELD_FOCUS);
let mut fields = data.get_temp::<Vec<(egui::Id, egui::Rect)>>(key).unwrap_or_default();
if visible {
fields.push((response.id, response.rect));
@@ -245,9 +245,9 @@ fn setting(ui: &mut Ui, field: &DetailSetting, focus: bool) -> Option<DetailEven
pub(crate) fn details(ui: &mut Ui, id: &str, description: &Details, max_height: f32, focus: Option<&str>) -> Vec<DetailEvent> {
let t = Tokens::get();
let mut events = Vec::new();
- ui.ctx().data_mut(|data| data.insert_temp(egui::Id::new(FIELD_FOCUS), Vec::<(egui::Id, egui::Rect)>::new()));
- ui.ctx().data_mut(|data| data.insert_temp(egui::Id::new(CONTROL_FOCUS), Vec::<egui::Id>::new()));
- ui.ctx().data_mut(|data| data.insert_temp(egui::Id::new(OWNED_POPUPS), Vec::<egui::Id>::new()));
+ ui.ctx().data_mut(|data| data.insert_temp(egui::Id::unique(FIELD_FOCUS), Vec::<(egui::Id, egui::Rect)>::new()));
+ ui.ctx().data_mut(|data| data.insert_temp(egui::Id::unique(CONTROL_FOCUS), Vec::<egui::Id>::new()));
+ ui.ctx().data_mut(|data| data.insert_temp(egui::Id::unique(OWNED_POPUPS), Vec::<egui::Id>::new()));
ui.set_width((t.form_card_width + if description.findings.is_empty() { 0.0 } else { t.space_24 * 2.0 }).min(ui.available_width()));
// A card's area is as tall as it was last frame: allowed `max_height`, a body that grew
// after the first frame scrolls instead, and its last row was cut off (#10708).
diff --git a/crates/ui-egui/src/ui_kit/disclosure.rs b/crates/ui-egui/src/ui_kit/disclosure.rs
index 8330d69e4b..774e0e7ea8 100644
--- a/crates/ui-egui/src/ui_kit/disclosure.rs
+++ b/crates/ui-egui/src/ui_kit/disclosure.rs
@@ -36,7 +36,9 @@ fn disclosure_button_with_hover(ui: &mut Ui, rect: Rect, open: bool, label: &str
}
}
disclosure(ui.painter(), rect.center(), open, if response.hovered() || response.has_focus() { t.form_ink } else { t.form_dim });
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::CollapsingHeader, ui.is_enabled(), open, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::DisclosureTriangle, ui.is_enabled(), open, label));
+ // A disclosure says whether it is open as expanded, as egui's own collapsing header does.
+ ui.ctx().accesskit_node_builder(response.id, |node| node.set_expanded(open));
response.on_hover_cursor(egui::CursorIcon::PointingHand).backing_on_hover_text(label)
}
@@ -64,7 +66,7 @@ pub(crate) fn strip_toggle(ui: &mut Ui, expanded: bool, label: &str) -> Response
if let Some(title) = title {
ui.painter().galley(pos2(rect.left() + t.control_height + t.space_6, rect.center().y - title.size().y / 2.0), title, t.form_ink);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
response.on_hover_cursor(egui::CursorIcon::PointingHand).backing_on_hover_text(label)
}
diff --git a/crates/ui-egui/src/ui_kit/disclosure_tests.rs b/crates/ui-egui/src/ui_kit/disclosure_tests.rs
index d67d6fd01c..453d046dfb 100644
--- a/crates/ui-egui/src/ui_kit/disclosure_tests.rs
+++ b/crates/ui-egui/src/ui_kit/disclosure_tests.rs
@@ -64,7 +64,7 @@ fn section_card_and_floating_window_folds_render_down_when_open_right_when_close
} else {
Panel::new(
"Fillet",
- egui::Id::new("window"),
+ egui::Id::unique("window"),
egui::pos2(20.0, 20.0),
viewport,
crate::frame::Side::Left,
diff --git a/crates/ui-egui/src/ui_kit/fields.rs b/crates/ui-egui/src/ui_kit/fields.rs
index c6cd6b837c..6da9a4e4a5 100644
--- a/crates/ui-egui/src/ui_kit/fields.rs
+++ b/crates/ui-egui/src/ui_kit/fields.rs
@@ -13,7 +13,7 @@ use egui::{Response, RichText, Ui, vec2};
/// approximating font metrics with integer margins (Plex Mono and Sans differ).
pub(super) fn text_input(edit: egui::TextEdit<'_>) -> egui::TextEdit<'_> {
let t = Tokens::get();
- edit.vertical_align(egui::Align::Center).margin(vec2(t.form_inset, 0.0)).min_size(vec2(0.0, t.control_height))
+ edit.align(egui::Align2::LEFT_CENTER).margin(vec2(t.form_inset, 0.0)).min_size(vec2(0.0, t.control_height))
}
/// Expression editor with the application's existing completion and number-focus behaviour.
@@ -64,7 +64,7 @@ pub(crate) fn count_field(ui: &mut Ui, value: &mut String, limits: &Count<'_>) -
let row = label(ui).to_owned();
for (delta, half, name) in [(1, column.split_top_bottom_at_fraction(0.5).0, "up"), (-1, column.split_top_bottom_at_fraction(0.5).1, "down")] {
let next = step_count(value, delta, limits);
- let arrow = ui.interact(half, ui.id().with(("sc_count_step", &row, name)), egui::Sense::click());
+ let arrow = ui.interact(half, ui.scope_id().with(("sc_count_step", &row, name)), egui::Sense::click());
let enabled = ui.is_enabled() && next.is_some();
// The arrows stand inside the editor, which claims the text cursor across its whole
// rect: they are not text, so each one takes the ordinary cursor back after it. The
@@ -85,7 +85,7 @@ pub(crate) fn count_field(ui: &mut Ui, value: &mut String, limits: &Count<'_>) -
egui::Stroke::NONE,
));
let sign = if delta > 0 { "+1" } else { "−1" };
- arrow.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, format!("{} {sign}", crate::i18n::tr_label(&row))));
+ arrow.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, format!("{} {sign}", crate::i18n::tr_label(&row))));
scenario::publish_handle(&format!("dialog:{row} {name}"), half.center());
if let (true, true, Some(next)) = (enabled, arrow.clicked(), next) {
*value = next;
@@ -285,7 +285,7 @@ pub(crate) fn multiline_text_field(ui: &mut Ui, label: &str, id: egui::Id, value
.background_color(t.input_fill()),
);
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINES);
- publish(ui, &response, egui::WidgetType::TextEdit);
+ publish(ui, &response, egui::Role::TextInput);
response
})
}
@@ -387,7 +387,7 @@ fn searchable_dropdown_with(
if popup.inner.is_some() && ui.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) {
response.request_focus();
}
- publish(ui, &response, egui::WidgetType::ComboBox);
+ publish(ui, &response, egui::Role::ComboBox);
chosen
}
@@ -454,7 +454,7 @@ pub(crate) fn search_picker(ui: &mut Ui, p: SearchPicker<'_>) -> egui::InnerResp
{
return egui::InnerResponse::new(None, crate::prefs_search::hidden_response(ui));
}
- let state = egui::Id::new(p.id);
+ let state = egui::Id::unique(p.id);
let mut picked = None;
let response = ui
.add_enabled_ui(p.enabled, |ui| {
@@ -480,7 +480,7 @@ pub(crate) fn search_picker(ui: &mut Ui, p: SearchPicker<'_>) -> egui::InnerResp
response
})
.inner;
- publish(ui, &response, egui::WidgetType::ComboBox);
+ publish(ui, &response, egui::Role::ComboBox);
scenario::publish_target(p.handles, response.rect);
egui::InnerResponse::new(picked, response)
}
@@ -804,7 +804,7 @@ fn editor_reserving(ui: &mut Ui, value: &mut String, hint: &str, completion: boo
}
let mut response = ui.add_sized(vec2(width, row_height()), edit);
if response.has_focus() {
- ui.ctx().data_mut(|data| data.insert_temp(egui::Id::new("sc_focused_editor"), response.id));
+ ui.ctx().data_mut(|data| data.insert_temp(egui::Id::unique("sc_focused_editor"), response.id));
}
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE);
if response.has_focus() {
@@ -812,7 +812,7 @@ fn editor_reserving(ui: &mut Ui, value: &mut String, hint: &str, completion: boo
}
if completion && ui.is_enabled() {
ui.ctx().data_mut(|data| {
- let id = egui::Id::new("sc_value_fields");
+ let id = egui::Id::unique("sc_value_fields");
if data.get_temp::<Vec<(egui::Id, usize)>>(id).is_some() {
data.get_temp_mut_or_default::<Vec<(egui::Id, usize)>>(id).push((response.id, value.chars().count()));
}
@@ -822,7 +822,7 @@ fn editor_reserving(ui: &mut Ui, value: &mut String, hint: &str, completion: boo
t.input_bevel(ui, &response);
let label = crate::i18n::tr_label(label(ui));
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), label);
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), label);
info.current_text_value = Some(value.clone());
info
});
@@ -985,7 +985,7 @@ fn dropdown_menu_width(
if let Some(icon) = leading_icon {
paint_dropdown_icon(ui, response.rect, icon);
}
- publish(ui, &response, egui::WidgetType::ComboBox);
+ publish(ui, &response, egui::Role::ComboBox);
response
}
@@ -1043,7 +1043,7 @@ pub(crate) fn selection_field(ui: &mut Ui, text: &str, options: Selection) -> Re
},
false,
);
- publish(ui, &response, egui::WidgetType::Button);
+ publish(ui, &response, egui::Role::Button);
scenario::publish_rect(&format!("dialog:field:{}", label(ui)), rect);
scenario::publish_count(&format!("dialog:selection:{}:filled", label(ui)), f64::from(filled));
scenario::publish_count(&format!("dialog:selection:{}:active", label(ui)), f64::from(active));
@@ -1142,12 +1142,12 @@ fn cell_editor_frame(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &str,
let mut response = ui.add_sized(vec2(dimension(ui.available_width()), row_height()), editor);
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE.limited(limit));
if frame {
- publish(ui, &response, egui::WidgetType::TextEdit);
+ publish(ui, &response, egui::Role::TextInput);
} else {
super::layout::publish_geometry(ui, &response);
}
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), crate::i18n::tr_label(label(ui)));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), crate::i18n::tr_label(label(ui)));
info.current_text_value = Some(value.clone());
info
});
@@ -1217,7 +1217,7 @@ pub fn wide_cell_editor(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &st
response.surrender_focus();
}
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE);
- publish(ui, &response, egui::WidgetType::TextEdit);
+ publish(ui, &response, egui::Role::TextInput);
crate::theme::TabAccent::number_focus(ui, &response);
t.input_bevel(ui, &response);
let (text, error) = note;
@@ -1235,7 +1235,7 @@ pub fn wide_cell_editor(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &st
});
let response = shown.inner;
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, enabled, crate::i18n::tr_label(hint));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, enabled, crate::i18n::tr_label(hint));
info.current_text_value = Some(value.clone());
info
});
@@ -1264,7 +1264,7 @@ pub(crate) fn search_field(ui: &mut Ui, id: egui::Id, value: &mut String, hint:
crate::icons::paint_ink(ui.painter(), icon, "zoom", t.form_dim);
super::layout::publish_geometry(ui, &response);
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), hint);
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), hint);
info.current_text_value = Some(value.clone());
info
});
@@ -1314,7 +1314,7 @@ pub(crate) fn menu_filter(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &
})
.inner;
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), hint_text);
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), hint_text);
info.current_text_value = Some(value.clone());
info
});
@@ -1470,7 +1470,7 @@ pub(crate) fn slider<T: egui::emath::Numeric>(ui: &mut Ui, value: &mut T, range:
t.control_fill
};
ui.painter().circle(center, t.space_8, fill, egui::Stroke::new(t.space_2, if off { t.form_dim } else { primary }));
- publish(ui, &response, egui::WidgetType::Slider);
+ publish(ui, &response, egui::Role::Slider);
response.widget_info(|| egui::WidgetInfo::slider(ui.is_enabled(), value.to_f64(), crate::i18n::tr_label(label(ui))));
scenario::publish_rect(&format!("dialog:slider_track:{}", label(ui)), slider);
scenario::publish_target(&format!("dialog:slider:{}", label(ui)), response.rect);
@@ -1604,7 +1604,7 @@ pub(crate) fn text_area(ui: &mut Ui, label: &str, id: egui::Id, value: &mut Stri
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINES.limited(limit));
t.input_bevel(ui, &response);
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), label);
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), label);
info.current_text_value = Some(value.clone());
info
});
@@ -1625,7 +1625,7 @@ pub(crate) fn password_field(ui: &mut Ui, id: egui::Id, value: &mut String, hint
.background_color(t.input_fill()),
);
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field { secret: true, ..super::text_menu::Field::LINE });
- publish(ui, &response, egui::WidgetType::TextEdit);
+ publish(ui, &response, egui::Role::TextInput);
response
}
@@ -1776,7 +1776,7 @@ pub(crate) fn canvas_value_field(ui: &mut Ui, id: egui::Id, value: &mut String,
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE);
t.input_bevel(ui, &response);
let field = (ui.ctx().cumulative_pass_nr(), response.id, value.chars().count());
- ui.ctx().data_mut(|data| data.insert_temp(egui::Id::new("sc_canvas_value_focus"), field));
+ ui.ctx().data_mut(|data| data.insert_temp(egui::Id::unique("sc_canvas_value_focus"), field));
response
}
@@ -1794,6 +1794,8 @@ pub(crate) fn placement_field(ui: &mut Ui, id: egui::Id, value: &mut String, hin
let t = Tokens::get();
let font = egui::FontId::proportional(t.font_body);
let size = placement_field_content_size(ui, value);
+ // egui 0.37 floors a text edit's height at the theme's interact height: lower it for this one.
+ let interact = std::mem::replace(&mut ui.spacing_mut().interact_size.y, size.y);
let mut response = ui.add(
text_input(egui::TextEdit::singleline(value))
.id(id)
@@ -1806,10 +1808,11 @@ pub(crate) fn placement_field(ui: &mut Ui, id: egui::Id, value: &mut String, hin
.text_color(t.form_ink)
.clip_text(true),
);
+ ui.spacing_mut().interact_size.y = interact;
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE);
- publish(ui, &response, egui::WidgetType::TextEdit);
+ publish(ui, &response, egui::Role::TextInput);
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), crate::i18n::tr_label(hint));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), crate::i18n::tr_label(hint));
info.current_text_value = Some(value.clone());
info
});
@@ -1849,10 +1852,8 @@ pub(crate) fn library_cell(ui: &mut Ui, id: egui::Id, value: &mut String, hint:
/// Inline tree-name editor in caller-owned geometry; preserves its native focus and selection ID.
/// Tokens: text. The caller retains commit/cancel and select-all behavior.
pub(crate) fn inline_name(ui: &mut Ui, rect: egui::Rect, id: egui::Id, value: &mut String) -> Response {
- let mut response = ui.put(
- rect,
- egui::TextEdit::singleline(value).id(id).frame(egui::Frame::NONE).text_color(Tokens::get().text).vertical_align(egui::Align::Center),
- );
+ let mut response = ui
+ .put(rect, egui::TextEdit::singleline(value).id(id).frame(egui::Frame::NONE).text_color(Tokens::get().text).align(egui::Align2::LEFT_CENTER));
super::text_menu::menu(ui, &mut response, value, super::text_menu::Field::LINE);
response
}
diff --git a/crates/ui-egui/src/ui_kit/fields_tests.rs b/crates/ui-egui/src/ui_kit/fields_tests.rs
index 6b87ca4fc6..4bf1169810 100644
--- a/crates/ui-egui/src/ui_kit/fields_tests.rs
+++ b/crates/ui-egui/src/ui_kit/fields_tests.rs
@@ -21,7 +21,7 @@ fn combo_backing_zero_preserves_stock_shapes_and_semantics() {
let combo = egui::ComboBox::from_id_salt("stock combo").selected_text("One");
let mut body = |ui: &mut Ui| {
let response = ui.button("Two");
- semantics = format!("{:?}", (ui.id(), ui.max_rect(), ui.clip_rect(), response.id, response.rect));
+ semantics = format!("{:?}", (ui.scope_id(), ui.max_rect(), ui.clip_rect(), response.id, response.rect));
};
let response = if stock { combo.show_ui(ui, &mut body) } else { container::show_combo(ui, widget, combo, &mut body) };
id = response.response.id;
@@ -47,7 +47,7 @@ fn every_text_input_centres_its_galley_for_mono_and_proportional_fonts() {
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
ui.set_width(280.0);
scope(ui, |ui| {
- let id = ui.id().with(case);
+ let id = ui.scope_id().with(case);
rect = match case {
"expression" | "plain" => super::editor(ui, &mut value, "", case == "expression").2.rect,
"search" => search_field(ui, id, &mut value, "Search").rect,
@@ -113,7 +113,7 @@ fn tab_visits_expression_fields_in_row_order() {
#[test]
fn multiline_text_retains_focus_id_and_three_line_geometry() {
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("multiline_test");
+ let id = egui::Id::unique("multiline_test");
let mut value = "First\nSecond".to_string();
let mut draw = |ui: &mut Ui| {
multiline_text_field(ui, "Text", id, &mut value);
@@ -214,7 +214,7 @@ fn search_picker_filters_focuses_picks_and_takes_custom_values() {
// Opening focuses the box: what is typed filters over labels, tips and values.
open();
assert!(is_open());
- assert!(ctx.memory(|m| m.has_focus(egui::Id::new("search_picker_test").with("search"))), "the box has the focus");
+ assert!(ctx.memory(|m| m.has_focus(egui::Id::unique("search_picker_test").with("search"))), "the box has the focus");
for row in ["a/one", "b/two", "b/three"] {
assert!(scenario::handle_at(&format!("test:model:{row}")).is_some(), "{row}");
}
@@ -305,7 +305,7 @@ fn search_picker_keeps_every_row_reachable_as_its_contents_change() {
scenario::clear_handles();
let raw =
egui::RawInput { events, screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(900.0, 700.0))), ..Default::default() };
- let _ = ctx.run_ui(raw, |ui| {
+ ctx.run_ui(raw, |ui| {
ui.allocate_ui(egui::vec2(160.0, 40.0), |ui| {
crate::ui_kit::scope(ui, |ui| {
let values = values.borrow();
@@ -331,7 +331,9 @@ fn search_picker_keeps_every_row_reachable_as_its_contents_change() {
}
});
});
- });
+ })
+ .textures_delta
+ .clear();
};
let pointer = |at: egui::Pos2, pressed: bool| {
vec![
@@ -572,7 +574,7 @@ fn dropdown_popups_own_escape_and_return_focus_without_canceling_the_window() {
let mut draw = |ui: &mut Ui| {
let ctx = ui.ctx().clone();
action.set(
- Window::new(egui::Id::new(("dropdown_escape", kind)), "settings", "Preferences")
+ Window::new(egui::Id::unique(("dropdown_escape", kind)), "settings", "Preferences")
.cards(1.0)
.fields()
.actions("OK", "Cancel", None)
@@ -651,7 +653,7 @@ fn dropdown_popups_own_escape_and_return_focus_without_canceling_the_window() {
#[test]
fn secret_field_retains_focus_and_masks_paint_and_accessibility_events() {
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("secret_test");
+ let id = egui::Id::unique("secret_test");
let mut secret = String::new();
let mut draw = |ui: &mut Ui| {
row(ui, "API key", |ui| {
@@ -673,7 +675,7 @@ fn secret_field_retains_focus_and_masks_paint_and_accessibility_events() {
#[test]
fn growing_message_field_retains_its_id_and_does_not_consume_enter() {
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("message_test");
+ let id = egui::Id::unique("message_test");
let mut message = String::new();
let mut enter = false;
let mut draw = |ui: &mut Ui| {
@@ -699,9 +701,9 @@ fn canvas_value_fields_grow_with_an_expression_up_to_three_times_their_width() {
let mut value = value.to_owned();
let mut rect = egui::Rect::NOTHING;
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
- egui::Area::new(egui::Id::new("grow")).fixed_pos(egui::pos2(10.0, 10.0)).show(ui.ctx(), |ui| {
+ egui::Area::new(egui::Id::unique("grow")).fixed_pos(egui::pos2(10.0, 10.0)).show(ui.ctx(), |ui| {
ui.horizontal(|ui| {
- let id = ui.id().with(case);
+ let id = ui.scope_id().with(case);
rect = match case {
"canvas" => canvas_value_field(ui, id, &mut value, false).rect,
_ => placement_field(ui, id, &mut value, "").rect,
@@ -725,7 +727,7 @@ fn canvas_value_fields_grow_with_an_expression_up_to_three_times_their_width() {
#[test]
fn placement_field_keeps_focus_for_owner_validation_on_enter() {
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("placement_enter");
+ let id = egui::Id::unique("placement_enter");
let mut value = String::from("invalid expression");
let mut draw = |ui: &mut Ui| {
row(ui, "Distance", |ui| {
@@ -769,7 +771,7 @@ fn an_angle_kept_in_radians_takes_a_typed_decimal_point() {
#[test]
fn bounded_name_editor_keeps_unicode_character_cap() {
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("bounded_name");
+ let id = egui::Id::unique("bounded_name");
let mut value = String::new();
let mut draw = |ui: &mut Ui| {
row(ui, "Name", |ui| {
@@ -946,7 +948,7 @@ fn navigation_dropdown_popups_own_escape_and_return_focus_without_canceling_the_
let mut draw = |ui: &mut Ui| {
let ctx = ui.ctx().clone();
action.set(
- Window::new(egui::Id::new(("dropdown_escape", kind)), "settings", "Preferences")
+ Window::new(egui::Id::unique(("dropdown_escape", kind)), "settings", "Preferences")
.cards(1.0)
.fields()
.actions("OK", "Cancel", None)
@@ -1090,7 +1092,7 @@ fn a_right_click_on_every_kind_of_text_field_opens_its_menu() {
let value = RefCell::new("12 mm".to_owned());
let rect = Cell::new(egui::Rect::NOTHING);
let mut draw = |ui: &mut Ui| {
- let id = ui.id().with(case);
+ let id = ui.scope_id().with(case);
let value = &mut *value.borrow_mut();
rect.set(match case {
"expression" | "plain" => super::editor(ui, value, "", case == "expression").2.rect,
@@ -1118,7 +1120,7 @@ fn a_right_click_on_every_kind_of_text_field_opens_its_menu() {
#[test]
fn paste_inserts_at_the_cursor_and_replaces_the_selection() {
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("paste_dimension");
+ let id = egui::Id::unique("paste_dimension");
let value = RefCell::new("12 mm".to_owned());
let rect = Cell::new(egui::Rect::NOTHING);
let changed = Cell::new(false);
@@ -1161,7 +1163,7 @@ fn paste_inserts_at_the_cursor_and_replaces_the_selection() {
fn copy_and_cut_put_the_selection_on_the_clipboard() {
set_clipboard(None);
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("copy_cut");
+ let id = egui::Id::unique("copy_cut");
let value = RefCell::new("width + 2 mm".to_owned());
let rect = Cell::new(egui::Rect::NOTHING);
let mut draw = |ui: &mut Ui| rect.set(cell_editor(ui, id, &mut value.borrow_mut(), "", false).rect);
@@ -1186,7 +1188,7 @@ fn copy_and_cut_put_the_selection_on_the_clipboard() {
fn the_menu_offers_only_what_the_field_and_its_selection_allow() {
set_clipboard(Some("5"));
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("nothing_selected");
+ let id = egui::Id::unique("nothing_selected");
let value = RefCell::new("12".to_owned());
let rect = Cell::new(egui::Rect::NOTHING);
let mut draw = |ui: &mut Ui| rect.set(cell_editor(ui, id, &mut value.borrow_mut(), "", false).rect);
@@ -1238,7 +1240,7 @@ fn the_menu_offers_only_what_the_field_and_its_selection_allow() {
fn a_right_click_on_a_value_box_over_the_canvas_does_not_reach_the_canvas() {
set_clipboard(None);
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("canvas_box");
+ let id = egui::Id::unique("canvas_box");
let value = RefCell::new("20".to_owned());
let (field, canvas_menu) = (Cell::new(egui::Rect::NOTHING), Cell::new(false));
let mut draw = |ui: &mut Ui| {
@@ -1246,7 +1248,7 @@ fn a_right_click_on_a_value_box_over_the_canvas_does_not_reach_the_canvas() {
let canvas = ui.allocate_rect(ui.max_rect(), egui::Sense::click_and_drag());
canvas_menu.set(canvas_menu.get() | canvas.secondary_clicked());
let ctx = ui.ctx().clone();
- let area = Container::new(&ctx, Surface::Canvas).area(egui::Id::new("canvas_box_area"));
+ let area = Container::new(&ctx, Surface::Canvas).area(egui::Id::unique("canvas_box_area"));
area.fixed_pos(egui::pos2(60.0, 60.0)).order(egui::Order::Foreground).show(&ctx, |ui| {
field.set(canvas_value_field(ui, id, &mut value.borrow_mut(), false).rect);
});
@@ -1267,7 +1269,7 @@ fn a_right_click_on_a_value_box_over_the_canvas_does_not_reach_the_canvas() {
fn esc_closes_the_text_menu_alone() {
set_clipboard(None);
let ctx = crate::fonts::test_context();
- let id = egui::Id::new("esc_dimension");
+ let id = egui::Id::unique("esc_dimension");
let value = RefCell::new("12".to_owned());
let (rect, owner_saw_esc, open) = (Cell::new(egui::Rect::NOTHING), Cell::new(false), Cell::new(false));
let mut draw = |ui: &mut Ui| {
diff --git a/crates/ui-egui/src/ui_kit/file_view.rs b/crates/ui-egui/src/ui_kit/file_view.rs
index c37cfdba32..efade47aba 100644
--- a/crates/ui-egui/src/ui_kit/file_view.rs
+++ b/crates/ui-egui/src/ui_kit/file_view.rs
@@ -108,7 +108,7 @@ impl FileView {
egui::Frame::NONE.fill(t.file_surface).stroke(t.tertiary_border(t.file_border)).corner_radius(t.radius_xl),
|ui| {
ui.spacing_mut().item_spacing.y = 0.0;
- let key = ui.id().with("file_recent_index");
+ let key = ui.scope_id().with("file_recent_index");
ui.ctx().data_mut(|data| data.insert_temp(key, 0_usize));
let result = add(ui);
ui.ctx().data_mut(|data| data.remove::<usize>(key));
@@ -276,7 +276,7 @@ impl FileView {
ui.painter().rect_filled(rect, t.radius_lg, t.hover);
}
let list = ui.stack().iter().find_map(|node| {
- let key = node.id.with("file_recent_index");
+ let key = node.unique_id.with("file_recent_index");
ui.ctx().data(|data| data.get_temp::<usize>(key)).map(|index| (key, index))
});
if let Some((key, index)) = list {
@@ -408,7 +408,7 @@ impl FileView {
fn allocate(ui: &mut Ui, id: &str, width: f32, height: f32, label: &str) -> (Rect, Response) {
let (rect, _) = ui.allocate_exact_size(vec2(dimension(width).min(dimension(ui.available_width())), height), Sense::hover());
let response = ui.interact(rect, ui.make_persistent_id(id), Sense::click());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
if response.clicked() {
response.request_focus();
}
diff --git a/crates/ui-egui/src/ui_kit/framing.rs b/crates/ui-egui/src/ui_kit/framing.rs
index f37602b532..d6edd8662a 100644
--- a/crates/ui-egui/src/ui_kit/framing.rs
+++ b/crates/ui-egui/src/ui_kit/framing.rs
@@ -47,7 +47,7 @@ pub(crate) fn aspect_grid(ui: &mut Ui, tiles: &[AspectTile<'_>]) -> Option<usize
egui::FontId::proportional(t.font_small),
ink,
);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), tile.selected, tile.label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), tile.selected, tile.label));
scenario::publish_target(tile.id, rect);
if response.clicked() {
clicked = Some(row * 3 + column);
diff --git a/crates/ui-egui/src/ui_kit/gallery.rs b/crates/ui-egui/src/ui_kit/gallery.rs
index 8b309ef705..03025a09e3 100644
--- a/crates/ui-egui/src/ui_kit/gallery.rs
+++ b/crates/ui-egui/src/ui_kit/gallery.rs
@@ -192,7 +192,7 @@ const ELEMENTS: &[Element] = &[
.enumerate()
{
let rect = tree_row_rect(ui, row);
- assert_eq!(tree_row(ui, ui.id().with(("tree_geometry", index)), row).rect, Some(rect));
+ assert_eq!(tree_row(ui, ui.scope_id().with(("tree_geometry", index)), row).rect, Some(rect));
}
}),
element!("editor_section", |ui, _| {
@@ -260,19 +260,23 @@ const ELEMENTS: &[Element] = &[
}),
element!("tree_row", |ui, _| {
let actions = [TreeAction { icon: "plus", hover_only: false, label: "Add", reason: None, target: "gallery:tree:add" }];
- tree_row(ui, ui.id().with("tree_plain"), &Row { label: "Objects", fold: Some(true), actions: &actions, ..Default::default() });
- tree_row(ui, ui.id().with("tree_subtitle"), &Row { label: "Output", subtitle: "1920 × 1080 · PNG", selected: true, ..Default::default() });
+ tree_row(ui, ui.scope_id().with("tree_plain"), &Row { label: "Objects", fold: Some(true), actions: &actions, ..Default::default() });
+ tree_row(
+ ui,
+ ui.scope_id().with("tree_subtitle"),
+ &Row { label: "Output", subtitle: "1920 × 1080 · PNG", selected: true, ..Default::default() },
+ );
}),
element!("tree_header", |ui, state| {
tree_header(ui, "Scene", &mut state.selected, &["By object", "By look"], "Search objects");
tree_row(
ui,
- ui.id().with("compact_environment"),
+ ui.scope_id().with("compact_environment"),
&Row { compact: true, label: "Environment", icon: "environment_map", subtitle: "Studio Soft 2K", ..Default::default() },
);
tree_row(
ui,
- ui.id().with("compact_object"),
+ ui.scope_id().with("compact_object"),
&Row {
compact: true,
depth: 1,
@@ -288,7 +292,7 @@ const ELEMENTS: &[Element] = &[
element!("tree_row_disabled_actions", |ui, _| {
let actions =
[TreeAction { icon: "lookat", hover_only: true, label: "Solo", reason: Some("Not available yet"), target: "gallery:tree:solo" }];
- tree_row(ui, ui.id().with("tree_actions"), &Row { label: "Light", actions: &actions, ..Default::default() });
+ tree_row(ui, ui.scope_id().with("tree_actions"), &Row { label: "Light", actions: &actions, ..Default::default() });
}),
element!("selection_actions", |ui, _| {
let actions = [
@@ -301,7 +305,7 @@ const ELEMENTS: &[Element] = &[
}),
element!("catalog_scope", |ui, state| {
catalog_scope(ui, |ui| {
- search_field(ui, ui.id().with("catalog_search"), &mut state.value, "Search appearances");
+ search_field(ui, ui.scope_id().with("catalog_search"), &mut state.value, "Search appearances");
segmented(
ui,
&mut state.selected,
@@ -924,7 +928,7 @@ const ELEMENTS: &[Element] = &[
element!("assistant_composer", |ui, s| {
assistant_composer_footer(ui, |ui| {
assistant_composer(ui, false, |ui| {
- assistant_input(ui, ui.id().with("assistant_gallery"), &mut s.value, "Ask for a change…");
+ assistant_input(ui, ui.scope_id().with("assistant_gallery"), &mut s.value, "Ask for a change…");
});
});
}),
@@ -1148,7 +1152,7 @@ const ELEMENTS: &[Element] = &[
workspace_menu(ui, &crate::context_menu::items(&app, &crate::context_menu::Target::Workspace), None, 550.0);
}),
element!("window", "dialog:footer", Some("dialog:ok"), |ui, _| {
- Window::new(ui.id().with("window"), "settings", "Preferences").content(
+ Window::new(ui.scope_id().with("window"), "settings", "Preferences").content(
ui,
true,
|ui| {
@@ -1177,7 +1181,7 @@ const ELEMENTS: &[Element] = &[
);
}),
element!("confirm_warning", "dialog:footer", Some("dialog:apply"), |ui, _| {
- Confirm::new(ui.id().with("confirm"), "status_warning", "Save changes?")
+ Confirm::new(ui.scope_id().with("confirm"), "status_warning", "Save changes?")
.tone(Tone::Warning)
.actions("Save", "Cancel", Some("Don't Save"))
.content(ui, true, |ui| {
@@ -1185,7 +1189,7 @@ const ELEMENTS: &[Element] = &[
});
}),
element!("confirm_danger", "dialog:footer", Some("dialog:ok"), |ui, _| {
- Confirm::new(ui.id().with("confirm"), "delete", "Delete")
+ Confirm::new(ui.scope_id().with("confirm"), "delete", "Delete")
.tone(Tone::Danger)
.detail("Fillet2 · Chamfer1")
.actions("Delete", "Cancel", None)
@@ -1194,7 +1198,7 @@ const ELEMENTS: &[Element] = &[
});
}),
element!("confirm_info", "dialog:footer", Some("dialog:ok"), |ui, _| {
- Confirm::new(ui.id().with("confirm"), "help", "Replace file?").actions("Replace", "Cancel", None).content(ui, true, |ui| {
+ Confirm::new(ui.scope_id().with("confirm"), "help", "Replace file?").actions("Replace", "Cancel", None).content(ui, true, |ui| {
text(ui, "A file with this name already exists.", Text::Report("message", false));
});
}),
@@ -1202,7 +1206,7 @@ const ELEMENTS: &[Element] = &[
text(ui, "solid.fillet · replayable", Text::MonoNote("sample"));
}),
element!("color_thumbnail", |ui, _| {
- color_thumbnail(ui, ui.id().with("thumb"), Tokens::get().accent, "Sample", ());
+ color_thumbnail(ui, ui.scope_id().with("thumb"), Tokens::get().accent, "Sample", ());
}),
element!("list_frame", |ui, _| {
list_frame(ui, "sample", |ui| {
@@ -1264,7 +1268,7 @@ const ELEMENTS: &[Element] = &[
active_pill(ui);
}),
element!("library_cell", |ui, s| {
- library_cell(ui, ui.id().with("library"), &mut s.value, "Default material", |ui| {
+ library_cell(ui, ui.scope_id().with("library"), &mut s.value, "Default material", |ui| {
button(ui, "Steel", Button::Normal);
});
}),
@@ -1324,7 +1328,7 @@ const ELEMENTS: &[Element] = &[
text(ui, "Width", Text::Cell);
});
row.cell(|ui| {
- cell_editor(ui, ui.id().with("expression"), &mut s.value, "Expression", false);
+ cell_editor(ui, ui.scope_id().with("expression"), &mut s.value, "Expression", false);
});
row.cell(|ui| {
bin_button(ui, "Delete");
@@ -1367,16 +1371,16 @@ const ELEMENTS: &[Element] = &[
slider(ui, &mut 12.0, 0.0..=100.0, Slider { show_value: false, integer: true, ..Default::default() });
}),
element!("canvas_value_field", |ui, s| {
- canvas_value_field(ui, ui.id().with("canvas_value"), &mut s.value, false);
+ canvas_value_field(ui, ui.scope_id().with("canvas_value"), &mut s.value, false);
}),
element!("placement_field", |ui, s| {
- placement_field(ui, ui.id().with("placement"), &mut s.value, "Distance");
+ placement_field(ui, ui.scope_id().with("placement"), &mut s.value, "Distance");
}),
element!("bounded_cell_editor", |ui, s| {
- bounded_cell_editor(ui, ui.id().with("name"), &mut s.value, "Name", false, 128);
+ bounded_cell_editor(ui, ui.scope_id().with("name"), &mut s.value, "Name", false, 128);
}),
element!("password_field", |ui, s| {
- password_field(ui, ui.id().with("secret"), &mut s.value, "API key");
+ password_field(ui, ui.scope_id().with("secret"), &mut s.value, "API key");
}),
element!("number_field", |ui, _| {
number_field(ui, &mut 3_u32, 1..=200, 1.0, "");
@@ -1403,7 +1407,7 @@ const ELEMENTS: &[Element] = &[
});
}),
element!("message_field", |ui, s| {
- message_field(ui, ui.id().with("message"), &mut s.value, "Message");
+ message_field(ui, ui.scope_id().with("message"), &mut s.value, "Message");
}),
element!("text_lines", |ui, _| {
text_lines(ui, "gallery", "Licence\nSecond line");
@@ -1422,7 +1426,7 @@ const ELEMENTS: &[Element] = &[
text(ui, "Width", Text::Cell);
});
row.cell(|ui| {
- cell_editor(ui, ui.id().with("value"), &mut s.value, "", false);
+ cell_editor(ui, ui.scope_id().with("value"), &mut s.value, "", false);
});
});
});
@@ -1460,13 +1464,13 @@ const ELEMENTS: &[Element] = &[
name_cell_with_hint(ui, "Width", false, "Double-click to rename");
}),
element!("search_field", |ui, s| {
- search_field(ui, ui.id().with("search"), &mut s.value, "Search");
+ search_field(ui, ui.scope_id().with("search"), &mut s.value, "Search");
}),
element!("menu_filter", |ui, s| {
- menu_filter(ui, ui.id().with("menu_filter"), &mut s.value, "Filter");
+ menu_filter(ui, ui.scope_id().with("menu_filter"), &mut s.value, "Filter");
}),
element!("cell_editor", |ui, s| {
- cell_editor(ui, ui.id().with("cell"), &mut s.value, "Expression", true);
+ cell_editor(ui, ui.scope_id().with("cell"), &mut s.value, "Expression", true);
}),
element!("color_field", |ui, _| {
color_field(ui, &mut [120, 150, 180]);
@@ -1499,14 +1503,14 @@ const ELEMENTS: &[Element] = &[
angle_field(ui, &mut 45.0);
}),
element!("text_area", |ui, s| {
- text_area(ui, "Gallery", ui.id().with("area"), &mut s.value, 5, 1024);
+ text_area(ui, "Gallery", ui.scope_id().with("area"), &mut s.value, 5, 1024);
}),
element!("color_swatch", |ui, _| {
- color_swatch(ui, ui.id().with("swatch"), Tokens::get().accent, true, "Sample", 1);
+ color_swatch(ui, ui.scope_id().with("swatch"), Tokens::get().accent, true, "Sample", 1);
}),
element!("swatch_grid", |ui, _| {
swatch_grid(ui, &[1, 2, 3], |ui, n| {
- color_swatch(ui, ui.id().with(n), Tokens::get().accent, true, "Sample", *n);
+ color_swatch(ui, ui.scope_id().with(n), Tokens::get().accent, true, "Sample", *n);
});
}),
element!("action_menu", |ui, _| {
@@ -1583,7 +1587,7 @@ const ELEMENTS: &[Element] = &[
choice_row(ui, "Gallery", "gallery", &mut s.selected, &["One", "Two"]);
}),
element!("multiline_text_field", "dialog:widget:Gallery", Some("dialog:Gallery"), |ui, s| {
- multiline_text_field(ui, "Gallery", ui.id().with("text"), &mut s.value);
+ multiline_text_field(ui, "Gallery", ui.scope_id().with("text"), &mut s.value);
}),
element!("searchable_dropdown", "dialog:row:Gallery", Some("dialog:Gallery"), |ui, _| {
row(ui, "Gallery", |ui| {
@@ -1619,7 +1623,7 @@ const ELEMENTS: &[Element] = &[
}),
element!("inline_name", |ui, s| {
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), row_height()), egui::Sense::hover());
- inline_name(ui, rect, ui.id().with("inline_name"), &mut s.value);
+ inline_name(ui, rect, ui.scope_id().with("inline_name"), &mut s.value);
}),
element!("field", "dialog:row:Gallery", Some("dialog:Gallery"), |ui, s| {
row(ui, "Gallery", |ui| {
@@ -1949,7 +1953,7 @@ const ELEMENTS: &[Element] = &[
let anchor = ui.allocate_space(vec2(100.0, row_height())).1;
popup_list(
ui.ctx(),
- ui.id().with("popup"),
+ ui.scope_id().with("popup"),
anchor,
Some(0),
&[PopupOption { kind: "parameter", text: "Width", detail: "10 mm", color: Tokens::get().text }],
@@ -2234,7 +2238,7 @@ fn table_cells_keep_alignment_fixed_rows_editing_and_action_targets() {
text(ui, name, Text::Cell);
});
row.cell(|ui| {
- let response = cell_editor(ui, ui.id().with("expression"), value, "Expression", false);
+ let response = cell_editor(ui, ui.scope_id().with("expression"), value, "Expression", false);
scenario::publish_handle(&format!("gallery:cell:{name}"), response.rect.center());
scenario::publish_rect(&format!("gallery:cell:{name}"), response.rect);
});
@@ -2281,7 +2285,7 @@ fn popup_suggestions_and_selectable_lists_keep_click_selection() {
let mut draw = |ui: &mut Ui| {
selected = popup_list(
ui.ctx(),
- egui::Id::new("suggestions"),
+ egui::Id::unique("suggestions"),
egui::Rect::from_min_size(egui::pos2(10.0, 10.0), vec2(220.0, 24.0)),
Some(0),
&[
@@ -2324,7 +2328,7 @@ fn many_draggable_samples_wrap_inside_the_available_width() {
scope(ui, |ui| {
bounds = ui.available_rect_before_wrap();
swatch_grid(ui, &(0..20).collect::<Vec<_>>(), |ui, index| {
- let response = color_swatch(ui, ui.id().with(index), Tokens::get().accent, false, "Sample", *index);
+ let response = color_swatch(ui, ui.scope_id().with(index), Tokens::get().accent, false, "Sample", *index);
rects.push(response.rect);
});
});
@@ -2694,7 +2698,7 @@ fn confirm_radial_and_history_rows_keep_multitone_artwork() {
"danger" => Tone::Danger,
_ => Tone::Info,
};
- Confirm::new(ui.id().with("confirm"), icon, "Confirm").tone(tone).content(ui, true, |_| {});
+ Confirm::new(ui.scope_id().with("confirm"), icon, "Confirm").tone(tone).content(ui, true, |_| {});
}
}
});
@@ -2956,7 +2960,7 @@ fn tree_icon_actions_keep_repeated_light_rows_independent() {
for index in 0..3 {
let target = format!("light:{index}:visibility");
let actions = [TreeAction { icon: "eye", hover_only: false, label: "Hide", reason: Some("Not available yet"), target: &target }];
- let row = tree_row(ui, ui.id().with(index), &Row { compact: true, label: "Directional", actions: &actions, ..Default::default() });
+ let row = tree_row(ui, ui.scope_id().with(index), &Row { compact: true, label: "Directional", actions: &actions, ..Default::default() });
for action in row.actions {
assert!(ids.insert(action.id), "each light action must have its own widget identity");
}
diff --git a/crates/ui-egui/src/ui_kit/history.rs b/crates/ui-egui/src/ui_kit/history.rs
index 77da08197d..f59d73ec24 100644
--- a/crates/ui-egui/src/ui_kit/history.rs
+++ b/crates/ui-egui/src/ui_kit/history.rs
@@ -32,7 +32,7 @@ impl StripHeading {
let width = self.width() - ui.spacing().item_spacing.x;
let (rect, response) = ui.allocate_exact_size(vec2(width.max(self.0.size().x), Tokens::get().control_height), egui::Sense::hover());
self.paint(ui.painter(), rect);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), self.0.text()));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), self.0.text()));
response
}
}
@@ -238,7 +238,7 @@ impl HistoryTransport {
/// `playing` turns the Play button into Stop; the other controls ignore it.
pub fn show(self, ui: &mut egui::Ui, rect: Rect, playing: bool) -> egui::Response {
let t = Tokens::get();
- let response = ui.interact(rect, ui.id().with(("history_transport", self.id())), egui::Sense::click());
+ let response = ui.interact(rect, ui.scope_id().with(("history_transport", self.id())), egui::Sense::click());
crate::scenario::publish_target(&format!("history:{}", self.id()), rect);
if response.hovered() {
ui.painter().rect_filled(rect, t.radius_sm, t.hover);
@@ -246,7 +246,7 @@ impl HistoryTransport {
let glyph = if self == Self::Play && playing { "pause" } else { self.id() };
icons::glyphs::transport_glyph(ui.painter(), rect.center(), glyph, t.icon);
let label = self.label(playing);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
response.on_hover_cursor(egui::CursorIcon::PointingHand).backing_on_hover_text(label)
}
}
@@ -348,11 +348,11 @@ pub(crate) struct HistorySeamResponse {
/// Focusable seam button and edge gesture, shared by the panel and CPU interaction tests.
pub(crate) fn history_seam(ui: &mut egui::Ui, card: Rect, names: bool) -> HistorySeamResponse {
let seam = HistorySeam::new(card);
- let id = ui.id().with("history_seam");
+ let id = ui.scope_id().with("history_seam");
let edge = ui.interact(seam.edge, id.with("edge"), egui::Sense::CLICK | egui::Sense::DRAG);
let button = ui.interact(seam.pill, id, egui::Sense::click_and_drag());
let label = crate::i18n::tr(if names { "ui.collapse" } else { "ui.expand" });
- button.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ button.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
if button.clicked() {
button.request_focus();
}
diff --git a/crates/ui-egui/src/ui_kit/layout.rs b/crates/ui-egui/src/ui_kit/layout.rs
index 8cee5627be..a4590d4e1c 100644
--- a/crates/ui-egui/src/ui_kit/layout.rs
+++ b/crates/ui-egui/src/ui_kit/layout.rs
@@ -97,7 +97,7 @@ pub(crate) fn catalog_footer(ui: &mut Ui, text: &str) -> Response {
job.wrap.max_rows = 1;
let galley = ui.painter().layout_job(job);
ui.painter().galley(rect.left_top() + vec2(t.space_24, t.space_8), galley, t.form_dim);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
crate::scenario::publish_rect("catalog:footer", rect);
response
}
@@ -168,16 +168,16 @@ pub(crate) fn label(ui: &Ui) -> &str {
}
/// Publish accessibility and scenario geometry. Tokens: `none`.
-pub(super) fn publish(ui: &Ui, response: &Response, kind: egui::WidgetType) {
+pub(super) fn publish(ui: &Ui, response: &Response, kind: egui::Role) {
let t = Tokens::get();
match kind {
- egui::WidgetType::TextEdit => {
+ egui::Role::TextInput => {
t.input_bevel(ui, response);
if response.has_focus() {
crate::prefs_search::note_key_sink(ui.ctx());
}
}
- egui::WidgetType::ComboBox | egui::WidgetType::Button => t.button_bevel(ui, response, false),
+ egui::Role::ComboBox | egui::Role::Button => t.button_bevel(ui, response, false),
_ => {}
}
let label = label(ui);
@@ -371,7 +371,7 @@ fn sized_row_body<R>(ui: &mut Ui, text: &str, height: f32, scrub: bool, control:
// beside the label keeps its own hover and click.
let scrub_width = if help.is_some() { (label_width - t.space_16 - t.space_4).max(0.0) } else { label_width };
let scrub_rect = egui::Rect::from_min_size(label_rect.min, vec2(scrub_width, rect.height()));
- let drag = (scrub && scrub_width > 0.0).then(|| ui.interact(scrub_rect, ui.id().with(("sc_row_scrub", text)), egui::Sense::drag()));
+ let drag = (scrub && scrub_width > 0.0).then(|| ui.interact(scrub_rect, ui.scope_id().with(("sc_row_scrub", text)), egui::Sense::drag()));
let gutter = if label_width > 0.0 { label_gap(ui, width) } else { 0.0 };
let control_rect = egui::Rect::from_min_max(egui::pos2((label_rect.right() + gutter).min(rect.right()), rect.top()), rect.max);
let result = ui
@@ -639,7 +639,9 @@ fn section_with_badge<R>(
if rule_left < rule_right {
t.secondary_hline(ui.painter(), rule_left..=rule_right, rect.center().y, t.dialog_rule);
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::CollapsingHeader, ui.is_enabled(), open, crate::i18n::tr_label(title)));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::DisclosureTriangle, ui.is_enabled(), open, crate::i18n::tr_label(title)));
+ // A disclosure says whether it is open as expanded, as egui's own collapsing header does.
+ ui.ctx().accesskit_node_builder(response.id, |node| node.set_expanded(open));
scenario::publish_handle(&format!("dialog:section:{title}"), response.rect.center());
scenario::publish_rect(&format!("dialog:section:{title}"), rect);
if response.clicked() && !pending && !searching {
@@ -663,7 +665,7 @@ fn section_with_badge<R>(
/// query changes, so a short word does not lay out every command.
pub(crate) fn search_fold<R>(ui: &mut Ui, title: &str, count: usize, add: impl FnOnce(&mut Ui) -> R) -> Option<R> {
let t = Tokens::get();
- let id = egui::Id::new(("prefs_search_fold", title));
+ let id = egui::Id::unique(("prefs_search_fold", title));
let query = crate::prefs_search::query(ui);
let mut open = ui.data(|data| data.get_temp::<bool>(id)).unwrap_or(false);
let previous = ui.data(|data| data.get_temp::<String>(id.with("query"))).unwrap_or_default();
@@ -712,7 +714,9 @@ pub(crate) fn search_fold<R>(ui: &mut Ui, title: &str, count: usize, add: impl F
t.secondary_hline(ui.painter(), rule_left..=rect.right(), rect.center().y, t.dialog_rule);
}
let accessible = format!("{title} ({count})");
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::CollapsingHeader, ui.is_enabled(), open, &accessible));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::DisclosureTriangle, ui.is_enabled(), open, &accessible));
+ // A disclosure says whether it is open as expanded, as egui's own collapsing header does.
+ ui.ctx().accesskit_node_builder(response.id, |node| node.set_expanded(open));
scenario::publish_rect("prefs:search:shortcuts", rect);
scenario::publish_handle("prefs:search:shortcuts", response.rect.center());
if response.clicked() {
@@ -882,7 +886,7 @@ fn text_impl(ui: &mut Ui, text: &str, style: Text<'_>, hover_hint: Option<&str>)
}
});
paint_text(ui, rect, text, font, ink, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
response.backing_on_hover_text(tooltip.as_deref().unwrap_or(text))
} else if matches!(style, Text::Error(_)) {
crate::ui_kit::Container::show_backing(
@@ -903,7 +907,7 @@ fn text_impl(ui: &mut Ui, text: &str, style: Text<'_>, hover_hint: Option<&str>)
let padding = if matches!(style, Text::Note(_) | Text::MonoNote(_)) { t.space_4 } else { 0.0 };
let (rect, response) = ui.allocate_exact_size(vec2(width, galley.size().y + padding * 2.0), egui::Sense::hover());
ui.painter().galley(egui::pos2(rect.left(), rect.top() + padding), galley, ink);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
response
} else {
let label = egui::Label::new(RichText::new(text).font(font).color(ink));
@@ -950,8 +954,8 @@ pub(crate) fn summary_row(ui: &mut Ui, name: &str, summary: &str, enabled: &mut
let detail = egui::Rect::from_min_max(egui::pos2(text.left(), text.center().y), text.max);
paint_text(ui, title, name, crate::fonts::semibold(t.font_label), t.form_ink, false);
paint_text(ui, detail, summary, egui::FontId::proportional(t.font_small), t.form_dim, false);
- let response = ui.interact(text, ui.id().with("summary"), egui::Sense::hover()).backing_on_hover_text(summary);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{name}: {summary}")));
+ let response = ui.interact(text, ui.scope_id().with("summary"), egui::Sense::hover()).backing_on_hover_text(summary);
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), format!("{name}: {summary}")));
scenario::publish_rect(&format!("dialog:inline:{name}"), title);
scenario::publish_rect("dialog:report:rule_report", detail);
ui.scope_builder(
diff --git a/crates/ui-egui/src/ui_kit/look_chain.rs b/crates/ui-egui/src/ui_kit/look_chain.rs
index f22d67944c..2cc2351fe8 100644
--- a/crates/ui-egui/src/ui_kit/look_chain.rs
+++ b/crates/ui-egui/src/ui_kit/look_chain.rs
@@ -49,7 +49,7 @@ pub fn look_chain(ui: &mut Ui, id: &str, labels: [&str; 4], looks: [Option<Spher
}
let key = format!("{id}:{}", step.name());
let response = ui.interact(cell, ui.make_persistent_id(&key), Sense::click());
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, ui.is_enabled(), active == step, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), active == step, label));
if response.clicked() {
clicked = Some(step);
}
diff --git a/crates/ui-egui/src/ui_kit/menu.rs b/crates/ui-egui/src/ui_kit/menu.rs
index da8ad89a48..1d7f0a33fb 100644
--- a/crates/ui-egui/src/ui_kit/menu.rs
+++ b/crates/ui-egui/src/ui_kit/menu.rs
@@ -19,7 +19,7 @@ impl Menu {
ui,
|ui, nested| {
let button = egui::Button::new(label.into());
- ui.add(if nested { button.right_text(egui::menu::SubMenuButton::RIGHT_ARROW) } else { button })
+ ui.add(if nested { button.right_text(egui::menu::SubMenuButton::arrow_atom(None)) } else { button })
},
add,
)
@@ -111,7 +111,7 @@ impl Menu {
// (open flyout, when the pointer left it, the pass that last showed it, the pointer has
// moved since the parent menu opened)
type State = (Option<egui::Id>, Option<f64>, u64, bool);
- let key = ui.id().with("sc_flyout");
+ let key = ui.scope_id().with("sc_flyout");
let ctx = ui.ctx();
let pass = ctx.cumulative_pass_nr();
let (mut open, mut leave, seen, mut moved) = ctx.data(|d| d.get_temp::<State>(key)).unwrap_or((None, None, 0, false));
@@ -361,7 +361,7 @@ impl<'a> MenuItem<'a> {
job.wrap.max_rows = 1;
let galley = painter.layout_job(job);
painter.galley(pos2(left, r.center().y - galley.size().y / 2.0), galley, ink);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, label));
crate::scenario::publish_target(&format!("menu:{}", self.id), r);
if enabled && response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
@@ -467,7 +467,7 @@ pub(crate) fn workspace_menu(ui: &mut egui::Ui, items: &[Item], key_row: Option<
let labels = crate::i18n::tr(tabs).split('·').map(|label| crate::i18n::tr_label(label.trim())).collect::<Vec<_>>().join(" · ");
line(labels, r.top() + 47.0);
}
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, item.enabled, name));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, item.enabled, name));
if resp.clicked() && item.enabled {
picked = Some(item.clone());
}
@@ -494,7 +494,7 @@ pub(crate) fn rename_menu(ui: &mut Ui, value: &mut String, focused: &mut bool) -
Menu::show(ui, t.form_card_width, |ui| {
super::scope(ui, |ui| {
Menu::heading(ui, "Rename");
- let id = egui::Id::new("sc_rename_text");
+ let id = egui::Id::unique("sc_rename_text");
let response = ui.add(super::fields::text_input(egui::TextEdit::singleline(value).id(id)).desired_width(ui.available_width()));
t.input_bevel(ui, &response);
crate::scenario::publish_target("rename:name", response.rect);
diff --git a/crates/ui-egui/src/ui_kit/metrics.rs b/crates/ui-egui/src/ui_kit/metrics.rs
index 6990ea468a..f947090ff9 100644
--- a/crates/ui-egui/src/ui_kit/metrics.rs
+++ b/crates/ui-egui/src/ui_kit/metrics.rs
@@ -89,7 +89,7 @@ pub(super) fn label_column(ui: &Ui, text: &str, row_width: f32) -> f32 {
// for their existing controls. Both sizes derive from the same form/spacing tokens.
let base = if row_width >= t.form_card_width + t.space_24 * 2.0 { t.form_label_width + t.space_24 + t.space_10 } else { t.form_label_width };
let natural = label_width(ui, text);
- let widest = match ui.stack().iter().find(|node| node.tags().contains(FORM)).map(|node| node.id) {
+ let widest = match ui.stack().iter().find(|node| node.tags().contains(FORM)).map(|node| node.unique_id) {
Some(form) => {
let key = form.with("label_column");
let pass = ui.ctx().cumulative_pass_nr();
diff --git a/crates/ui-egui/src/ui_kit/metrics_tests.rs b/crates/ui-egui/src/ui_kit/metrics_tests.rs
index 2ee9025a2a..c424d1c222 100644
--- a/crates/ui-egui/src/ui_kit/metrics_tests.rs
+++ b/crates/ui-egui/src/ui_kit/metrics_tests.rs
@@ -31,7 +31,7 @@ fn a_growing_form_widens_past_the_cap_and_publishes_the_card_extra() {
let ctx = egui::Context::default();
crate::fonts::setup_fonts(&ctx);
let t = Tokens::get();
- let key = egui::Id::new("grow-test");
+ let key = egui::Id::unique("grow-test");
let long = "Anpassung an Leitkurve";
let mut label = None;
for _ in 0..3 {
@@ -130,7 +130,7 @@ fn file_grid_cells_use_vertical_layout_even_inside_a_horizontal_parent() {
fn sample_grid_stretches_each_row_without_clipping_long_descriptions() {
let ctx = crate::fonts::test_context();
let mut cards = Vec::new();
- let output = ctx.run_ui(
+ let mut output = ctx.run_ui(
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(680.0, 600.0))), ..Default::default() },
|ui| {
ui.set_width(680.0);
@@ -140,6 +140,7 @@ fn sample_grid_stretches_each_row_without_clipping_long_descriptions() {
]);
},
);
+ output.textures_delta.clear();
assert_eq!(cards.len(), 2);
assert!((cards[0].rect.top() - cards[1].rect.top()).abs() < 0.1);
assert!((cards[0].rect.bottom() - cards[1].rect.bottom()).abs() < 0.1);
diff --git a/crates/ui-egui/src/ui_kit/name_list.rs b/crates/ui-egui/src/ui_kit/name_list.rs
index c3391b5c77..6f79d464b0 100644
--- a/crates/ui-egui/src/ui_kit/name_list.rs
+++ b/crates/ui-egui/src/ui_kit/name_list.rs
@@ -21,7 +21,7 @@ const MEASURE_WIDTH: f32 = 4096.0;
pub fn name_list(ui: &mut Ui, id: &str, columns: &[&str], empty: &str, add: impl FnOnce(&mut NameList<'_, '_>)) {
let t = Tokens::get();
let columns = columns.get(..columns.len().min(MAX_COLUMNS)).unwrap_or_default();
- let key = ui.id().with(("name_list", id));
+ let key = ui.scope_id().with(("name_list", id));
let measured: Vec<f32> = ui.data(|d| d.get_temp(key)).unwrap_or_default();
let grid: Vec<Column<'_>> = columns
.iter()
@@ -109,7 +109,7 @@ fn name_text(ui: &mut Ui, name: &str) -> Response {
job.wrap.max_rows = 1;
let cut = ui.fonts_mut(|fonts| fonts.layout_job(job)).elided;
super::text::paint_text(ui, rect, name, font, t.form_ink, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), name));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), name));
let id = format!("dialog:name:{name}");
scenario::publish_rect(&id, rect);
scenario::publish_count(&format!("{id}:cut"), f64::from(u8::from(cut)));
diff --git a/crates/ui-egui/src/ui_kit/navigation.rs b/crates/ui-egui/src/ui_kit/navigation.rs
index dd13ee40a3..466dd48b0a 100644
--- a/crates/ui-egui/src/ui_kit/navigation.rs
+++ b/crates/ui-egui/src/ui_kit/navigation.rs
@@ -176,7 +176,7 @@ pub(crate) fn navigation_button_editable(ui: &mut Ui, rect: Rect, button: Naviga
if response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), button.selected, button.label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), button.selected, button.label));
response
}
@@ -199,8 +199,10 @@ pub(crate) fn navigation_edit_outline(ui: &Ui, rect: Rect, hidden: bool, selecte
let mut points = Vec::new();
egui::epaint::tessellator::path::rounded_rectangle(
&mut points,
- rect.shrink(NAV_BORDER / 2.0),
- egui::epaint::CornerRadiusF32::same(f32::from(metrics.button_radius) - NAV_BORDER / 2.0),
+ egui::epaint::RoundedRect::new(
+ rect.shrink(NAV_BORDER / 2.0),
+ egui::epaint::CornerRadiusF32::same(f32::from(metrics.button_radius) - NAV_BORDER / 2.0),
+ ),
);
if let Some(first) = points.first().copied() {
points.push(first);
diff --git a/crates/ui-egui/src/ui_kit/navigation_menu.rs b/crates/ui-egui/src/ui_kit/navigation_menu.rs
index a1f43ac310..f3df2c086b 100644
--- a/crates/ui-egui/src/ui_kit/navigation_menu.rs
+++ b/crates/ui-egui/src/ui_kit/navigation_menu.rs
@@ -42,7 +42,7 @@ impl<'a> NavigationMenuRow<'a> {
pub(crate) fn show(self, ui: &mut Ui) -> Response {
let t = Tokens::get();
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), NAV_MENU_ROW), Sense::hover());
- let response = ui.interact(rect, ui.id().with(self.id), if self.enabled { Sense::click() } else { Sense::hover() });
+ let response = ui.interact(rect, ui.scope_id().with(self.id), if self.enabled { Sense::click() } else { Sense::hover() });
let ink = if self.selected { t.form_primary } else { t.form_ink };
let bg = if self.selected {
Some(t.selected_bg)
@@ -88,7 +88,7 @@ impl<'a> NavigationMenuRow<'a> {
Rect::from_center_size(pos2(rect.right() - NAV_MENU_INSET - NAV_CHEVRON / 2.0, rect.center().y), vec2(NAV_CHEVRON, NAV_CHEVRON));
icons::paint_ink(ui.painter(), arrow, "chevron", t.form_dim);
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, self.enabled && ui.is_enabled(), self.selected, self.label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, self.enabled && ui.is_enabled(), self.selected, self.label));
if cut { response.backing_on_hover_text(self.label) } else { response }
}
}
diff --git a/crates/ui-egui/src/ui_kit/navigation_settings.rs b/crates/ui-egui/src/ui_kit/navigation_settings.rs
index a67d9e12c2..ccd6d2e0b6 100644
--- a/crates/ui-egui/src/ui_kit/navigation_settings.rs
+++ b/crates/ui-egui/src/ui_kit/navigation_settings.rs
@@ -109,7 +109,7 @@ pub(crate) fn navigation_anchor_picker(ui: &mut Ui, id: &str, selected: usize, l
pos2(rect.left() + rect.width() * column as f32 / 3.0, rect.top() + rect.height() * row as f32 / 2.0),
pos2(rect.left() + rect.width() * (column + 1) as f32 / 3.0, rect.top() + rect.height() * (row + 1) as f32 / 2.0),
);
- let response = ui.interact(cell, ui.id().with((id, "anchor", index)), Sense::click());
+ let response = ui.interact(cell, ui.scope_id().with((id, "anchor", index)), Sense::click());
let on = index == selected;
let (fill, stroke) = if on {
(t.form_primary, egui::Stroke::new(NAV_BORDER, t.form_primary))
@@ -127,7 +127,7 @@ pub(crate) fn navigation_anchor_picker(ui: &mut Ui, id: &str, selected: usize, l
egui::StrokeKind::Outside,
);
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::RadioButton, ui.is_enabled(), on, *label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::RadioButton, ui.is_enabled(), on, *label));
crate::scenario::publish_target(&format!("prefs:navbar:anchor:{index}"), cell);
if response.backing_on_hover_text(*label).clicked() {
clicked = Some(index);
@@ -158,10 +158,10 @@ pub(crate) fn navigation_separator_source(ui: &mut Ui, id: &str, label: &str, dr
let width = (2.0 * NAV_BORDER + NAV_TILE_INSET + NAV_TILE_ICON + NAV_TILE_GAP + text.size().x + NAV_TILE_GAP + NAV_TILE_ADD + t.space_4)
.min(ui.max_rect().width().max(0.0));
let (rect, _) = ui.allocate_exact_size(vec2(width, NAV_TILE_HEIGHT), Sense::hover());
- let response = ui.interact(rect, ui.id().with((id, "tile")), Sense::click_and_drag());
+ let response = ui.interact(rect, ui.scope_id().with((id, "tile")), Sense::click_and_drag());
let add_rect =
Rect::from_center_size(pos2(rect.right() - NAV_BORDER - t.space_4 - NAV_TILE_ADD / 2.0, rect.center().y), vec2(NAV_TILE_ADD, NAV_TILE_ADD));
- let add = ui.interact(add_rect, ui.id().with((id, "add")), Sense::click());
+ let add = ui.interact(add_rect, ui.scope_id().with((id, "add")), Sense::click());
let mut painter = ui.painter().clone();
if dragging {
painter.multiply_opacity(NAV_TILE_DRAG_OPACITY);
@@ -190,9 +190,9 @@ pub(crate) fn navigation_separator_source(ui: &mut Ui, id: &str, label: &str, dr
painter.rect_filled(add_rect, t.control_radius.saturating_sub(NAV_BORDER as u8), t.nav_hover);
}
icons::paint_ink(&painter, Rect::from_center_size(add_rect.center(), vec2(t.space_14, t.space_14)), "plus", t.form_primary);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
add.widget_info(|| {
- egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::format("navbar.custom.add_slot", &[("slot", label)]))
+ egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::format("navbar.custom.add_slot", &[("slot", label)]))
});
(response, add)
}
@@ -203,10 +203,10 @@ pub(crate) fn navigation_tile(ui: &mut Ui, id: &str, label: &str, icon: &str, dr
let width = (2.0 * NAV_BORDER + NAV_TILE_INSET + NAV_TILE_ICON + NAV_TILE_GAP + text.size().x + NAV_TILE_GAP + NAV_TILE_ADD + t.space_4)
.min(ui.max_rect().width().max(0.0));
let (rect, _) = ui.allocate_exact_size(vec2(width, NAV_TILE_HEIGHT), Sense::hover());
- let response = ui.interact(rect, ui.id().with((id, "tile")), Sense::click_and_drag());
+ let response = ui.interact(rect, ui.scope_id().with((id, "tile")), Sense::click_and_drag());
let add_rect =
Rect::from_center_size(pos2(rect.right() - NAV_BORDER - t.space_4 - NAV_TILE_ADD / 2.0, rect.center().y), vec2(NAV_TILE_ADD, NAV_TILE_ADD));
- let add = ui.interact(add_rect, ui.id().with((id, "add")), Sense::click());
+ let add = ui.interact(add_rect, ui.scope_id().with((id, "add")), Sense::click());
let mut painter = ui.painter().clone();
if dragging {
painter.multiply_opacity(NAV_TILE_DRAG_OPACITY);
@@ -234,9 +234,9 @@ pub(crate) fn navigation_tile(ui: &mut Ui, id: &str, label: &str, icon: &str, dr
painter.rect_filled(add_rect, t.control_radius.saturating_sub(NAV_BORDER as u8), t.nav_hover);
}
icons::paint_ink(&painter, Rect::from_center_size(add_rect.center(), vec2(t.space_14, t.space_14)), "plus", t.form_primary);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
add.widget_info(|| {
- egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::format("navbar.custom.add_slot", &[("slot", label)]))
+ egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::format("navbar.custom.add_slot", &[("slot", label)]))
});
(response, add)
}
@@ -248,7 +248,7 @@ pub(crate) fn navigation_drag_ghost(ui: &Ui, at: egui::Pos2, button: NavigationB
let width =
if button.menu { metrics.icon + NAV_MENU_LEFT + NAV_MENU_RIGHT + NAV_MENU_GAP + NAV_CHEVRON + 2.0 * NAV_BORDER } else { metrics.button };
Container::new(ctx, Surface::Navigation)
- .area(ui.id().with("navigation_drag_ghost"))
+ .area(ui.scope_id().with("navigation_drag_ghost"))
.order(egui::Order::Tooltip)
.interactable(false)
.fixed_pos(at + vec2(t.space_14, t.space_16))
diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rs
index 5db9a8abb4..9b94567229 100644
--- a/crates/ui-egui/src/ui_kit/panel.rs
+++ b/crates/ui-egui/src/ui_kit/panel.rs
@@ -102,7 +102,7 @@ fn header_actions(
let title_rect = egui::Rect::from_min_max(egui::pos2(left, rect.top()), egui::pos2(right.max(left), rect.bottom()));
paint_text(ui, title_rect, title, crate::fonts::semibold(if icon.0.is_empty() { t.font_label } else { t.font_heading }), t.form_ink, false);
let title_response = ui.interact(title_rect, ui.make_persistent_id("title_text"), egui::Sense::hover());
- title_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
+ title_response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), title));
scenario::publish_rect("dialog:header", rect);
t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);
}
@@ -122,11 +122,11 @@ pub enum DialogButtons {
impl DialogButtons {
pub(crate) fn publish(self, ctx: &egui::Context) {
- ctx.data_mut(|data| data.insert_temp(egui::Id::new("sc_dialog_buttons"), self));
+ ctx.data_mut(|data| data.insert_temp(egui::Id::unique("sc_dialog_buttons"), self));
}
pub(crate) fn current(ctx: &egui::Context) -> Self {
- ctx.data(|data| data.get_temp(egui::Id::new("sc_dialog_buttons"))).unwrap_or_default()
+ ctx.data(|data| data.get_temp(egui::Id::unique("sc_dialog_buttons"))).unwrap_or_default()
}
}
@@ -205,7 +205,7 @@ impl<'a> TopHeader<'a> {
if state.busy {
egui::Spinner::new().size(t.space_14).paint_at(ui, self.icon);
let status = state.text.as_deref().unwrap_or_else(|| crate::i18n::tr_label("Updating the preview"));
- ui.interact(self.icon, ui.id().with("compute_status"), egui::Sense::hover()).backing_on_hover_text(status);
+ ui.interact(self.icon, ui.scope_id().with("compute_status"), egui::Sense::hover()).backing_on_hover_text(status);
ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));
} else {
crate::icons::paint_icon(ui.painter(), self.icon, icon, 1.0);
@@ -216,7 +216,7 @@ impl<'a> TopHeader<'a> {
None => paint_text(ui, self.title, title, heading.clone(), t.form_ink, false),
}
let title_response = ui.interact(self.title, ui.make_persistent_id("title_text"), egui::Sense::hover());
- title_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
+ title_response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), title));
// The buttons take the row's width first; a title that no longer fits says itself on hover.
if ui.painter().layout_no_wrap(title.to_owned(), heading, t.form_ink).size().x > self.title.width() {
title_response.backing_on_hover_text(title);
@@ -270,7 +270,7 @@ pub(crate) fn inspector_header(ui: &mut Ui, icon: &str, title: &str, kind: &str)
let name = egui::Rect::from_min_max(egui::pos2(icon_rect.right() + t.space_8, rect.top()), egui::pos2(badge.left() - t.space_8, rect.bottom()));
paint_text(ui, name, title, crate::fonts::semibold(t.font_label), t.form_ink, false);
ui.interact(name, ui.make_persistent_id("inspector_title"), egui::Sense::hover())
- .widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
+ .widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), title));
t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);
scenario::publish_rect("dialog:header", rect);
action
@@ -411,7 +411,7 @@ impl<'a> Panel<'a> {
return None;
}
let ctx = ui.ctx().clone();
- Some(container.area(egui::Id::new(id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {
+ Some(container.area(egui::Id::unique(id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {
let frame = container.frame(&ctx, Tokens::get().panel, crate::frame::Side::Left).inner_margin(Tokens::get().space_4);
container
.show_frame(ui, frame, rect, |ui| {
@@ -491,7 +491,7 @@ impl<'a> Panel<'a> {
);
let ctx = ui.ctx().clone();
let mut move_side = None;
- let response = container.area(egui::Id::new(options.id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {
+ let response = container.area(egui::Id::unique(options.id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {
let frame = container
.frame(
&ctx,
@@ -520,8 +520,9 @@ impl<'a> Panel<'a> {
ui.spacing_mut().item_spacing.y = 0.0;
let band = egui::Rect::from_min_size(ui.cursor().min, vec2(ui.available_width(), header_height()));
let grip_rect = if tree { egui::Rect::from_min_size(band.min, vec2(t.space_24 * 2.0 + t.space_8, band.height())) } else { band };
- let grip =
- ui.interact(grip_rect, ui.id().with("workspace_grip"), egui::Sense::click_and_drag()).on_hover_cursor(egui::CursorIcon::Grab);
+ let grip = ui
+ .interact(grip_rect, ui.scope_id().with("workspace_grip"), egui::Sense::click_and_drag())
+ .on_hover_cursor(egui::CursorIcon::Grab);
scenario::publish_target(&format!("{}:grip", options.id), grip.rect);
super::Menu::context(&grip, |ui| {
let (target, label) = if left { ("right", "Move to right side") } else { ("left", "Move to left side") };
@@ -536,7 +537,7 @@ impl<'a> Panel<'a> {
scenario::publish_rect(&format!("{}:header", options.id), band);
if grip.dragged() {
let frame_nr = ui.ctx().cumulative_frame_nr();
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_dock_drag_frame"), frame_nr));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique("sc_dock_drag_frame"), frame_nr));
ui.ctx().set_cursor_icon(egui::CursorIcon::Grabbing);
}
if grip.drag_stopped()
@@ -572,7 +573,8 @@ impl<'a> Panel<'a> {
if left { card.right() - t.space_6..=card.right() } else { card.left()..=card.left() + t.space_6 },
card.y_range(),
);
- let resize = ui.interact(rail, ui.id().with("workspace_resize"), egui::Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
+ let resize =
+ ui.interact(rail, ui.scope_id().with("workspace_resize"), egui::Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeHorizontal);
scenario::publish_target(&format!("{}:resize", options.id), rail);
if resize.dragged() && !options.compact {
let delta = ui.input(|i| i.pointer.delta().x) * if left { 1.0 } else { -1.0 };
@@ -838,7 +840,7 @@ impl<'a> Panel<'a> {
.inner
});
scenario::publish_count("dialog:body:content_height", f64::from(scroll.content_size.y));
- scenario::publish_count("dialog:body:scroll_y", f64::from(scroll.state.offset.y));
+ scenario::publish_count("dialog:body:scroll_y", f64::from(scroll.state.clamped_offset().y));
scenario::publish_rect("dialog:body:viewport", scroll.inner_rect);
scroll.inner
})
@@ -864,7 +866,7 @@ impl<'a> Panel<'a> {
egui::Spinner::new().size(t.space_14).paint_at(ui, rect);
scenario::publish_rect("dialog:footer:spinner", rect);
let status = state.text.as_deref().unwrap_or_else(|| crate::i18n::tr_label("Updating the preview"));
- ui.interact(rect, ui.id().with("compute_status"), egui::Sense::hover()).backing_on_hover_text(status);
+ ui.interact(rect, ui.scope_id().with("compute_status"), egui::Sense::hover()).backing_on_hover_text(status);
ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));
}
},
@@ -1331,7 +1333,7 @@ fn page_list_sized<S>(
ui.scope_builder(egui::UiBuilder::new().max_rect(list), |ui| {
ui.set_clip_rect(ui.clip_rect().intersect(nav));
ui.spacing_mut().item_spacing.y = t.space_2;
- let selection_id = ui.id().with("page_selection");
+ let selection_id = ui.scope_id().with("page_selection");
let changed = ui.data_mut(|data| {
let previous = data.get_temp::<usize>(selection_id);
data.insert_temp(selection_id, *selected);
@@ -1374,7 +1376,7 @@ fn page_list_sized<S>(
ink,
false,
);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, ui.is_enabled(), on, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), on, label));
if response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
diff --git a/crates/ui-egui/src/ui_kit/panel_tests.rs b/crates/ui-egui/src/ui_kit/panel_tests.rs
index 5c7cb5d2aa..c5a23fea05 100644
--- a/crates/ui-egui/src/ui_kit/panel_tests.rs
+++ b/crates/ui-egui/src/ui_kit/panel_tests.rs
@@ -47,15 +47,15 @@ fn blur_host_fixture(host: BlurHost, mode: u8, position: egui::Pos2, transform:
.inner_margin(egui::Margin { left: 9, right: 13, top: 7, bottom: 11 })
.outer_margin(egui::Margin { left: -2, right: 3, top: -1, bottom: 4 })
.corner_radius(egui::CornerRadius { nw: 3, ne: 7, sw: 11, se: 15 });
- let id = egui::Id::new("stock host fixture");
+ let id = egui::Id::unique("stock host fixture");
let mut output = egui::FullOutput::default();
let mut observation = String::new();
for _ in 0..3 {
output = crate::test_support::frame(&ctx, egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| {
ui.multiply_opacity(0.75);
let mut body = |ui: &mut egui::Ui| {
- let stack: Vec<_> = ui.stack().iter().map(|node| (node.id, node.kind(), *node.frame())).collect();
- let semantic = format!("{:?}", (ui.id(), ui.max_rect(), ui.clip_rect(), ui.stack().bg_color(), stack));
+ let stack: Vec<_> = ui.stack().iter().map(|node| (node.scope_id, node.kind(), *node.frame())).collect();
+ let semantic = format!("{:?}", (ui.scope_id(), ui.max_rect(), ui.clip_rect(), ui.stack().bg_color(), stack));
ui.allocate_space(egui::vec2(83.0, 47.0));
let response = ui.button("Content stays above its frame");
// A child changing its content clip must not cut the host's padding/border.
@@ -143,7 +143,7 @@ fn blur_stock_window_open_flag_preserves_closed_close_and_reopen_behavior() {
let ctx = crate::fonts::test_context();
let container = Container::for_layout(crate::shell::LayoutMode::Floating, Surface::Feature);
let frame = container.frame(&ctx, Tokens::get().dialog_body, crate::frame::Side::Left);
- let id = egui::Id::new("open flag fixture");
+ let id = egui::Id::unique("open flag fixture");
let mut recorded = Vec::new();
for (index, mut keep) in [false, false, true, true, true, false, false, false, true, true, true].into_iter().enumerate() {
let mut observation = String::new();
@@ -411,7 +411,7 @@ fn panel_keeps_actions_and_body_geometry_in_both_layouts() {
let side = crate::frame::Side::Right;
let frame = Panel::feature_frame(&ctx, layout, side);
let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
- let panel = Panel::new("Fillet", egui::Id::new("gallery_feature"), anchor, vp, side, frame);
+ let panel = Panel::new("Fillet", egui::Id::unique("gallery_feature"), anchor, vp, side, frame);
panel.window(&ctx).show(&ctx, |ui| {
panel.feature(
ui,
@@ -468,7 +468,7 @@ fn feature_frame_with(
let side = crate::frame::Side::Right;
let frame = Panel::feature_frame(ctx, crate::shell::LayoutMode::Floating, side);
let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
- let panel = Panel::new("Fillet", egui::Id::new("top_actions"), anchor, vp, side, frame);
+ let panel = Panel::new("Fillet", egui::Id::unique("top_actions"), anchor, vp, side, frame);
panel.window(ctx).show(ctx, |ui| {
let heading = FeatureOptions {
icon: "fillet",
@@ -558,7 +558,7 @@ fn top_placement_shows_the_compute_status_in_the_title_row() {
let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
let panel = Panel::new(
"Fillet",
- egui::Id::new("top_status"),
+ egui::Id::unique("top_status"),
anchor,
vp,
side,
@@ -601,7 +601,7 @@ fn bottom_placement_puts_the_busy_spinner_in_the_footer_row() {
let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
let panel = Panel::new(
"Fillet",
- egui::Id::new("bottom_status"),
+ egui::Id::unique("bottom_status"),
anchor,
vp,
side,
@@ -662,7 +662,7 @@ fn palette_scrolls_short_views_and_retains_its_status_and_action_handles() {
let bottom = vp.bottom() - crate::shell::SHELL_GAP;
let panel = Panel::new(
"Options",
- egui::Id::new("gallery_palette"),
+ egui::Id::unique("gallery_palette"),
egui::pos2(vp.right() - crate::shell::SHELL_GAP, 0.0),
vp,
crate::frame::Side::Right,
@@ -717,7 +717,8 @@ fn wide_tables_remain_bounded_with_pinned_actions_on_small_viewports() {
crate::test_support::frame(&ctx, egui::RawInput { screen_rect: Some(viewport), ..Default::default() }, |_| {
let side = crate::frame::Side::Right;
let anchor = viewport.right_top();
- let panel = Panel::new("Table", egui::Id::new("wide"), anchor, viewport, side, Panel::feature_frame(&ctx, layout, side)).wide();
+ let panel =
+ Panel::new("Table", egui::Id::unique("wide"), anchor, viewport, side, Panel::feature_frame(&ctx, layout, side)).wide();
panel.window(&ctx).show(&ctx, |ui| {
panel.feature(
ui,
@@ -767,7 +768,7 @@ fn window_is_one_and_a_half_cards_wide_with_its_actions_in_both_themes() {
..Default::default()
},
|ui| {
- action = Window::new(egui::Id::new("prompt_test"), "delete", "Delete")
+ action = Window::new(egui::Id::unique("prompt_test"), "delete", "Delete")
.actions("Delete", "Cancel", Some("Keep"))
.show(ui.ctx(), true, |ui| {
text(ui, "Three features go with it.", Text::Report("body", false));
@@ -807,7 +808,7 @@ fn escape_closes_a_window_unless_it_keeps_the_card_open() {
..Default::default()
},
|ui| {
- let prompt = Window::new(egui::Id::new(("prompt_escape", keep)), "settings", "Report").actions("Open", "Close", None);
+ let prompt = Window::new(egui::Id::unique(("prompt_escape", keep)), "settings", "Report").actions("Open", "Close", None);
let prompt = if keep { prompt.keep_open_on_escape() } else { prompt };
action = prompt
.show(ui.ctx(), true, |ui| {
@@ -863,7 +864,7 @@ fn window_pages_have_shared_metrics_callbacks_and_a_pinned_left_footer_action()
..Default::default()
},
|ui| {
- Window::new(ui.id().with("pages"), "settings", "Preferences").cards(3.0).show_pages(
+ Window::new(ui.scope_id().with("pages"), "settings", "Preferences").cards(3.0).show_pages(
ui.ctx(),
&mut selected,
&pages,
@@ -899,7 +900,7 @@ fn window_pages_have_shared_metrics_callbacks_and_a_pinned_left_footer_action()
..Default::default()
},
|ui| {
- Window::new(ui.id().with("pages"), "settings", "Preferences").cards(3.0).show_pages(
+ Window::new(ui.scope_id().with("pages"), "settings", "Preferences").cards(3.0).show_pages(
ui.ctx(),
&mut selected,
&pages,
@@ -941,7 +942,7 @@ fn page_window_is_as_opaque_as_every_other_window_in_both_themes() {
..Default::default()
},
|ui| {
- let window = Window::new(ui.id().with("opaque"), "settings", "Preferences");
+ let window = Window::new(ui.scope_id().with("opaque"), "settings", "Preferences");
if pages {
window.cards(3.0).show_pages(ui.ctx(), &mut selected, &list, &mut (), |_| {});
} else {
@@ -1014,7 +1015,7 @@ fn confirm_routes_enter_escape_selected_answers_and_blocks_background_clicks() {
let button = button(ui, "Background", Button::Normal);
at = button.rect.center();
background |= button.clicked();
- action = Confirm::new(ui.id().with("modal"), "status_warning", "Save changes?")
+ action = Confirm::new(ui.scope_id().with("modal"), "status_warning", "Save changes?")
.tone(Tone::Warning)
.actions("Save", "Cancel", Some("Don't Save"))
.secondary_left()
@@ -1123,7 +1124,7 @@ fn destructive_confirm_paints_error_primary_with_readable_on_colour_in_both_them
..Default::default()
},
|ui| {
- Confirm::new(ui.id().with("delete"), "delete", "Delete").tone(Tone::Danger).actions("Delete", "Cancel", None).show(
+ Confirm::new(ui.scope_id().with("delete"), "delete", "Delete").tone(Tone::Danger).actions("Delete", "Cancel", None).show(
ui.ctx(),
true,
|ui| {
@@ -1228,7 +1229,7 @@ fn window_footer_is_optional_and_can_contain_only_a_left_action() {
for _ in 0..3 {
scenario::clear_handles();
frame(&ctx, vec![], |ui| {
- let window = Window::new(ui.id().with("optional_footer"), "settings", "Preferences").actions("", "", None);
+ let window = Window::new(ui.scope_id().with("optional_footer"), "settings", "Preferences").actions("", "", None);
if left {
window.show_with_left(
ui.ctx(),
@@ -1301,7 +1302,7 @@ fn required_platform_window_keeps_recovery_pending_until_an_explicit_choice() {
for _ in 0..3 {
scenario::clear_handles();
frame(&ctx, vec![], |ui| {
- assert!(!Window::new(ui.id().with("required_recovery"), "restore", "Recover unsaved work?").required().show_body(ui.ctx(), |ui| {
+ assert!(!Window::new(ui.scope_id().with("required_recovery"), "restore", "Recover unsaved work?").required().show_body(ui.ctx(), |ui| {
button(ui, "Recover", Button::Normal);
button(ui, "Discard", Button::Normal);
}));
@@ -1333,7 +1334,7 @@ fn window_body_buttons_stay_visible_after_the_page_grows_from_nothing() {
};
buttons.clear();
crate::test_support::frame(&ctx, input, |ui| {
- let window = Window::new(egui::Id::new("sc_browser_recovery"), "restore", "Recover unsaved work?");
+ let window = Window::new(egui::Id::unique("sc_browser_recovery"), "restore", "Recover unsaved work?");
let body = |ui: &mut Ui| {
ui.label("“Bracket” had unsaved changes when this page last closed.");
ui.horizontal(|ui| {
@@ -1584,7 +1585,7 @@ fn bevel_lighting_reverses_for_fields_and_pressed_buttons_without_changing_geome
ui.set_width(240.0);
scope(ui, |ui| {
button_rect = button(ui, "Review", Button::Normal).rect;
- field_rect = cell_editor(ui, egui::Id::new("bevel-field"), &mut text, "", false).rect;
+ field_rect = cell_editor(ui, egui::Id::unique("bevel-field"), &mut text, "", false).rect;
});
};
fn top_color(output: &egui::FullOutput, rect: Rect, inset: f32) -> Color32 {
@@ -1609,7 +1610,7 @@ fn bevel_lighting_reverses_for_fields_and_pressed_buttons_without_changing_geome
ui.set_width(240.0);
scope(ui, |ui| {
button_rect = button(ui, "Review", Button::Normal).rect;
- cell_editor(ui, egui::Id::new("bevel-field"), &mut text, "", false);
+ cell_editor(ui, egui::Id::unique("bevel-field"), &mut text, "", false);
});
};
let down = crate::test_support::frame(
@@ -1632,7 +1633,7 @@ fn a_left_panel_in_an_inside_out_view_keeps_an_anchor() {
let inside_out = egui::Rect::from_min_max(egui::pos2(264.1875, 40.0), egui::pos2(159.0, 600.0));
let panel = super::Panel::new(
"Panel",
- egui::Id::new("inside_out_panel"),
+ egui::Id::unique("inside_out_panel"),
egui::pos2(200.0, 80.0),
inside_out,
crate::frame::Side::Left,
@@ -1656,6 +1657,7 @@ fn page_sidebar_footer_stays_visible_when_the_page_list_scrolls() {
h.frame_with(vec![
egui::Event::PointerMoved(egui::pos2(nav.center().x, nav.top() + 30.0)),
egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: egui::vec2(0.0, -1000.0),
modifiers: egui::Modifiers::NONE,
diff --git a/crates/ui-egui/src/ui_kit/preferences.rs b/crates/ui-egui/src/ui_kit/preferences.rs
index 9d79a75fc5..4f13cd0539 100644
--- a/crates/ui-egui/src/ui_kit/preferences.rs
+++ b/crates/ui-egui/src/ui_kit/preferences.rs
@@ -401,7 +401,7 @@ fn theme_option_switch(ui: &mut Ui, label: &str, on: &mut bool) {
if response.has_focus() {
ui.painter().rect_stroke(rect, t.control_radius, Stroke::new(t.space_2, t.form_primary), egui::StrokeKind::Inside);
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), *on, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::CheckBox, ui.is_enabled(), *on, label));
scenario::publish_target(&format!("prefs:theme_option_switch:{label}"), response.rect);
}
@@ -460,7 +460,7 @@ pub(crate) fn settings_heading_with_tag(ui: &mut Ui, title: &str, description: &
ui.spacing_mut().item_spacing.y = t.space_3;
let (rect, response) =
ui.allocate_exact_size(vec2(dimension(ui.available_width()), if page { t.space_24 } else { t.space_16 + t.space_3 }), Sense::hover());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), title));
paint_text(ui, rect, title, crate::fonts::semibold(if page { t.font_page_heading } else { t.font_intro }), t.form_ink, false);
if let Some(tag) = tag {
let width = ui
@@ -635,7 +635,7 @@ pub(crate) fn theme_import_tile(ui: &mut Ui, label: &str, note: &str) -> Respons
FontId::proportional(t.font_small),
t.form_dim,
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
scenario::publish_target(&format!("dialog:{label}"), r);
response.on_hover_cursor(egui::CursorIcon::PointingHand)
}
@@ -759,7 +759,7 @@ pub(crate) fn option_card(ui: &mut Ui, label: &str, note: Option<&str>, selected
ui.painter().line_segment([centre + vec2(-t.space_4, 0.0), centre + vec2(-t.space_2, t.space_2)], Stroke::new(2.0, ink));
ui.painter().line_segment([centre + vec2(-t.space_2, t.space_2), centre + vec2(t.space_4, -t.space_3)], Stroke::new(2.0, ink));
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::RadioButton, enabled, selected, label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::RadioButton, enabled, selected, label));
scenario::publish_target(&format!("prefs:option:{label}"), rect);
let response = response.backing_on_hover_text(label);
if enabled { response.on_hover_cursor(egui::CursorIcon::PointingHand) } else { response }
@@ -970,7 +970,7 @@ pub(crate) fn settings_inline_note(ui: &mut Ui, text: &str) {
ui.painter().layout_no_wrap(text.to_owned(), FontId::proportional(t.font_body), t.form_dim)
};
let (r, response) = ui.allocate_exact_size(galley.size(), Sense::hover());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
ui.painter().galley(r.min, galley, t.form_dim);
}
diff --git a/crates/ui-egui/src/ui_kit/preferences_assistant.rs b/crates/ui-egui/src/ui_kit/preferences_assistant.rs
index 7cd8a77173..84d142f3cc 100644
--- a/crates/ui-egui/src/ui_kit/preferences_assistant.rs
+++ b/crates/ui-egui/src/ui_kit/preferences_assistant.rs
@@ -134,7 +134,7 @@ fn choice_card(ui: &mut Ui, width: f32, choice: &SettingsChoice<'_>, selected: b
crate::prefs_search::follow(ui, text, rect);
}
response.widget_info(|| {
- egui::WidgetInfo::selected(egui::WidgetType::RadioButton, ui.is_enabled(), selected, format!("{}: {}", choice.title, choice.detail))
+ egui::WidgetInfo::selected(egui::Role::RadioButton, ui.is_enabled(), selected, format!("{}: {}", choice.title, choice.detail))
});
scenario::publish_target(choice.key, rect);
response.backing_on_hover_text(choice.detail).on_hover_cursor(egui::CursorIcon::PointingHand)
@@ -161,7 +161,7 @@ pub(crate) fn settings_pointer_preview(ui: &mut Ui, visible: bool, speed: &str,
};
let caption_rect = Rect::from_min_max(rect.min + vec2(t.space_8, t.space_4), pos2(rect.right() - t.space_8, rect.top() + t.space_24));
paint_text(ui, caption_rect, &caption, FontId::proportional(t.font_small), t.form_dim, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), &caption));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), &caption));
response.backing_on_hover_text(crate::i18n::tr(if follows_camera { "ai.prefs.follow_camera_on" } else { "ai.prefs.follow_camera_off" }));
}
@@ -170,6 +170,6 @@ pub(crate) fn settings_short_note(ui: &mut Ui, text: &str) -> Response {
let t = Tokens::get();
let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_16), Sense::hover());
paint_text(ui, rect, text, FontId::proportional(t.font_small), t.form_dim, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
response.backing_on_hover_text(text)
}
diff --git a/crates/ui-egui/src/ui_kit/preferences_cards.rs b/crates/ui-egui/src/ui_kit/preferences_cards.rs
index 77b5f7ddc3..54fbf9d025 100644
--- a/crates/ui-egui/src/ui_kit/preferences_cards.rs
+++ b/crates/ui-egui/src/ui_kit/preferences_cards.rs
@@ -185,7 +185,7 @@ fn paint_card(ui: &mut Ui, card: &Card, width: f32, tile: bool) -> Response {
crate::icons::paint_ink(p, dot, "settings", dim(t.on_accent));
}
}
- let kind = if tile { egui::WidgetType::Checkbox } else { egui::WidgetType::RadioButton };
+ let kind = if tile { egui::Role::CheckBox } else { egui::Role::RadioButton };
response.widget_info(|| egui::WidgetInfo::selected(kind, enabled, card.selected, card.label));
scenario::publish_target(&format!("prefs:card:{}", card.label), rect);
let response = response.backing_on_hover_text(card.label);
@@ -372,7 +372,7 @@ pub(crate) fn preset_card(
p.circle_filled(centre, t.space_8 + 1.0, dim(t.form_primary));
tick(p, Rect::from_center_size(centre, vec2(t.space_12, t.space_12)), dim(t.on_accent));
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::RadioButton, enabled, selected, name));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::RadioButton, enabled, selected, name));
scenario::publish_target(&format!("prefs:preset:{name}"), rect);
if enabled { response.on_hover_cursor(egui::CursorIcon::PointingHand) } else { response }
}
@@ -387,7 +387,7 @@ pub(crate) fn help_icon(ui: &mut Ui, text: &str) -> Response {
p.circle_stroke(rect.center(), size * 0.5 - 0.5, Stroke::new(1.0, ink));
p.circle_filled(pos2(rect.center().x, rect.top() + size * 0.3), 0.9, ink);
p.line_segment([pos2(rect.center().x, rect.top() + size * 0.46), pos2(rect.center().x, rect.bottom() - size * 0.24)], Stroke::new(1.2, ink));
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
scenario::publish_target("prefs:help_icon", rect);
response.backing_on_hover_text(text)
}
@@ -460,7 +460,7 @@ fn carousel_arrow(ui: &mut Ui, size: egui::Vec2, direction: f32, enabled: bool,
if enabled && response.has_focus() {
p.rect_stroke(rect.expand(t.space_2), f32::from(t.radius_lg) + t.space_2, Stroke::new(t.space_2, t.form_primary), StrokeKind::Outside);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, label));
scenario::publish_target(&format!("prefs:carousel:{label}"), rect);
if enabled { response.on_hover_cursor(egui::CursorIcon::PointingHand) } else { response }
}
@@ -534,7 +534,7 @@ pub(crate) fn settings_plugin_card(
let icon = Rect::from_center_size(pos2(folder_rect.left() + t.space_8 + t.space_14 / 2.0, center_y), vec2(t.space_14, t.space_14));
crate::icons::paint_ink(ui.painter(), icon, "folder", t.form_dim);
ui.painter().galley(pos2(icon.right() + t.space_6, center_y - folder_galley.size().y / 2.0), folder_galley, t.form_dim);
- folder.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), folder_label));
+ folder.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), folder_label));
if folder.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
diff --git a/crates/ui-egui/src/ui_kit/preferences_navigation.rs b/crates/ui-egui/src/ui_kit/preferences_navigation.rs
index e1339f1867..85734a8103 100644
--- a/crates/ui-egui/src/ui_kit/preferences_navigation.rs
+++ b/crates/ui-egui/src/ui_kit/preferences_navigation.rs
@@ -118,7 +118,7 @@ pub(crate) fn settings_axis_row(
} else {
let [label_rect, live_rect, invert_rect, speed_rect, source_rect] = axis_columns(rect);
paint_text(ui, label_rect, name, FontId::proportional(t.font_label), t.form_ink, false);
- ui.interact(label_rect, ui.id().with("axis_name"), Sense::hover()).backing_on_hover_text(name);
+ ui.interact(label_rect, ui.scope_id().with("axis_name"), Sense::hover()).backing_on_hover_text(name);
let live_rect = Rect::from_center_size(live_rect.center(), vec2(live_rect.width(), t.space_14));
live_axis_bar_in(ui, live_rect, value, dead_zone);
axis_control(ui, invert_rect, "invert", name, invert);
diff --git a/crates/ui-egui/src/ui_kit/preferences_small.rs b/crates/ui-egui/src/ui_kit/preferences_small.rs
index 3971b80727..056f51d3db 100644
--- a/crates/ui-egui/src/ui_kit/preferences_small.rs
+++ b/crates/ui-egui/src/ui_kit/preferences_small.rs
@@ -55,7 +55,7 @@ pub(crate) fn settings_change_dot(ui: &mut Ui, label: &str) -> egui::Response {
let t = Tokens::get();
let (rect, response) = ui.allocate_exact_size(vec2(t.space_8, t.space_8), Sense::hover());
ui.painter().circle_filled(rect.center(), (t.space_8 - t.space_2 / 2.0) / 2.0, t.pref_note);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), label));
response.backing_on_hover_text(label)
}
@@ -100,7 +100,7 @@ pub(crate) fn settings_profile_button(ui: &mut Ui, label: &str, name: &str, edit
if response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), name));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), name));
crate::scenario::publish_rect("prefs:profile:sidebar_card", response.rect);
response.backing_on_hover_text(label)
}
@@ -125,7 +125,7 @@ pub(crate) fn settings_state_badge(ui: &mut Ui, label: &str, tone: SettingsBadge
} else {
ui.painter().galley(rect.center() - galley.size() / 2.0, galley, ink);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), label));
if clipped { response.backing_on_hover_text(label) } else { response }
}
@@ -182,7 +182,7 @@ pub(crate) fn settings_chip(ui: &mut Ui, label: &str, chip: SettingsChip<'_>) ->
let text_left = (rect.left() + t.space_8 + icon_width).min(rect.right());
let text_rect = Rect::from_min_max(pos2(text_left, rect.top()), pos2((rect.right() - t.space_8 - remove_width).max(text_left), rect.bottom()));
super::text::paint_text(ui, text_rect, label, font, ink, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), label));
if let Some(remove) = chip.remove {
let target = Rect::from_min_max(pos2((rect.right() - t.space_24).max(rect.left()), rect.top()), rect.max);
if let Some(key) = chip.key {
@@ -353,8 +353,7 @@ pub(crate) fn settings_bindings(ui: &mut Ui, bindings: &[(&[&str], &str)]) {
let action = ui.painter().layout((*action).to_owned(), FontId::proportional(t.font_label), t.form_ink, (width - action_left).max(0.0));
let height = (action_top + action.size().y + t.space_4).max(keys_bottom).max(t.control_height + t.space_2);
let (r, response) = ui.allocate_exact_size(vec2(width, height), Sense::hover());
- response
- .widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{}: {}", keys.join(" + "), action.text())));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), format!("{}: {}", keys.join(" + "), action.text())));
t.secondary_hline(ui.painter(), r.x_range(), r.bottom(), t.dialog_rule);
for (key, cap) in caps {
let cap = cap.translate(r.min.to_vec2());
@@ -370,6 +369,6 @@ pub(crate) fn settings_precision_sample(ui: &mut Ui, text: &str) {
let t = Tokens::get();
let galley = ui.painter().layout_no_wrap(text.to_owned(), FontId::monospace(t.font_body), t.form_dim);
let (r, response) = ui.allocate_exact_size(galley.size(), Sense::hover());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), text));
ui.painter().galley(r.min, galley, t.form_dim);
}
diff --git a/crates/ui-egui/src/ui_kit/radial.rs b/crates/ui-egui/src/ui_kit/radial.rs
index 884ebc8e38..4eef73a8c8 100644
--- a/crates/ui-egui/src/ui_kit/radial.rs
+++ b/crates/ui-egui/src/ui_kit/radial.rs
@@ -109,7 +109,7 @@ pub(crate) fn radial_menu(ui: &mut Ui, center: Pos2, items: &[Item], hot: Option
let a = -FRAC_PI_2 + k as f32 * FRAC_PI_4;
let at = center + unit(a) * 104.0;
let target = Rect::from_center_size(at, vec2(t.space_24 * 2.0 + t.space_12, t.space_24 + t.space_16 + t.space_2));
- let response = ui.interact(target, ui.id().with(("radial", k)), Sense::hover());
+ let response = ui.interact(target, ui.scope_id().with(("radial", k)), Sense::hover());
crate::scenario::publish_target(&format!("radial:{}", item.id), target);
let ink = if lit { accent.ink } else { t.form_ink };
crate::icons::paint_accented(
@@ -125,7 +125,7 @@ pub(crate) fn radial_menu(ui: &mut Ui, center: Pos2, items: &[Item], hot: Option
job.wrap.max_rows = 1;
let galley = painter.layout_job(job);
painter.galley(at + vec2(-galley.size().x / 2.0, t.space_10), galley, ink);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, label));
if lit && ui.input(|i| i.pointer.primary_clicked() && i.pointer.interact_pos().is_some_and(|p| contains(k, p - center))) {
picked = Some(item.clone());
}
diff --git a/crates/ui-egui/src/ui_kit/reports.rs b/crates/ui-egui/src/ui_kit/reports.rs
index 0731a7d8b5..bcac64976a 100644
--- a/crates/ui-egui/src/ui_kit/reports.rs
+++ b/crates/ui-egui/src/ui_kit/reports.rs
@@ -67,7 +67,7 @@ pub(crate) fn path_chip(ui: &mut Ui, path: &str, add: impl FnOnce(&mut Ui)) {
let (rect, response) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), t.control_height), egui::Sense::hover());
ui.painter().rect(rect, t.control_radius, t.dialog_footer, t.tertiary_border(t.dialog_rule), egui::StrokeKind::Inside);
super::text::paint_text(ui, rect.shrink2(vec2(t.space_8, 0.0)), path, egui::FontId::monospace(t.font_small), t.form_dim, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), path));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), path));
response.backing_on_hover_text(path);
let key = format!("dialog:cell:{path}");
scenario::publish_handle(&key, rect.center());
@@ -87,7 +87,7 @@ pub(crate) fn empty_box(ui: &mut Ui, key: &str, message: &str) {
}
let t = Tokens::get();
let (rect, response) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), t.control_height * 3.0), egui::Sense::hover());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), message));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), message));
let mut points = super::preferences::rounded_perimeter(rect.shrink(0.5), f32::from(t.radius_lg));
if let Some(first) = points.first().copied() {
points.push(first);
@@ -135,7 +135,7 @@ pub(crate) fn report_header(ui: &mut Ui, kind: &str, count: u64, time: &str, ali
t.form_dim,
false,
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), alias));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), alias));
response.backing_on_hover_text(alias);
let key = format!("dialog:cell:{alias}");
scenario::publish_rect(&key, rect);
diff --git a/crates/ui-egui/src/ui_kit/review.rs b/crates/ui-egui/src/ui_kit/review.rs
index e287625185..08018a122c 100644
--- a/crates/ui-egui/src/ui_kit/review.rs
+++ b/crates/ui-egui/src/ui_kit/review.rs
@@ -17,7 +17,7 @@ pub(crate) struct ReviewAndApply<'a> {
impl ReviewAndApply<'_> {
pub(crate) fn show(&self, ctx: &egui::Context, valid: bool, acknowledged: &mut bool, content: impl FnOnce(&mut egui::Ui)) -> (bool, Action) {
- Confirm::new(egui::Id::new("render_review_apply"), "inspect", self.title)
+ Confirm::new(egui::Id::unique("render_review_apply"), "inspect", self.title)
.actions(self.apply, tr("ui.cancel"), self.copy.then(|| tr("render.physical_copy_plan")))
.secondary_left()
.show(ctx, valid && *acknowledged, |ui| self.content(ui, acknowledged, content))
diff --git a/crates/ui-egui/src/ui_kit/search.rs b/crates/ui-egui/src/ui_kit/search.rs
index 046e0e137e..61057571f4 100644
--- a/crates/ui-egui/src/ui_kit/search.rs
+++ b/crates/ui-egui/src/ui_kit/search.rs
@@ -94,7 +94,7 @@ impl CommandSearch {
let SearchFieldGeometry { height, radius, progress } = geometry;
let spacing = FieldSpacing::at(progress);
let (r, _) = ui.allocate_exact_size(vec2(ui.available_width(), height), Sense::hover());
- let focused = open && (focus || ui.memory(|m| m.has_focus(egui::Id::new("sc_sbox_text"))));
+ let focused = open && (focus || ui.memory(|m| m.has_focus(egui::Id::unique("sc_sbox_text"))));
let ink = if invalid {
t.form_error
} else if focused {
@@ -125,7 +125,9 @@ impl CommandSearch {
crate::scenario::publish_target("ribbon:search", r);
crate::scenario::publish_target("shortcut:search", r);
crate::scenario::publish_target("palette:search", r);
- return ui.interact(r, egui::Id::new("sc_sbox_compact"), Sense::click()).backing_on_hover_text(crate::i18n::tr_label("Search commands"));
+ return ui
+ .interact(r, egui::Id::unique("sc_sbox_compact"), Sense::click())
+ .backing_on_hover_text(crate::i18n::tr_label("Search commands"));
}
icons::paint_icon(
ui.painter(),
@@ -144,12 +146,15 @@ impl CommandSearch {
let response = ui
.scope_builder(egui::UiBuilder::new().max_rect(editor), |ui| {
ui.set_clip_rect(ui.clip_rect().intersect(editor));
+ // egui 0.37 floors a text edit's height at the theme's interact height, which centred
+ // the text below the field's middle.
+ ui.spacing_mut().interact_size.y = height;
ui.add_sized(
editor.size(),
super::fields::text_input(egui::TextEdit::singleline(value))
.min_size(vec2(0.0, height))
.margin(vec2(spacing.editor_margin, 0.0))
- .id(egui::Id::new("sc_sbox_text"))
+ .id(egui::Id::unique("sc_sbox_text"))
.char_limit(limit)
.interactive(open)
.frame(egui::Frame::NONE)
@@ -203,7 +208,7 @@ impl CommandSearch {
/// remembered natural height is refreshed with a sizing pass when results change.
pub(crate) fn sheet(ui: &mut Ui, width: f32, progress: f32, command: bool, add: impl FnOnce(&mut Ui)) -> Rect {
let t = Tokens::get();
- let id = ui.id().with("search_sheet_height");
+ let id = ui.scope_id().with("search_sheet_height");
let known = ui.ctx().data(|d| d.get_temp::<f32>(id)).unwrap_or(0.0);
let origin = ui.cursor().min;
let clip = Rect::from_min_size(origin, vec2(width, known * progress));
@@ -352,7 +357,7 @@ impl super::MenuItem<'_> {
} else {
super::text::paint_text(ui, path_rect, path, FontId::proportional(t.font_small), t.form_dim, false);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, self.enabled, label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, self.enabled, label));
crate::scenario::publish_target(&format!("menu:{}", self.id), r);
response
}
@@ -413,9 +418,10 @@ mod tests {
let radius = CommandSearch::field_radius(progress, floating);
let ctx = crate::fonts::test_context();
let mut query = String::new();
- let output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
CommandSearch::field(ui, &mut query, false, true, true, SearchFieldGeometry { height: 40.0, radius, progress }, 4096);
});
+ output.textures_delta.clear();
for shape in output.shapes {
if let egui::Shape::Rect(rect) = shape.shape
&& (rect.fill == tokens.control_fill || rect.fill == tokens.accent_soft)
diff --git a/crates/ui-egui/src/ui_kit/shortcuts.rs b/crates/ui-egui/src/ui_kit/shortcuts.rs
index f6e4f07c6f..7282d1b54a 100644
--- a/crates/ui-egui/src/ui_kit/shortcuts.rs
+++ b/crates/ui-egui/src/ui_kit/shortcuts.rs
@@ -54,7 +54,7 @@ pub(crate) fn shortcut_binding(ui: &mut Ui, chord: &str, editable: bool) -> Resp
}
response.widget_info(|| {
egui::WidgetInfo::labeled(
- if editable { egui::WidgetType::Button } else { egui::WidgetType::Label },
+ if editable { egui::Role::Button } else { egui::Role::Label },
ui.is_enabled(),
if chord.is_empty() { crate::i18n::tr("prefs.shortcuts_not_assigned") } else { chord },
)
@@ -109,7 +109,7 @@ fn search_with_icon(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &str) -
if show_clear {
let clear_rect = Rect::from_center_size(pos2(r.right() - height * 0.5, r.center().y), vec2(height, height));
let clear = ui.push_id(id.with("clear"), |ui| super::quiet_icon_button_at(ui, clear_rect, "close", "Clear")).inner;
- if id == egui::Id::new("prefs_search") {
+ if id == egui::Id::unique("prefs_search") {
crate::scenario::publish_handle("prefs:search:clear", clear_rect.center());
}
if clear.clicked() {
@@ -120,9 +120,9 @@ fn search_with_icon(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &str) -
if frame.clicked() && !cleared {
response.request_focus();
}
- super::layout::publish(ui, &response, egui::WidgetType::TextEdit);
+ super::layout::publish(ui, &response, egui::Role::TextInput);
response.widget_info(|| {
- let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), crate::i18n::tr_label(hint));
+ let mut info = egui::WidgetInfo::labeled(egui::Role::TextInput, ui.is_enabled(), crate::i18n::tr_label(hint));
info.current_text_value = Some(value.clone());
info
});
diff --git a/crates/ui-egui/src/ui_kit/sphere.rs b/crates/ui-egui/src/ui_kit/sphere.rs
index e19650e01d..afe7aba569 100644
--- a/crates/ui-egui/src/ui_kit/sphere.rs
+++ b/crates/ui-egui/src/ui_kit/sphere.rs
@@ -121,7 +121,7 @@ pub(super) fn paint_sphere(ui: &Ui, rect: Rect, sphere: Sphere) {
}
let t = Tokens::get();
let key = sphere.key(rect.width());
- let mesh = ui.ctx().data_mut(|data| data.get_temp_mut_or_default::<SphereCache>(egui::Id::new("ui_kit:spheres")).mesh(key, &t));
+ let mesh = ui.ctx().data_mut(|data| data.get_temp_mut_or_default::<SphereCache>(egui::Id::unique("ui_kit:spheres")).mesh(key, &t));
if sphere.kind == FinishKind::Glass {
// A bounded four-by-four checker remains visible through the sphere.
for y in 0..4 {
@@ -294,7 +294,7 @@ impl SphereTile<'_> {
scenario::publish_rect(&format!("{}:label", self.id), label);
scenario::publish_rect(&format!("{}:galley", self.id), galley.rect.translate(label_pos.to_vec2()));
ui.painter().with_clip_rect(ui.clip_rect().intersect(label)).galley(label_pos, galley, t.form_ink);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), self.selected, self.name));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), self.selected, self.name));
scenario::publish_target(self.id, rect);
let mut tip = egui::Tooltip::for_enabled(&response);
tip.popup = tip.popup.frame(super::Container::new(ui.ctx(), super::Surface::Toast).tooltip_frame(ui.ctx()));
@@ -311,7 +311,7 @@ pub(crate) fn sphere_cursor(ui: &mut egui::Ui, sphere: Sphere) {
let t = Tokens::get();
let rect = Rect::from_min_size(pointer + vec2(t.space_12, t.space_12), vec2(t.control_height, t.control_height));
let mut ghost =
- ui.new_child(egui::UiBuilder::new().layer_id(egui::LayerId::new(egui::Order::Tooltip, egui::Id::new("sphere_cursor"))).max_rect(rect));
+ ui.new_child(egui::UiBuilder::new().layer_id(egui::LayerId::new(egui::Order::Tooltip, egui::Id::unique("sphere_cursor"))).max_rect(rect));
ghost.set_clip_rect(ui.ctx().content_rect());
paint_sphere(&ghost, rect, sphere);
}
diff --git a/crates/ui-egui/src/ui_kit/stages.rs b/crates/ui-egui/src/ui_kit/stages.rs
index c40991fb16..0b5fb9039e 100644
--- a/crates/ui-egui/src/ui_kit/stages.rs
+++ b/crates/ui-egui/src/ui_kit/stages.rs
@@ -199,7 +199,7 @@ impl StageBar {
if on { accent.ink } else { t.text },
false,
);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, true, on, *label));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, true, on, *label));
result.chips.push(chip.intersect(ui.clip_rect()));
if response.clicked() {
result.stage = Some(index);
@@ -223,7 +223,7 @@ impl StageBar {
// CommandSearch owns the actual field, focus, S shortcut and registered command dispatch.
let search = search.intersect(ui.clip_rect());
ui.ctx().data_mut(|d| {
- let id = egui::Id::new("sc_ribbon_search");
+ let id = egui::Id::unique("sc_ribbon_search");
if search.is_positive() {
d.insert_temp(id, search);
} else {
diff --git a/crates/ui-egui/src/ui_kit/status.rs b/crates/ui-egui/src/ui_kit/status.rs
index 1878a4c667..081a3651aa 100644
--- a/crates/ui-egui/src/ui_kit/status.rs
+++ b/crates/ui-egui/src/ui_kit/status.rs
@@ -57,7 +57,7 @@ pub(crate) fn progress(ui: &mut egui::Ui, key: &str, fraction: f32) -> egui::Res
if fraction > 0.0 {
ui.painter().rect_filled(egui::Rect::from_min_size(bar.min, vec2(bar.width() * fraction, bar.height())), t.space_3, t.form_primary);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ProgressIndicator, ui.is_enabled(), format!("{:.0}%", fraction * 100.0)));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::ProgressIndicator, ui.is_enabled(), format!("{:.0}%", fraction * 100.0)));
crate::scenario::publish_rect(&format!("dialog:progress:{key}"), bar);
response
}
@@ -131,7 +131,7 @@ pub(crate) fn steps(ui: &mut egui::Ui, key: &str, labels: &[&str], current: usiz
std::cmp::Ordering::Equal => "current",
std::cmp::Ordering::Greater => "next",
};
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), *label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), *label));
crate::scenario::publish_rect(&format!("dialog:step:{key}:{i}:{state}"), row);
crate::scenario::publish_rect(&format!("dialog:step_mark:{key}:{i}"), slot);
}
@@ -161,7 +161,7 @@ pub(crate) fn completion_text(ui: &mut egui::Ui, label: &str, complete: bool) ->
if complete { t.form_ink } else { t.form_dim },
false,
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), label));
response
}
diff --git a/crates/ui-egui/src/ui_kit/table.rs b/crates/ui-egui/src/ui_kit/table.rs
index 7aabce200a..8191e9b212 100644
--- a/crates/ui-egui/src/ui_kit/table.rs
+++ b/crates/ui-egui/src/ui_kit/table.rs
@@ -198,7 +198,10 @@ impl Table<'_> {
let (rect, response) = ui.allocate_exact_size(vec2(self.width(), row_height() - t.space_4), egui::Sense::click());
let stroke = t.control_border_stroke(t.control_border);
let mut outline = Vec::new();
- egui::epaint::tessellator::path::rounded_rectangle(&mut outline, rect.shrink(stroke.width * 0.5), f32::from(t.control_radius).into());
+ egui::epaint::tessellator::path::rounded_rectangle(
+ &mut outline,
+ egui::epaint::RoundedRect::new(rect.shrink(stroke.width * 0.5), f32::from(t.control_radius)),
+ );
if let Some(first) = outline.first().copied() {
outline.push(first);
}
@@ -213,7 +216,7 @@ impl Table<'_> {
t.form_dim,
false,
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::tr_label(label)));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::tr_label(label)));
scenario::publish_handle(&format!("dialog:table:{}:add", self.id), rect.center());
scenario::publish_rect(&format!("dialog:table:{}:add", self.id), rect);
response.on_hover_cursor(egui::CursorIcon::PointingHand).backing_on_hover_text(crate::i18n::tr_label(tooltip))
@@ -228,7 +231,7 @@ impl Table<'_> {
if selected || (ui.is_enabled() && ui.rect_contains_pointer(rect)) {
ui.painter().rect_filled(rect, t.control_radius, if selected { t.selected_bg } else { t.hover });
}
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::SelectableLabel, ui.is_enabled(), selected, key));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), selected, key));
scenario::publish_rect(&format!("dialog:table:{}:{key}", self.id), rect);
let ppp = ui.ctx().pixels_per_point().max(0.5);
let left = (rect.left() * ppp).round() / ppp + t.space_8;
@@ -391,7 +394,7 @@ pub(crate) fn sort_header(ui: &mut Ui, label: &str, sort: &mut Sort) -> Response
Sort::Ascending => "Sort Z to A",
Sort::Descending => "Back to the original order",
};
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), text));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), text));
response.on_hover_cursor(egui::CursorIcon::PointingHand).backing_on_hover_text(crate::i18n::tr_label(tip))
}
@@ -463,7 +466,7 @@ pub(crate) fn active_pill(ui: &mut Ui) {
let (rect, response) = ui.allocate_exact_size(vec2(width, t.font_small + t.space_6), egui::Sense::hover());
ui.painter().rect(rect, t.radius_xl, t.control_fill, t.control_border_stroke(t.control_border), egui::StrokeKind::Inside);
super::text::paint_text(ui, rect.shrink2(vec2(t.space_8, 0.0)), label, crate::fonts::semibold(t.font_small), t.form_primary, false);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), label));
scenario::publish_handle(&format!("dialog:inline:{label}"), rect.center());
scenario::publish_rect(&format!("dialog:inline:{label}"), rect);
}
diff --git a/crates/ui-egui/src/ui_kit/table_tests.rs b/crates/ui-egui/src/ui_kit/table_tests.rs
index 8a8ef0c7cc..e297b03ac5 100644
--- a/crates/ui-egui/src/ui_kit/table_tests.rs
+++ b/crates/ui-egui/src/ui_kit/table_tests.rs
@@ -24,7 +24,7 @@ fn fitting_flex_tables_have_no_horizontal_scrollbar_at_card_widths_and_pixel_sca
ui_kit::text(ui, "Width", ui_kit::Text::Cell);
});
row.cell(|ui| {
- ui_kit::cell_editor(ui, ui.id().with("value"), &mut "10 mm".into(), "", false);
+ ui_kit::cell_editor(ui, ui.scope_id().with("value"), &mut "10 mm".into(), "", false);
});
row.cell(|ui| {
ui_kit::text(ui, "10 mm", ui_kit::Text::MonoCell);
@@ -96,7 +96,7 @@ fn row_hover_paints_under_every_interactive_child_and_respects_clip_and_enabled(
ui_kit::text(ui, "Width", ui_kit::Text::Cell);
});
row.cell(|ui| {
- ui_kit::cell_editor(ui, ui.id().with("value"), &mut value, "", false);
+ ui_kit::cell_editor(ui, ui.scope_id().with("value"), &mut value, "", false);
});
row.cell(|ui| {
ui_kit::dropdown(ui, "choice", &mut selected, &["mm", "in"]);
@@ -203,7 +203,7 @@ fn hover_remove_bin_prompt_and_plus_menu_share_one_grid() {
if pending {
table.row(ui, "draft", false, |row| {
row.cell(|ui| {
- ui_kit::cell_editor(ui, ui.id().with("name"), &mut String::new(), "Name", false);
+ ui_kit::cell_editor(ui, ui.scope_id().with("name"), &mut String::new(), "Name", false);
});
row.cell(|ui| {
deleted |= bin_button(ui, "Delete").clicked();
diff --git a/crates/ui-egui/src/ui_kit/text_menu.rs b/crates/ui-egui/src/ui_kit/text_menu.rs
index db70ec644f..928fea18af 100644
--- a/crates/ui-egui/src/ui_kit/text_menu.rs
+++ b/crates/ui-egui/src/ui_kit/text_menu.rs
@@ -154,7 +154,7 @@ const OPEN: &str = "sc_text_menu_open";
/// meanwhile, rather than cover the menu.
pub(crate) fn menu_open(ctx: &egui::Context, field: egui::Id) -> bool {
let pass = ctx.cumulative_pass_nr();
- ctx.data(|d| d.get_temp::<(egui::Id, u64)>(egui::Id::new(OPEN))).is_some_and(|(id, drawn)| id == field && drawn == pass)
+ ctx.data(|d| d.get_temp::<(egui::Id, u64)>(egui::Id::unique(OPEN))).is_some_and(|(id, drawn)| id == field && drawn == pass)
}
#[cfg(test)]
@@ -198,16 +198,20 @@ fn keep_selection(ui: &Ui, response: &Response, len: usize) -> Option<CCursorRan
if !down {
kept = None;
}
+ // Read before `data_mut`: both lock the context's memory.
+ let focused = response.has_focus();
let range = match kept {
Some(keep) => {
state.cursor.set_char_range(Some(keep));
state.store(ctx, id);
Some(keep)
}
+ // The click on a menu row took the focus before the field drew, and egui 0.37 drops an
+ // unfocused field's selection: the row acts on the selection of the last focused frame.
+ // Drop once emilk/egui#8763 is fixed.
+ None if !focused => last.or(now),
None => now,
};
- // Read before `data_mut`: both lock the context's memory.
- let focused = response.has_focus();
ctx.data_mut(|d| {
match kept {
Some(keep) => {
@@ -262,7 +266,7 @@ pub(crate) fn menu(ui: &Ui, response: &mut Response, text: &mut dyn TextBuffer,
.is_some();
if open {
let pass = ui.ctx().cumulative_pass_nr();
- ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new(OPEN), (id, pass)));
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::unique(OPEN), (id, pass)));
}
if open && ui.ctx().input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) {
// Esc closes the menu alone: the field keeps its focus, and its owner (a dimension's box,
diff --git a/crates/ui-egui/src/ui_kit/tree.rs b/crates/ui-egui/src/ui_kit/tree.rs
index c97d00ffff..907ad90e9c 100644
--- a/crates/ui-egui/src/ui_kit/tree.rs
+++ b/crates/ui-egui/src/ui_kit/tree.rs
@@ -127,7 +127,7 @@ pub(crate) struct RowResp {
/// The state a drag over the eyes sets them to: the first eye's new state, while the button is
/// down (egui temporary data). Absent when no eye drag is under way.
pub(crate) fn eye_drag_id() -> egui::Id {
- egui::Id::new("sc_tree_eye_drag")
+ egui::Id::unique("sc_tree_eye_drag")
}
/// Geometry used by Browser culling and the shared row painter.
@@ -187,13 +187,13 @@ pub(crate) fn tree_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp {
if show {
super::quiet_icon_button_at(ui, rect, action.icon, action.label)
} else {
- ui.interact(rect, ui.id().with(action.target), Sense::hover())
+ ui.interact(rect, ui.scope_id().with(action.target), Sense::hover())
}
})
.inner
})
.inner;
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, response.enabled(), action.label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, response.enabled(), action.label));
let response = match action.reason {
Some(reason) => response.backing_on_disabled_hover_text(format!("{}\n{reason}", action.label)),
None => response.backing_on_hover_text(action.label),
diff --git a/crates/ui-egui/src/ui_kit/value_focus.rs b/crates/ui-egui/src/ui_kit/value_focus.rs
index f47f569789..63c78f0ff6 100644
--- a/crates/ui-egui/src/ui_kit/value_focus.rs
+++ b/crates/ui-egui/src/ui_kit/value_focus.rs
@@ -3,7 +3,7 @@
/// Collect the expression editors drawn by a form, in display order.
pub(crate) fn value_fields(ctx: &egui::Context, draw: impl FnOnce() -> bool) -> (bool, Vec<(egui::Id, usize)>) {
- let id = egui::Id::new("sc_value_fields");
+ let id = egui::Id::unique("sc_value_fields");
ctx.data_mut(|data| data.insert_temp(id, Vec::<(egui::Id, usize)>::new()));
let enter = draw();
let fields = ctx.data_mut(|data| data.remove_temp::<Vec<(egui::Id, usize)>>(id)).unwrap_or_default();
@@ -12,19 +12,20 @@ pub(crate) fn value_fields(ctx: &egui::Context, draw: impl FnOnce() -> bool) ->
/// The expression editor the form drew last so far, in [`value_fields`].
pub(crate) fn last_value_field(ctx: &egui::Context) -> Option<egui::Id> {
- ctx.data(|data| data.get_temp::<Vec<(egui::Id, usize)>>(egui::Id::new("sc_value_fields"))).and_then(|fields| fields.last().map(|(id, _)| *id))
+ ctx.data(|data| data.get_temp::<Vec<(egui::Id, usize)>>(egui::Id::unique("sc_value_fields"))).and_then(|fields| fields.last().map(|(id, _)| *id))
}
/// True while a text editor drawn by the kit holds the keyboard. A dialog uses this to keep at
/// most one field looking active: its pick fields drop their accent ring while a text field
/// has the keyboard (#10066).
pub(crate) fn editor_has_focus(ctx: &egui::Context) -> bool {
- ctx.data(|data| data.get_temp::<egui::Id>(egui::Id::new("sc_focused_editor"))).is_some_and(|id| ctx.memory(|memory| memory.focused() == Some(id)))
+ ctx.data(|data| data.get_temp::<egui::Id>(egui::Id::unique("sc_focused_editor")))
+ .is_some_and(|id| ctx.memory(|memory| memory.focused() == Some(id)))
}
/// Only a value box drawn this pass can receive the keyboard after a viewport pick.
pub(crate) fn canvas_value_focus(ctx: &egui::Context) -> Option<(egui::Id, usize)> {
- ctx.data(|data| data.get_temp::<(u64, egui::Id, usize)>(egui::Id::new("sc_canvas_value_focus")))
+ ctx.data(|data| data.get_temp::<(u64, egui::Id, usize)>(egui::Id::unique("sc_canvas_value_focus")))
.filter(|(pass, _, _)| *pass == ctx.cumulative_pass_nr())
.map(|(_, id, length)| (id, length))
}
diff --git a/crates/ui-egui/src/ui_kit/viewport_status.rs b/crates/ui-egui/src/ui_kit/viewport_status.rs
index 2af81f1cbe..fdfd0852dc 100644
--- a/crates/ui-egui/src/ui_kit/viewport_status.rs
+++ b/crates/ui-egui/src/ui_kit/viewport_status.rs
@@ -174,7 +174,7 @@ fn icon_action(ui: &mut Ui, item: &StatusItem, part: &str, icon: &str, label: &s
} else {
crate::icons::paint_icon(ui.painter(), glyph, icon, 1.0);
}
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
scenario::publish_target(&target(item, part), response.rect);
scenario::publish_target(&target(item, &format!("{part}_glyph")), glyph);
response.backing_on_hover_text(hint)
@@ -250,9 +250,9 @@ pub(crate) fn viewport_status_item(ui: &mut Ui, item: &StatusItem, state: &mut S
});
})
.response;
- let focus = ui.interact(response.rect, Id::new(target(item, "item")), egui::Sense::focusable_noninteractive());
+ let focus = ui.interact(response.rect, Id::unique(target(item, "item")), egui::Sense::focusable_noninteractive());
state.focus_ids.push(focus.id);
- focus.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{} {}", item.name, item.setting)));
+ focus.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, ui.is_enabled(), format!("{} {}", item.name, item.setting)));
if focus.has_focus() {
ui.painter().rect_stroke(response.rect.expand(t.space_3), frame.corner_radius, ui.visuals().selection.stroke, egui::StrokeKind::Outside);
}
@@ -281,7 +281,7 @@ pub(crate) fn viewport_status_row(
let mut actions = Vec::new();
let mut key_anchor = None;
let row = container
- .area(Id::new("viewport_status_row"))
+ .area(Id::unique("viewport_status_row"))
.movable(false)
.pivot(egui::Align2::CENTER_TOP)
.fixed_pos(egui::pos2(free.center().x, free.top() + t.space_8))
@@ -333,7 +333,7 @@ pub(crate) fn viewport_status_summary(
let container = Container::new(ctx, Surface::ViewportStatus);
let was_open = state.summary_popup.is_some_and(|id| egui::Popup::is_id_open(ctx, id));
let row = container
- .area(Id::new("viewport_status_summary"))
+ .area(Id::unique("viewport_status_summary"))
.movable(false)
.pivot(egui::Align2::CENTER_TOP)
.fixed_pos(egui::pos2(free.center().x, free.top() + t.space_8))
@@ -396,7 +396,7 @@ pub(crate) fn viewport_status_summary(
"ui.viewport_status_summary_label",
&[("name", &latest.name), ("count", &items.len().saturating_sub(1).to_string())],
);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label.as_str()));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label.as_str()));
scenario::publish_target("viewport_status:summary", rect);
scenario::publish_target(&target(latest, "summary"), rect);
response
@@ -512,7 +512,7 @@ fn show_card(
let t = Tokens::get();
let card = Container::new(ctx, Surface::Popup);
let result =
- card.area(Id::new("viewport_status_key")).order(egui::Order::Background).movable(false).fixed_pos(anchor + vec2(0.0, t.space_6)).show(
+ card.area(Id::unique("viewport_status_key")).order(egui::Order::Background).movable(false).fixed_pos(anchor + vec2(0.0, t.space_6)).show(
ctx,
|ui| {
let frame = card.frame(ctx, t.overlay, crate::frame::Side::Left).inner_margin(t.space_12);
diff --git a/crates/ui-egui/src/update.rs b/crates/ui-egui/src/update.rs
index 1721897708..c61788da1a 100644
--- a/crates/ui-egui/src/update.rs
+++ b/crates/ui-egui/src/update.rs
@@ -1003,7 +1003,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
State::Offer if managed.is_some() => ("", crate::i18n::tr("update.later"), Some(crate::i18n::tr("update.skip"))),
State::Offer => (primary, crate::i18n::tr("update.later"), Some(crate::i18n::tr("update.skip"))),
};
- let id = egui::Id::new("sc_update");
+ let id = egui::Id::unique("sc_update");
let mut also_download = false;
let (closed, answer) =
ui_kit::Window::new(id, "update", crate::i18n::tr("update.title")).cards(1.7).actions(ok, cancel, apply).show(ctx, true, |ui| {
@@ -1130,7 +1130,7 @@ fn show_check_status(app: &mut SolveApp, ctx: &egui::Context) {
Status::Idle => (crate::i18n::tr("update.check_unavailable").to_string(), false),
}
};
- let id = egui::Id::new("sc_update");
+ let id = egui::Id::unique("sc_update");
let (closed, action) = ui_kit::Window::new(id, "update", crate::i18n::tr("update.check_for_updates"))
.cards(1.7)
.actions("", crate::i18n::tr("ui.close"), None)
diff --git a/crates/ui-egui/src/value_step.rs b/crates/ui-egui/src/value_step.rs
index b8022ab5cc..4851d1cac2 100644
--- a/crates/ui-egui/src/value_step.rs
+++ b/crates/ui-egui/src/value_step.rs
@@ -11,7 +11,7 @@
use egui::{Event, Key, Modifiers, MouseWheelUnit};
fn enabled_id() -> egui::Id {
- egui::Id::new("value_step_enabled")
+ egui::Id::unique("value_step_enabled")
}
/// Turn stepping on or off for this frame, from the preference (the app calls this every frame).
diff --git a/crates/ui-egui/src/value_step_tests.rs b/crates/ui-egui/src/value_step_tests.rs
index b8c2592064..a52cbdcd24 100644
--- a/crates/ui-egui/src/value_step_tests.rs
+++ b/crates/ui-egui/src/value_step_tests.rs
@@ -93,7 +93,7 @@ impl Field {
let ctx = egui::Context::default();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
crate::params_dialog::publish(&mut app, &ctx);
- let id = egui::Id::new("value_step_test_field");
+ let id = egui::Id::unique("value_step_test_field");
let mut f = Self { on, ctx, app, text: text.into(), id, changed: false, rect: egui::Rect::NOTHING, scroll: egui::Id::NULL };
f.ctx.memory_mut(|m| m.request_focus(id));
f.frame(Vec::new());
@@ -127,7 +127,13 @@ impl Field {
}
fn wheel(&mut self, at: egui::Pos2, unit: MouseWheelUnit, dy: f32) {
- let wheel = Event::MouseWheel { unit, delta: vec2(0.0, dy), modifiers: Modifiers::NONE, phase: TouchPhase::Move };
+ let wheel = Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit,
+ delta: vec2(0.0, dy),
+ modifiers: Modifiers::NONE,
+ phase: TouchPhase::Move,
+ };
self.frame(vec![Event::PointerMoved(at), wheel]);
}
@@ -138,7 +144,7 @@ impl Field {
}
fn scrolled(&self) -> f32 {
- egui::scroll_area::State::load(&self.ctx, self.scroll).map_or(0.0, |s| s.offset.y)
+ egui::scroll_area::State::load(&self.ctx, self.scroll).map_or(0.0, |s| s.clamped_offset().y)
}
}
@@ -254,7 +260,7 @@ fn flange(h: &Harness) -> (usize, String, String) {
fn flange_height_and_bend_radius_step_with_arrows_and_wheel() {
let mut h = edge_flange(true);
// The box sits at the arrow's tip, so it moves as the height does.
- let at = |h: &Harness| h.ctx.read_response(egui::Id::new("sc_canvas_value")).expect("the Height box beside the edge").rect.center();
+ let at = |h: &Harness| h.ctx.read_response(egui::Id::unique("sc_canvas_value")).expect("the Height box beside the edge").rect.center();
let height = at(&h);
h.step(&json!({"click": [height.x, height.y]})).unwrap();
h.step(&json!({"key": "ArrowUp"})).unwrap();
@@ -267,7 +273,7 @@ fn flange_height_and_bend_radius_step_with_arrows_and_wheel() {
// shrinks, so every notch steps it and none reaches the camera.
h.call("ui.camera", json!({"target": [50, 0, 15], "distance": 40}));
h.frames(4);
- let rect = h.ctx.read_response(egui::Id::new("sc_canvas_value")).unwrap().rect;
+ let rect = h.ctx.read_response(egui::Id::unique("sc_canvas_value")).unwrap().rect;
let tip = h.at(&json!({"handle": "arrow"})).unwrap()[1];
let cam = h.app.cam;
for _ in 0..4 {
@@ -334,7 +340,7 @@ fn off_by_default_the_keys_and_the_wheel_do_what_they_did() {
assert!(f.scrolled() > 0.0, "the wheel scrolled the panel");
let mut h = edge_flange(false);
- let at = h.ctx.read_response(egui::Id::new("sc_canvas_value")).unwrap().rect.center();
+ let at = h.ctx.read_response(egui::Id::unique("sc_canvas_value")).unwrap().rect.center();
h.step(&json!({"click": [at.x, at.y]})).unwrap();
h.step(&json!({"key": "ArrowUp"})).unwrap();
h.call("ui.scroll", json!({"x": at.x, "y": at.y, "delta": 40.0}));
@@ -345,7 +351,7 @@ fn off_by_default_the_keys_and_the_wheel_do_what_they_did() {
h.step(&json!({"text": "40 mm"})).unwrap();
h.frames(3);
assert_eq!(flange(&h).1, "40 mm");
- let moved = h.ctx.read_response(egui::Id::new("sc_canvas_value")).unwrap().rect.center();
+ let moved = h.ctx.read_response(egui::Id::unique("sc_canvas_value")).unwrap().rect.center();
assert!((moved.y - at.y).abs() > 5.0, "the box moved with the arrow ({at:?} -> {moved:?})");
}
@@ -361,7 +367,7 @@ fn the_preference_is_on_the_design_page() {
// The row can be below the page's fold: scroll the page to it, as a user would, a little at a
// time so the page's length doesn't matter.
for _ in 0..40 {
- let window = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).unwrap();
+ let window = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).unwrap();
let row = crate::scenario::handle_at("prefs:step_values").expect("the Design page shows the row");
if window.shrink(60.0).contains(row) {
break;
diff --git a/crates/ui-egui/src/view_angles.rs b/crates/ui-egui/src/view_angles.rs
index e5466bc550..36931ca0ab 100644
--- a/crates/ui-egui/src/view_angles.rs
+++ b/crates/ui-egui/src/view_angles.rs
@@ -22,17 +22,17 @@ use crate::ui_kit::{self, Container, Surface};
/// The angles typed in the card while it is open; no entry while it is closed.
pub(crate) fn draft_id() -> egui::Id {
- egui::Id::new("sc_view_angles_draft")
+ egui::Id::unique("sc_view_angles_draft")
}
/// Where the readout was drawn last frame over the viewport `viewport`, so a click on it never
/// reaches the model below.
pub(crate) fn readout_rect(ctx: &egui::Context, viewport: Rect) -> Option<Rect> {
- ctx.data(|d| d.get_temp::<(Rect, Rect)>(egui::Id::new("sc_view_angles_readout"))).filter(|(v, _)| *v == viewport).map(|(_, r)| r)
+ ctx.data(|d| d.get_temp::<(Rect, Rect)>(egui::Id::unique("sc_view_angles_readout"))).filter(|(v, _)| *v == viewport).map(|(_, r)| r)
}
fn set_readout_rect(ui: &egui::Ui, viewport: Rect, rect: Option<Rect>) {
- let id = egui::Id::new("sc_view_angles_readout");
+ let id = egui::Id::unique("sc_view_angles_readout");
ui.data_mut(|d| match rect {
Some(r) => {
d.insert_temp(id, (viewport, r));
@@ -148,8 +148,8 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
painter.galley(pos2(right - second.size().x, chip.bottom() - 3.0 - second.size().y), second, t.text_dim);
crate::scenario::publish_target("view_angles:readout", chip);
let label = format!("{angles} · {projection}");
- let response = ui.interact(chip, ui.id().with("view_angles_readout"), Sense::click());
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &label));
+ let response = ui.interact(chip, ui.scope_id().with("view_angles_readout"), Sense::click());
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &label));
if response.hovered() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
@@ -162,7 +162,7 @@ pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
return;
};
let area = Container::new(ui.ctx(), Surface::Popup)
- .area(egui::Id::new("sc_view_angles_card"))
+ .area(egui::Id::unique("sc_view_angles_card"))
.order(egui::Order::Foreground)
.pivot(Align2::RIGHT_TOP)
.fixed_pos(chip.right_bottom() + vec2(0.0, 4.0));
diff --git a/crates/ui-egui/src/view_confirm.rs b/crates/ui-egui/src/view_confirm.rs
index 00bb2a1421..1e6a966981 100644
--- a/crates/ui-egui/src/view_confirm.rs
+++ b/crates/ui-egui/src/view_confirm.rs
@@ -96,20 +96,20 @@ pub(crate) fn show(app: &mut SolveApp, ctx: &egui::Context) {
let container = Container::new(ctx, Surface::Navigation);
let frame = container.frame(ctx, t.overlay, crate::frame::Side::Right);
let mut clicked = None;
- container.area(egui::Id::new("sc_view_confirm")).order(egui::Order::Middle).fixed_pos(rect.min).fade_in(false).show(ctx, |ui| {
+ container.area(egui::Id::unique("sc_view_confirm")).order(egui::Order::Middle).fixed_pos(rect.min).fade_in(false).show(ctx, |ui| {
let (outer, _) = ui.allocate_exact_size(rect.size(), Sense::hover());
Container::paint_frame(ui.painter(), frame, outer.shrink(frame.stroke.width));
// The check, then the cross in the very corner, where a close sits on a title bar.
for (index, choice) in choices.iter().enumerate() {
let at = Rect::from_min_size(outer.min + vec2(t.space_4 + index as f32 * (TARGET + t.space_4), t.space_4), vec2(TARGET, TARGET));
- let response = ui.interact(at, ui.id().with(choice.key), if choice.enabled { Sense::click() } else { Sense::hover() });
+ let response = ui.interact(at, ui.scope_id().with(choice.key), if choice.enabled { Sense::click() } else { Sense::hover() });
if choice.enabled && response.hovered() {
ui.painter().rect_filled(at, t.radius_sm, t.hover);
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
crate::icons::paint_icon(ui.painter(), at.shrink(t.space_6), choice.icon, if choice.enabled { 1.0 } else { 0.35 });
let label = crate::i18n::tr_label(choice.label);
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, choice.enabled, label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, choice.enabled, label));
crate::scenario::publish_target(choice.key, at);
if response.backing_on_hover_text(label).clicked() && choice.enabled {
clicked = Some(choice.action);
diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs
index 6f2e7df483..ed0de0a4db 100644
--- a/crates/ui-egui/src/viewport.rs
+++ b/crates/ui-egui/src/viewport.rs
@@ -4667,7 +4667,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
let rect = ui.max_rect();
app.viewport.rect = Some(rect);
refresh_layout(app, ui.ctx());
- let resp = ui.interact(rect, ui.id().with("viewport"), Sense::click_and_drag());
+ let resp = ui.interact(rect, ui.scope_id().with("viewport"), Sense::click_and_drag());
let flat = crate::dialogs_sheet::flat_active(app);
if !flat {
app.flat_view.fitted = false;
@@ -5563,7 +5563,7 @@ fn agent_chip(app: &mut SolveApp, ui: &egui::Ui, view: Rect, taken: &[Rect]) ->
.paint_at(ui, Rect::from_center_size(pos2(r.left() + 13.0, r.center().y), vec2(12.0, 12.0)));
painter.galley(pos + vec2(26.0, 4.0), galley.clone(), t.text);
let button = Rect::from_min_size(pos2(pos.x + galley.size().x + 34.0, r.top() + 2.0), vec2(stop.size().x + 12.0, r.height() - 4.0));
- let clicked = ui.interact(button, egui::Id::new("sc_agent_stop"), Sense::click());
+ let clicked = ui.interact(button, egui::Id::unique("sc_agent_stop"), Sense::click());
painter.rect_filled(button, t.radius_sm.saturating_sub(1), if clicked.hovered() { t.hover } else { t.overlay });
painter.galley(button.min + vec2(6.0, 2.0), stop, t.text);
crate::scenario::publish_handle("agent:stop", button.center());
@@ -5774,11 +5774,11 @@ pub enum ToastPlace {
impl ToastPlace {
pub(crate) fn publish(self, ctx: &egui::Context) {
- ctx.data_mut(|data| data.insert_temp(egui::Id::new("sc_toast_place"), self));
+ ctx.data_mut(|data| data.insert_temp(egui::Id::unique("sc_toast_place"), self));
}
pub(crate) fn current(ctx: &egui::Context) -> Self {
- ctx.data(|data| data.get_temp(egui::Id::new("sc_toast_place"))).unwrap_or_default()
+ ctx.data(|data| data.get_temp(egui::Id::unique("sc_toast_place"))).unwrap_or_default()
}
}
@@ -5910,7 +5910,7 @@ fn toast_action_spots_trailing(buttons: &[(f32, ToastKind)], row_width: f32, gap
/// Where a toast button's drawn width is remembered: by its text and kind, which set its look.
fn toast_button_key(label: &str, kind: ToastKind) -> egui::Id {
- egui::Id::new(("sc_toast_button_width", label, kind))
+ egui::Id::unique(("sc_toast_button_width", label, kind))
}
/// The width a toast button with this text and kind was last drawn at, if it has been drawn.
@@ -6022,7 +6022,7 @@ fn toast_close(ui: &egui::Ui, rect: Rect, id: egui::Id, left: Option<f32>) -> eg
let ink = if lit && ui.is_enabled() { t.text } else { t.text_dim };
crate::icons::paint_ink(painter, Rect::from_center_size(centre, vec2(t.space_10, t.space_10)), "close", ink);
let label = crate::i18n::tr("ui.close");
- response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), label));
if response.hovered() && ui.is_enabled() {
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
@@ -6112,7 +6112,7 @@ fn paint_toast_ext(
let blocked = crate::issue_report::cad_input_blocked();
let card_clicked = extras.card_hint.is_some_and(|hint| {
let sense = if blocked { Sense::hover() } else { Sense::click() };
- ui.interact(r, egui::Id::new(("sc_toast_card", extras.close.unwrap_or_default())), sense).backing_on_hover_text(hint).clicked()
+ ui.interact(r, egui::Id::unique(("sc_toast_card", extras.close.unwrap_or_default())), sense).backing_on_hover_text(hint).clicked()
});
let mut clicked = None;
let mut buttons = Vec::with_capacity(actions.len());
@@ -6125,7 +6125,7 @@ fn paint_toast_ext(
let room = Rect::from_min_size(at.min, vec2(row_width.max(at.width()), at.height()));
let mut button_ui = egui::Ui::new(
ui.ctx().clone(),
- egui::Id::new(("sc_toast_action", index)),
+ egui::Id::unique(("sc_toast_action", index)),
egui::UiBuilder::new().layer_id(ui.layer_id()).max_rect(room).layout(egui::Layout::left_to_right(egui::Align::Center)),
);
button_ui.set_clip_rect(button_ui.clip_rect().intersect(r));
@@ -6162,7 +6162,7 @@ fn paint_toast_ext(
let at = Rect::from_center_size(centre, vec2(2.0 * radius, 2.0 * radius));
let mut close_ui = egui::Ui::new(
ui.ctx().clone(),
- egui::Id::new(("sc_toast_close_ui", handle)),
+ egui::Id::unique(("sc_toast_close_ui", handle)),
egui::UiBuilder::new().layer_id(ui.layer_id()).max_rect(at),
);
close_ui.set_clip_rect(close_ui.clip_rect().intersect(r));
@@ -6170,7 +6170,7 @@ fn paint_toast_ext(
close_ui.disable();
}
let left = extras.countdown.map(|(left, _)| left);
- closed = toast_close(&close_ui, at, egui::Id::new(("sc_toast_close", handle)), left).clicked();
+ closed = toast_close(&close_ui, at, egui::Id::unique(("sc_toast_close", handle)), left).clicked();
crate::scenario::publish_handle(handle, centre);
close = Some(at);
// A frame each time the ring's end moves about a point, not one per display refresh.
@@ -7173,13 +7173,12 @@ fn signed_axis_view(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
&& let Some((name, d, _, _)) = tips.get(i)
{
crate::scenario::publish_handle(&format!("axis_view_hover:{name}"), hover.unwrap_or(c));
- ui.interact(Rect::from_center_size(hover.unwrap_or(c), vec2(2.0, 2.0)), ui.id().with("axis_view_tip"), Sense::hover()).backing_on_hover_text(
- format!(
+ ui.interact(Rect::from_center_size(hover.unwrap_or(c), vec2(2.0, 2.0)), ui.scope_id().with("axis_view_tip"), Sense::hover())
+ .backing_on_hover_text(format!(
"View from {}. Click again to reverse. Drag to orbit{}.",
name.to_uppercase(),
if app.preferences.free_orbit { "" } else { "; hold Shift to snap" }
- ),
- );
+ ));
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
if ui.input(|i| i.pointer.primary_clicked()) {
let frame = app.cam.to_frame(*d);
@@ -7193,7 +7192,7 @@ fn signed_axis_view(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
}
let home = Rect::from_center_size(pos2(c.x - 37.0, c.y - 37.0), vec2(18.0, 18.0));
crate::scenario::publish_target("axis_view:home", home);
- let hr = ui.interact(home, ui.id().with("axis_view_home"), Sense::click());
+ let hr = ui.interact(home, ui.scope_id().with("axis_view_home"), Sense::click());
// The home button sits in its own small round chip.
painter.circle(home.center(), 12.0, t.overlay.gamma_multiply(if hr.hovered() { 0.9 } else { 0.5 }), Stroke::new(1.0, t.border));
icons::paint_icon(&painter, home, "home", f32::from(t.icon.a()) / 255.0);
@@ -7775,13 +7774,14 @@ mod tests {
// will have settled (with no input to wake the window, the full count must follow).
let at = |app: &mut SolveApp, time: f64, x: f32| {
let mut n = 0;
- let out = ctx.run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| n = ao_samples(app, ui.ctx(), view(x), size));
+ let mut out = ctx.run_ui(egui::RawInput { time: Some(time), ..Default::default() }, |ui| n = ao_samples(app, ui.ctx(), view(x), size));
+ out.textures_delta.clear();
let delay = out.viewport_output.get(&egui::ViewportId::ROOT).map_or(std::time::Duration::MAX, |v| v.repaint_delay);
(n, delay <= std::time::Duration::from_secs_f64(SS_SETTLE + 0.02))
};
// A new context asks for its own first repaints: let it settle.
for _ in 0..3 {
- let _ = ctx.run_ui(egui::RawInput { time: Some(0.0), ..Default::default() }, |_| {});
+ ctx.run_ui(egui::RawInput { time: Some(0.0), ..Default::default() }, |_| {}).textures_delta.clear();
}
app.preferences.ambient_occlusion = false;
assert_eq!(at(&mut app, 0.0, 0.0), (AO_SAMPLES, false), "AO off");
@@ -9955,6 +9955,7 @@ mod tests {
let before = h.app.cam;
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -9971,6 +9972,7 @@ mod tests {
h.app.preferences.nav = "fusion".into();
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -10928,6 +10930,7 @@ mod tests {
{
let height = h.app.cam.half_height();
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit,
delta: vec2(0.0, amount),
modifiers: egui::Modifiers::NONE,
@@ -10954,6 +10957,7 @@ mod tests {
h.app.preferences.trackpad_pan = false;
h.call("ui.move", json!({"x":800,"y":500}));
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -10972,6 +10976,7 @@ mod tests {
h.app.preferences.smooth_wheel_zoom = false;
for _ in 0..3 {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -11009,7 +11014,13 @@ mod tests {
h.app.preferences.zoom_to_cursor = false;
h.call("ui.move", json!({"x":800,"y":500}));
let before = h.app.cam;
- let event = |phase| egui::Event::MouseWheel { unit: U::Point, delta: vec2(60.0, 120.0), modifiers: held, phase };
+ let event = |phase| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: U::Point,
+ delta: vec2(60.0, 120.0),
+ modifiers: held,
+ phase,
+ };
if bracket {
h.app.synthetic.push(event(P::Start));
h.frame();
@@ -11049,6 +11060,7 @@ mod tests {
let before = h.app.cam;
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(120.0, 0.0),
modifiers: chosen.modifiers().unwrap(),
@@ -11074,6 +11086,7 @@ mod tests {
h.call("ui.move", json!({"x":800,"y":500}));
let before = h.app.cam;
let event = |modifiers| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit,
delta: vec2(0.0, if unit == egui::MouseWheelUnit::Point { 120.0 } else { 3.0 }),
modifiers,
@@ -11104,6 +11117,7 @@ mod tests {
let before = h.app.cam;
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, invalid),
modifiers: egui::Modifiers::COMMAND,
@@ -11124,8 +11138,13 @@ mod tests {
assert!(h.app.preferences.trackpad_pan, "two-finger pan is the default");
h.app.preferences.zoom_to_cursor = false;
h.call("ui.move", json!({"x":800,"y":500}));
- let gesture =
- |phase| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(60.0, -40.0), modifiers: egui::Modifiers::NONE, phase };
+ let gesture = |phase| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(60.0, -40.0),
+ modifiers: egui::Modifiers::NONE,
+ phase,
+ };
// A bracketed trackpad gesture pans (measured macOS Start…End bracketing).
let before = h.app.cam;
h.app.synthetic.push(gesture(egui::TouchPhase::Start));
@@ -11142,6 +11161,7 @@ mod tests {
// Bare moves are a mouse: vertical zooms…
h.app.preferences.smooth_wheel_zoom = false;
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -11152,6 +11172,7 @@ mod tests {
// …and horizontal pans without zooming (thumb wheel).
let zoomed = h.app.cam;
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(40.0, 0.0),
modifiers: egui::Modifiers::NONE,
@@ -11163,6 +11184,7 @@ mod tests {
// Opting out restores the legacy wheel behaviour for all point input.
h.app.preferences.trackpad_pan = false;
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -11175,6 +11197,7 @@ mod tests {
let legacy_target = h.app.cam.target;
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, 120.0),
modifiers: egui::Modifiers::NONE,
@@ -11187,6 +11210,7 @@ mod tests {
// The thumb wheel pans sideways even with panning off: it is a mouse.
let h0 = h.app.cam.half_height();
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(40.0, 0.0),
modifiers: egui::Modifiers::NONE,
@@ -11209,6 +11233,7 @@ mod tests {
let before = h.app.cam;
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(60.0, -40.0),
modifiers: egui::Modifiers::SHIFT,
@@ -11225,6 +11250,7 @@ mod tests {
h.step(&json!({"shot":"fusion-trackpad-orbit"})).unwrap();
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(60.0, -40.0),
modifiers: egui::Modifiers::NONE,
@@ -11247,7 +11273,13 @@ mod tests {
h.app.preferences.orbit_around = crate::prefs::OrbitAround::ViewCentre;
h.app.preferences.orbit_reverse = orbit_reverse;
h.call("ui.move", json!({"x":800,"y":500}));
- let gesture = |phase| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(20.0, -10.0), modifiers, phase };
+ let gesture = |phase| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(20.0, -10.0),
+ modifiers,
+ phase,
+ };
h.app.synthetic.push(gesture(egui::TouchPhase::Start));
h.frame();
let before = h.app.cam;
@@ -11268,7 +11300,13 @@ mod tests {
h.app.preferences.nav = "fusion".into();
h.app.preferences.orbit_around = crate::prefs::OrbitAround::ViewCentre;
h.call("ui.move", json!({"x":800,"y":500}));
- let gesture = |phase, modifiers| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(20.0, -10.0), modifiers, phase };
+ let gesture = |phase, modifiers| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(20.0, -10.0),
+ modifiers,
+ phase,
+ };
h.app.synthetic.push(gesture(egui::TouchPhase::Start, egui::Modifiers::NONE));
h.frame();
for modifiers in [egui::Modifiers::NONE, egui::Modifiers::SHIFT, egui::Modifiers::NONE, egui::Modifiers::SHIFT] {
@@ -11320,7 +11358,13 @@ mod tests {
h.app.preferences.nav = "fusion".into();
h.app.preferences.orbit_around = crate::prefs::OrbitAround::ViewCentre;
h.call("ui.move", json!({"x":800,"y":500}));
- let gesture = |phase, modifiers| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(20.0, -10.0), modifiers, phase };
+ let gesture = |phase, modifiers| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(20.0, -10.0),
+ modifiers,
+ phase,
+ };
let play = |h: &mut crate::scenario::Harness, phase, modifiers| {
h.app.synthetic.push(gesture(phase, modifiers));
h.frame();
@@ -11384,6 +11428,7 @@ mod tests {
let before = h.app.cam;
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(20.0, -10.0),
modifiers: egui::Modifiers::SHIFT,
@@ -11412,7 +11457,13 @@ mod tests {
h.app.cam.target = Vec3::new(30.0, 20.0, 10.0);
h.call("ui.move", json!({"x":800,"y":500}));
let before = h.app.cam;
- let gesture = |phase, delta| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta, modifiers: egui::Modifiers::SHIFT, phase };
+ let gesture = |phase, delta| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta,
+ modifiers: egui::Modifiers::SHIFT,
+ phase,
+ };
h.app.synthetic.push(gesture(egui::TouchPhase::Start, egui::Vec2::ZERO));
h.frame();
h.app.synthetic.push(gesture(egui::TouchPhase::Move, vec2(20.0, -10.0)));
@@ -11471,15 +11522,20 @@ mod tests {
h.step(&json!({"start": "solid.extrude"})).unwrap();
h.frames(6);
let over =
- |h: &crate::scenario::Harness| h.ctx.read_response(egui::Id::new("sc_canvas_value")).expect("Extrude's distance box").rect.center();
+ |h: &crate::scenario::Harness| h.ctx.read_response(egui::Id::unique("sc_canvas_value")).expect("Extrude's distance box").rect.center();
let distance = |h: &crate::scenario::Harness| format!("{:?}", h.app.dialog.as_ref().map(|d| &d.kind));
let typed = distance(&h);
let at = over(&h);
h.call("ui.move", json!({"x": at.x, "y": at.y}));
h.frames(2);
assert!(h.ctx.layer_id_at(at).is_some_and(crate::ui_kit::container::is_canvas), "the pointer is on the box");
- let gesture =
- |phase| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(30.0, -20.0), modifiers: egui::Modifiers::NONE, phase };
+ let gesture = |phase| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(30.0, -20.0),
+ modifiers: egui::Modifiers::NONE,
+ phase,
+ };
let before = h.app.cam;
h.app.synthetic.push(gesture(egui::TouchPhase::Start));
h.frame();
@@ -11523,7 +11579,7 @@ mod tests {
h.step(&json!({"start": "solid.extrude"})).unwrap();
h.frames(6);
let over =
- |h: &crate::scenario::Harness| h.ctx.read_response(egui::Id::new("sc_canvas_value")).expect("Extrude's distance box").rect.center();
+ |h: &crate::scenario::Harness| h.ctx.read_response(egui::Id::unique("sc_canvas_value")).expect("Extrude's distance box").rect.center();
let typed = format!("{:?}", h.app.dialog.as_ref().map(|d| &d.kind));
// The orbit is in progress and the box slides under the cursor: the pointer sits on the
// box every frame, as it does when the spinning model carries the box to the pointer.
@@ -11531,8 +11587,13 @@ mod tests {
h.call("ui.move", json!({"x": at.x, "y": at.y}));
h.frames(2);
assert!(h.ctx.layer_id_at(at).is_some_and(crate::ui_kit::container::is_canvas), "the pointer is on the box");
- let orbit =
- |phase| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(24.0, -16.0), modifiers: egui::Modifiers::SHIFT, phase };
+ let orbit = |phase| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(24.0, -16.0),
+ modifiers: egui::Modifiers::SHIFT,
+ phase,
+ };
h.app.synthetic.push(orbit(egui::TouchPhase::Start));
h.frame();
let mut last = h.app.cam;
@@ -11557,7 +11618,13 @@ mod tests {
assert!(app.preferences.trackpad_pan);
crate::help::run(&mut app, &ctx, "shortcuts");
let mut time = 0.0;
- let pan = |phase, modifiers| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(40.0, -20.0), modifiers, phase };
+ let pan = |phase, modifiers| egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(40.0, -20.0),
+ modifiers,
+ phase,
+ };
let mut frame = |app: &mut SolveApp, pointer: Option<Pos2>, events: Vec<egui::Event>| {
time += 1.0 / 60.0;
let mut input = events;
@@ -11581,7 +11648,7 @@ mod tests {
for _ in 0..4 {
frame(&mut app, None, Vec::new());
}
- let window = ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).unwrap();
+ let window = ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).unwrap();
let over = window.center();
let height = app.cam.half_height();
let target = app.cam.target;
@@ -11628,6 +11695,7 @@ mod tests {
}
if wheel != 0.0 {
events.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
unit: egui::MouseWheelUnit::Point,
delta: vec2(0.0, wheel),
modifiers: egui::Modifiers::NONE,
@@ -11652,7 +11720,7 @@ mod tests {
for _ in 0..4 {
frame(&mut app, None, 0.0);
}
- let window = ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).unwrap();
+ let window = ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).unwrap();
let list = window.center() + vec2(140.0, 0.0);
let height = app.cam.half_height();
let target = app.cam.target;
@@ -11703,7 +11771,13 @@ mod tests {
h.app.synthetic.push(egui::Event::Zoom(1.2));
for phase in [egui::TouchPhase::Start, egui::TouchPhase::Move, egui::TouchPhase::End] {
let unit = egui::MouseWheelUnit::Point;
- h.app.synthetic.push(egui::Event::MouseWheel { unit, delta: vec2(30.0, -20.0), modifiers: egui::Modifiers::NONE, phase });
+ h.app.synthetic.push(egui::Event::MouseWheel {
+ source: egui::MouseWheelSource::Unknown,
+ unit,
+ delta: vec2(30.0, -20.0),
+ modifiers: egui::Modifiers::NONE,
+ phase,
+ });
}
h.settle();
h.frames(20);
@@ -11803,7 +11877,7 @@ mod tests {
h.app.session.selection.clear();
h.call("ui.prefs", json!({"open": "Navigation"}));
- let window = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).unwrap();
+ let window = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).unwrap();
assert!(window.contains(p), "the dialog must cover the model at the test point");
h.call("ui.move", json!({"x": p.x, "y": p.y}));
assert!(h.app.viewport.hover.is_none(), "the dialog must block model highlights");
@@ -11828,7 +11902,7 @@ mod tests {
h.call("ui.move", json!({"x": p.x, "y": p.y}));
assert_eq!(crate::scenario::count_of("axis_view_highlights"), Some(1.0));
h.call("ui.prefs", json!({"open": "Navigation"}));
- let window = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_prefs"))).unwrap();
+ let window = h.ctx.memory(|m| m.area_rect(egui::Id::unique("sc_prefs"))).unwrap();
assert!(window.contains(p), "the floating dialog must cover the axis target");
let camera = serde_json::to_value(h.app.cam).unwrap();
h.call("ui.move", json!({"x": p.x, "y": p.y}));
diff --git a/crates/ui-egui/src/viewport_details.rs b/crates/ui-egui/src/viewport_details.rs
index 580d7e0a93..3f156e94a9 100644
--- a/crates/ui-egui/src/viewport_details.rs
+++ b/crates/ui-egui/src/viewport_details.rs
@@ -319,7 +319,7 @@ fn legacy_legend(_app: &SolveApp, ui: &mut egui::Ui, free: egui::Rect, id: &str,
let t = crate::theme::Tokens::get();
let container = crate::ui_kit::Container::new(ui.ctx(), crate::ui_kit::Surface::ViewportStatus);
let result = container
- .area(egui::Id::new(id))
+ .area(egui::Id::unique(id))
.order(egui::Order::Background)
.movable(false)
.pivot(egui::Align2::LEFT_BOTTOM)
diff --git a/crates/ui-egui/src/viewport_overlays_tests.rs b/crates/ui-egui/src/viewport_overlays_tests.rs
index d7b1a46be9..62ba1d884e 100644
--- a/crates/ui-egui/src/viewport_overlays_tests.rs
+++ b/crates/ui-egui/src/viewport_overlays_tests.rs
@@ -2128,8 +2128,8 @@ fn analysis_status_row_and_key_stay_below_preferences_and_cannot_steal_its_click
assert!(window.contains(at), "the real Preferences window must overlap {target}");
let layer = h.ctx.layer_id_at(at).unwrap();
assert_eq!(layer.order, egui::Order::Middle, "Preferences stays above {target}");
- assert_ne!(layer.id, egui::Id::new("viewport_status_row"));
- assert_ne!(layer.id, egui::Id::new("viewport_status_key"));
+ assert_ne!(layer.id, egui::Id::unique("viewport_status_row"));
+ assert_ne!(layer.id, egui::Id::unique("viewport_status_key"));
}
let at = crate::scenario::handle_at(&format!("viewport_status:{}:close", item.id)).unwrap();
h.call("ui.click", json!({"x":at.x,"y":at.y}));
diff --git a/crates/ui-egui/tests/icon_audit.rs b/crates/ui-egui/tests/icon_audit.rs
index f9c44243e0..a04de8d669 100644
--- a/crates/ui-egui/tests/icon_audit.rs
+++ b/crates/ui-egui/tests/icon_audit.rs
@@ -483,7 +483,7 @@ fn requested_menu_icons_have_artwork_and_match_manifest() {
documents.call("ui.resize", json!({"width":640,"height":1000}));
click(&mut documents, "tab:overflow");
documents.frames(3);
- assert!(documents.ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_doc_more"))).unwrap_or(false), "the document list must actually be open");
+ assert!(documents.ctx.data(|d| d.get_temp::<bool>(egui::Id::unique("sc_doc_more"))).unwrap_or(false), "the document list must actually be open");
collect(&mut documents, "document overflow list (active icon is a selection marker)", &mut requested);
// Diagnostic badges and Copy Error/Warning Message only appear on troubled features.
for failing in [false, true] {
diff --git a/crates/ui-egui/tests/joint_move_render.rs b/crates/ui-egui/tests/joint_move_render.rs
index 9588156e85..91e3c94344 100644
--- a/crates/ui-egui/tests/joint_move_render.rs
+++ b/crates/ui-egui/tests/joint_move_render.rs
@@ -71,10 +71,7 @@ fn save_frame(h: &mut Harness, textures: &mut HashMap<TextureId, ColorImage>, mu
}
out.shapes.insert(
background,
- egui::epaint::ClippedShape {
- clip_rect: rect,
- shape: egui::Shape::image(id, rect, Rect::from_min_max(Pos2::ZERO, egui::pos2(1., 1.)), egui::Color32::WHITE),
- },
+ egui::epaint::ClippedShape::new(rect, egui::Shape::image(id, rect, Rect::from_min_max(Pos2::ZERO, egui::pos2(1., 1.)), egui::Color32::WHITE)),
);
raster::raster(h, textures, out).save(path).unwrap();
}
diff --git a/crates/ui-egui/tests/window_widths.rs b/crates/ui-egui/tests/window_widths.rs
index 828d42c0d5..6e5e2a40bc 100644
--- a/crates/ui-egui/tests/window_widths.rs
+++ b/crates/ui-egui/tests/window_widths.rs
@@ -15,7 +15,7 @@ fn window_widths(h: &Harness) -> Vec<(egui::Id, f32)> {
// Workspace hosts are not command windows; Shots has wide expanded and small collapsed forms.
.filter(|l| {
l.order == egui::Order::Middle
- && ![egui::Id::new("sc_browser_card"), egui::Id::new("sc_render_shots_strip"), egui::Id::new("sc_render_shots_pill")]
+ && ![egui::Id::unique("sc_browser_card"), egui::Id::unique("sc_render_shots_strip"), egui::Id::unique("sc_render_shots_pill")]
.contains(&l.id)
})
.filter_map(|l| m.area_rect(l.id).map(|r| (l.id, r.width())))
@@ -25,17 +25,17 @@ fn window_widths(h: &Harness) -> Vec<(egui::Id, f32)> {
fn kit_table_limit(id: egui::Id) -> Option<f32> {
// The accepted Preferences board has a page list and one control/preview pair at 880 pt.
- if id == egui::Id::new("sc_prefs") {
+ if id == egui::Id::unique("sc_prefs") {
return Some(solidcraft_ui_egui::theme::Tokens::get().form_card_width * 10.0 / 3.0);
}
[
- egui::Id::new("sc_bom"),
- egui::Id::new("sc_gesture_editor"),
- egui::Id::new("sc_params_dialog"),
- egui::Id::new("sc_material_card_review"),
- egui::Id::new(("sc_dialog", "CONFIGURATIONS")),
- egui::Id::new(("sc_dialog", "MOTION STUDY")),
- egui::Id::new(("sc_dialog", "EDIT MOTION STUDY")),
+ egui::Id::unique("sc_bom"),
+ egui::Id::unique("sc_gesture_editor"),
+ egui::Id::unique("sc_params_dialog"),
+ egui::Id::unique("sc_material_card_review"),
+ egui::Id::unique(("sc_dialog", "CONFIGURATIONS")),
+ egui::Id::unique(("sc_dialog", "MOTION STUDY")),
+ egui::Id::unique(("sc_dialog", "EDIT MOTION STUDY")),
]
.contains(&id)
.then(|| solidcraft_ui_egui::theme::Tokens::get().form_card_width * 3.0)
@@ -54,20 +54,20 @@ fn render_strip_is_excluded_while_real_windows_are_still_measured() {
assert_eq!(h.call("ui.workspace", json!({"workspace":"render"}))["ok"], true);
h.app.help.about = true;
h.frames(6);
- let strip = egui::Id::new("sc_render_shots_strip");
+ let strip = egui::Id::unique("sc_render_shots_strip");
let width = h.ctx.memory(|m| m.area_rect(strip)).expect("visible Shots strip").width();
assert!(width > DIALOG_MAX_W, "the workspace strip should span the canvas: {width}");
let windows = window_widths(&h);
assert!(!windows.iter().any(|(id, _)| *id == strip));
- assert!(windows.iter().any(|(id, _)| *id == egui::Id::new("sc_about")), "real About window is still measured: {windows:?}");
+ assert!(windows.iter().any(|(id, _)| *id == egui::Id::unique("sc_about")), "real About window is still measured: {windows:?}");
assert_eq!(h.call("engine.execute", json!({"command":"view.shots_strip","params":{"visible":false}}))["ok"], true);
h.frames(6);
- let pill = egui::Id::new("sc_render_shots_pill");
+ let pill = egui::Id::unique("sc_render_shots_pill");
let width = h.ctx.memory(|m| m.area_rect(pill)).expect("visible Shots restore control").width();
assert!(width < DIALOG_MIN_W, "the restore control is intentionally smaller than a dialog: {width}");
let windows = window_widths(&h);
assert!(!windows.iter().any(|(id, _)| *id == pill));
- assert!(windows.iter().any(|(id, _)| *id == egui::Id::new("sc_about")), "real window remains measured with Shots collapsed: {windows:?}");
+ assert!(windows.iter().any(|(id, _)| *id == egui::Id::unique("sc_about")), "real window remains measured with Shots collapsed: {windows:?}");
assert_eq!(h.call("ui.start", json!({"command":"file.export_view_dxf"}))["ok"], true);
h.frames(6);
let dialog = solidcraft_ui_egui::scenario::rect_of("dialog:outer").expect("DXF dialog has an outer rectangle");
diff --git a/vendor/README.md b/vendor/README.md
index 11a7b85e8a..d3c32f58e9 100644
--- a/vendor/README.md
+++ b/vendor/README.md
@@ -4,30 +4,9 @@ Copies of third-party crates that SolidCraft builds with local fixes, wired in w
`[patch.crates-io]` in the workspace `Cargo.toml`. They keep their own licence; changed lines
are marked `SolidCraft:` in the source.
-## accesskit_macos 0.26.3 (MIT OR Apache-2.0, The AccessKit contributors, https://github.com/AccessKit/accesskit)
+## egui-wgpu 0.37.0 (MIT OR Apache-2.0, Emil Ernerfeldt and contributors)
-The published package (it carries no licence files; `Cargo.toml` names the licence). eframe's
-accessibility support (`accesskit_winit` 0.32) uses it on macOS. Drop this copy when eframe
-moves to accesskit_macos 0.27.2 or later, which has the fix.
-
-Changes:
-- `src/subclass.rs` is accesskit_macos 0.27.2's (AccessKit/accesskit#835). The adapter swaps
- the window's view to a subclass of its own; key-value observing then subclasses it again when
- AppKit's Touch Bar observes the first responder (`nextResponder`). 0.26.3 reset the view's
- class when the adapter was dropped, which threw away KVO's subclass, so AppKit's removal of
- its observer on quit raised `NSRangeException` and the app crashed on Macs with a Touch Bar
- (#7535). Dropping the adapter now leaves the class alone when KVO subclassed it, and the
- subclass's methods fall back to the view's own without the adapter. 0.27.2 also refuses
- (panics) to subclass a view that is already observed; eframe creates the adapter right after
- the window, before anything observes it.
-- `tests/integration/` is 0.27.2's tests of the subclassing adapter, with its `[[test]]` and
- `libtest-mimic` dev-dependency in `Cargo.toml` (AppKit needs the main thread, where libtest
- doesn't run tests). On a Mac: `cargo test --manifest-path vendor/accesskit_macos/Cargo.toml`
- (it writes a `Cargo.lock` there; don't commit it).
-
-## egui-wgpu 0.36.2 (MIT OR Apache-2.0, Emil Ernerfeldt and contributors)
-
-Original package sources from https://github.com/emilk/egui/tree/0.36.2/crates/egui-wgpu,
+Original package sources from https://github.com/emilk/egui/tree/0.37.0/crates/egui-wgpu,
with both original licence texts retained. No images or bundled documentation are copied.
SolidCraft changes:
@@ -121,7 +100,7 @@ SolidCraft changes:
rust-windowing/winit#4778 was closed unmerged). A trackpad pinch otherwise produces no
input at all on Wayland: egui-winit already maps `PinchGesture` to `egui::Event::Zoom`, and
`navigation::handle` already zooms the camera from that, so the Wayland backend is the only
- missing piece. eframe 0.36 requires winit 0.30, so this cannot come from a newer winit.
+ missing piece. eframe 0.37 requires winit 0.30, so this cannot come from a newer winit.
- `src/platform_impl/linux/wayland/seat/mod.rs`, `state.rs`, `seat/pointer/mod.rs`: the
global bound with the connection, the gesture object of each seat's pointer, and the
module wiring.
diff --git a/vendor/accesskit_macos/Cargo.toml b/vendor/accesskit_macos/Cargo.toml
deleted file mode 100644
index edc5ae0f09..0000000000
--- a/vendor/accesskit_macos/Cargo.toml
+++ /dev/null
@@ -1,87 +0,0 @@
-# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
-#
-# When uploading crates to the registry Cargo will automatically
-# "normalize" Cargo.toml files for maximal compatibility
-# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies.
-#
-# If you are reading this file be aware that the original Cargo.toml
-# will likely look very different (and much more reasonable).
-# See Cargo.toml.orig for the original contents.
-
-[package]
-edition = "2024"
-rust-version = "1.85"
-name = "accesskit_macos"
-version = "0.26.3"
-authors = ["The AccessKit contributors"]
-build = false
-autolib = false
-autobins = false
-autoexamples = false
-autotests = false
-autobenches = false
-description = "AccessKit UI accessibility infrastructure: macOS adapter"
-readme = "README.md"
-keywords = [
- "gui",
- "ui",
- "accessibility",
-]
-categories = ["gui"]
-license = "MIT OR Apache-2.0"
-repository = "https://github.com/AccessKit/accesskit"
-resolver = "2"
-
-[package.metadata.docs.rs]
-default-target = "x86_64-apple-darwin"
-
-[lib]
-name = "accesskit_macos"
-path = "src/lib.rs"
-
-# SolidCraft: accesskit_macos 0.27.2's tests of the subclassing adapter, with its fix (vendor/README.md).
-[[test]]
-name = "integration"
-path = "tests/integration/main.rs"
-harness = false
-
-[dependencies.accesskit]
-version = "0.24.1"
-
-[dependencies.accesskit_consumer]
-version = "0.38.0"
-
-[dependencies.hashbrown]
-version = "0.16"
-features = ["default-hasher"]
-default-features = false
-
-[dependencies.objc2]
-version = "0.5.1"
-
-[dependencies.objc2-app-kit]
-version = "0.2.0"
-features = [
- "NSAccessibility",
- "NSAccessibilityConstants",
- "NSAccessibilityElement",
- "NSAccessibilityProtocols",
- "NSColor",
- "NSResponder",
- "NSText",
- "NSView",
- "NSWindow",
-]
-
-[dependencies.objc2-foundation]
-version = "0.2.0"
-features = [
- "NSArray",
- "NSDictionary",
- "NSValue",
- "NSThread",
-]
-
-[dev-dependencies.libtest-mimic]
-version = "0.8.2"
diff --git a/vendor/accesskit_macos/Cargo.toml.orig b/vendor/accesskit_macos/Cargo.toml.orig
deleted file mode 100644
index d158c111ae..0000000000
--- a/vendor/accesskit_macos/Cargo.toml.orig
+++ /dev/null
@@ -1,38 +0,0 @@
-[package]
-name = "accesskit_macos"
-version = "0.26.3"
-authors.workspace = true
-license.workspace = true
-description = "AccessKit UI accessibility infrastructure: macOS adapter"
-categories.workspace = true
-keywords = ["gui", "ui", "accessibility"]
-repository.workspace = true
-readme = "README.md"
-edition.workspace = true
-rust-version.workspace = true
-
-[package.metadata.docs.rs]
-default-target = "x86_64-apple-darwin"
-
-[dependencies]
-accesskit = { version = "0.24.1", path = "../../common" }
-accesskit_consumer = { version = "0.38.0", path = "../../consumer" }
-hashbrown.workspace = true
-objc2 = "0.5.1"
-objc2-foundation = { version = "0.2.0", features = [
- "NSArray",
- "NSDictionary",
- "NSValue",
- "NSThread",
-] }
-objc2-app-kit = { version = "0.2.0", features = [
- "NSAccessibility",
- "NSAccessibilityConstants",
- "NSAccessibilityElement",
- "NSAccessibilityProtocols",
- "NSColor",
- "NSResponder",
- "NSText",
- "NSView",
- "NSWindow",
-] }
diff --git a/vendor/accesskit_macos/README.md b/vendor/accesskit_macos/README.md
deleted file mode 100644
index 4a7bbef4e7..0000000000
--- a/vendor/accesskit_macos/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# AccessKit macOS adapter
-
-This is the macOS adapter for [AccessKit](https://accesskit.dev/). It exposes an AccessKit accessibility tree through the Cocoa `NSAccessibility` protocol.
-
-## Known issues
-
-- The selected state of ListBox items is not reported ([#520](https://github.com/AccessKit/accesskit/issues/520))
diff --git a/vendor/accesskit_macos/src/adapter.rs b/vendor/accesskit_macos/src/adapter.rs
deleted file mode 100644
index 0f894cefa1..0000000000
--- a/vendor/accesskit_macos/src/adapter.rs
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use crate::{
- context::{ActionHandlerNoMut, ActionHandlerWrapper, Context},
- event::{EventGenerator, QueuedEvents, focus_event},
- filters::filter,
- node::can_be_focused,
- util::*,
-};
-use accesskit::{
- ActionHandler, ActionRequest, ActivationHandler, Node as NodeProvider, NodeId as LocalNodeId,
- Role, Tree as TreeData, TreeId, TreeUpdate,
-};
-use accesskit_consumer::{FilterResult, Tree};
-use objc2::rc::{Id, WeakId};
-use objc2_app_kit::NSView;
-use objc2_foundation::{MainThreadMarker, NSArray, NSObject, NSPoint};
-use std::fmt::{Debug, Formatter};
-use std::{ffi::c_void, ptr::null_mut, rc::Rc};
-
-const PLACEHOLDER_ROOT_ID: LocalNodeId = LocalNodeId(0);
-
-enum State {
- Inactive {
- view: WeakId<NSView>,
- is_view_focused: bool,
- action_handler: Rc<dyn ActionHandlerNoMut>,
- mtm: MainThreadMarker,
- },
- Placeholder {
- placeholder_context: Rc<Context>,
- is_view_focused: bool,
- action_handler: Rc<dyn ActionHandlerNoMut>,
- },
- Active(Rc<Context>),
-}
-
-impl Debug for State {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- match self {
- State::Inactive {
- view,
- is_view_focused,
- action_handler: _,
- mtm,
- } => f
- .debug_struct("Inactive")
- .field("view", view)
- .field("is_view_focused", is_view_focused)
- .field("mtm", mtm)
- .finish(),
- State::Placeholder {
- placeholder_context,
- is_view_focused,
- action_handler: _,
- } => f
- .debug_struct("Placeholder")
- .field("placeholder_context", placeholder_context)
- .field("is_view_focused", is_view_focused)
- .finish(),
- State::Active(context) => f.debug_struct("Active").field("context", context).finish(),
- }
- }
-}
-
-struct PlaceholderActionHandler;
-
-impl ActionHandler for PlaceholderActionHandler {
- fn do_action(&mut self, _request: ActionRequest) {}
-}
-
-#[derive(Debug)]
-pub struct Adapter {
- state: State,
-}
-
-impl Adapter {
- /// Create a new macOS adapter. This function must be called on
- /// the main thread.
- ///
- /// The action handler will always be called on the main thread.
- ///
- /// # Safety
- ///
- /// `view` must be a valid, unreleased pointer to an `NSView`.
- pub unsafe fn new(
- view: *mut c_void,
- is_view_focused: bool,
- action_handler: impl 'static + ActionHandler,
- ) -> Self {
- let view = unsafe { Id::retain(view as *mut NSView) }.unwrap();
- let view = WeakId::from_id(&view);
- let mtm = MainThreadMarker::new().unwrap();
- let state = State::Inactive {
- view,
- is_view_focused,
- action_handler: Rc::new(ActionHandlerWrapper::new(action_handler)),
- mtm,
- };
- Self { state }
- }
-
- /// If and only if the tree has been initialized, call the provided function
- /// and apply the resulting update. Note: If the caller's implementation of
- /// [`ActivationHandler::request_initial_tree`] initially returned `None`,
- /// the [`TreeUpdate`] returned by the provided function must contain
- /// a full tree.
- ///
- /// If a [`QueuedEvents`] instance is returned, the caller must call
- /// [`QueuedEvents::raise`] on it.
- pub fn update_if_active(
- &mut self,
- update_factory: impl FnOnce() -> TreeUpdate,
- ) -> Option<QueuedEvents> {
- match &self.state {
- State::Inactive { .. } => None,
- State::Placeholder {
- placeholder_context,
- is_view_focused,
- action_handler,
- } => {
- let tree = Tree::new(update_factory(), *is_view_focused);
- let context = Context::new(
- placeholder_context.view.clone(),
- tree,
- Rc::clone(action_handler),
- placeholder_context.mtm,
- );
- let result = context.tree.borrow().state().focus().map(|node| {
- QueuedEvents::new(Rc::clone(&context), vec![focus_event(node.id())])
- });
- self.state = State::Active(context);
- result
- }
- State::Active(context) => {
- let mut event_generator = EventGenerator::new(context.clone());
- let mut tree = context.tree.borrow_mut();
- tree.update_and_process_changes(update_factory(), &mut event_generator);
- Some(event_generator.into_result())
- }
- }
- }
-
- /// Update the tree state based on whether the window is focused.
- ///
- /// If a [`QueuedEvents`] instance is returned, the caller must call
- /// [`QueuedEvents::raise`] on it.
- pub fn update_view_focus_state(&mut self, is_focused: bool) -> Option<QueuedEvents> {
- match &mut self.state {
- State::Inactive {
- is_view_focused, ..
- } => {
- *is_view_focused = is_focused;
- None
- }
- State::Placeholder {
- is_view_focused, ..
- } => {
- *is_view_focused = is_focused;
- None
- }
- State::Active(context) => {
- let mut event_generator = EventGenerator::new(context.clone());
- let mut tree = context.tree.borrow_mut();
- tree.update_host_focus_state_and_process_changes(is_focused, &mut event_generator);
- Some(event_generator.into_result())
- }
- }
- }
-
- fn get_or_init_context<H: ActivationHandler + ?Sized>(
- &mut self,
- activation_handler: &mut H,
- ) -> Rc<Context> {
- match &self.state {
- State::Inactive {
- view,
- is_view_focused,
- action_handler,
- mtm,
- } => match activation_handler.request_initial_tree() {
- Some(initial_state) => {
- let tree = Tree::new(initial_state, *is_view_focused);
- let context = Context::new(view.clone(), tree, Rc::clone(action_handler), *mtm);
- let result = Rc::clone(&context);
- self.state = State::Active(context);
- result
- }
- None => {
- let placeholder_update = TreeUpdate {
- nodes: vec![(PLACEHOLDER_ROOT_ID, NodeProvider::new(Role::Window))],
- tree: Some(TreeData::new(PLACEHOLDER_ROOT_ID)),
- tree_id: TreeId::ROOT,
- focus: PLACEHOLDER_ROOT_ID,
- };
- let placeholder_tree = Tree::new(placeholder_update, false);
- let placeholder_context = Context::new(
- view.clone(),
- placeholder_tree,
- Rc::new(ActionHandlerWrapper::new(PlaceholderActionHandler {})),
- *mtm,
- );
- let result = Rc::clone(&placeholder_context);
- self.state = State::Placeholder {
- placeholder_context,
- is_view_focused: *is_view_focused,
- action_handler: Rc::clone(action_handler),
- };
- result
- }
- },
- State::Placeholder {
- placeholder_context,
- ..
- } => Rc::clone(placeholder_context),
- State::Active(context) => Rc::clone(context),
- }
- }
-
- pub fn view_children<H: ActivationHandler + ?Sized>(
- &mut self,
- activation_handler: &mut H,
- ) -> *mut NSArray<NSObject> {
- let context = self.get_or_init_context(activation_handler);
- let tree = context.tree.borrow();
- let state = tree.state();
- let node = state.root();
- let platform_nodes = if filter(&node) == FilterResult::Include {
- vec![Id::into_super(Id::into_super(
- context.get_or_create_platform_node(node.id()),
- ))]
- } else {
- node.filtered_children(filter)
- .map(|node| {
- Id::into_super(Id::into_super(
- context.get_or_create_platform_node(node.id()),
- ))
- })
- .collect::<Vec<Id<NSObject>>>()
- };
- let array = NSArray::from_vec(platform_nodes);
- Id::autorelease_return(array)
- }
-
- pub fn focus<H: ActivationHandler + ?Sized>(
- &mut self,
- activation_handler: &mut H,
- ) -> *mut NSObject {
- let context = self.get_or_init_context(activation_handler);
- let tree = context.tree.borrow();
- let state = tree.state();
- if let Some(node) = state.focus() {
- if can_be_focused(&node) {
- return Id::autorelease_return(context.get_or_create_platform_node(node.id()))
- as *mut _;
- }
- }
- null_mut()
- }
-
- fn weak_view(&self) -> &WeakId<NSView> {
- match &self.state {
- State::Inactive { view, .. } => view,
- State::Placeholder {
- placeholder_context,
- ..
- } => &placeholder_context.view,
- State::Active(context) => &context.view,
- }
- }
-
- pub fn hit_test<H: ActivationHandler + ?Sized>(
- &mut self,
- point: NSPoint,
- activation_handler: &mut H,
- ) -> *mut NSObject {
- let view = match self.weak_view().load() {
- Some(view) => view,
- None => {
- return null_mut();
- }
- };
-
- let context = self.get_or_init_context(activation_handler);
- let tree = context.tree.borrow();
- let state = tree.state();
- let root = state.root();
- let point = from_ns_point(&view, &root, point);
- let node = root.node_at_point(point, &filter).unwrap_or(root);
- Id::autorelease_return(context.get_or_create_platform_node(node.id())) as *mut _
- }
-}
diff --git a/vendor/accesskit_macos/src/context.rs b/vendor/accesskit_macos/src/context.rs
deleted file mode 100644
index 687fcbc6bb..0000000000
--- a/vendor/accesskit_macos/src/context.rs
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use crate::node::PlatformNode;
-use accesskit::{ActionHandler, ActionRequest};
-use accesskit_consumer::{NodeId, Tree};
-use hashbrown::HashMap;
-use objc2::rc::{Id, WeakId};
-use objc2_app_kit::*;
-use objc2_foundation::MainThreadMarker;
-use std::fmt::Debug;
-use std::{cell::RefCell, rc::Rc};
-
-pub(crate) trait ActionHandlerNoMut {
- fn do_action(&self, request: ActionRequest);
-}
-
-pub(crate) struct ActionHandlerWrapper<H: ActionHandler>(RefCell<H>);
-
-impl<H: 'static + ActionHandler> ActionHandlerWrapper<H> {
- pub(crate) fn new(inner: H) -> Self {
- Self(RefCell::new(inner))
- }
-}
-
-impl<H: ActionHandler> ActionHandlerNoMut for ActionHandlerWrapper<H> {
- fn do_action(&self, request: ActionRequest) {
- self.0.borrow_mut().do_action(request)
- }
-}
-
-pub(crate) struct Context {
- pub(crate) view: WeakId<NSView>,
- pub(crate) tree: RefCell<Tree>,
- pub(crate) action_handler: Rc<dyn ActionHandlerNoMut>,
- platform_nodes: RefCell<HashMap<NodeId, Id<PlatformNode>>>,
- pub(crate) mtm: MainThreadMarker,
-}
-
-impl Debug for Context {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- f.debug_struct("Context")
- .field("view", &self.view)
- .field("tree", &self.tree)
- .field("action_handler", &"ActionHandler")
- .field("platform_nodes", &self.platform_nodes)
- .field("mtm", &self.mtm)
- .finish()
- }
-}
-
-impl Context {
- pub(crate) fn new(
- view: WeakId<NSView>,
- tree: Tree,
- action_handler: Rc<dyn ActionHandlerNoMut>,
- mtm: MainThreadMarker,
- ) -> Rc<Self> {
- Rc::new(Self {
- view,
- tree: RefCell::new(tree),
- action_handler,
- platform_nodes: RefCell::new(HashMap::new()),
- mtm,
- })
- }
-
- pub(crate) fn get_or_create_platform_node(self: &Rc<Self>, id: NodeId) -> Id<PlatformNode> {
- let mut platform_nodes = self.platform_nodes.borrow_mut();
- if let Some(result) = platform_nodes.get(&id) {
- return result.clone();
- }
-
- let result = PlatformNode::new(Rc::downgrade(self), id);
- platform_nodes.insert(id, result.clone());
- result
- }
-
- pub(crate) fn remove_platform_node(&self, id: NodeId) -> Option<Id<PlatformNode>> {
- let mut platform_nodes = self.platform_nodes.borrow_mut();
- platform_nodes.remove(&id)
- }
-
- pub(crate) fn do_action(&self, request: ActionRequest) {
- self.action_handler.do_action(request);
- }
-}
-
-impl Drop for Context {
- fn drop(&mut self) {
- let platform_nodes = self.platform_nodes.borrow();
- for platform_node in platform_nodes.values() {
- unsafe {
- NSAccessibilityPostNotification(
- platform_node,
- NSAccessibilityUIElementDestroyedNotification,
- )
- };
- }
- }
-}
diff --git a/vendor/accesskit_macos/src/event.rs b/vendor/accesskit_macos/src/event.rs
deleted file mode 100644
index 5a1cdc41ce..0000000000
--- a/vendor/accesskit_macos/src/event.rs
+++ /dev/null
@@ -1,330 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use accesskit::{Live, Role};
-use accesskit_consumer::{FilterResult, Node, NodeId, TreeChangeHandler};
-use hashbrown::HashSet;
-use objc2::runtime::{AnyObject, ProtocolObject};
-use objc2_app_kit::*;
-use objc2_foundation::{NSMutableDictionary, NSNumber, NSString};
-use std::{collections::VecDeque, rc::Rc};
-
-use crate::{
- context::Context,
- filters::filter,
- node::{NodeWrapper, Value},
-};
-
-// This type is designed to be safe to create on a non-main thread
-// and send to the main thread. This ability isn't yet used though.
-pub(crate) enum QueuedEvent {
- Generic {
- node_id: NodeId,
- notification: &'static NSAccessibilityNotificationName,
- },
- NodeDestroyed(NodeId),
- Announcement {
- text: String,
- priority: NSAccessibilityPriorityLevel,
- },
-}
-
-impl QueuedEvent {
- fn live_region_announcement(node: &Node) -> Self {
- Self::Announcement {
- text: node.value().unwrap(),
- priority: if node.live() == Live::Assertive {
- NSAccessibilityPriorityLevel::NSAccessibilityPriorityHigh
- } else {
- NSAccessibilityPriorityLevel::NSAccessibilityPriorityMedium
- },
- }
- }
-
- fn raise(self, context: &Rc<Context>) {
- match self {
- Self::Generic {
- node_id,
- notification,
- } => {
- let platform_node = context.get_or_create_platform_node(node_id);
- unsafe { NSAccessibilityPostNotification(&platform_node, notification) };
- }
- Self::NodeDestroyed(node_id) => {
- if let Some(platform_node) = context.remove_platform_node(node_id) {
- unsafe {
- NSAccessibilityPostNotification(
- &platform_node,
- NSAccessibilityUIElementDestroyedNotification,
- )
- };
- }
- }
- Self::Announcement { text, priority } => {
- let view = match context.view.load() {
- Some(view) => view,
- None => {
- return;
- }
- };
-
- let window = match view.window() {
- Some(window) => window,
- None => {
- return;
- }
- };
-
- let mut user_info = NSMutableDictionary::<_, AnyObject>::new();
- let text = NSString::from_str(&text);
- unsafe {
- user_info.setObject_forKey(
- &*text,
- ProtocolObject::from_ref(NSAccessibilityAnnouncementKey),
- )
- };
- let priority = NSNumber::new_isize(priority.0);
- unsafe {
- user_info.setObject_forKey(
- &*priority,
- ProtocolObject::from_ref(NSAccessibilityPriorityKey),
- )
- };
-
- unsafe {
- NSAccessibilityPostNotificationWithUserInfo(
- &window,
- NSAccessibilityAnnouncementRequestedNotification,
- Some(&**user_info),
- )
- };
- }
- }
- }
-}
-
-/// Events generated by a tree update.
-#[must_use = "events must be explicitly raised"]
-pub struct QueuedEvents {
- context: Rc<Context>,
- events: Vec<QueuedEvent>,
-}
-
-impl QueuedEvents {
- pub(crate) fn new(context: Rc<Context>, events: Vec<QueuedEvent>) -> Self {
- Self { context, events }
- }
-
- /// Raise all queued events synchronously.
- ///
- /// It is unknown whether accessibility methods on the view may be
- /// called while events are being raised. This means that any locks
- /// or runtime borrows required to access the adapter must not
- /// be held while this method is called.
- pub fn raise(self) {
- for event in self.events {
- event.raise(&self.context);
- }
- }
-}
-
-pub(crate) fn focus_event(node_id: NodeId) -> QueuedEvent {
- QueuedEvent::Generic {
- node_id,
- notification: unsafe { NSAccessibilityFocusedUIElementChangedNotification },
- }
-}
-
-pub(crate) struct EventGenerator {
- context: Rc<Context>,
- events: Vec<QueuedEvent>,
- text_changed: HashSet<NodeId>,
- selected_rows_changed: HashSet<NodeId>,
-}
-
-impl EventGenerator {
- pub(crate) fn new(context: Rc<Context>) -> Self {
- Self {
- context,
- events: Vec::new(),
- text_changed: HashSet::new(),
- selected_rows_changed: HashSet::new(),
- }
- }
-
- pub(crate) fn into_result(self) -> QueuedEvents {
- QueuedEvents::new(self.context, self.events)
- }
-
- fn remove_subtree(&mut self, node: &Node) {
- let mut to_remove = VecDeque::new();
- to_remove.push_back(*node);
-
- while let Some(node) = to_remove.pop_front() {
- for child in node.filtered_children(&filter) {
- to_remove.push_back(child);
- }
-
- self.events.push(QueuedEvent::NodeDestroyed(node.id()));
- }
- }
-
- fn insert_text_change_if_needed_parent(&mut self, node: Node) {
- if !node.supports_text_ranges() {
- return;
- }
- let id = node.id();
- if self.text_changed.contains(&id) {
- return;
- }
- // Text change events must come before selection change
- // events. It doesn't matter if text change events come
- // before other events.
- self.events.insert(
- 0,
- QueuedEvent::Generic {
- node_id: id,
- notification: unsafe { NSAccessibilityValueChangedNotification },
- },
- );
- self.text_changed.insert(id);
- }
-
- fn insert_text_change_if_needed(&mut self, node: &Node) {
- if node.role() != Role::TextRun {
- return;
- }
- if let Some(node) = node.filtered_parent(&filter) {
- self.insert_text_change_if_needed_parent(node);
- }
- }
-
- fn enqueue_selected_rows_change_if_needed_parent(&mut self, node: Node) {
- let id = node.id();
- if self.selected_rows_changed.contains(&id) {
- return;
- }
- self.events.push(QueuedEvent::Generic {
- node_id: id,
- notification: unsafe { NSAccessibilitySelectedRowsChangedNotification },
- });
- self.selected_rows_changed.insert(id);
- }
-
- fn enqueue_selected_rows_change_if_needed(&mut self, node: &Node) {
- let wrapper = NodeWrapper(node);
- if !wrapper.is_item_like() {
- return;
- }
- if let Some(node) = node.selection_container(&filter) {
- self.enqueue_selected_rows_change_if_needed_parent(node);
- }
- }
-}
-
-impl TreeChangeHandler for EventGenerator {
- fn node_added(&mut self, node: &Node) {
- self.insert_text_change_if_needed(node);
- if filter(node) != FilterResult::Include {
- return;
- }
- if let Some(true) = node.is_selected() {
- self.enqueue_selected_rows_change_if_needed(node);
- }
- if node.value().is_some() && node.live() != Live::Off {
- self.events
- .push(QueuedEvent::live_region_announcement(node));
- }
- }
-
- fn node_updated(&mut self, old_node: &Node, new_node: &Node) {
- if old_node.raw_value() != new_node.raw_value() {
- self.insert_text_change_if_needed(new_node);
- }
- let old_filter_result = filter(old_node);
- let new_filter_result = filter(new_node);
- if new_filter_result != FilterResult::Include {
- if old_filter_result == FilterResult::Include && old_node.is_selected() == Some(true) {
- self.enqueue_selected_rows_change_if_needed(old_node);
- }
- if new_filter_result == FilterResult::ExcludeSubtree {
- self.remove_subtree(old_node);
- } else {
- self.events.push(QueuedEvent::NodeDestroyed(new_node.id()));
- }
- return;
- }
- let node_id = new_node.id();
- let old_wrapper = NodeWrapper(old_node);
- let new_wrapper = NodeWrapper(new_node);
- if old_wrapper.title() != new_wrapper.title() {
- self.events.push(QueuedEvent::Generic {
- node_id,
- notification: unsafe { NSAccessibilityTitleChangedNotification },
- });
- }
- let new_value = new_wrapper.value();
- if old_wrapper.value() != new_value {
- if !new_node.is_focused() && new_value.is_some_and(|v| matches!(v, Value::Bool(_))) {
- // Bool value changed event for the focused node must come last
- // in order for VoiceOver to announce it. Otherwise, if we raise
- // bool value changed events for other nodes after this one, VoiceOver
- // will announce them instead.
- self.events.insert(
- 0,
- QueuedEvent::Generic {
- node_id,
- notification: unsafe { NSAccessibilityValueChangedNotification },
- },
- );
- } else {
- self.events.push(QueuedEvent::Generic {
- node_id,
- notification: unsafe { NSAccessibilityValueChangedNotification },
- });
- }
- }
- if old_wrapper.supports_text_ranges()
- && new_wrapper.supports_text_ranges()
- && old_wrapper.raw_text_selection() != new_wrapper.raw_text_selection()
- {
- self.events.push(QueuedEvent::Generic {
- node_id,
- notification: unsafe { NSAccessibilitySelectedTextChangedNotification },
- });
- }
- if new_node.value().is_some()
- && new_node.live() != Live::Off
- && (new_node.value() != old_node.value()
- || new_node.live() != old_node.live()
- || old_filter_result != FilterResult::Include)
- {
- self.events
- .push(QueuedEvent::live_region_announcement(new_node));
- }
- if new_node.is_selected() != old_node.is_selected()
- || (old_filter_result != FilterResult::Include && new_node.is_selected() == Some(true))
- {
- self.enqueue_selected_rows_change_if_needed(new_node);
- }
- }
-
- fn focus_moved(&mut self, _old_node: Option<&Node>, new_node: Option<&Node>) {
- if let Some(new_node) = new_node {
- if filter(new_node) != FilterResult::Include {
- return;
- }
- self.events.push(focus_event(new_node.id()));
- }
- }
-
- fn node_removed(&mut self, node: &Node) {
- self.insert_text_change_if_needed(node);
- if let Some(true) = node.is_selected() {
- self.enqueue_selected_rows_change_if_needed(node);
- }
- self.events.push(QueuedEvent::NodeDestroyed(node.id()));
- }
-}
diff --git a/vendor/accesskit_macos/src/filters.rs b/vendor/accesskit_macos/src/filters.rs
deleted file mode 100644
index 2802d57e64..0000000000
--- a/vendor/accesskit_macos/src/filters.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright 2023 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-pub(crate) use accesskit_consumer::common_filter as filter;
diff --git a/vendor/accesskit_macos/src/lib.rs b/vendor/accesskit_macos/src/lib.rs
deleted file mode 100644
index 5b795424ea..0000000000
--- a/vendor/accesskit_macos/src/lib.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-#![deny(unsafe_op_in_unsafe_fn)]
-
-mod context;
-mod filters;
-mod node;
-mod util;
-
-mod adapter;
-pub use adapter::Adapter;
-
-mod event;
-pub use event::QueuedEvents;
-
-mod patch;
-pub use patch::add_focus_forwarder_to_window_class;
-
-mod subclass;
-pub use subclass::SubclassingAdapter;
-
-pub use objc2_foundation::{NSArray, NSObject, NSPoint};
diff --git a/vendor/accesskit_macos/src/node.rs b/vendor/accesskit_macos/src/node.rs
deleted file mode 100644
index 16314b5b47..0000000000
--- a/vendor/accesskit_macos/src/node.rs
+++ /dev/null
@@ -1,1338 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-// Derived from Chromium's accessibility abstraction.
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE.chromium file.
-
-#![allow(non_upper_case_globals)]
-
-use accesskit::{
- Action, ActionData, ActionRequest, Orientation, Role, TextAlign, TextSelection, Toggled,
-};
-use accesskit_consumer::{FilterResult, Node, NodeId, Tree};
-use objc2::{
- ClassType, DeclaredClass, declare_class, msg_send_id,
- mutability::InteriorMutable,
- rc::Id,
- runtime::{AnyObject, Sel},
- sel,
-};
-use objc2_app_kit::*;
-use objc2_foundation::{
- NSArray, NSAttributedString, NSCopying, NSInteger, NSMutableAttributedString,
- NSMutableDictionary, NSNumber, NSObject, NSObjectProtocol, NSPoint, NSRange, NSRect, NSString,
- NSURL, ns_string,
-};
-use std::rc::{Rc, Weak};
-
-use crate::{context::Context, filters::filter, util::*};
-
-const SCROLL_TO_VISIBLE_ACTION: &str = "AXScrollToVisible";
-
-fn ns_role(node: &Node) -> &'static NSAccessibilityRole {
- let role = node.role();
- // TODO: Handle special cases.
- unsafe {
- match role {
- Role::Unknown => NSAccessibilityUnknownRole,
- Role::TextRun => NSAccessibilityUnknownRole,
- Role::Cell | Role::GridCell => NSAccessibilityCellRole,
- Role::Label => NSAccessibilityStaticTextRole,
- Role::Image => NSAccessibilityImageRole,
- Role::Link => NSAccessibilityLinkRole,
- Role::Row => NSAccessibilityRowRole,
- Role::ListItem => NSAccessibilityGroupRole,
- Role::ListMarker => ns_string!("AXListMarker"),
- Role::TreeItem => NSAccessibilityRowRole,
- Role::ListBoxOption => NSAccessibilityStaticTextRole,
- Role::MenuItem => NSAccessibilityMenuItemRole,
- Role::MenuListOption => NSAccessibilityMenuItemRole,
- Role::Paragraph => NSAccessibilityGroupRole,
- Role::GenericContainer => NSAccessibilityUnknownRole,
- Role::CheckBox => NSAccessibilityCheckBoxRole,
- Role::RadioButton => NSAccessibilityRadioButtonRole,
- Role::TextInput
- | Role::SearchInput
- | Role::EmailInput
- | Role::NumberInput
- | Role::PasswordInput
- | Role::PhoneNumberInput
- | Role::UrlInput => NSAccessibilityTextFieldRole,
- Role::Button => {
- if node.toggled().is_some() {
- NSAccessibilityCheckBoxRole
- } else {
- NSAccessibilityButtonRole
- }
- }
- Role::DefaultButton => NSAccessibilityButtonRole,
- Role::Pane => NSAccessibilityUnknownRole,
- Role::RowHeader => NSAccessibilityCellRole,
- Role::ColumnHeader => NSAccessibilityCellRole,
- Role::RowGroup => NSAccessibilityGroupRole,
- Role::List => NSAccessibilityListRole,
- Role::Table => NSAccessibilityTableRole,
- Role::LayoutTableCell => NSAccessibilityGroupRole,
- Role::LayoutTableRow => NSAccessibilityGroupRole,
- Role::LayoutTable => NSAccessibilityGroupRole,
- Role::Switch => NSAccessibilityCheckBoxRole,
- Role::Menu => NSAccessibilityMenuRole,
- Role::MultilineTextInput => NSAccessibilityTextAreaRole,
- Role::DateInput | Role::DateTimeInput | Role::WeekInput | Role::MonthInput => {
- ns_string!("AXDateField")
- }
- Role::TimeInput => ns_string!("AXTimeField"),
- Role::Abbr => NSAccessibilityGroupRole,
- Role::Alert => NSAccessibilityGroupRole,
- Role::AlertDialog => NSAccessibilityWindowRole,
- Role::Application => NSAccessibilityGroupRole,
- Role::Article => NSAccessibilityGroupRole,
- Role::Audio => NSAccessibilityGroupRole,
- Role::Banner => NSAccessibilityGroupRole,
- Role::Blockquote => NSAccessibilityGroupRole,
- Role::Canvas => NSAccessibilityImageRole,
- Role::Caption => NSAccessibilityGroupRole,
- Role::Caret => NSAccessibilityUnknownRole,
- Role::Code => NSAccessibilityGroupRole,
- Role::ColorWell => NSAccessibilityColorWellRole,
- Role::ComboBox => NSAccessibilityPopUpButtonRole,
- Role::EditableComboBox => NSAccessibilityComboBoxRole,
- Role::Complementary => NSAccessibilityGroupRole,
- Role::Comment => NSAccessibilityGroupRole,
- Role::ContentDeletion => NSAccessibilityGroupRole,
- Role::ContentInsertion => NSAccessibilityGroupRole,
- Role::ContentInfo => NSAccessibilityGroupRole,
- Role::Definition => NSAccessibilityGroupRole,
- Role::DescriptionList => NSAccessibilityListRole,
- Role::Details => NSAccessibilityGroupRole,
- Role::Dialog => NSAccessibilityWindowRole,
- Role::DisclosureTriangle => NSAccessibilityButtonRole,
- Role::Document => NSAccessibilityGroupRole,
- Role::EmbeddedObject => NSAccessibilityGroupRole,
- Role::Emphasis => NSAccessibilityGroupRole,
- Role::Feed => NSAccessibilityUnknownRole,
- Role::FigureCaption => NSAccessibilityGroupRole,
- Role::Figure => NSAccessibilityGroupRole,
- Role::Footer => NSAccessibilityGroupRole,
- Role::Form => NSAccessibilityGroupRole,
- Role::Grid => NSAccessibilityTableRole,
- Role::Group => NSAccessibilityGroupRole,
- Role::Header => NSAccessibilityGroupRole,
- Role::Heading => ns_string!("Heading"),
- Role::Iframe => NSAccessibilityGroupRole,
- Role::IframePresentational => NSAccessibilityGroupRole,
- Role::ImeCandidate => NSAccessibilityUnknownRole,
- Role::Keyboard => NSAccessibilityUnknownRole,
- Role::Legend => NSAccessibilityGroupRole,
- Role::LineBreak => NSAccessibilityGroupRole,
- Role::ListBox => NSAccessibilityListRole,
- Role::Log => NSAccessibilityGroupRole,
- Role::Main => NSAccessibilityGroupRole,
- Role::Mark => NSAccessibilityGroupRole,
- Role::Marquee => NSAccessibilityGroupRole,
- Role::Math => NSAccessibilityGroupRole,
- Role::MenuBar => NSAccessibilityMenuBarRole,
- Role::MenuItemCheckBox => NSAccessibilityMenuItemRole,
- Role::MenuItemRadio => NSAccessibilityMenuItemRole,
- Role::MenuListPopup => NSAccessibilityMenuRole,
- Role::Meter => NSAccessibilityLevelIndicatorRole,
- Role::Navigation => NSAccessibilityGroupRole,
- Role::Note => NSAccessibilityGroupRole,
- Role::PluginObject => NSAccessibilityGroupRole,
- Role::ProgressIndicator => NSAccessibilityProgressIndicatorRole,
- Role::RadioGroup => NSAccessibilityRadioGroupRole,
- Role::Region => NSAccessibilityGroupRole,
- Role::RootWebArea => ns_string!("AXWebArea"),
- Role::Ruby => NSAccessibilityGroupRole,
- Role::RubyAnnotation => NSAccessibilityUnknownRole,
- Role::ScrollBar => NSAccessibilityScrollBarRole,
- Role::ScrollView => NSAccessibilityUnknownRole,
- Role::Search => NSAccessibilityGroupRole,
- Role::Section => NSAccessibilityGroupRole,
- Role::SectionFooter => NSAccessibilityGroupRole,
- Role::SectionHeader => NSAccessibilityGroupRole,
- Role::Slider => NSAccessibilitySliderRole,
- Role::SpinButton => NSAccessibilityIncrementorRole,
- Role::Splitter => NSAccessibilitySplitterRole,
- Role::Status => NSAccessibilityGroupRole,
- Role::Strong => NSAccessibilityGroupRole,
- Role::Suggestion => NSAccessibilityGroupRole,
- Role::SvgRoot => NSAccessibilityGroupRole,
- Role::Tab => NSAccessibilityRadioButtonRole,
- Role::TabList => NSAccessibilityTabGroupRole,
- Role::TabPanel => NSAccessibilityGroupRole,
- Role::Term => NSAccessibilityGroupRole,
- Role::Time => NSAccessibilityGroupRole,
- Role::Timer => NSAccessibilityGroupRole,
- Role::TitleBar => NSAccessibilityStaticTextRole,
- Role::Toolbar => NSAccessibilityToolbarRole,
- Role::Tooltip => NSAccessibilityGroupRole,
- Role::Tree => NSAccessibilityOutlineRole,
- Role::TreeGrid => NSAccessibilityTableRole,
- Role::Video => NSAccessibilityGroupRole,
- Role::WebView => NSAccessibilityUnknownRole,
- // Use the group role for Role::Window, since the NSWindow
- // provides the top-level accessibility object for the window.
- Role::Window => NSAccessibilityGroupRole,
- Role::PdfActionableHighlight => NSAccessibilityButtonRole,
- Role::PdfRoot => NSAccessibilityGroupRole,
- Role::GraphicsDocument => NSAccessibilityGroupRole,
- Role::GraphicsObject => NSAccessibilityGroupRole,
- Role::GraphicsSymbol => NSAccessibilityImageRole,
- Role::DocAbstract => NSAccessibilityGroupRole,
- Role::DocAcknowledgements => NSAccessibilityGroupRole,
- Role::DocAfterword => NSAccessibilityGroupRole,
- Role::DocAppendix => NSAccessibilityGroupRole,
- Role::DocBackLink => NSAccessibilityLinkRole,
- Role::DocBiblioEntry => NSAccessibilityGroupRole,
- Role::DocBibliography => NSAccessibilityGroupRole,
- Role::DocBiblioRef => NSAccessibilityGroupRole,
- Role::DocChapter => NSAccessibilityGroupRole,
- Role::DocColophon => NSAccessibilityGroupRole,
- Role::DocConclusion => NSAccessibilityGroupRole,
- Role::DocCover => NSAccessibilityImageRole,
- Role::DocCredit => NSAccessibilityGroupRole,
- Role::DocCredits => NSAccessibilityGroupRole,
- Role::DocDedication => NSAccessibilityGroupRole,
- Role::DocEndnote => NSAccessibilityGroupRole,
- Role::DocEndnotes => NSAccessibilityGroupRole,
- Role::DocEpigraph => NSAccessibilityGroupRole,
- Role::DocEpilogue => NSAccessibilityGroupRole,
- Role::DocErrata => NSAccessibilityGroupRole,
- Role::DocExample => NSAccessibilityGroupRole,
- Role::DocFootnote => NSAccessibilityGroupRole,
- Role::DocForeword => NSAccessibilityGroupRole,
- Role::DocGlossary => NSAccessibilityGroupRole,
- Role::DocGlossRef => NSAccessibilityLinkRole,
- Role::DocIndex => NSAccessibilityGroupRole,
- Role::DocIntroduction => NSAccessibilityGroupRole,
- Role::DocNoteRef => NSAccessibilityLinkRole,
- Role::DocNotice => NSAccessibilityGroupRole,
- Role::DocPageBreak => NSAccessibilitySplitterRole,
- Role::DocPageFooter => NSAccessibilityGroupRole,
- Role::DocPageHeader => NSAccessibilityGroupRole,
- Role::DocPageList => NSAccessibilityGroupRole,
- Role::DocPart => NSAccessibilityGroupRole,
- Role::DocPreface => NSAccessibilityGroupRole,
- Role::DocPrologue => NSAccessibilityGroupRole,
- Role::DocPullquote => NSAccessibilityGroupRole,
- Role::DocQna => NSAccessibilityGroupRole,
- Role::DocSubtitle => ns_string!("AXHeading"),
- Role::DocTip => NSAccessibilityGroupRole,
- Role::DocToc => NSAccessibilityGroupRole,
- Role::ListGrid => NSAccessibilityUnknownRole,
- Role::Terminal => NSAccessibilityTextAreaRole,
- }
- }
-}
-
-fn ns_sub_role(node: &Node) -> &'static NSAccessibilitySubrole {
- let role = node.role();
-
- unsafe {
- match role {
- Role::Alert => ns_string!("AXApplicationAlert"),
- Role::AlertDialog => NSAccessibilityDialogSubrole,
- Role::Article => ns_string!("AXDocumentArticle"),
- Role::Banner => ns_string!("AXLandmarkBanner"),
- Role::Button if node.toggled().is_some() => NSAccessibilityToggleSubrole,
- Role::Code => ns_string!("AXCodeStyleGroup"),
- Role::Complementary => ns_string!("AXLandmarkComplementary"),
- Role::ContentDeletion => ns_string!("AXDeleteStyleGroup"),
- Role::ContentInsertion => ns_string!("AXInsertStyleGroup"),
- Role::ContentInfo => ns_string!("AXLandmarkContentInfo"),
- Role::Definition => ns_string!("AXDefinition"),
- Role::Dialog => NSAccessibilityDialogSubrole,
- Role::Document => ns_string!("AXDocument"),
- Role::Emphasis => ns_string!("AXEmphasisStyleGroup"),
- Role::Feed => ns_string!("AXApplicationGroup"),
- Role::Footer => ns_string!("AXLandmarkContentInfo"),
- Role::Form => ns_string!("AXLandmarkForm"),
- Role::GraphicsDocument => ns_string!("AXDocument"),
- Role::Group => ns_string!("AXApplicationGroup"),
- Role::Header => ns_string!("AXLandmarkBanner"),
- Role::LayoutTableCell => NSAccessibilityGroupRole,
- Role::LayoutTableRow => NSAccessibilityTableRowSubrole,
- Role::Log => ns_string!("AXApplicationLog"),
- Role::Main => ns_string!("AXLandmarkMain"),
- Role::Marquee => ns_string!("AXApplicationMarquee"),
- Role::Math => ns_string!("AXDocumentMath"),
- Role::Meter => ns_string!("AXMeter"),
- Role::Navigation => ns_string!("AXLandmarkNavigation"),
- Role::Note => ns_string!("AXDocumentNote"),
- Role::PasswordInput => NSAccessibilitySecureTextFieldSubrole,
- Role::Region => ns_string!("AXLandmarkRegion"),
- Role::Search => ns_string!("AXLandmarkSearch"),
- Role::SearchInput => NSAccessibilitySearchFieldSubrole,
- Role::SectionFooter => ns_string!("AXSectionFooter"),
- Role::SectionHeader => ns_string!("AXSectionHeader"),
- Role::Status => ns_string!("AXApplicationStatus"),
- Role::Strong => ns_string!("AXStrongStyleGroup"),
- Role::Switch => NSAccessibilitySwitchSubrole,
- Role::Tab => NSAccessibilityTabButtonSubrole,
- Role::TabPanel => ns_string!("AXTabPanel"),
- Role::Term => ns_string!("AXTerm"),
- Role::Time => ns_string!("AXTimeGroup"),
- Role::Timer => ns_string!("AXApplicationTimer"),
- Role::TreeItem => NSAccessibilityOutlineRowSubrole,
- Role::Tooltip => ns_string!("AXUserInterfaceTooltip"),
- _ => NSAccessibilityUnknownSubrole,
- }
- }
-}
-
-pub(crate) fn can_be_focused(node: &Node) -> bool {
- filter(node) == FilterResult::Include && node.role() != Role::Window
-}
-
-#[derive(PartialEq)]
-pub(crate) enum Value {
- Bool(bool),
- Number(f64),
- String(String),
-}
-
-pub(crate) struct NodeWrapper<'a>(pub(crate) &'a Node<'a>);
-
-impl NodeWrapper<'_> {
- fn is_root(&self) -> bool {
- self.0.is_root()
- }
-
- pub(crate) fn title(&self) -> Option<String> {
- if self.is_root() && self.0.role() == Role::Window {
- // If the group element that we expose for the top-level window
- // includes a title, VoiceOver behavior is broken.
- return None;
- }
- self.0.label()
- }
-
- pub(crate) fn description(&self) -> Option<String> {
- self.0.description()
- }
-
- pub(crate) fn placeholder(&self) -> Option<&str> {
- self.0.placeholder()
- }
-
- pub(crate) fn value(&self) -> Option<Value> {
- if let Some(toggled) = self.0.toggled() {
- return Some(Value::Bool(toggled != Toggled::False));
- }
- if self.0.role() == Role::Tab {
- // On Mac, tabs are exposed as radio buttons, and are treated as checkable.
- // Also, `Node::is_selected` is mapped to checked via `accessibilityValue`.
- return Some(Value::Bool(self.0.is_selected().unwrap_or(false)));
- }
- if let Some(value) = self.0.value() {
- return Some(Value::String(value));
- }
- if let Some(value) = self.0.numeric_value() {
- return Some(Value::Number(value));
- }
- None
- }
-
- pub(crate) fn supports_text_ranges(&self) -> bool {
- self.0.supports_text_ranges()
- }
-
- pub(crate) fn raw_text_selection(&self) -> Option<&TextSelection> {
- self.0.raw_text_selection()
- }
-
- fn is_container_with_selectable_children(&self) -> bool {
- self.0.is_container_with_selectable_children() && self.0.role() != Role::TabList
- }
-
- pub(crate) fn is_item_like(&self) -> bool {
- self.0.is_item_like() && self.0.role() != Role::Tab
- }
-}
-
-// derived from objc2 0.6 `AnyObject::downcast_ref`
-// TODO: can be removed after updating objc2 to 0.6 which has `AnyObject::downcast_ref`
-fn downcast_ref<T: ClassType>(obj: &NSObject) -> Option<&T> {
- obj.is_kind_of::<T>()
- .then(|| unsafe { &*(obj as *const NSObject).cast::<T>() })
-}
-
-pub(crate) struct PlatformNodeIvars {
- context: Weak<Context>,
- node_id: NodeId,
-}
-
-declare_class!(
- #[derive(Debug)]
- pub(crate) struct PlatformNode;
-
- unsafe impl ClassType for PlatformNode {
- #[inherits(NSObject)]
- type Super = NSAccessibilityElement;
- type Mutability = InteriorMutable;
- const NAME: &'static str = "AccessKitNode";
- }
-
- impl DeclaredClass for PlatformNode {
- type Ivars = PlatformNodeIvars;
- }
-
- unsafe impl PlatformNode {
- #[method_id(accessibilityParent)]
- fn parent(&self) -> Option<Id<AnyObject>> {
- self.resolve_with_context(|node, _, context| {
- if let Some(parent) = node.filtered_parent(&filter) {
- Some(Id::into_super(Id::into_super(Id::into_super(context.get_or_create_platform_node(parent.id())))))
- } else {
- context
- .view
- .load()
- .and_then(|view| unsafe { NSAccessibility::accessibilityParent(&*view) })
- }
- })
- .flatten()
- }
-
- #[method_id(accessibilityWindow)]
- fn window(&self) -> Option<Id<AnyObject>> {
- self.resolve_with_context(|_, _, context| {
- context
- .view
- .load()
- .and_then(|view| unsafe { NSAccessibility::accessibilityParent(&*view) })
- })
- .flatten()
- }
-
- #[method_id(accessibilityTopLevelUIElement)]
- fn top_level(&self) -> Option<Id<AnyObject>> {
- self.resolve_with_context(|_, _, context| {
- context
- .view
- .load()
- .and_then(|view| unsafe { NSAccessibility::accessibilityParent(&*view) })
- })
- .flatten()
- }
-
- #[method_id(accessibilityChildren)]
- fn children(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.children_internal()
- }
-
- #[method_id(accessibilityChildrenInNavigationOrder)]
- fn children_in_navigation_order(&self) -> Option<Id<NSArray<PlatformNode>>> {
- // For now, we assume the children are in navigation order.
- self.children_internal()
- }
-
- #[method_id(accessibilitySelectedChildren)]
- fn selected_children(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.resolve_with_context(|node, _, context| {
- let wrapper = NodeWrapper(node);
- if !wrapper.is_container_with_selectable_children() {
- return None;
- }
- let platform_nodes = node
- .items(filter)
- .filter(|item| item.is_selected() == Some(true))
- .map(|child| context.get_or_create_platform_node(child.id()))
- .collect::<Vec<Id<PlatformNode>>>();
- Some(NSArray::from_vec(platform_nodes))
- })
- .flatten()
- }
-
- #[method(accessibilityFrame)]
- fn frame(&self) -> NSRect {
- self.resolve_with_context(|node, _, context| {
- let view = match context.view.load() {
- Some(view) => view,
- None => {
- return NSRect::ZERO;
- }
- };
-
- node.bounding_box().map_or_else(
- || {
- if node.is_root() {
- unsafe { NSAccessibility::accessibilityFrame(&*view) }
- } else {
- NSRect::ZERO
- }
- },
- |rect| to_ns_rect(&view, rect),
- )
- })
- .unwrap_or(NSRect::ZERO)
- }
-
- #[method_id(accessibilityRole)]
- fn role(&self) -> Id<NSAccessibilityRole> {
- self.resolve(ns_role)
- .unwrap_or(unsafe { NSAccessibilityUnknownRole })
- .copy()
- }
-
- #[method_id(accessibilitySubrole)]
- fn sub_role(&self) -> Id<NSAccessibilitySubrole> {
- self.resolve(ns_sub_role)
- .unwrap_or(unsafe { NSAccessibilityUnknownSubrole })
- .copy()
- }
-
- #[method_id(accessibilityRoleDescription)]
- fn role_description(&self) -> Option<Id<NSString>> {
- self.resolve(|node| {
- if let Some(role_description) = node.role_description() {
- Some(NSString::from_str(role_description))
- } else {
- unsafe { msg_send_id![super(self), accessibilityRoleDescription] }
- }
- })
- .flatten()
- }
-
- #[method_id(accessibilityIdentifier)]
- fn identifier(&self) -> Option<Id<NSString>> {
- self.resolve(|node| {
- node.author_id().map(NSString::from_str)
- })
- .flatten()
- }
-
- #[method_id(accessibilityTitle)]
- fn title(&self) -> Option<Id<NSString>> {
- self.resolve(|node| {
- let wrapper = NodeWrapper(node);
- wrapper.title().map(|title| NSString::from_str(&title))
- })
- .flatten()
- }
-
- #[method_id(accessibilityHelp)]
- fn description(&self) -> Option<Id<NSString>> {
- self.resolve(|node| {
- let wrapper = NodeWrapper(node);
- wrapper.description().map(|description| NSString::from_str(&description))
- })
- .flatten()
- }
-
- #[method_id(accessibilityPlaceholderValue)]
- fn placeholder(&self) -> Option<Id<NSString>> {
- self.resolve(|node| {
- let wrapper = NodeWrapper(node);
- wrapper.placeholder().map(NSString::from_str)
- })
- .flatten()
- }
-
- #[method_id(accessibilityValue)]
- fn value(&self) -> Option<Id<NSObject>> {
- self.resolve(|node| {
- let wrapper = NodeWrapper(node);
- wrapper.value().map(|value| match value {
- Value::Bool(value) => {
- Id::into_super(Id::into_super(NSNumber::new_bool(value)))
- }
- Value::Number(value) => {
- Id::into_super(Id::into_super(NSNumber::new_f64(value)))
- }
- Value::String(value) => {
- Id::into_super(NSString::from_str(&value))
- }
- })
- })
- .flatten()
- }
-
- #[method(setAccessibilityValue:)]
- fn set_value(&self, value: &NSObject) {
- if let Some(string) = downcast_ref::<NSString>(value) {
- self.resolve_with_context(|node, tree, context| {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::SetValue,
- target_tree,
- target_node,
- data: Some(ActionData::Value(string.to_string().into())),
- });
- }
- });
- } else if let Some(number) = downcast_ref::<NSNumber>(value) {
- self.resolve_with_context(|node, tree, context| {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::SetValue,
- target_tree,
- target_node,
- data: Some(ActionData::NumericValue(number.doubleValue())),
- });
- }
- });
- }
- }
-
- #[method_id(accessibilityMinValue)]
- fn min_value(&self) -> Option<Id<NSNumber>> {
- self.resolve(|node| {
- node.min_numeric_value().map(NSNumber::new_f64)
- })
- .flatten()
- }
-
- #[method_id(accessibilityMaxValue)]
- fn max_value(&self) -> Option<Id<NSNumber>> {
- self.resolve(|node| {
- node.max_numeric_value().map(NSNumber::new_f64)
- })
- .flatten()
- }
-
- #[method_id(accessibilityURL)]
- fn url(&self) -> Option<Id<NSURL>> {
- self.resolve(|node| {
- node.supports_url().then(|| node.url()).flatten().and_then(|url| {
- let ns_string = NSString::from_str(url);
- unsafe { NSURL::URLWithString(&ns_string) }
- })
- })
- .flatten()
- }
-
- #[method(accessibilityOrientation)]
- fn orientation(&self) -> NSAccessibilityOrientation {
- self.resolve(|node| {
- match node.orientation() {
- Some(Orientation::Horizontal) => NSAccessibilityOrientation::Horizontal,
- Some(Orientation::Vertical) => NSAccessibilityOrientation::Vertical,
- None => NSAccessibilityOrientation::Unknown,
- }
- })
- .unwrap_or(NSAccessibilityOrientation::Unknown)
- }
-
- #[method(isAccessibilityElement)]
- fn is_accessibility_element(&self) -> bool {
- self.resolve(|node| filter(node) == FilterResult::Include)
- .unwrap_or(false)
- }
-
- #[method(isAccessibilityFocused)]
- fn is_focused(&self) -> bool {
- self.resolve(|node| node.is_focused() && can_be_focused(node))
- .unwrap_or(false)
- }
-
- #[method(isAccessibilityEnabled)]
- fn is_enabled(&self) -> bool {
- self.resolve(|node| !node.is_disabled()).unwrap_or(false)
- }
-
- #[method(setAccessibilityFocused:)]
- fn set_focused(&self, focused: bool) {
- self.resolve_with_context(|node, tree, context| {
- if focused {
- if node.is_focusable(&filter) {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::Focus,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- } else {
- let root = tree.state().root();
- if root.is_focusable(&filter) {
- if let Some((target_node, target_tree)) = tree.state().locate_node(root.id()) {
- context.do_action(ActionRequest {
- action: Action::Focus,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- }
- });
- }
-
- #[method(accessibilityPerformPress)]
- fn press(&self) -> bool {
- self.resolve_with_context(|node, tree, context| {
- let clickable = node.is_clickable(&filter);
- if clickable {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::Click,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- clickable
- })
- .unwrap_or(false)
- }
-
- #[method(accessibilityPerformIncrement)]
- fn increment(&self) -> bool {
- self.resolve_with_context(|node, tree, context| {
- let supports_increment = node.supports_increment(&filter);
- if supports_increment {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::Increment,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- supports_increment
- })
- .unwrap_or(false)
- }
-
- #[method(accessibilityPerformDecrement)]
- fn decrement(&self) -> bool {
- self.resolve_with_context(|node, tree, context| {
- let supports_decrement = node.supports_decrement(&filter);
- if supports_decrement {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::Decrement,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- supports_decrement
- })
- .unwrap_or(false)
- }
-
- #[method(accessibilityNotifiesWhenDestroyed)]
- fn notifies_when_destroyed(&self) -> bool {
- true
- }
-
- #[method(accessibilityNumberOfCharacters)]
- fn number_of_characters(&self) -> NSInteger {
- self.resolve(|node| {
- if node.supports_text_ranges() {
- node.document_range().end().to_global_utf16_index() as _
- } else {
- 0
- }
- })
- .unwrap_or(0)
- }
-
- #[method_id(accessibilitySelectedText)]
- fn selected_text(&self) -> Option<Id<NSString>> {
- self.resolve(|node| {
- if node.supports_text_ranges() {
- if let Some(range) = node.text_selection() {
- let text = range.text();
- return Some(NSString::from_str(&text));
- }
- }
- None
- })
- .flatten()
- }
-
- #[method(accessibilitySelectedTextRange)]
- fn selected_text_range(&self) -> NSRange {
- self.resolve(|node| {
- if node.supports_text_ranges() {
- if let Some(range) = node.text_selection() {
- return to_ns_range(&range);
- }
- }
- NSRange::new(0, 0)
- })
- .unwrap_or_else(|| NSRange::new(0, 0))
- }
-
- #[method(accessibilityInsertionPointLineNumber)]
- fn insertion_point_line_number(&self) -> NSInteger {
- self.resolve(|node| {
- if node.supports_text_ranges() {
- if let Some(pos) = node.text_selection_focus() {
- return pos.to_line_index() as _;
- }
- }
- 0
- })
- .unwrap_or(0)
- }
-
- #[method(accessibilityRangeForLine:)]
- fn range_for_line(&self, line_index: NSInteger) -> NSRange {
- self.resolve(|node| {
- if node.supports_text_ranges() && line_index >= 0 {
- if let Some(range) = node.line_range_from_index(line_index as _) {
- return to_ns_range(&range);
- }
- }
- NSRange::new(0, 0)
- })
- .unwrap_or_else(|| NSRange::new(0, 0))
- }
-
- #[method(accessibilityRangeForPosition:)]
- fn range_for_position(&self, point: NSPoint) -> NSRange {
- self.resolve_with_context(|node, _, context| {
- let view = match context.view.load() {
- Some(view) => view,
- None => {
- return NSRange::new(0, 0);
- }
- };
-
- if node.supports_text_ranges() {
- let point = from_ns_point(&view, node, point);
- let pos = node.text_position_at_point(point);
- return to_ns_range_for_character(&pos);
- }
- NSRange::new(0, 0)
- })
- .unwrap_or_else(|| NSRange::new(0, 0))
- }
-
- #[method_id(accessibilityStringForRange:)]
- fn string_for_range(&self, range: NSRange) -> Option<Id<NSString>> {
- self.resolve(|node| {
- if node.supports_text_ranges() {
- if let Some(range) = from_ns_range(node, range) {
- let text = range.text();
- return Some(NSString::from_str(&text));
- }
- }
- None
- })
- .flatten()
- }
-
- #[method_id(accessibilityAttributedStringForRange:)]
- fn attributed_string_for_range(&self, range: NSRange) -> Option<Id<NSAttributedString>> {
- self.resolve(|node| {
- if node.supports_text_ranges() {
- if let Some(range) = from_ns_range(node, range) {
- let mut result = NSMutableAttributedString::new();
- unsafe { result.beginEditing() };
- range.traverse_text::<_, ()>(|node, text| {
- let ns_text = NSString::from_str(text);
- let mut attrs = NSMutableDictionary::new();
- if let Some(color) = node.background_color() {
- attrs.insert_id(
- unsafe { NSAccessibilityBackgroundColorTextAttribute },
- to_color_attribute(color)
- );
- }
- if let Some(color) = node.foreground_color() {
- attrs.insert_id(
- unsafe { NSAccessibilityForegroundColorTextAttribute },
- to_color_attribute(color)
- );
- }
- let mut font_attrs = NSMutableDictionary::<NSAccessibilityFontAttributeKey, AnyObject>::new();
- if let Some(family) = node.font_family() {
- font_attrs.insert_id(
- unsafe { NSAccessibilityFontFamilyKey },
- Id::into_super(Id::into_super(NSString::from_str(family)))
- );
- }
- if let Some(size) = node.font_size() {
- font_attrs.insert_id(
- unsafe { NSAccessibilityFontSizeKey },
- Id::into_super(Id::into_super(Id::into_super(NSNumber::new_f32(size))))
- );
- }
- if let Some(weight) = node.font_weight() {
- if weight >= 700.0 {
- font_attrs.insert_id(
- ns_string!("AXFontBold"),
- Id::into_super(Id::into_super(Id::into_super(NSNumber::new_bool(true))))
- );
- }
- }
- if node.is_italic() {
- font_attrs.insert_id(
- ns_string!("AXFontItalic"),
- Id::into_super(Id::into_super(Id::into_super(NSNumber::new_bool(true))))
- );
- }
- if !font_attrs.is_empty() {
- attrs.insert_id(
- unsafe { NSAccessibilityFontTextAttribute },
- Id::into_super(Id::into_super(Id::into_super(font_attrs)))
- );
- }
- if let Some(deco) = node.underline() {
- attrs.insert_id(
- unsafe { NSAccessibilityUnderlineTextAttribute },
- Id::into_super(Id::into_super(Id::into_super(NSNumber::new_bool(true))))
- );
- attrs.insert_id(
- unsafe { NSAccessibilityUnderlineColorTextAttribute },
- to_color_attribute(deco.color)
- );
- }
- if let Some(deco) = node.strikethrough() {
- attrs.insert_id(
- unsafe { NSAccessibilityStrikethroughTextAttribute },
- Id::into_super(Id::into_super(Id::into_super(NSNumber::new_bool(true))))
- );
- attrs.insert_id(
- unsafe { NSAccessibilityStrikethroughColorTextAttribute },
- to_color_attribute(deco.color)
- );
- }
- if let Some(language) = node.language() {
- attrs.insert_id(
- unsafe { NSAccessibilityLanguageTextAttribute },
- Id::into_super(Id::into_super(NSString::from_str(language)))
- );
- }
- if let Some(align) = node.text_align() {
- let ns_align = match align {
- TextAlign::Left => NSTextAlignment::Left,
- TextAlign::Center => NSTextAlignment::Center,
- TextAlign::Right => NSTextAlignment::Right,
- TextAlign::Justify => NSTextAlignment::Justified,
- };
- attrs.insert_id(
- unsafe { NSAccessibilityTextAlignmentAttribute },
- Id::into_super(Id::into_super(Id::into_super(NSNumber::new_isize(ns_align.0))))
- );
- }
- let part = unsafe { NSAttributedString::new_with_attributes(&ns_text, &attrs) };
- unsafe { result.appendAttributedString(&part) };
- None
- });
- unsafe { result.endEditing() };
- return Some(Id::into_super(result));
- }
- }
- None
- })
- .flatten()
- }
-
- #[method(accessibilityFrameForRange:)]
- fn frame_for_range(&self, range: NSRange) -> NSRect {
- self.resolve_with_context(|node, _, context| {
- let view = match context.view.load() {
- Some(view) => view,
- None => {
- return NSRect::ZERO;
- }
- };
-
- if node.supports_text_ranges() {
- if let Some(range) = from_ns_range(node, range) {
- let rects = range.bounding_boxes();
- if let Some(rect) =
- rects.into_iter().reduce(|rect1, rect2| rect1.union(rect2))
- {
- return to_ns_rect(&view, rect);
- }
- }
- }
- NSRect::ZERO
- })
- .unwrap_or(NSRect::ZERO)
- }
-
- #[method(accessibilityLineForIndex:)]
- fn line_for_index(&self, index: NSInteger) -> NSInteger {
- self.resolve(|node| {
- if node.supports_text_ranges() && index >= 0 {
- if let Some(pos) = node.text_position_from_global_utf16_index(index as _) {
- return pos.to_line_index() as _;
- }
- }
- 0
- })
- .unwrap_or(0)
- }
-
- #[method(accessibilityRangeForIndex:)]
- fn range_for_index(&self, index: NSInteger) -> NSRange {
- self.resolve(|node| {
- if node.supports_text_ranges() && index >= 0 {
- if let Some(pos) = node.text_position_from_global_utf16_index(index as _) {
- return to_ns_range_for_character(&pos);
- }
- }
- NSRange::new(0, 0)
- })
- .unwrap_or_else(|| NSRange::new(0, 0))
- }
-
- #[method(accessibilityStyleRangeForIndex:)]
- fn style_range_for_index(&self, index: NSInteger) -> NSRange {
- self.resolve(|node| {
- if node.supports_text_ranges() && index >= 0 {
- if let Some(pos) = node.text_position_from_global_utf16_index(index as _) {
- let start = if pos.is_format_start() {
- pos
- } else {
- pos.backward_to_format_start()
- };
- let mut range = start.to_degenerate_range();
- range.set_end(pos.forward_to_format_end());
- return to_ns_range(&range);
- }
- }
- NSRange::new(0, 0)
- })
- .unwrap_or_else(|| NSRange::new(0, 0))
- }
-
- #[method(setAccessibilitySelectedTextRange:)]
- fn set_selected_text_range(&self, range: NSRange) {
- self.resolve_with_context(|node, tree, context| {
- if node.supports_text_ranges() {
- if let Some(range) = from_ns_range(node, range) {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::SetTextSelection,
- target_tree,
- target_node,
- data: Some(ActionData::SetTextSelection(range.to_text_selection())),
- });
- }
- }
- }
- });
- }
-
- #[method(isAccessibilityRequired)]
- fn is_required(&self) -> bool {
- self.resolve(|node| node.is_required())
- .unwrap_or(false)
- }
-
- #[method(isAccessibilitySelected)]
- fn is_selected(&self) -> bool {
- self.resolve(|node| {
- let wrapper = NodeWrapper(node);
- wrapper.is_item_like()
- && node.is_selectable()
- && node.is_selected().unwrap_or(false)
- })
- .unwrap_or(false)
- }
-
- #[method(setAccessibilitySelected:)]
- fn set_selected(&self, selected: bool) {
- self.resolve_with_context(|node, tree, context| {
- let wrapper = NodeWrapper(node);
- if !node.is_clickable(&filter)
- || !wrapper.is_item_like()
- || !node.is_selectable()
- {
- return;
- }
- if node.is_selected() == Some(selected) {
- return;
- }
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::Click,
- target_tree,
- target_node,
- data: None,
- });
- }
- });
- }
-
- #[method_id(accessibilityAttributeValue:)]
- fn accessibility_attribute_value(&self, attr: &NSString) -> Option<Id<NSString>> {
- self.resolve(|node| {
- if attr == ns_string!("AXBrailleLabel") && node.has_braille_label() {
- return Some(NSString::from_str(node.braille_label().unwrap()))
- } else if attr == ns_string!("AXBrailleRoleDescription") && node.has_braille_role_description() {
- return Some(NSString::from_str(node.braille_role_description().unwrap()))
- }
-
- None
- })
- .flatten()
- }
-
- #[method_id(accessibilityRows)]
- fn rows(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.resolve_with_context(|node, _, context| {
- let wrapper = NodeWrapper(node);
- if !wrapper.is_container_with_selectable_children() {
- return None;
- }
- let platform_nodes = node
- .items(filter)
- .map(|child| context.get_or_create_platform_node(child.id()))
- .collect::<Vec<Id<PlatformNode>>>();
- Some(NSArray::from_vec(platform_nodes))
- })
- .flatten()
- }
-
- #[method_id(accessibilitySelectedRows)]
- fn selected_rows(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.resolve_with_context(|node, _, context| {
- let wrapper = NodeWrapper(node);
- if !wrapper.is_container_with_selectable_children() {
- return None;
- }
- let platform_nodes = node
- .items(filter)
- .filter(|item| item.is_selected() == Some(true))
- .map(|child| context.get_or_create_platform_node(child.id()))
- .collect::<Vec<Id<PlatformNode>>>();
- Some(NSArray::from_vec(platform_nodes))
- })
- .flatten()
- }
-
- #[method(accessibilityPerformPick)]
- fn pick(&self) -> bool {
- self.resolve_with_context(|node, tree, context| {
- let wrapper = NodeWrapper(node);
- let selectable = node.is_clickable(&filter)
- && wrapper.is_item_like()
- && node.is_selectable();
- if selectable {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::Click,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- selectable
- })
- .unwrap_or(false)
- }
-
- #[method_id(accessibilityLinkedUIElements)]
- fn linked_ui_elements(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.resolve_with_context(|node, _, context| {
- let platform_nodes: Vec<Id<PlatformNode>> = node
- .controls()
- .filter(|controlled| filter(controlled) == FilterResult::Include)
- .map(|controlled| context.get_or_create_platform_node(controlled.id()))
- .collect();
- if platform_nodes.is_empty() {
- None
- } else {
- Some(NSArray::from_vec(platform_nodes))
- }
- })
- .flatten()
- }
-
- #[method_id(accessibilityTabs)]
- fn tabs(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.resolve_with_context(|node, _, context| {
- if node.role() != Role::TabList {
- return None;
- }
- let platform_nodes = node
- .filtered_children(filter)
- .filter(|child| child.role() == Role::Tab)
- .map(|tab| context.get_or_create_platform_node(tab.id()))
- .collect::<Vec<Id<PlatformNode>>>();
- Some(NSArray::from_vec(platform_nodes))
- })
- .flatten()
- }
-
- #[method(isAccessibilityModal)]
- fn is_modal(&self) -> bool {
- self.resolve(|node| node.is_modal())
- .unwrap_or(false)
- }
-
- // We discovered through experimentation that when mixing the newer
- // NSAccessibility protocols with the older informal protocol,
- // the platform uses both protocols to discover which actions are
- // available and then perform actions. That means our implementation
- // of the legacy methods below only needs to cover actions not already
- // handled by the newer methods.
-
- #[method_id(accessibilityActionNames)]
- fn action_names(&self) -> Id<NSArray<NSString>> {
- let mut result = vec![];
- self.resolve(|node| {
- if node.supports_action(Action::ScrollIntoView, &filter) {
- result.push(ns_string!(SCROLL_TO_VISIBLE_ACTION).copy());
- }
- });
- NSArray::from_vec(result)
- }
-
- #[method(accessibilityPerformAction:)]
- fn perform_action(&self, action: &NSString) {
- self.resolve_with_context(|node, tree, context| {
- if action == ns_string!(SCROLL_TO_VISIBLE_ACTION) {
- if let Some((target_node, target_tree)) = tree.state().locate_node(node.id()) {
- context.do_action(ActionRequest {
- action: Action::ScrollIntoView,
- target_tree,
- target_node,
- data: None,
- });
- }
- }
- });
- }
-
- #[method(isAccessibilitySelectorAllowed:)]
- fn is_selector_allowed(&self, selector: Sel) -> bool {
- self.resolve(|node| {
- if selector == sel!(setAccessibilityFocused:) {
- return node.is_focusable(&filter);
- }
- if selector == sel!(accessibilityPerformPress) {
- return node.is_clickable(&filter);
- }
- if selector == sel!(accessibilityPerformIncrement) {
- return node.supports_increment(&filter);
- }
- if selector == sel!(accessibilityPerformDecrement) {
- return node.supports_decrement(&filter);
- }
- if selector == sel!(accessibilityNumberOfCharacters)
- || selector == sel!(accessibilitySelectedText)
- || selector == sel!(accessibilitySelectedTextRange)
- || selector == sel!(accessibilityInsertionPointLineNumber)
- || selector == sel!(accessibilityRangeForLine:)
- || selector == sel!(accessibilityRangeForPosition:)
- || selector == sel!(accessibilityStringForRange:)
- || selector == sel!(accessibilityAttributedStringForRange:)
- || selector == sel!(accessibilityFrameForRange:)
- || selector == sel!(accessibilityLineForIndex:)
- || selector == sel!(accessibilityRangeForIndex:)
- || selector == sel!(accessibilityStyleRangeForIndex:)
- || selector == sel!(setAccessibilitySelectedTextRange:)
- {
- return node.supports_text_ranges();
- }
- if selector == sel!(setAccessibilityValue:) {
- return (node.supports_text_ranges() && !node.is_read_only()) || node.supports_action(Action::SetValue, &filter);
- }
- if selector == sel!(isAccessibilitySelected) {
- let wrapper = NodeWrapper(node);
- return wrapper.is_item_like();
- }
- if selector == sel!(accessibilityRows)
- || selector == sel!(accessibilitySelectedRows)
- {
- let wrapper = NodeWrapper(node);
- return wrapper.is_container_with_selectable_children()
- }
- if selector == sel!(setAccessibilitySelected:)
- || selector == sel!(accessibilityPerformPick)
- {
- let wrapper = NodeWrapper(node);
- return node.is_clickable(&filter)
- && wrapper.is_item_like()
- && node.is_selectable();
- }
- if selector == sel!(accessibilityTabs) {
- return node.role() == Role::TabList;
- }
- if selector == sel!(isAccessibilityModal) {
- return node.is_dialog();
- }
- if selector == sel!(accessibilityAttributeValue:) {
- return node.has_braille_label() || node.has_braille_role_description()
- }
- if selector == sel!(accessibilityURL) {
- return node.supports_url();
- }
- selector == sel!(accessibilityParent)
- || selector == sel!(accessibilityChildren)
- || selector == sel!(accessibilityChildrenInNavigationOrder)
- || selector == sel!(accessibilitySelectedChildren)
- || selector == sel!(accessibilityFrame)
- || selector == sel!(accessibilityRole)
- || selector == sel!(accessibilitySubrole)
- || selector == sel!(isAccessibilityEnabled)
- || selector == sel!(accessibilityWindow)
- || selector == sel!(accessibilityTopLevelUIElement)
- || selector == sel!(accessibilityLinkedUIElements)
- || selector == sel!(accessibilityRoleDescription)
- || selector == sel!(accessibilityIdentifier)
- || selector == sel!(accessibilityTitle)
- || selector == sel!(accessibilityHelp)
- || selector == sel!(accessibilityPlaceholderValue)
- || selector == sel!(accessibilityValue)
- || selector == sel!(accessibilityMinValue)
- || selector == sel!(accessibilityMaxValue)
- || selector == sel!(isAccessibilityRequired)
- || selector == sel!(accessibilityOrientation)
- || selector == sel!(isAccessibilityElement)
- || selector == sel!(isAccessibilityFocused)
- || selector == sel!(accessibilityNotifiesWhenDestroyed)
- || selector == sel!(isAccessibilitySelectorAllowed:)
- || selector == sel!(accessibilityActionNames)
- || selector == sel!(accessibilityPerformAction:)
- })
- .unwrap_or(false)
- }
- }
-);
-
-impl PlatformNode {
- pub(crate) fn new(context: Weak<Context>, node_id: NodeId) -> Id<Self> {
- let this = Self::alloc().set_ivars(PlatformNodeIvars { context, node_id });
-
- unsafe { msg_send_id![super(this), init] }
- }
-
- fn resolve_with_context<F, T>(&self, f: F) -> Option<T>
- where
- F: FnOnce(&Node, &Tree, &Rc<Context>) -> T,
- {
- let context = self.ivars().context.upgrade()?;
- let tree = context.tree.borrow();
- let state = tree.state();
- let node = state.node_by_id(self.ivars().node_id)?;
- Some(f(&node, &tree, &context))
- }
-
- fn resolve<F, T>(&self, f: F) -> Option<T>
- where
- F: FnOnce(&Node) -> T,
- {
- self.resolve_with_context(|node, _, _| f(node))
- }
-
- fn children_internal(&self) -> Option<Id<NSArray<PlatformNode>>> {
- self.resolve_with_context(|node, _, context| {
- let platform_nodes = node
- .filtered_children(filter)
- .map(|child| context.get_or_create_platform_node(child.id()))
- .collect::<Vec<Id<PlatformNode>>>();
- NSArray::from_vec(platform_nodes)
- })
- }
-}
diff --git a/vendor/accesskit_macos/src/patch.rs b/vendor/accesskit_macos/src/patch.rs
deleted file mode 100644
index 1b4732eb25..0000000000
--- a/vendor/accesskit_macos/src/patch.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2023 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use objc2::{
- Message,
- encode::{Encode, EncodeArguments, EncodeReturn, Encoding},
- ffi::class_addMethod,
- msg_send,
- runtime::{AnyClass, AnyObject, Bool, MethodImplementation, Sel},
- sel,
-};
-use objc2_app_kit::NSWindow;
-use std::{ffi::CString, ptr::null_mut};
-
-extern "C" fn focus_forwarder(this: &NSWindow, _cmd: Sel) -> *mut AnyObject {
- unsafe {
- this.contentView().map_or_else(null_mut, |view| {
- msg_send![&*view, accessibilityFocusedUIElement]
- })
- }
-}
-
-/// Modifies the specified class, which must be a subclass of `NSWindow`,
-/// to include an `accessibilityFocusedUIElement` method that calls
-/// the corresponding method on the window's content view. This is needed
-/// for windowing libraries such as SDL that place the keyboard focus
-/// directly on the window rather than the content view.
-///
-/// # Safety
-///
-/// This function is declared unsafe because the caller must ensure that the
-/// code for this crate is never unloaded from the application process,
-/// since it's not possible to reverse this operation. It's safest
-/// if this crate is statically linked into the application's main executable.
-/// Also, this function assumes that the specified class is a subclass
-/// of `NSWindow`.
-pub unsafe fn add_focus_forwarder_to_window_class(class_name: &str) {
- let class = AnyClass::get(class_name).unwrap();
- unsafe {
- add_method(
- class as *const AnyClass as *mut AnyClass,
- sel!(accessibilityFocusedUIElement),
- focus_forwarder as unsafe extern "C" fn(_, _) -> _,
- )
- };
-}
-
-// The rest of this file is copied from objc2 with only minor adaptations,
-// to allow a method to be added to an existing class.
-
-unsafe fn add_method<T, F>(class: *mut AnyClass, sel: Sel, func: F)
-where
- T: Message + ?Sized,
- F: MethodImplementation<Callee = T>,
-{
- let encs = F::Arguments::ENCODINGS;
- let sel_args = count_args(sel);
- assert_eq!(
- sel_args,
- encs.len(),
- "Selector {:?} accepts {} arguments, but function accepts {}",
- sel,
- sel_args,
- encs.len(),
- );
-
- let types = method_type_encoding(&F::Return::ENCODING_RETURN, encs);
- let success = Bool::from_raw(unsafe {
- class_addMethod(
- class as *mut _,
- sel.as_ptr(),
- Some(func.__imp()),
- types.as_ptr(),
- )
- });
- assert!(success.as_bool(), "Failed to add method {sel:?}");
-}
-
-fn count_args(sel: Sel) -> usize {
- sel.name().chars().filter(|&c| c == ':').count()
-}
-
-fn method_type_encoding(ret: &Encoding, args: &[Encoding]) -> CString {
- // First two arguments are always self and the selector
- let mut types = format!("{}{}{}", ret, <*mut AnyObject>::ENCODING, Sel::ENCODING);
- for enc in args {
- use core::fmt::Write;
- write!(&mut types, "{enc}").unwrap();
- }
- CString::new(types).unwrap()
-}
diff --git a/vendor/accesskit_macos/src/subclass.rs b/vendor/accesskit_macos/src/subclass.rs
deleted file mode 100644
index b0f55477c4..0000000000
--- a/vendor/accesskit_macos/src/subclass.rs
+++ /dev/null
@@ -1,354 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-// SolidCraft: this file is accesskit_macos 0.27.2's, which leaves the view's class alone when
-// key-value observing subclassed it after the adapter did (AccessKit/accesskit#835). 0.26.3 reset
-// it on drop, and AppKit's Touch Bar then failed to remove its observers on quit (#7535).
-
-use accesskit::{ActionHandler, ActivationHandler, TreeUpdate};
-use objc2::{
- ClassType, DeclaredClass,
- declare::ClassBuilder,
- declare_class,
- ffi::{
- OBJC_ASSOCIATION_RETAIN_NONATOMIC, objc_getAssociatedObject, objc_setAssociatedObject,
- object_setClass,
- },
- msg_send, msg_send_id,
- mutability::InteriorMutable,
- rc::Id,
- runtime::{AnyClass, AnyObject, Sel},
- sel,
-};
-use objc2_app_kit::{NSView, NSWindow};
-use objc2_foundation::{NSArray, NSObject, NSPoint};
-use std::{cell::RefCell, ffi::c_void, sync::Mutex};
-
-use crate::{Adapter, event::QueuedEvents};
-
-static SUBCLASSES: Mutex<Vec<(&'static AnyClass, &'static AnyClass)>> = Mutex::new(Vec::new());
-
-static ASSOCIATED_OBJECT_KEY: u8 = 0;
-
-fn associated_object_key() -> *const c_void {
- (&ASSOCIATED_OBJECT_KEY as *const u8).cast()
-}
-
-struct AssociatedObjectState {
- adapter: Adapter,
- activation_handler: Box<dyn ActivationHandler>,
-}
-
-struct AssociatedObjectIvars {
- state: RefCell<AssociatedObjectState>,
- prev_class: &'static AnyClass,
-}
-
-declare_class!(
- struct AssociatedObject;
-
- unsafe impl ClassType for AssociatedObject {
- type Super = NSObject;
- type Mutability = InteriorMutable;
- const NAME: &'static str = "AccessKitSubclassAssociatedObject";
- }
-
- impl DeclaredClass for AssociatedObject {
- type Ivars = AssociatedObjectIvars;
- }
-);
-
-impl AssociatedObject {
- fn new(
- adapter: Adapter,
- activation_handler: impl 'static + ActivationHandler,
- prev_class: &'static AnyClass,
- ) -> Id<Self> {
- let state = RefCell::new(AssociatedObjectState {
- adapter,
- activation_handler: Box::new(activation_handler),
- });
- let this = Self::alloc().set_ivars(AssociatedObjectIvars { state, prev_class });
-
- unsafe { msg_send_id![super(this), init] }
- }
-}
-
-fn associated_object(view: &NSView) -> Option<&AssociatedObject> {
- unsafe {
- (objc_getAssociatedObject(view as *const NSView as *const _, associated_object_key())
- as *const AssociatedObject)
- .as_ref()
- }
-}
-
-// Unlike `[view class]`, this sees the subclass that key-value observing
-// hides by overriding `class`.
-fn runtime_class(view: &NSView) -> &'static AnyClass {
- let object: &AnyObject = view;
- object.class()
-}
-
-// Key-value observing may have subclassed our subclass in turn.
-fn installed_subclass(view: &NSView) -> Option<(&'static AnyClass, &'static AnyClass)> {
- let subclasses = SUBCLASSES.lock().unwrap();
- let mut class: Option<&AnyClass> = Some(runtime_class(view));
- while let Some(current) = class {
- if let Some(entry) = subclasses
- .iter()
- .find(|entry| std::ptr::eq(entry.1, current))
- {
- return Some(*entry);
- }
- class = current.superclass();
- }
- None
-}
-
-fn prev_class(view: &NSView) -> &'static AnyClass {
- installed_subclass(view).unwrap().0
-}
-
-// Some view classes, like the one in winit 0.27, assume that they are the
-// lowest subclass, and call [self superclass] to get their superclass.
-// Give them the answer they need.
-unsafe extern "C" fn superclass(this: &NSView, _cmd: Sel) -> Option<&AnyClass> {
- let prev_class = match associated_object(this) {
- Some(associated) => associated.ivars().prev_class,
- None => prev_class(this),
- };
- prev_class.superclass()
-}
-
-unsafe extern "C" fn children(this: &NSView, _cmd: Sel) -> *mut NSArray<NSObject> {
- let Some(associated) = associated_object(this) else {
- return unsafe { msg_send![super(this, prev_class(this)), accessibilityChildren] };
- };
- let mut state = associated.ivars().state.borrow_mut();
- let state_mut = &mut *state;
- state_mut
- .adapter
- .view_children(&mut *state_mut.activation_handler)
-}
-
-unsafe extern "C" fn focus(this: &NSView, _cmd: Sel) -> *mut NSObject {
- let Some(associated) = associated_object(this) else {
- return unsafe { msg_send![super(this, prev_class(this)), accessibilityFocusedUIElement] };
- };
- let mut state = associated.ivars().state.borrow_mut();
- let state_mut = &mut *state;
- state_mut.adapter.focus(&mut *state_mut.activation_handler)
-}
-
-unsafe extern "C" fn hit_test(this: &NSView, _cmd: Sel, point: NSPoint) -> *mut NSObject {
- let Some(associated) = associated_object(this) else {
- return unsafe { msg_send![super(this, prev_class(this)), accessibilityHitTest: point] };
- };
- let mut state = associated.ivars().state.borrow_mut();
- let state_mut = &mut *state;
- state_mut
- .adapter
- .hit_test(point, &mut *state_mut.activation_handler)
-}
-
-fn subclass_of(prev_class: &'static AnyClass) -> &'static AnyClass {
- let mut subclasses = SUBCLASSES.lock().unwrap();
- match subclasses
- .iter()
- .find(|entry| std::ptr::eq(entry.0, prev_class))
- {
- Some(entry) => entry.1,
- None => {
- let name = format!("AccessKitSubclassOf{}", prev_class.name());
- let mut builder = ClassBuilder::new(&name, prev_class).unwrap();
- unsafe {
- builder.add_method(
- sel!(superclass),
- superclass as unsafe extern "C" fn(_, _) -> _,
- );
- builder.add_method(
- sel!(accessibilityChildren),
- children as unsafe extern "C" fn(_, _) -> _,
- );
- builder.add_method(
- sel!(accessibilityFocusedUIElement),
- focus as unsafe extern "C" fn(_, _) -> _,
- );
- builder.add_method(
- sel!(accessibilityHitTest:),
- hit_test as unsafe extern "C" fn(_, _, _) -> _,
- );
- }
- let class = builder.register();
- subclasses.push((prev_class, class));
- class
- }
- }
-}
-
-/// Uses dynamic Objective-C subclassing to implement the `NSView`
-/// accessibility methods when normal subclassing isn't an option.
-pub struct SubclassingAdapter {
- view: Id<NSView>,
- associated: Id<AssociatedObject>,
-}
-
-impl SubclassingAdapter {
- /// Create an adapter that dynamically subclasses the specified view.
- /// This must be done before the view is shown or focused for
- /// the first time, and before anything observes the view with
- /// key-value observing.
- ///
- /// The action handler will always be called on the main thread.
- ///
- /// # Safety
- ///
- /// `view` must be a valid, unreleased pointer to an `NSView`.
- pub unsafe fn new(
- view: *mut c_void,
- activation_handler: impl 'static + ActivationHandler,
- action_handler: impl 'static + ActionHandler,
- ) -> Self {
- let view = view as *mut NSView;
- let retained_view = unsafe { Id::retain(view) }.unwrap();
- Self::new_internal(retained_view, activation_handler, action_handler)
- }
-
- fn new_internal(
- retained_view: Id<NSView>,
- activation_handler: impl 'static + ActivationHandler,
- action_handler: impl 'static + ActionHandler,
- ) -> Self {
- let view = Id::as_ptr(&retained_view) as *mut NSView;
- if !unsafe {
- objc_getAssociatedObject(view as *const NSView as *const _, associated_object_key())
- }
- .is_null()
- {
- panic!("subclassing adapter already instantiated on view {view:?}");
- }
- // A previous adapter may have left its subclass on the view,
- // if key-value observing had subclassed it in turn.
- let installed = installed_subclass(unsafe { &*view });
- if installed.is_none() {
- // Key-value observing crashes when it adds or removes an observer
- // while our subclass sits on top of its own.
- let reported_class: &AnyClass = unsafe { msg_send![view, class] };
- let actual_class = runtime_class(unsafe { &*view });
- if !std::ptr::eq(reported_class, actual_class) {
- panic!(
- "view {view:?} is already observed with key-value observing (its class {} reports itself as {}); create the subclassing adapter before anything observes the view",
- actual_class.name(),
- reported_class.name()
- );
- }
- }
- let adapter = unsafe { Adapter::new(view as *mut c_void, false, action_handler) };
- let (prev_class, subclass) = installed.unwrap_or_else(|| {
- let prev_class = runtime_class(unsafe { &*view });
- (prev_class, subclass_of(prev_class))
- });
- let associated = AssociatedObject::new(adapter, activation_handler, prev_class);
- unsafe {
- objc_setAssociatedObject(
- view as *mut _,
- associated_object_key(),
- Id::as_ptr(&associated) as *mut _,
- OBJC_ASSOCIATION_RETAIN_NONATOMIC,
- )
- };
- // SAFETY: Changing the view's class is only safe because
- // the subclass doesn't add any instance variables;
- // it uses an associated object instead.
- if installed.is_none() {
- unsafe { object_setClass(view as *mut _, (subclass as *const AnyClass).cast()) };
- }
- Self {
- view: retained_view,
- associated,
- }
- }
-
- /// Create an adapter that dynamically subclasses the content view
- /// of the specified window.
- ///
- /// The action handler will always be called on the main thread.
- ///
- /// # Safety
- ///
- /// `window` must be a valid, unreleased pointer to an `NSWindow`.
- ///
- /// # Panics
- ///
- /// This function panics if the specified window doesn't currently have
- /// a content view.
- pub unsafe fn for_window(
- window: *mut c_void,
- activation_handler: impl 'static + ActivationHandler,
- action_handler: impl 'static + ActionHandler,
- ) -> Self {
- let window = unsafe { &*(window as *const NSWindow) };
- let retained_view = window.contentView().unwrap();
- Self::new_internal(retained_view, activation_handler, action_handler)
- }
-
- /// If and only if the tree has been initialized, call the provided function
- /// and apply the resulting update. Note: If the caller's implementation of
- /// [`ActivationHandler::request_initial_tree`] initially returned `None`,
- /// the [`TreeUpdate`] returned by the provided function must contain
- /// a full tree.
- ///
- /// If a [`QueuedEvents`] instance is returned, the caller must call
- /// [`QueuedEvents::raise`] on it.
- pub fn update_if_active(
- &mut self,
- update_factory: impl FnOnce() -> TreeUpdate,
- ) -> Option<QueuedEvents> {
- let mut state = self.associated.ivars().state.borrow_mut();
- state.adapter.update_if_active(update_factory)
- }
-
- /// Update the tree state based on whether the window is focused.
- ///
- /// If a [`QueuedEvents`] instance is returned, the caller must call
- /// [`QueuedEvents::raise`] on it.
- pub fn update_view_focus_state(&mut self, is_focused: bool) -> Option<QueuedEvents> {
- let mut state = self.associated.ivars().state.borrow_mut();
- state.adapter.update_view_focus_state(is_focused)
- }
-}
-
-impl Drop for SubclassingAdapter {
- fn drop(&mut self) {
- let prev_class = self.associated.ivars().prev_class;
- let view = Id::as_ptr(&self.view) as *mut NSView;
- unsafe {
- objc_setAssociatedObject(
- view as *mut _,
- associated_object_key(),
- std::ptr::null_mut(),
- OBJC_ASSOCIATION_RETAIN_NONATOMIC,
- )
- };
- // Key-value observing may have subclassed our subclass in turn
- // (AppKit observes the first responder), and resetting the class
- // would then break those observers. Our subclass is harmless
- // without the associated object.
- let view = unsafe { &*view };
- let is_our_subclass = SUBCLASSES
- .lock()
- .unwrap()
- .iter()
- .any(|entry| std::ptr::eq(entry.1, runtime_class(view)));
- if is_our_subclass {
- unsafe {
- object_setClass(
- view as *const _ as *mut _,
- (prev_class as *const AnyClass).cast(),
- )
- };
- }
- }
-}
diff --git a/vendor/accesskit_macos/src/util.rs b/vendor/accesskit_macos/src/util.rs
deleted file mode 100644
index 4015e1def6..0000000000
--- a/vendor/accesskit_macos/src/util.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2022 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use accesskit::{Color, Point, Rect};
-use accesskit_consumer::{Node, TextPosition, TextRange};
-use objc2::encode::{Encoding, RefEncode};
-use objc2::{msg_send, rc::Id, runtime::AnyObject};
-use objc2_app_kit::*;
-use objc2_foundation::{NSPoint, NSRange, NSRect, NSSize};
-
-pub(crate) fn from_ns_range<'a>(node: &'a Node<'a>, ns_range: NSRange) -> Option<TextRange<'a>> {
- let pos = node.text_position_from_global_utf16_index(ns_range.location)?;
- let mut range = pos.to_degenerate_range();
- if ns_range.length > 0 {
- let end =
- node.text_position_from_global_utf16_index(ns_range.location + ns_range.length)?;
- range.set_end(end);
- }
- Some(range)
-}
-
-pub(crate) fn to_ns_range(range: &TextRange) -> NSRange {
- let start = range.start().to_global_utf16_index();
- let end = range.end().to_global_utf16_index();
- NSRange::from(start..end)
-}
-
-pub(crate) fn to_ns_range_for_character(pos: &TextPosition) -> NSRange {
- let mut range = pos.to_degenerate_range();
- if !pos.is_document_end() {
- range.set_end(pos.forward_to_character_end());
- }
- to_ns_range(&range)
-}
-
-pub(crate) fn from_ns_point(view: &NSView, node: &Node, point: NSPoint) -> Point {
- let window = view.window().unwrap();
- let point = window.convertPointFromScreen(point);
- let point = view.convertPoint_fromView(point, None);
- // AccessKit coordinates are in physical (DPI-dependent) pixels, but
- // macOS provides logical (DPI-independent) coordinates here.
- let factor = window.backingScaleFactor();
- let point = Point::new(
- point.x * factor,
- if view.isFlipped() {
- point.y * factor
- } else {
- let view_bounds = view.bounds();
- (view_bounds.size.height - point.y) * factor
- },
- );
- node.transform().inverse() * point
-}
-
-pub(crate) fn to_ns_rect(view: &NSView, rect: Rect) -> NSRect {
- let window = view.window().unwrap();
- // AccessKit coordinates are in physical (DPI-dependent)
- // pixels, but macOS expects logical (DPI-independent)
- // coordinates here.
- let factor = window.backingScaleFactor();
- let rect = NSRect {
- origin: NSPoint {
- x: rect.x0 / factor,
- y: if view.isFlipped() {
- rect.y0 / factor
- } else {
- let view_bounds = view.bounds();
- view_bounds.size.height - rect.y1 / factor
- },
- },
- size: NSSize {
- width: rect.width() / factor,
- height: rect.height() / factor,
- },
- };
- let rect = view.convertRect_toView(rect, None);
- let window = view.window().unwrap();
- window.convertRectToScreen(rect)
-}
-
-fn color_channel_to_f64(channel: u8) -> f64 {
- (channel as f64) / 255.0
-}
-
-// TODO: can be removed after updating objc2 to 0.6 which has proper `CGColor` support
-#[repr(C)]
-struct CGColor {
- _private: [u8; 0],
-}
-
-unsafe impl RefEncode for CGColor {
- const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("CGColor", &[]));
-}
-
-pub(crate) fn to_color_attribute(color: Color) -> Id<AnyObject> {
- let ns_color = unsafe {
- NSColor::colorWithSRGBRed_green_blue_alpha(
- color_channel_to_f64(color.red),
- color_channel_to_f64(color.green),
- color_channel_to_f64(color.blue),
- color_channel_to_f64(color.alpha),
- )
- };
- let cg_color: *const CGColor = unsafe { msg_send![&ns_color, CGColor] };
- unsafe { Id::retain(cg_color as *mut AnyObject).unwrap() }
-}
diff --git a/vendor/accesskit_macos/tests/integration/harness.rs b/vendor/accesskit_macos/tests/integration/harness.rs
deleted file mode 100644
index 3672e95f5d..0000000000
--- a/vendor/accesskit_macos/tests/integration/harness.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2026 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use libtest_mimic::{Arguments, Trial};
-use std::process::ExitCode;
-
-pub struct Test {
- pub name: &'static str,
- pub run: fn(),
-}
-
-macro_rules! tests {
- ($($name:ident),* $(,)?) => {
- &[$($crate::harness::Test { name: stringify!($name), run: $name }),*]
- };
-}
-pub(crate) use tests;
-
-pub fn run(suites: &[(&str, &[Test])]) -> ExitCode {
- let mut args = Arguments::from_args();
- // libtest-mimic only runs tests on the main thread when it uses a single thread.
- args.test_threads = Some(1);
- let trials = suites
- .iter()
- .flat_map(|(suite, tests)| {
- tests.iter().map(move |test| {
- let run = test.run;
- Trial::test(format!("{suite}::{}", test.name), move || {
- run();
- Ok(())
- })
- })
- })
- .collect();
- libtest_mimic::run(&args, trials).exit_code()
-}
diff --git a/vendor/accesskit_macos/tests/integration/main.rs b/vendor/accesskit_macos/tests/integration/main.rs
deleted file mode 100644
index c756fae50c..0000000000
--- a/vendor/accesskit_macos/tests/integration/main.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2026 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-mod harness;
-mod subclassing_adapter;
-mod util;
-
-fn main() -> std::process::ExitCode {
- harness::run(&[("subclassing_adapter", subclassing_adapter::TESTS)])
-}
diff --git a/vendor/accesskit_macos/tests/integration/subclassing_adapter.rs b/vendor/accesskit_macos/tests/integration/subclassing_adapter.rs
deleted file mode 100644
index 46637dfb86..0000000000
--- a/vendor/accesskit_macos/tests/integration/subclassing_adapter.rs
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2026 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use std::{
- ffi::c_void,
- panic::{self, AssertUnwindSafe},
- rc::Rc,
-};
-
-use accesskit_macos::SubclassingAdapter;
-use objc2::msg_send;
-use objc2::rc::Id;
-use objc2::runtime::{AnyClass, AnyObject};
-use objc2_app_kit::NSView;
-use objc2_foundation::{NSArray, NSObject, NSPoint, NSString};
-
-use crate::harness::{Test, tests};
-use crate::util::*;
-
-pub const TESTS: &[Test] = tests![
- the_view_is_subclassed,
- querying_the_view_requests_the_tree,
- dropping_restores_the_view_class,
- dropping_releases_the_handlers,
- a_view_can_get_a_new_adapter,
- observers_can_be_removed_after_dropping,
- an_observed_view_can_get_a_new_adapter,
- a_view_observed_before_the_adapter_is_rejected,
-];
-
-fn adapter_for(view: &NSView) -> (SubclassingAdapter, Rc<HandlerEvents>) {
- let events = Rc::new(HandlerEvents::default());
- let adapter = unsafe {
- SubclassingAdapter::new(
- view as *const NSView as *mut c_void,
- NoTree(Rc::clone(&events)),
- NoActions,
- )
- };
- (adapter, events)
-}
-
-fn query_accessibility(view: &NSView) {
- let _: *mut NSArray<NSObject> = unsafe { msg_send![view, accessibilityChildren] };
- let _: *mut AnyObject = unsafe { msg_send![view, accessibilityFocusedUIElement] };
- let superclass: &AnyClass = unsafe { msg_send![view, superclass] };
- assert_eq!(superclass.name(), "NSResponder");
-}
-
-// The adapter can only hit test a view that is in a window, but the
-// fallback doesn't need one.
-fn query_accessibility_without_adapter(view: &NSView) {
- query_accessibility(view);
- let _: *mut AnyObject = unsafe { msg_send![view, accessibilityHitTest: NSPoint::new(0., 0.)] };
-}
-
-struct Observation {
- observer: Id<NSObject>,
- key_path: Id<NSString>,
-}
-
-// AppKit observes the first responder this way.
-fn observe(view: &NSView) -> Observation {
- let observer = NSObject::new();
- let key_path = NSString::from_str("nextResponder");
- let no_context: *mut c_void = std::ptr::null_mut();
- let _: () = unsafe {
- msg_send![view, addObserver: &*observer, forKeyPath: &*key_path, options: 0usize, context: no_context]
- };
- Observation { observer, key_path }
-}
-
-fn stop_observing(view: &NSView, observation: Observation) {
- let _: () = unsafe {
- msg_send![view, removeObserver: &*observation.observer, forKeyPath: &*observation.key_path]
- };
-}
-
-fn the_view_is_subclassed() {
- let view = new_view();
- let (_adapter, _) = adapter_for(&view);
- assert_eq!(class_name(&view), "AccessKitSubclassOfNSView");
-}
-
-fn querying_the_view_requests_the_tree() {
- let view = new_view();
- let (_adapter, events) = adapter_for(&view);
- assert!(!events.tree_requested.get());
- query_accessibility(&view);
- assert!(events.tree_requested.get());
-}
-
-fn dropping_restores_the_view_class() {
- let view = new_view();
- let (adapter, _) = adapter_for(&view);
- drop(adapter);
- assert_eq!(class_name(&view), "NSView");
- query_accessibility_without_adapter(&view);
-}
-
-fn dropping_releases_the_handlers() {
- let view = new_view();
- let (adapter, events) = adapter_for(&view);
- drop(adapter);
- assert!(events.dropped.get());
-}
-
-fn a_view_can_get_a_new_adapter() {
- let view = new_view();
- drop(adapter_for(&view));
- let (adapter, events) = adapter_for(&view);
- assert_eq!(class_name(&view), "AccessKitSubclassOfNSView");
- query_accessibility(&view);
- assert!(events.tree_requested.get());
- drop(adapter);
- assert_eq!(class_name(&view), "NSView");
-}
-
-fn observers_can_be_removed_after_dropping() {
- let view = new_view();
- let (adapter, events) = adapter_for(&view);
- let observation = observe(&view);
- assert_eq!(
- class_name(&view),
- "NSKVONotifying_AccessKitSubclassOfNSView"
- );
-
- drop(adapter);
- assert!(events.dropped.get());
- assert_eq!(
- class_name(&view),
- "NSKVONotifying_AccessKitSubclassOfNSView"
- );
- query_accessibility_without_adapter(&view);
-
- stop_observing(&view, observation);
- assert_eq!(class_name(&view), "AccessKitSubclassOfNSView");
- query_accessibility_without_adapter(&view);
-}
-
-fn an_observed_view_can_get_a_new_adapter() {
- let view = new_view();
- let (adapter, _) = adapter_for(&view);
- let observation = observe(&view);
- drop(adapter);
-
- let (adapter, events) = adapter_for(&view);
- assert_eq!(
- class_name(&view),
- "NSKVONotifying_AccessKitSubclassOfNSView"
- );
- query_accessibility(&view);
- assert!(events.tree_requested.get());
- drop(adapter);
- assert!(events.dropped.get());
-
- stop_observing(&view, observation);
- let (adapter, events) = adapter_for(&view);
- assert_eq!(class_name(&view), "AccessKitSubclassOfNSView");
- query_accessibility(&view);
- assert!(events.tree_requested.get());
- drop(adapter);
- assert_eq!(class_name(&view), "NSView");
-}
-
-fn a_view_observed_before_the_adapter_is_rejected() {
- let view = new_view();
- let observation = observe(&view);
- let result = panic::catch_unwind(AssertUnwindSafe(|| adapter_for(&view)));
- assert!(result.is_err());
- assert_eq!(class_name(&view), "NSKVONotifying_NSView");
-
- stop_observing(&view, observation);
- assert_eq!(class_name(&view), "NSView");
- query_accessibility_without_adapter(&view);
-}
diff --git a/vendor/accesskit_macos/tests/integration/util.rs b/vendor/accesskit_macos/tests/integration/util.rs
deleted file mode 100644
index e5346b8549..0000000000
--- a/vendor/accesskit_macos/tests/integration/util.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2026 The AccessKit Authors. All rights reserved.
-// Licensed under the Apache License, Version 2.0 (found in
-// the LICENSE-APACHE file) or the MIT license (found in
-// the LICENSE-MIT file), at your option.
-
-use std::{cell::Cell, rc::Rc};
-
-use accesskit::{ActionHandler, ActionRequest, ActivationHandler, TreeUpdate};
-use objc2::rc::Id;
-use objc2::runtime::AnyObject;
-use objc2::{class, msg_send_id};
-use objc2_app_kit::NSView;
-
-#[derive(Default)]
-pub struct HandlerEvents {
- pub tree_requested: Cell<bool>,
- pub dropped: Cell<bool>,
-}
-
-pub struct NoTree(pub Rc<HandlerEvents>);
-
-impl ActivationHandler for NoTree {
- fn request_initial_tree(&mut self) -> Option<TreeUpdate> {
- self.0.tree_requested.set(true);
- None
- }
-}
-
-impl Drop for NoTree {
- fn drop(&mut self) {
- self.0.dropped.set(true);
- }
-}
-
-pub struct NoActions;
-
-impl ActionHandler for NoActions {
- fn do_action(&mut self, _request: ActionRequest) {}
-}
-
-pub fn new_view() -> Id<NSView> {
- unsafe { msg_send_id![class!(NSView), new] }
-}
-
-// KVO overrides the `class` method to hide its own subclass.
-pub fn class_name(view: &NSView) -> String {
- let object: &AnyObject = view;
- object.class().name().to_owned()
-}
diff --git a/vendor/egui-wgpu/Cargo.toml b/vendor/egui-wgpu/Cargo.toml
index 2809d7bb17..47fa2794ce 100644
--- a/vendor/egui-wgpu/Cargo.toml
+++ b/vendor/egui-wgpu/Cargo.toml
@@ -13,7 +13,7 @@
edition = "2024"
rust-version = "1.95"
name = "egui-wgpu"
-version = "0.36.2"
+version = "0.37.0"
authors = [
"Nils Hasenbanck <[email protected]>",
"embotech <[email protected]>",
@@ -90,17 +90,17 @@ version = "1.25"
version = "0.2.12"
[dependencies.egui]
-version = "0.36.2"
+version = "0.37.0"
optional = true
default-features = false
[dependencies.epaint]
-version = "0.36.2"
+version = "0.37.0"
features = ["bytemuck"]
default-features = false
[dependencies.log]
-version = "0.4.33"
+version = "0.4.34"
features = ["std"]
[dependencies.profiling]
@@ -133,188 +133,123 @@ default-features = false
allow_attributes = "warn"
as_ptr_cast_mut = "warn"
assigning_clones = "allow"
-bool_to_int_with_if = "warn"
branches_sharing_code = "warn"
+cast_lossless = "allow"
cast_possible_truncation = "allow"
cast_possible_wrap = "allow"
-checked_conversions = "warn"
+cast_precision_loss = "allow"
+cast_sign_loss = "allow"
clear_with_drain = "warn"
clone_on_ref_ptr = "warn"
-cloned_instead_of_copied = "warn"
coerce_container_to_any = "warn"
comparison_chain = "allow"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
-decimal_bitwise_operands = "warn"
+default_trait_access = "allow"
default_union_representation = "warn"
derive_partial_eq_without_eq = "warn"
disallowed_script_idents = "warn"
-doc_broken_link = "warn"
-doc_comment_double_space_linebreaks = "warn"
doc_include_without_cfg = "warn"
-doc_link_with_quotes = "warn"
-doc_markdown = "warn"
-duration_suboptimal_units = "warn"
-elidable_lifetime_names = "warn"
empty_enum_variants_with_brackets = "warn"
-empty_enums = "warn"
-enum_glob_use = "warn"
equatable_if_let = "warn"
exit = "warn"
-expl_impl_clone_on_copy = "warn"
-explicit_deref_methods = "warn"
-explicit_into_iter_loop = "warn"
-explicit_iter_loop = "warn"
fallible_impl_from = "warn"
-filter_map_next = "warn"
-flat_map_option = "warn"
+float_cmp = "allow"
float_cmp_const = "warn"
-fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn"
-format_push_string = "warn"
-from_iter_instead_of_collect = "warn"
get_unwrap = "warn"
-ignore_without_reason = "warn"
-ignored_unit_patterns = "warn"
-implicit_clone = "warn"
imprecise_flops = "warn"
-inconsistent_struct_constructor = "warn"
-index_refutable_slice = "warn"
-inefficient_to_string = "warn"
infinite_loop = "warn"
-into_iter_without_iter = "warn"
-invalid_upcast_comparisons = "warn"
-ip_constant = "warn"
-iter_filter_is_ok = "warn"
-iter_filter_is_some = "warn"
-iter_not_returning_iterator = "warn"
+inline_always = "allow"
+items_after_statements = "allow"
iter_on_empty_collections = "warn"
iter_on_single_items = "warn"
iter_over_hash_type = "warn"
-iter_without_into_iter = "warn"
-large_digit_groups = "warn"
-large_futures = "warn"
large_include_file = "warn"
-large_stack_arrays = "warn"
large_stack_frames = "warn"
-large_types_passed_by_value = "warn"
let_underscore_must_use = "allow"
let_underscore_untyped = "allow"
-linkedlist = "warn"
literal_string_with_formatting_args = "warn"
lossy_float_literal = "warn"
-macro_use_imports = "warn"
-manual_assert = "warn"
-manual_ilog2 = "warn"
-manual_instant_elapsed = "warn"
-manual_is_power_of_two = "warn"
-manual_is_variant_and = "warn"
-manual_let_else = "warn"
-manual_midpoint = "warn"
manual_range_contains = "allow"
-manual_string_new = "warn"
+many_single_char_names = "allow"
map_err_ignore = "warn"
map_unwrap_or = "allow"
-match_bool = "warn"
-match_same_arms = "warn"
-match_wild_err_arm = "warn"
-match_wildcard_for_single_variants = "warn"
mem_forget = "warn"
-mismatching_type_param_order = "warn"
missing_assert_message = "warn"
-missing_errors_doc = "warn"
-missing_fields_in_debug = "warn"
-mut_mut = "warn"
+missing_panics_doc = "allow"
+multiple_crate_versions = "allow"
+must_use_candidate = "allow"
mutex_integer = "warn"
-needless_continue = "warn"
-needless_for_each = "warn"
needless_pass_by_ref_mut = "warn"
-needless_pass_by_value = "warn"
-needless_raw_string_hashes = "warn"
needless_type_cast = "warn"
-negative_feature_names = "warn"
-non_std_lazy_statics = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
-option_as_ref_cloned = "warn"
-option_option = "warn"
or_fun_call = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
precedence_bits = "warn"
print_stderr = "warn"
print_stdout = "warn"
-ptr_as_ptr = "warn"
-ptr_cast_constness = "warn"
-pub_underscore_fields = "warn"
pub_without_shorthand = "warn"
rc_mutex = "warn"
+redundant_closure_for_method_calls = "allow"
redundant_type_annotations = "warn"
-ref_as_ptr = "warn"
-ref_option = "warn"
-ref_option_ref = "warn"
ref_patterns = "warn"
rest_pat_in_fully_bound_structs = "warn"
return_and_then = "warn"
-same_functions_in_if_condition = "warn"
-same_length_and_capacity = "warn"
+return_self_not_must_use = "allow"
self_named_module_files = "allow"
-self_only_used_in_recursion = "warn"
-semicolon_if_nothing_returned = "warn"
set_contains_or_insert = "warn"
should_panic_without_expect = "allow"
significant_drop_tightening = "allow"
-single_char_pattern = "warn"
-single_match_else = "warn"
+similar_names = "allow"
single_option_map = "warn"
std_instead_of_core = "warn"
-str_split_at_newline = "warn"
str_to_string = "warn"
string_add = "warn"
-string_add_assign = "warn"
string_lit_as_bytes = "warn"
string_lit_chars_any = "warn"
+struct_excessive_bools = "allow"
+struct_field_names = "allow"
suspicious_xor_used_as_pow = "warn"
todo = "warn"
too_long_first_doc_paragraph = "warn"
too_many_lines = "allow"
trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
-transmute_ptr_to_ptr = "warn"
+trivially_copy_pass_by_ref = "allow"
tuple_array_conversions = "warn"
-unchecked_time_subtraction = "warn"
undocumented_unsafe_blocks = "warn"
unimplemented = "warn"
uninhabited_references = "warn"
-uninlined_format_args = "warn"
-unnecessary_box_returns = "warn"
-unnecessary_debug_formatting = "warn"
-unnecessary_literal_bound = "warn"
unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
-unnecessary_semicolon = "warn"
unnecessary_struct_initialization = "warn"
-unnecessary_trailing_comma = "warn"
-unnecessary_wraps = "warn"
-unnested_or_patterns = "warn"
-unused_async = "warn"
+unreadable_literal = "allow"
unused_peekable = "warn"
unused_rounding = "warn"
-unused_self = "warn"
unused_trait_names = "warn"
unwrap_used = "warn"
use_self = "warn"
+used_underscore_binding = "allow"
useless_let_if_seq = "warn"
verbose_file_reads = "warn"
-wildcard_dependencies = "warn"
wildcard_imports = "allow"
-zero_sized_map_values = "warn"
[lints.clippy.all]
level = "warn"
priority = -1
+[lints.clippy.cargo]
+level = "warn"
+priority = -1
+
+[lints.clippy.pedantic]
+level = "warn"
+priority = -1
+
[lints.rust]
trivial_casts = "allow"
trivial_numeric_casts = "warn"
@@ -335,5 +270,10 @@ priority = -1
level = "warn"
priority = -1
+[lints.rust.unexpected_cfgs]
+level = "warn"
+priority = 0
+check-cfg = ["cfg(web_sys_unstable_apis)"]
+
[lints.rustdoc]
all = "warn"
diff --git a/vendor/egui-wgpu/src/capture.rs b/vendor/egui-wgpu/src/capture.rs
index 54ddeb884c..23e7932b01 100644
--- a/vendor/egui-wgpu/src/capture.rs
+++ b/vendor/egui-wgpu/src/capture.rs
@@ -1,6 +1,6 @@
-use egui::{UserData, ViewportId};
+use egui::ScreenshotCallback;
use epaint::ColorImage;
-use std::sync::{Arc, mpsc};
+use std::sync::Arc;
use wgpu::{BindGroupLayout, MultisampleState, StoreOp};
/// A texture and a buffer for reading the rendered frame back to the cpu.
@@ -11,6 +11,10 @@ use wgpu::{BindGroupLayout, MultisampleState, StoreOp};
/// both the surface texture (via a render pass) and the buffer (via a texture to buffer copy),
/// from where we can pull it back
/// to the cpu.
+///
+/// Since the frame is rendered to this texture and not to the surface, a capture needs no
+/// surface texture at all: an occluded or minimized window, which has none to give, can still
+/// be captured.
pub struct CaptureState {
padding: BufferPadding,
pub texture: wgpu::Texture,
@@ -18,12 +22,9 @@ pub struct CaptureState {
bind_group: wgpu::BindGroup,
}
-pub type CaptureReceiver = mpsc::Receiver<(ViewportId, Vec<UserData>, ColorImage)>;
-pub type CaptureSender = mpsc::Sender<(ViewportId, Vec<UserData>, ColorImage)>;
-pub use mpsc::channel as capture_channel;
-
impl CaptureState {
- pub fn new(device: &wgpu::Device, surface_texture: &wgpu::Texture) -> Self {
+ /// `size` and `format` are those of the surface we would otherwise render to.
+ pub fn new(device: &wgpu::Device, size: wgpu::Extent3d, format: wgpu::TextureFormat) -> Self {
let shader = device.create_shader_module(wgpu::include_wgsl!("texture_copy.wgsl"));
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
@@ -39,7 +40,7 @@ impl CaptureState {
module: &shader,
entry_point: Some("fs_main"),
compilation_options: Default::default(),
- targets: &[Some(surface_texture.format().into())],
+ targets: &[Some(format.into())],
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
@@ -54,7 +55,7 @@ impl CaptureState {
let bind_group_layout = pipeline.get_bind_group_layout(0);
let (texture, padding, bind_group) =
- Self::create_texture(device, surface_texture, &bind_group_layout);
+ Self::create_texture(device, size, format, &bind_group_layout);
Self {
padding,
@@ -66,23 +67,24 @@ impl CaptureState {
fn create_texture(
device: &wgpu::Device,
- surface_texture: &wgpu::Texture,
+ size: wgpu::Extent3d,
+ format: wgpu::TextureFormat,
layout: &BindGroupLayout,
) -> (wgpu::Texture, BufferPadding, wgpu::BindGroup) {
let texture = device.create_texture(&wgpu::TextureDescriptor {
label: Some("egui_screen_capture_texture"),
- size: surface_texture.size(),
- mip_level_count: surface_texture.mip_level_count(),
- sample_count: surface_texture.sample_count(),
- dimension: surface_texture.dimension(),
- format: surface_texture.format(),
+ size,
+ mip_level_count: 1,
+ sample_count: 1,
+ dimension: wgpu::TextureDimension::D2,
+ format,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::TEXTURE_BINDING
| wgpu::TextureUsages::COPY_SRC,
view_formats: &[],
});
- let padding = BufferPadding::new(surface_texture.width());
+ let padding = BufferPadding::new(size.width);
let view = texture.create_view(&Default::default());
@@ -98,28 +100,33 @@ impl CaptureState {
(texture, padding, bind_group)
}
- /// Updates the [`CaptureState`] if the size of the surface texture has changed
- pub fn update(&mut self, device: &wgpu::Device, texture: &wgpu::Texture) {
- if self.texture.size() != texture.size() {
- let (new_texture, padding, bind_group) =
- Self::create_texture(device, texture, &self.pipeline.get_bind_group_layout(0));
+ /// Updates the [`CaptureState`] if the size of the surface has changed
+ pub fn update(&mut self, device: &wgpu::Device, size: wgpu::Extent3d) {
+ if self.texture.size() != size {
+ let format = self.texture.format();
+ let (new_texture, padding, bind_group) = Self::create_texture(
+ device,
+ size,
+ format,
+ &self.pipeline.get_bind_group_layout(0),
+ );
self.texture = new_texture;
self.padding = padding;
self.bind_group = bind_group;
}
}
- /// Handles copying from the [`CaptureState`] texture to the surface texture and the buffer.
+ /// Handles copying from the [`CaptureState`] texture to the buffer, and to the surface
+ /// texture when there is one to present to.
/// Pass the returned buffer to [`CaptureState::read_screen_rgba`] to read the data back to the cpu.
pub fn copy_textures(
&mut self,
device: &wgpu::Device,
- output_frame: &wgpu::SurfaceTexture,
+ output_frame: Option<&wgpu::SurfaceTexture>,
encoder: &mut wgpu::CommandEncoder,
) -> wgpu::Buffer {
- debug_assert_eq!(
- self.texture.size(),
- output_frame.texture.size(),
+ debug_assert!(
+ output_frame.is_none_or(|frame| frame.texture.size() == self.texture.size()),
"Texture sizes must match, `CaptureState::update` was probably not called"
);
@@ -151,26 +158,30 @@ impl CaptureState {
tex_extent,
);
- let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
- label: Some("texture_copy"),
- color_attachments: &[Some(wgpu::RenderPassColorAttachment {
- view: &output_frame.texture.create_view(&Default::default()),
- resolve_target: None,
- ops: wgpu::Operations {
- load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
- store: StoreOp::Store,
- },
- depth_slice: None,
- })],
- depth_stencil_attachment: None,
- occlusion_query_set: None,
- timestamp_writes: None,
- multiview_mask: None,
- });
+ // Blit to the surface, for the frame that is actually shown. A hidden window has no
+ // surface texture to blit to, and nothing to show: the capture above is all we want.
+ if let Some(output_frame) = output_frame {
+ let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
+ label: Some("texture_copy"),
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
+ view: &output_frame.texture.create_view(&Default::default()),
+ resolve_target: None,
+ ops: wgpu::Operations {
+ load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
+ store: StoreOp::Store,
+ },
+ depth_slice: None,
+ })],
+ depth_stencil_attachment: None,
+ occlusion_query_set: None,
+ timestamp_writes: None,
+ multiview_mask: None,
+ });
- pass.set_pipeline(&self.pipeline);
- pass.set_bind_group(0, &self.bind_group, &[]);
- pass.draw(0..3, 0..1);
+ pass.set_pipeline(&self.pipeline);
+ pass.set_bind_group(0, &self.bind_group, &[]);
+ pass.draw(0..3, 0..1);
+ }
buffer
}
@@ -179,14 +190,7 @@ impl CaptureState {
/// This function is non-blocking and will send the data to the given sender when it's ready.
/// Pass in the buffer returned from [`CaptureState::copy_textures`].
/// Make sure to call this after the encoder has been submitted.
- pub fn read_screen_rgba(
- &self,
- ctx: egui::Context,
- buffer: wgpu::Buffer,
- data: Vec<UserData>,
- tx: CaptureSender,
- viewport_id: ViewportId,
- ) {
+ pub fn read_screen_rgba(&self, buffer: wgpu::Buffer, callbacks: Vec<ScreenshotCallback>) {
#[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm
let buffer = Arc::new(buffer);
let buffer_clone = Arc::clone(&buffer);
@@ -233,16 +237,13 @@ impl CaptureState {
drop(mapped_range);
buffer.unmap();
- tx.send((
- viewport_id,
- data,
- ColorImage::new(
- [tex_extent.width as usize, tex_extent.height as usize],
- pixels,
- ),
- ))
- .ok();
- ctx.request_repaint();
+ let image = Arc::new(ColorImage::new(
+ [tex_extent.width as usize, tex_extent.height as usize],
+ pixels,
+ ));
+ for callback in callbacks {
+ callback.complete(Arc::clone(&image));
+ }
});
}
}
diff --git a/vendor/egui-wgpu/src/egui.wgsl b/vendor/egui-wgpu/src/egui.wgsl
index 39210841bd..9567b0d3ec 100644
--- a/vendor/egui-wgpu/src/egui.wgsl
+++ b/vendor/egui-wgpu/src/egui.wgsl
@@ -98,24 +98,64 @@ fn vs_main(
@group(1) @binding(0) var r_tex_color: texture_2d<f32>;
@group(1) @binding(1) var r_tex_sampler: sampler;
+
+/// Set in bit 0 of `r_tex_flags` if the sampler uses nearest filtering.
+///
+/// Must match `TEX_FLAG_NEAREST` in `renderer.rs`.
+const TEX_FLAG_NEAREST: u32 = 1u;
+
+/// Wrap modes, stored in bits 1+ of `r_tex_flags`.
+///
+/// Must match the `WRAP_MODE_*` constants in `renderer.rs`.
+const WRAP_MODE_CLAMP_TO_EDGE: u32 = 0u;
+const WRAP_MODE_REPEAT: u32 = 1u;
+const WRAP_MODE_MIRRORED_REPEAT: u32 = 2u;
+
+/// Texture flags, only read when `predictable_texture_filtering` is on.
+///
+/// Bit 0: `TEX_FLAG_NEAREST`.
+/// Bits 1+: one of the `WRAP_MODE_*` constants.
+@group(1) @binding(2) var<uniform> r_tex_flags: vec4<u32>;
+
+/// Map a texel coordinate to a valid texel according to the texture's wrap mode.
+fn wrap_texel_coord(coord: vec2<i32>, texture_size: vec2<i32>) -> vec2<i32> {
+ let wrap_mode = r_tex_flags[0] >> 1u;
+ if wrap_mode == WRAP_MODE_REPEAT {
+ return ((coord % texture_size) + texture_size) % texture_size;
+ } else if wrap_mode == WRAP_MODE_MIRRORED_REPEAT {
+ let period = 2 * texture_size;
+ let phase = ((coord % period) + period) % period;
+ return min(phase, period - vec2<i32>(1, 1) - phase);
+ } else {
+ // WRAP_MODE_CLAMP_TO_EDGE
+ return clamp(coord, vec2<i32>(0, 0), texture_size - vec2<i32>(1, 1));
+ }
+}
+
+
fn sample_texture(in: VertexOutput) -> vec4<f32> {
if r_locals.predictable_texture_filtering == 0 {
// Hardware filtering: fast, but varies across GPUs and drivers.
return textureSample(r_tex_color, r_tex_sampler, in.tex_coord);
} else {
- // Manual bilinear filtering with four taps at pixel centers using textureLoad
let texture_size = vec2<i32>(textureDimensions(r_tex_color, 0));
let texture_size_f = vec2<f32>(texture_size);
+
+ if (r_tex_flags[0] & TEX_FLAG_NEAREST) != 0u {
+ // Nearest filtering: load the texel under the sample position.
+ let texel = wrap_texel_coord(vec2<i32>(floor(in.tex_coord * texture_size_f)), texture_size);
+ return textureLoad(r_tex_color, texel, 0);
+ }
+
+ // Manual bilinear filtering with four taps at pixel centers using textureLoad
let pixel_coord = in.tex_coord * texture_size_f - 0.5;
let pixel_fract = fract(pixel_coord);
let pixel_floor = vec2<i32>(floor(pixel_coord));
- // Manual texture clamping
- let max_coord = texture_size - vec2<i32>(1, 1);
- let p00 = clamp(pixel_floor + vec2<i32>(0, 0), vec2<i32>(0, 0), max_coord);
- let p10 = clamp(pixel_floor + vec2<i32>(1, 0), vec2<i32>(0, 0), max_coord);
- let p01 = clamp(pixel_floor + vec2<i32>(0, 1), vec2<i32>(0, 0), max_coord);
- let p11 = clamp(pixel_floor + vec2<i32>(1, 1), vec2<i32>(0, 0), max_coord);
+ let p00 = wrap_texel_coord(pixel_floor + vec2<i32>(0, 0), texture_size);
+ let p10 = wrap_texel_coord(pixel_floor + vec2<i32>(1, 0), texture_size);
+ let p01 = wrap_texel_coord(pixel_floor + vec2<i32>(0, 1), texture_size);
+ let p11 = wrap_texel_coord(pixel_floor + vec2<i32>(1, 1), texture_size);
// Load at pixel centers
let tl = textureLoad(r_tex_color, p00, 0);
diff --git a/vendor/egui-wgpu/src/lib.rs b/vendor/egui-wgpu/src/lib.rs
index 94778079db..db3c5b83f6 100644
--- a/vendor/egui-wgpu/src/lib.rs
+++ b/vendor/egui-wgpu/src/lib.rs
@@ -98,8 +98,6 @@ pub enum WgpuError {
}
/// Runtime-mutable subset of [`WgpuConfiguration`].
-///
-/// Edit any field to have the surface reconfigured on the next paint.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct SurfaceConfig {
/// Present mode used for the primary surface.
@@ -319,11 +317,6 @@ pub struct RenderState {
/// Egui renderer responsible for drawing the UI.
pub renderer: Arc<RwLock<Renderer>>,
- /// Runtime-mutable subset of the wgpu configuration.
- ///
- /// Update this to have the surface reconfigured on the next paint.
- pub surface_config: SurfaceConfig,
-
/// SolidCraft: the device was lost; the painter draws nothing more (#4172).
pub device_lost: DeviceLost,
}
@@ -541,7 +534,6 @@ impl RenderState {
msaa_samples: options.msaa_samples,
msaa_supported,
renderer: Arc::new(RwLock::new(renderer)),
- surface_config: config.surface,
device_lost,
})
}
@@ -584,9 +576,6 @@ pub enum SurfaceErrorAction {
#[derive(Clone)]
pub struct WgpuConfiguration {
/// Runtime-mutable configuration for the surface (present mode, frame latency).
- ///
- /// These are the fields exposed via [`RenderState::surface_config`] for live
- /// reconfiguration at runtime.
pub surface: SurfaceConfig,
/// How to create the wgpu adapter & device
@@ -603,11 +592,21 @@ pub struct WgpuConfiguration {
Arc<dyn Fn(&wgpu::CurrentSurfaceTexture) -> SurfaceErrorAction + Send + Sync>,
}
-#[test]
-fn wgpu_config_impl_send_sync() {
- fn assert_send_sync<T: Send + Sync>() {}
+// Compile-time check that `WgpuConfiguration` is `Send + Sync`.
+// Deliberately not a `#[test]`: tests never run on wasm, but `cargo check` does.
+// On wasm this only holds with `fragile-send-sync-non-atomic-wasm` and without threads;
+// look at the feature flag for an explanation.
+#[cfg(any(
+ not(target_arch = "wasm32"),
+ all(
+ feature = "fragile-send-sync-non-atomic-wasm",
+ not(target_feature = "atomics")
+ ),
+))]
+const _: () = {
+ const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<WgpuConfiguration>();
-}
+};
impl core::fmt::Debug for WgpuConfiguration {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
diff --git a/vendor/egui-wgpu/src/renderer.rs b/vendor/egui-wgpu/src/renderer.rs
index 774de7ee2f..41d96e4c86 100644
--- a/vendor/egui-wgpu/src/renderer.rs
+++ b/vendor/egui-wgpu/src/renderer.rs
@@ -268,6 +268,11 @@ pub struct Renderer {
uniform_bind_group: wgpu::BindGroup,
texture_bind_group_layout: wgpu::BindGroupLayout,
+ /// Uniform buffers each holding a single `u32` of texture flags
+ /// (see [`texture_flags`]), indexed by that flag value.
+ /// Read by the shader when `predictable_texture_filtering` is on.
+ texture_flag_buffers: [wgpu::Buffer; NUM_TEXTURE_FLAGS],
+
/// Map of egui texture IDs to textures and their associated bindgroups (texture view +
/// sampler). The texture may be None if the `TextureId` is just a handle to a user-provided
/// sampler.
@@ -377,10 +382,31 @@ impl Renderer {
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
+ wgpu::BindGroupLayoutEntry {
+ binding: 2,
+ visibility: wgpu::ShaderStages::FRAGMENT,
+ ty: wgpu::BindingType::Buffer {
+ has_dynamic_offset: false,
+ min_binding_size: NonZeroU64::new(
+ (core::mem::size_of::<u32>() * 4) as _,
+ ),
+ ty: wgpu::BufferBindingType::Uniform,
+ },
+ count: None,
+ },
],
})
};
+ let texture_flag_buffers = core::array::from_fn::<_, NUM_TEXTURE_FLAGS, _>(|flag| {
+ let flag = flag as u32;
+ device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
+ label: Some(&format!("egui_texture_flags_{flag}")),
+ contents: bytemuck::bytes_of(&[flag, 0, 0, 0]),
+ usage: wgpu::BufferUsages::UNIFORM,
+ })
+ });
+
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("egui_pipeline_layout"),
bind_group_layouts: &[
@@ -489,6 +515,7 @@ impl Renderer {
previous_uniform_buffer_content: UniformBuffer::zeroed(),
uniform_bind_group,
texture_bind_group_layout,
+ texture_flag_buffers,
textures: HashMap::default(),
next_user_texture_id: 0,
samplers: HashMap::default(),
@@ -758,6 +785,9 @@ impl Renderer {
};
let bind_group = bind_group.unwrap_or_else(|| {
+ let nearest =
+ image_delta.options.magnification == epaint::textures::TextureFilter::Nearest;
+ let wrap_mode = wrap_mode_flag(image_delta.options.wrap_mode);
let sampler = self
.samplers
.entry(image_delta.options)
@@ -776,6 +806,11 @@ impl Renderer {
binding: 1,
resource: wgpu::BindingResource::Sampler(sampler),
},
+ wgpu::BindGroupEntry {
+ binding: 2,
+ resource: self.texture_flag_buffers[texture_flags(nearest, wrap_mode)]
+ .as_entire_binding(),
+ },
],
})
});
@@ -878,6 +913,8 @@ impl Renderer {
) -> epaint::TextureId {
profiling::function_scope!();
+ let nearest = sampler_descriptor.mag_filter == wgpu::FilterMode::Nearest;
+ let wrap_mode = address_mode_wrap_flag(sampler_descriptor.address_mode_u);
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
compare: None,
..sampler_descriptor
@@ -895,6 +932,11 @@ impl Renderer {
binding: 1,
resource: wgpu::BindingResource::Sampler(&sampler),
},
+ wgpu::BindGroupEntry {
+ binding: 2,
+ resource: self.texture_flag_buffers[texture_flags(nearest, wrap_mode)]
+ .as_entire_binding(),
+ },
],
});
@@ -934,6 +976,8 @@ impl Renderer {
.get_mut(&id)
.expect("Tried to update a texture that has not been allocated yet.");
+ let nearest = sampler_descriptor.mag_filter == wgpu::FilterMode::Nearest;
+ let wrap_mode = address_mode_wrap_flag(sampler_descriptor.address_mode_u);
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
compare: None,
..sampler_descriptor
@@ -951,6 +995,11 @@ impl Renderer {
binding: 1,
resource: wgpu::BindingResource::Sampler(&sampler),
},
+ wgpu::BindGroupEntry {
+ binding: 2,
+ resource: self.texture_flag_buffers[texture_flags(nearest, wrap_mode)]
+ .as_entire_binding(),
+ },
],
});
@@ -1137,6 +1186,49 @@ impl Renderer {
}
}
+/// Set in bit 0 of the texture flags if the sampler uses nearest filtering.
+///
+/// Must match `TEX_FLAG_NEAREST` in `egui.wgsl`.
+const TEX_FLAG_NEAREST: u32 = 1;
+
+/// Wrap modes, stored in bits 1+ of the texture flags.
+///
+/// Must match the `WRAP_MODE_*` constants in `egui.wgsl`.
+const WRAP_MODE_CLAMP_TO_EDGE: u32 = 0;
+const WRAP_MODE_REPEAT: u32 = 1;
+const WRAP_MODE_MIRRORED_REPEAT: u32 = 2;
+
+/// Number of distinct values [`texture_flags`] can return.
+const NUM_TEXTURE_FLAGS: usize = 6;
+
+fn wrap_mode_flag(wrap_mode: epaint::textures::TextureWrapMode) -> u32 {
+ match wrap_mode {
+ epaint::textures::TextureWrapMode::ClampToEdge => WRAP_MODE_CLAMP_TO_EDGE,
+ epaint::textures::TextureWrapMode::Repeat => WRAP_MODE_REPEAT,
+ epaint::textures::TextureWrapMode::MirroredRepeat => WRAP_MODE_MIRRORED_REPEAT,
+ }
+}
+
+fn address_mode_wrap_flag(address_mode: wgpu::AddressMode) -> u32 {
+ match address_mode {
+ wgpu::AddressMode::Repeat => WRAP_MODE_REPEAT,
+ wgpu::AddressMode::MirrorRepeat => WRAP_MODE_MIRRORED_REPEAT,
+ wgpu::AddressMode::ClampToEdge | wgpu::AddressMode::ClampToBorder => {
+ WRAP_MODE_CLAMP_TO_EDGE
+ }
+ }
+}
+
+/// Index into [`Renderer::texture_flag_buffers`]: the texture flags
+/// read by the shader when `predictable_texture_filtering` is on.
+///
+/// Bit 0: [`TEX_FLAG_NEAREST`].
+/// Bits 1+: one of the `WRAP_MODE_*` constants.
+fn texture_flags(nearest: bool, wrap_mode: u32) -> usize {
+ let nearest = if nearest { TEX_FLAG_NEAREST } else { 0 };
+ (nearest | (wrap_mode << 1)) as usize
+}
+
fn create_sampler(
options: epaint::textures::TextureOptions,
device: &wgpu::Device,
@@ -1223,13 +1315,18 @@ impl ScissorRect {
}
}
-// Look at the feature flag for an explanation.
-#[cfg(not(all(
- target_arch = "wasm32",
- not(feature = "fragile-send-sync-non-atomic-wasm"),
-)))]
-#[test]
-fn renderer_impl_send_sync() {
- fn assert_send_sync<T: Send + Sync>() {}
+// Compile-time check that `Renderer` is `Send + Sync`.
+// Deliberately not a `#[test]`: tests never run on wasm, but `cargo check` does.
+// On wasm this only holds with `fragile-send-sync-non-atomic-wasm` and without threads;
+// look at the feature flag for an explanation.
+#[cfg(any(
+ not(target_arch = "wasm32"),
+ all(
+ feature = "fragile-send-sync-non-atomic-wasm",
+ not(target_feature = "atomics")
+ ),
+))]
+const _: () = {
+ const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<Renderer>();
-}
+};
diff --git a/vendor/egui-wgpu/src/winit.rs b/vendor/egui-wgpu/src/winit.rs
index 7dea37b0b1..9c49ec9681 100644
--- a/vendor/egui-wgpu/src/winit.rs
+++ b/vendor/egui-wgpu/src/winit.rs
@@ -4,12 +4,9 @@
#![expect(unsafe_code)]
use crate::{RenderState, SurfaceConfig, SurfaceErrorAction, WgpuConfiguration, renderer};
-use crate::{
- RendererOptions,
- capture::{CaptureReceiver, CaptureSender, CaptureState, capture_channel},
-};
+use crate::{RendererOptions, capture::CaptureState};
use core::num::NonZeroU32;
-use egui::{Context, Event, UserData, ViewportId, ViewportIdMap, ViewportIdSet};
+use egui::{Context, ViewportId, ViewportIdMap, ViewportIdSet};
use std::sync::Arc;
struct SurfaceState {
@@ -52,8 +49,6 @@ pub struct Painter {
depth_texture_view: ViewportIdMap<wgpu::TextureView>,
msaa_texture_view: ViewportIdMap<wgpu::TextureView>,
surfaces: ViewportIdMap<SurfaceState>,
- capture_tx: CaptureSender,
- capture_rx: CaptureReceiver,
}
impl Painter {
@@ -75,7 +70,6 @@ impl Painter {
support_transparent_backbuffer: bool,
options: RendererOptions,
) -> Self {
- let (capture_tx, capture_rx) = capture_channel();
crate::startup_step(crate::STEP_INSTANCE, ""); // SolidCraft
let instance = config.wgpu_setup.new_instance().await;
@@ -92,9 +86,6 @@ impl Painter {
depth_texture_view: Default::default(),
surfaces: Default::default(),
msaa_texture_view: Default::default(),
-
- capture_tx,
- capture_rx,
}
}
@@ -105,6 +96,29 @@ impl Painter {
self.render_state.clone()
}
+ /// The surface configuration (present mode, frame latency) the surfaces are configured with.
+ pub fn surface_config(&self) -> SurfaceConfig {
+ self.config.surface
+ }
+
+ /// Change the surface configuration (present mode, frame latency) at runtime.
+ ///
+ /// All surfaces are reconfigured before the next paint.
+ ///
+ /// This is cheap to call every frame.
+ pub fn set_surface_config(&mut self, surface_config: SurfaceConfig) {
+ if self.config.surface == surface_config {
+ return;
+ }
+
+ self.config.surface = surface_config;
+
+ #[expect(clippy::iter_over_hash_type)]
+ for surface in self.surfaces.values_mut() {
+ surface.needs_reconfigure = true;
+ }
+ }
+
/// SolidCraft: a configuration the device refuses (D3D12: "Failed to wait for GPU to come
/// idle before reconfiguring the Surface", #1935) comes back as the error instead of reaching
/// the device's uncaptured-error handler, which panics; so does a configure that met a lost
@@ -624,7 +638,7 @@ impl Painter {
clear_color: [f32; 4],
clipped_primitives: &[epaint::ClippedPrimitive],
textures_delta: &mut epaint::textures::TexturesDelta,
- capture_data: Vec<UserData>,
+ capture_data: Vec<egui::ScreenshotCallback>,
window: &Arc<winit::window::Window>,
) -> f32 {
// SolidCraft: a device lost while the frame is drawn, after its probe, panics inside wgpu
@@ -670,7 +684,7 @@ impl Painter {
clear_color: [f32; 4],
clipped_primitives: &[epaint::ClippedPrimitive],
textures_delta: &mut epaint::textures::TexturesDelta,
- capture_data: Vec<UserData>,
+ capture_data: Vec<egui::ScreenshotCallback>,
window: &Arc<winit::window::Window>,
) -> f32 {
profiling::function_scope!();
@@ -736,20 +750,6 @@ impl Painter {
return vsync_sec;
}
- // Apply any runtime changes requested via `RenderState::surface_config`.
- // We diff against the already-applied values in `self.config.surface`
- // and, if anything differs, mark every surface as needing reconfiguration so
- // the existing `needs_reconfigure` pathway below picks them up.
- if let Some(render_state) = self.render_state.as_ref()
- && render_state.surface_config != self.config.surface
- {
- self.config.surface = render_state.surface_config;
- #[expect(clippy::iter_over_hash_type)]
- for surface in self.surfaces.values_mut() {
- surface.needs_reconfigure = true;
- }
- }
-
let Some(render_state) = self.render_state.as_mut() else {
return vsync_sec;
};
@@ -811,11 +811,14 @@ impl Painter {
output_frame
};
+ // `None` when there is no frame to present to. A capture is rendered to its own
+ // texture and copied back to the cpu, so it is served even then — that is how a hidden
+ // window, which the compositor gives no surface texture, is screenshotted at all.
let frame = match output_frame {
- wgpu::CurrentSurfaceTexture::Success(frame) => frame,
+ wgpu::CurrentSurfaceTexture::Success(frame) => Some(frame),
wgpu::CurrentSurfaceTexture::Suboptimal(frame) => {
surface_state.needs_reconfigure = true;
- frame
+ Some(frame)
}
other => {
match (*self.config.on_surface_status)(&other) {
@@ -843,14 +846,19 @@ impl Painter {
}
SurfaceErrorAction::SkipFrame => {}
}
- return vsync_sec;
+ if !capture {
+ return vsync_sec;
+ }
+ None
}
};
// SolidCraft: however this frame ends (presented, dropped by an early return below, or
// dropped while a panic unwinds), the surface gets its image back, also on a lost device,
// where wgpu's present and discard keep it and the surface's drop then panicked (#7148).
- let texture = frame.texture.clone();
- let output_frame = crate::AcquiredFrame::new(frame, texture);
+ let output_frame = frame.map(|frame| {
+ let texture = frame.texture.clone();
+ crate::AcquiredFrame::new(frame, texture)
+ });
// SolidCraft: before the uploads, a probe asks the driver whether the device is still
// there. The first queue write to meet a lost device panics inside wgpu (#4172, #6528);
@@ -917,14 +925,39 @@ impl Painter {
let renderer = render_state.renderer.read();
let target_texture = if capture {
- let capture_state = self.screen_capture_state.get_or_insert_with(|| {
- CaptureState::new(&render_state.device, &output_frame.frame.texture)
- });
- capture_state.update(&render_state.device, &output_frame.frame.texture);
+ // The frame we would have presented decides the capture, when there is one.
+ // Without it we have only the surface we configured, which is the same thing
+ // as long as no resize is in flight.
+ let (size, format) = match &output_frame {
+ Some(output_frame) => {
+ (output_frame.frame.texture.size(), output_frame.frame.texture.format())
+ }
+ None => (
+ wgpu::Extent3d {
+ width: surface_state.width,
+ height: surface_state.height,
+ depth_or_array_layers: 1,
+ },
+ render_state.target_format,
+ ),
+ };
+ if size.width == 0 || size.height == 0 {
+ log::warn!("Cannot capture a screenshot of a zero-sized surface");
+ return vsync_sec;
+ }
+
+ let capture_state = self
+ .screen_capture_state
+ .get_or_insert_with(|| CaptureState::new(&render_state.device, size, format));
+ capture_state.update(&render_state.device, size);
&capture_state.texture
- } else {
+ } else if let Some(output_frame) = &output_frame {
&output_frame.frame.texture
+ } else {
+ // Unreachable: without a frame to present to, and with nothing to capture,
+ // we returned above.
+ return vsync_sec;
};
let target_view = target_texture.create_view(&wgpu::TextureViewDescriptor::default());
@@ -1012,7 +1045,7 @@ impl Painter {
if capture && let Some(capture_state) = &mut self.screen_capture_state {
capture_buffer = Some(capture_state.copy_textures(
&render_state.device,
- &output_frame.frame,
+ output_frame.as_ref().map(|output_frame| &output_frame.frame),
&mut encoder,
));
}
@@ -1055,18 +1088,12 @@ impl Painter {
if let Some(capture_buffer) = capture_buffer
&& let Some(screen_capture_state) = &mut self.screen_capture_state
{
- screen_capture_state.read_screen_rgba(
- self.context.clone(),
- capture_buffer,
- capture_data,
- self.capture_tx.clone(),
- viewport_id,
- );
+ screen_capture_state.read_screen_rgba(capture_buffer, capture_data);
}
- window.pre_present_notify();
+ if let Some(output_frame) = output_frame {
+ window.pre_present_notify();
- {
profiling::scope!("present");
// wgpu doesn't document where vsync can happen. Maybe here?
let start = web_time::Instant::now();
@@ -1077,20 +1104,6 @@ impl Painter {
vsync_sec
}
- /// Call this at the beginning of each frame to receive the requested screenshots.
- pub fn handle_screenshots(&self, events: &mut Vec<Event>) {
- for (viewport_id, user_data, screenshot) in self.capture_rx.try_iter() {
- let screenshot = Arc::new(screenshot);
- for data in user_data {
- events.push(Event::Screenshot {
- viewport_id,
- user_data: data,
- image: Arc::clone(&screenshot),
- });
- }
- }
- }
-
pub fn gc_viewports(&mut self, active_viewports: &ViewportIdSet) {
self.surfaces.retain(|id, _| active_viewports.contains(id));
self.depth_texture_view