diff --git a/Cargo.lock b/Cargo.lock index 462646a5..9d7c11a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1343,6 +1343,7 @@ dependencies = [ "egui", "egui_extras", "egui_kittest", + "image", "mimalloc", "rand", "serde", diff --git a/crates/egui_demo_lib/Cargo.toml b/crates/egui_demo_lib/Cargo.toml index a86f3dcd..f83258e5 100644 --- a/crates/egui_demo_lib/Cargo.toml +++ b/crates/egui_demo_lib/Cargo.toml @@ -43,7 +43,7 @@ syntect = ["egui_extras/syntect"] [dependencies] egui = { workspace = true, default-features = false, features = ["color-hex"] } -egui_extras = { workspace = true, features = ["default", "file", "svg"] } +egui_extras = { workspace = true, features = ["image", "svg"] } unicode_names2 = { version = "0.6.0", default-features = false } # this old version has fewer dependencies @@ -57,7 +57,9 @@ serde = { workspace = true, optional = true } [dev-dependencies] criterion.workspace = true egui = { workspace = true, features = ["default_fonts"] } +egui_extras = { workspace = true, features = ["image", "svg"] } egui_kittest = { workspace = true, features = ["wgpu", "snapshot"] } +image = { workspace = true, features = ["png"] } mimalloc.workspace = true # for benchmarks rand = "0.9" diff --git a/crates/egui_demo_lib/src/demo/demo_app_windows.rs b/crates/egui_demo_lib/src/demo/demo_app_windows.rs index 892c6f40..cc43645c 100644 --- a/crates/egui_demo_lib/src/demo/demo_app_windows.rs +++ b/crates/egui_demo_lib/src/demo/demo_app_windows.rs @@ -13,6 +13,16 @@ struct DemoGroup { demos: Vec>, } +impl std::ops::Add for DemoGroup { + type Output = Self; + + fn add(self, other: Self) -> Self { + let mut demos = self.demos; + demos.extend(other.demos); + Self { demos } + } +} + impl DemoGroup { pub fn new(demos: Vec>) -> Self { Self { demos } @@ -367,7 +377,12 @@ mod tests { #[test] fn demos_should_match_snapshot() { - let demos = DemoGroups::default().demos; + let DemoGroups { + demos, + tests, + about: _, + } = DemoGroups::default(); + let demos = demos + tests; let mut results = SnapshotResults::new(); @@ -377,13 +392,10 @@ mod tests { continue; } - // Remove the emoji from the demo name - let name = demo - .name() - .split_once(' ') - .map_or(demo.name(), |(_, name)| name); + let name = remove_leading_emoji(demo.name()); let mut harness = Harness::new(|ctx| { + egui_extras::install_image_loaders(ctx); demo.show(ctx, &mut true); }); @@ -406,4 +418,13 @@ mod tests { results.add(harness.try_snapshot_options(&format!("demos/{name}"), &options)); } } + + fn remove_leading_emoji(full_name: &str) -> &str { + if let Some((start, name)) = full_name.split_once(' ') { + if start.len() <= 4 && start.bytes().next().is_some_and(|byte| byte >= 128) { + return name; + } + } + full_name + } } diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Clipboard Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Clipboard Test.png new file mode 100644 index 00000000..ec951000 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Clipboard Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4f807098e0bc56eaacabb76d646a76036cc66a7a6e54b1c934fa9fecb5b0170 +size 26470 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Cursor Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Cursor Test.png new file mode 100644 index 00000000..77849361 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Cursor Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:629006243b61f25e48a454cc617b8e49e38985eebbfe136f3bcb0b361d204671 +size 61431 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Grid Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Grid Test.png new file mode 100644 index 00000000..526dc7ac --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Grid Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c69c211061663cd17756eb0ad5a7720ed883047dbcedb39c493c544cfc644ed3 +size 99087 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/ID Test.png b/crates/egui_demo_lib/tests/snapshots/demos/ID Test.png new file mode 100644 index 00000000..dd67f7ad --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/ID Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d31533f812b2b72410b5caafea9b647d3f4cc9da3db9fcf37c332cb57d58742 +size 111670 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Input Event History.png b/crates/egui_demo_lib/tests/snapshots/demos/Input Event History.png new file mode 100644 index 00000000..440fbf0b --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Input Event History.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:502790125ddd0204ea8a468c80c6f3e824adcd98f5a3f626e97f3512d31e1074 +size 24516 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Input Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Input Test.png new file mode 100644 index 00000000..91548c42 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Input Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fc9e2ec3253a30ac9649995b019b6b23d745dba07a327886f574a15c0e99e84 +size 50082 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Layout Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Layout Test.png new file mode 100644 index 00000000..e2899160 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Layout Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18fe761145335a60b1eeb1f7f2072224df86f0e2006caa09d1f3cc4bd263d90c +size 46560 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Manual Layout Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Manual Layout Test.png new file mode 100644 index 00000000..857cd2d6 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Manual Layout Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3110fab8444cb41dffe8b27277fa5dafd0d335aaf13dca511bcccc8b53fb25c8 +size 24046 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/SVG Test.png b/crates/egui_demo_lib/tests/snapshots/demos/SVG Test.png new file mode 100644 index 00000000..ccc938b6 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/SVG Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f1e0657cae72e7ee117d8826bcd18685fd0cdd61d0d613685e4337533c7d4801 +size 23050 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Scene.png b/crates/egui_demo_lib/tests/snapshots/demos/Scene.png index a2c2e7ba..212a7ccd 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Scene.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Scene.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4bf35ad4ce01122de5bc0830018044fd70f116938293fbeb72a2278de0bbb22 -size 35068 +oid sha256:0fcfee082fe1dcbb7515ca6e3d5457e71fecf91a3efc4f76906a32fdb588adb4 +size 35096 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Tessellation Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Tessellation Test.png new file mode 100644 index 00000000..723bb599 --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Tessellation Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f90d56d40004f61628e3f66cfac817c426cd18eb4b9c69ea1b3a6fe5e75e3f05 +size 70354 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png new file mode 100644 index 00000000..bfa5643f --- /dev/null +++ b/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c0ce7090ba12d849f9e3c77010503b394f3e1fce65c382738f55f7181fd7450 +size 42527 diff --git a/crates/egui_extras/Cargo.toml b/crates/egui_extras/Cargo.toml index 2e7b1bd2..15b88f8b 100644 --- a/crates/egui_extras/Cargo.toml +++ b/crates/egui_extras/Cargo.toml @@ -30,7 +30,7 @@ rustdoc-args = ["--generate-link-to-definition"] [features] default = ["dep:mime_guess2"] -## Shorthand for enabling the different types of image loaders (`file`, `http`, `image`, `svg`). +## Shorthand for enabling all the different types of image loaders. all_loaders = ["file", "http", "image", "svg", "gif", "webp"] ## Enable [`DatePickerButton`] widget.