diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a4610b..e163c03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: | cargo check -p gpui-native-core --no-default-features cargo check -p gpui-native-core --all-features - for f in button checkbox switch radio toggle link slider progress avatar input popover tooltip menu dialog toast; do + for f in button checkbox context_menu switch radio toggle link slider progress avatar badge input clipboard popover scroll_area scrollbar segmented separator spinner field status_dot combobox command_palette tooltip menu dropdown_menu select dialog empty_state grain alert toast speech; do cargo check -p gpui-native-core --no-default-features --features "$f" done - name: Feature checks (data) @@ -40,7 +40,7 @@ jobs: run: | cargo check -p gpui-native-layout --no-default-features cargo check -p gpui-native-layout --all-features - for f in dock resize_handle shell window_controls; do + for f in grain panel resize_handle resizable shell titlebar toast alert window_controls; do cargo check -p gpui-native-layout --no-default-features --features "$f" done - name: Feature checks (facade) diff --git a/Cargo.lock b/Cargo.lock index 7c655e0..373fef4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -489,7 +489,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bench_metrics" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "criterion", @@ -624,9 +624,9 @@ checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" [[package]] name = "bumpalo" -version = "3.20.3" +version = "3.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" [[package]] name = "bytemuck" @@ -719,9 +719,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff2a8126fff0f8c839080d619675a585e61720bb12d2baceae45769fd66f155" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" dependencies = [ "find-msvc-tools", "jobserver", @@ -852,7 +852,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "gpui_util", "indexmap", @@ -1161,9 +1161,9 @@ dependencies = [ [[package]] name = "ctor" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d" +checksum = "ea691ed9f36489d087419b8b2ba3ef27d89621380b4178c73e2445a379e4e0f4" dependencies = [ "link-section", "linktime-proc-macro", @@ -1212,7 +1212,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "proc-macro2", "quote", @@ -1401,9 +1401,9 @@ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" [[package]] name = "errno" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" dependencies = [ "libc", "windows-sys 0.61.2", @@ -1523,12 +1523,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" -[[package]] -name = "float_next_after" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" - [[package]] name = "flume" version = "0.12.0" @@ -1893,7 +1887,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.2.2" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "anyhow", @@ -1921,7 +1915,7 @@ dependencies = [ "itertools 0.14.0", "libc", "log", - "lyon", + "lyon_path", "num_cpus", "objc2-core-foundation", "objc2-core-video", @@ -1949,6 +1943,7 @@ dependencies = [ "sum_tree", "taffy", "thiserror 2.0.21", + "tiny-skia-path", "ttf-parser", "unicode-segmentation", "url", @@ -2069,7 +2064,7 @@ dependencies = [ [[package]] name = "gpui_apple" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "async-task", @@ -2108,7 +2103,7 @@ dependencies = [ [[package]] name = "gpui_ios" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "block2 0.6.2", @@ -2129,7 +2124,7 @@ dependencies = [ [[package]] name = "gpui_linux" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "anyhow", @@ -2156,7 +2151,7 @@ dependencies = [ [[package]] name = "gpui_macos" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "accesskit_macos", @@ -2188,6 +2183,7 @@ dependencies = [ "raw-window-handle", "scheduler", "semver", + "serde_json", "smallvec", "strum", "uuid", @@ -2196,7 +2192,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -2207,7 +2203,7 @@ dependencies = [ [[package]] name = "gpui_platform" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "console_error_panic_hook", @@ -2222,7 +2218,7 @@ dependencies = [ [[package]] name = "gpui_shared_string" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "schemars", "serde", @@ -2232,7 +2228,7 @@ dependencies = [ [[package]] name = "gpui_util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "log", @@ -2242,7 +2238,7 @@ dependencies = [ [[package]] name = "gpui_web" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "async-channel", @@ -2271,7 +2267,7 @@ dependencies = [ [[package]] name = "gpui_wgpu" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "bytemuck", @@ -2281,6 +2277,7 @@ dependencies = [ "gpui", "gpui_util", "itertools 0.14.0", + "js-sys", "log", "parking_lot", "profiling", @@ -2296,7 +2293,7 @@ dependencies = [ [[package]] name = "gpui_windows" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "accesskit", "accesskit_windows", @@ -2483,7 +2480,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "bytes", @@ -2501,7 +2498,7 @@ dependencies = [ [[package]] name = "http_client_tls" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "log", "rustls", @@ -3073,9 +3070,9 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "link-section" -version = "0.19.3" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c29a617ce3df32c08497bdc1ab6e2376e0b17948ac166a2fbe5977c5954cd9" +checksum = "4d9aae57673c1a235149777a74d152f3210ebd3e3b13346d2cdb6809e566bd3c" [[package]] name = "linktime-proc-macro" @@ -3134,26 +3131,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f" -[[package]] -name = "lyon" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0578bdecb7d6d88987b8b2b1e3a4e2f81df9d0ece1078623324a567904e7b7" -dependencies = [ - "lyon_algorithms", - "lyon_tessellation", -] - -[[package]] -name = "lyon_algorithms" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a6b9d4e8b48acd531fbf1241ad9b270df6e60b6b92bdea1469f4f40899d805" -dependencies = [ - "lyon_path", - "num-traits", -] - [[package]] name = "lyon_geom" version = "1.0.20" @@ -3175,17 +3152,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "lyon_tessellation" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4872650e70dc907dd4f7ebc449d7d657a0d2658e423b2e724970870bbbf75b" -dependencies = [ - "float_next_after", - "lyon_path", - "num-traits", -] - [[package]] name = "mac-notification-sys" version = "0.6.15" @@ -3294,9 +3260,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.4" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" dependencies = [ "libc", "log", @@ -3461,14 +3427,14 @@ dependencies = [ "mac-notification-sys", "serde", "tauri-winrt-notification", - "zbus 6.2.1", + "zbus 6.3.0", ] [[package]] name = "notify-types" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c491a384baf9fec20df565cdb8138a12809d4c7439763b566eb8114c5d59979" +checksum = "cbd044e85df3d939d8e32a1c35a3b737c7d0a4eeb7acd737bd207644e00f4e5f" dependencies = [ "bitflags 2.13.2", ] @@ -4411,7 +4377,7 @@ dependencies = [ "core_detect", "num-traits", "proptest-macro", - "rand 0.10.3", + "rand 0.10.4", "rand_xorshift", "regex-syntax", "rusty-fork", @@ -4507,7 +4473,7 @@ dependencies = [ "bytes", "getrandom 0.4.3", "lru-slab", - "rand 0.10.3", + "rand 0.10.4", "rand_pcg", "ring", "rustc-hash 2.1.3", @@ -4578,9 +4544,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" dependencies = [ "chacha20", "getrandom 0.4.3", @@ -4813,7 +4779,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "derive_refineable", ] @@ -4856,7 +4822,7 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "anyhow", "bytes", @@ -5041,9 +5007,9 @@ checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" [[package]] name = "rustls-webpki" -version = "0.103.16" +version = "0.103.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" dependencies = [ "aws-lc-rs", "ring", @@ -5114,7 +5080,7 @@ dependencies = [ [[package]] name = "scheduler" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "async-task", "backtrace", @@ -5557,7 +5523,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "heapless", "rayon", @@ -7364,9 +7330,9 @@ dependencies = [ [[package]] name = "zbus" -version = "6.2.1" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ddb2961d9587ef9f24ad14cde1c3bc4c5edc9f1525932a8cffdd5bd98886eb9" +checksum = "6b4aae740b23927ceabed962431abab2cdefb9f7f885e5bbab062da09bf580e4" dependencies = [ "async-trait", "bitflags 2.13.2", @@ -7383,7 +7349,7 @@ dependencies = [ "uuid", "windows-sys 0.61.2", "winnow 1.0.5", - "zbus_macros 6.2.1", + "zbus_macros 6.3.0", "zbus_utils", "zcheapstr", "zruntime", @@ -7406,9 +7372,9 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "6.2.1" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083b38add47c340fc12ec560124fb1d9c23acb584f7021099f85ec6587a03c54" +checksum = "37c9dd4beaf145c16fcb2902862f50da86e54aed13dd368ddf64a1d17e6b8529" dependencies = [ "proc-macro2", "quote", @@ -7651,9 +7617,9 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" [[package]] name = "zruntime" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ef5ed7d628cdf0af82f93dfe03330a8e37383bf7422a1d3d6eb72326680be5" +checksum = "ce6a55d4f521760475a30f7b96779508fe8c40dc834478709454dd1d5f0ebc72" dependencies = [ "futures-core", "futures-io", @@ -7665,7 +7631,7 @@ dependencies = [ [[package]] name = "ztracing" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" dependencies = [ "tracing", "ztracing_macro", @@ -7674,7 +7640,7 @@ dependencies = [ [[package]] name = "ztracing_macro" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed?rev=f8cfc7ed9e57503def9479138894f3139f5400cc#f8cfc7ed9e57503def9479138894f3139f5400cc" +source = "git+https://github.com/zed-industries/zed#053d91cb14b5fd138f221ec02bd76efb15e7b2af" [[package]] name = "zune-core" diff --git a/Cargo.toml b/Cargo.toml index 2d18109..29982b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,9 +24,9 @@ gpui-native-icons = { path = "crates/icons" } gpui-native-theme = { path = "crates/theme" } [workspace.dependencies] -gpui = { git = "https://github.com/zed-industries/zed", rev = "f8cfc7ed9e57503def9479138894f3139f5400cc" } -gpui_platform = { git = "https://github.com/zed-industries/zed", rev = "f8cfc7ed9e57503def9479138894f3139f5400cc", features = ["font-kit"] } -reqwest_client = { git = "https://github.com/zed-industries/zed", rev = "f8cfc7ed9e57503def9479138894f3139f5400cc" } +gpui = { git = "https://github.com/zed-industries/zed" } +gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["font-kit"] } +reqwest_client = { git = "https://github.com/zed-industries/zed" } gpui-native-core = { path = "crates/core", default-features = false } gpui-native-data = { path = "crates/data", default-features = false } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index c5c0e1e..27ed078 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -87,6 +87,6 @@ select = ["menu"] dialog = ["button", "scroll_area", "grain"] empty_state = [] grain = ["dep:image"] -alert = [] -toast = [] +alert = ["button"] +toast = ["button"] speech = ["spinner", "tooltip", "dep:flume", "dep:cpal"] diff --git a/crates/core/src/spinner.rs b/crates/core/src/spinner.rs index 1f9f571..b2a2d10 100644 --- a/crates/core/src/spinner.rs +++ b/crates/core/src/spinner.rs @@ -8,8 +8,8 @@ use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationElement, AnimationExt as _, App, Canvas, ElementId, Hsla, InteractiveElement as _, IntoElement, ParentElement as _, Path, PathBuilder, Pixels, Point, - RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled as _, Transformation, - Window, canvas, div, percentage, point, px, + RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled as _, Window, canvas, + div, point, px, }; use gpui_native_icons::{Icon, IconRole, icon}; use gpui_native_theme::{ActiveTheme as _, SPINNER_PERIOD, Size}; @@ -184,15 +184,11 @@ fn spinning_ring(side: Pixels, stroke: Pixels, accent: Hsla) -> AnimationElement ) } -fn spinning_icon(side: Pixels, accent: Hsla) -> AnimationElement { +fn spinning_icon(side: Pixels, accent: Hsla) -> Icon { icon(IconRole::Loader) .size(side) .color(accent) - .with_animation( - "spin", - Animation::new(SPINNER_PERIOD).repeat().with_max_fps(60.), - |glyph, delta| glyph.with_transformation(Transformation::rotate(percentage(delta))), - ) + .with_rotation_animation(SPINNER_PERIOD) } fn paint_circle( @@ -222,7 +218,7 @@ fn arc_path( stroke: Pixels, start: f32, sweep: f32, -) -> Option> { +) -> Option { let mut builder = PathBuilder::stroke(stroke); builder.move_to(ring_point(center, radius, start)); builder.arc_to( @@ -236,7 +232,7 @@ fn arc_path( } /// A stroked full circle; `None` on degenerate geometry. -fn circle_path(center: Point, radius: Pixels, stroke: Pixels) -> Option> { +fn circle_path(center: Point, radius: Pixels, stroke: Pixels) -> Option { let mut builder = PathBuilder::stroke(stroke); builder.move_to(ring_point(center, radius, 0.0)); builder.arc_to( diff --git a/crates/icons/src/lib.rs b/crates/icons/src/lib.rs index d189061..8472be6 100644 --- a/crates/icons/src/lib.rs +++ b/crates/icons/src/lib.rs @@ -2,10 +2,12 @@ //! and the crate resolves each role to a glyph for the current platform. //! Apps ship their own icon set by implementing [`IconNamed`]. +use std::time::Duration; + use gpui::prelude::FluentBuilder as _; use gpui::{ AnyElement, AssetSource, Hsla, IntoElement, ParentElement as _, Pixels, RenderOnce, - SharedString, Styled as _, Transformation, Window, div, px, svg, + SharedString, Styled as _, TimedTransformation, Transformation, Window, div, px, svg, }; #[cfg_attr(not(target_os = "linux"), allow(dead_code))] @@ -16,6 +18,8 @@ mod segoe; const SMALL_ICON_SIZE: Pixels = px(14.0); const DEFAULT_ICON_SIZE: Pixels = px(16.0); const LARGE_ICON_SIZE: Pixels = px(20.0); +/// The spin presents at most this rate, rotating a sprite needs no more frames. +const SPIN_MAX_FPS: f32 = 60.0; /// The semantic glyphs UI components need. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -539,6 +543,7 @@ pub struct Icon { size: Pixels, color: Option, transformation: Option, + rotation_period: Option, } /// Creates an icon for the role at the default size. @@ -548,6 +553,7 @@ pub fn icon(role: IconRole) -> Icon { size: DEFAULT_ICON_SIZE, color: None, transformation: None, + rotation_period: None, } } @@ -562,6 +568,7 @@ impl Icon { size: DEFAULT_ICON_SIZE, color: None, transformation: None, + rotation_period: None, } } @@ -593,12 +600,18 @@ impl Icon { self } - /// An extra SVG transformation, e.g. a spinner's rotation. + /// An extra static SVG transformation. pub fn with_transformation(mut self, transformation: Transformation) -> Self { self.transformation = Some(transformation); self } + /// Spins the icon clockwise, one full turn per `period`. + pub fn with_rotation_animation(mut self, period: Duration) -> Self { + self.rotation_period = Some(period); + self + } + /// The asset key a resolved freedesktop file is served under. #[cfg(target_os = "linux")] fn freedesktop_asset_path(size: Pixels, role: &IconRole) -> Option { @@ -611,6 +624,7 @@ impl Icon { size: Pixels, color: Option, transformation: Option, + rotation_period: Option, role: IconRole, ) -> AnyElement { #[cfg(target_os = "windows")] @@ -619,12 +633,14 @@ impl Icon { } #[cfg(target_os = "linux")] if let Some(path) = Self::freedesktop_asset_path(size, &role) { - return Self::render_svg_path(size, color, transformation, path).into_any_element(); + return Self::render_svg_path(size, color, transformation, rotation_period, path) + .into_any_element(); } Self::render_svg_path( size, color, transformation, + rotation_period, SharedString::from(role.asset_path()), ) .into_any_element() @@ -653,6 +669,7 @@ impl Icon { size: Pixels, color: Option, transformation: Option, + rotation_period: Option, path: SharedString, ) -> AnyElement { div() @@ -665,6 +682,15 @@ impl Icon { .when_some(color, |el, color| el.text_color(color)) .when_some(transformation, |el, transformation| { el.with_transformation(transformation) + }) + .when_some(rotation_period, |el, period| { + el.with_timed_transformation( + TimedTransformation::rotation( + period, + transformation.unwrap_or_default(), + ) + .with_max_fps(SPIN_MAX_FPS), + ) }), ) .into_any_element() @@ -687,13 +713,18 @@ impl RenderOnce for Icon { size, color, transformation, + rotation_period, } = self; let color = color.unwrap_or_else(|| window.text_style().color); match glyph { - Glyph::Named(path) => Self::render_svg_path(size, Some(color), transformation, path), - Glyph::Role(role) => Self::render_role(size, Some(color), transformation, role), + Glyph::Named(path) => { + Self::render_svg_path(size, Some(color), transformation, rotation_period, path) + } + Glyph::Role(role) => { + Self::render_role(size, Some(color), transformation, rotation_period, role) + } } } } diff --git a/crates/layout/tests/panel.rs b/crates/layout/tests/panel.rs index 69917e8..71f4b25 100644 --- a/crates/layout/tests/panel.rs +++ b/crates/layout/tests/panel.rs @@ -124,7 +124,8 @@ fn dragging_the_divider_resizes_the_panels(cx: &mut TestAppContext) { .expect("main panel laid out"); // Press the divider between the islands and drag it 100px to the right. - let seam = point(before.right() + px(13.0), px(400.0)); + let handle = cx.debug_bounds("resize-handle").expect("divider laid out"); + let seam = point(handle.center().x, px(400.0)); cx.simulate_event(MouseDownEvent { position: seam, button: MouseButton::Left,