(misc) Add window-shadows for rounded corners on Windows and a shadow on all other platforms

This commit is contained in:
KingRainbow44
2023-11-30 11:47:38 -05:00
parent 3c43ba04e3
commit 3e0ffc19b9
3 changed files with 90 additions and 13 deletions

91
src-tauri/Cargo.lock generated
View File

@@ -506,8 +506,24 @@ dependencies = [
"block",
"cocoa-foundation",
"core-foundation",
"core-graphics",
"foreign-types",
"core-graphics 0.22.3",
"foreign-types 0.3.2",
"libc",
"objc",
]
[[package]]
name = "cocoa"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
dependencies = [
"bitflags 1.3.2",
"block",
"cocoa-foundation",
"core-foundation",
"core-graphics 0.23.1",
"foreign-types 0.5.0",
"libc",
"objc",
]
@@ -582,7 +598,20 @@ dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-graphics-types",
"foreign-types",
"foreign-types 0.3.2",
"libc",
]
[[package]]
name = "core-graphics"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-graphics-types",
"foreign-types 0.5.0",
"libc",
]
@@ -714,6 +743,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-build",
"window-shadows",
]
[[package]]
@@ -1003,7 +1033,28 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
"foreign-types-shared 0.1.1",
]
[[package]]
name = "foreign-types"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [
"foreign-types-macros",
"foreign-types-shared 0.3.1",
]
[[package]]
name = "foreign-types-macros"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
]
[[package]]
@@ -1012,6 +1063,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "foreign-types-shared"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@@ -2260,7 +2317,7 @@ checksum = "79a4c6c3a2b158f7f8f2a2fc5a969fa3a068df6fc9dbb4a43845436e3af7c800"
dependencies = [
"bitflags 2.4.1",
"cfg-if",
"foreign-types",
"foreign-types 0.3.2",
"libc",
"once_cell",
"openssl-macros",
@@ -3446,9 +3503,9 @@ dependencies = [
"bitflags 1.3.2",
"cairo-rs",
"cc",
"cocoa",
"cocoa 0.24.1",
"core-foundation",
"core-graphics",
"core-graphics 0.22.3",
"crossbeam-channel",
"dispatch",
"gdk",
@@ -3520,7 +3577,7 @@ checksum = "9bfe673cf125ef364d6f56b15e8ce7537d9ca7e4dae1cf6fbbdeed2e024db3d9"
dependencies = [
"anyhow",
"bytes",
"cocoa",
"cocoa 0.24.1",
"dirs-next",
"embed_plist",
"encoding_rs",
@@ -3653,7 +3710,7 @@ version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8141d72b6b65f2008911e9ef5b98a68d1e3413b7a1464e8f85eb3673bb19a895"
dependencies = [
"cocoa",
"cocoa 0.24.1",
"gtk",
"percent-encoding",
"rand 0.8.5",
@@ -4373,6 +4430,18 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "window-shadows"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ff424735b1ac21293b0492b069394b0a189c8a463fb015a16dea7c2e221c08"
dependencies = [
"cocoa 0.25.0",
"objc",
"raw-window-handle",
"windows-sys 0.48.0",
]
[[package]]
name = "windows"
version = "0.37.0"
@@ -4704,8 +4773,8 @@ checksum = "64a70547e8f9d85da0f5af609143f7bde3ac7457a6e1073104d9b73d6c5ac744"
dependencies = [
"base64 0.13.1",
"block",
"cocoa",
"core-graphics",
"cocoa 0.24.1",
"core-graphics 0.22.3",
"crossbeam-channel",
"dunce",
"gdk",

View File

@@ -13,11 +13,11 @@ edition = "2021"
tauri-build = { version = "1.5", features = [] }
[dependencies]
tauri = { version = "1.5", features = [ "api-all"] }
tauri = { version = "1.5", features = ["api-all"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
reqwest = "0.11.22"
window-shadows = "0.2.2"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem

View File

@@ -2,6 +2,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::fs::create_dir;
use tauri::Manager;
use window_shadows::set_shadow;
mod http;
@@ -22,6 +24,12 @@ fn main() {
.expect("Failed to create app data directory");
}
// Enable window shadows.
let main_window = app.get_window("main")
.expect("Unable to fetch Tauri window.");
#[cfg(any(windows, target_os = "macos"))]
set_shadow(&main_window, true).unwrap();
Ok(())
})
.run(tauri::generate_context!())