[Update] Add Window Title bar.

[bugfix] Note: I think this is tauri's bug. When I try to resize the window and hovered dragable area, I could see resize cursor but it work as a dragging the window behavior that should't be.
Updated npm packages but still not work so I  managed it as adding margin-top by referring Discord title bar.
This commit is contained in:
Sakamoto Shiina
2024-10-09 22:00:30 +09:00
parent 98d57bdc13
commit 61f50215d7
16 changed files with 797 additions and 740 deletions

36
src-tauri/Cargo.lock generated
View File

@@ -11,6 +11,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-build",
"window-shadows",
]
[[package]]
@@ -329,6 +330,22 @@ dependencies = [
"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.2",
"foreign-types 0.5.0",
"libc",
"objc",
]
[[package]]
name = "cocoa-foundation"
version = "0.1.2"
@@ -2749,7 +2766,7 @@ dependencies = [
"bitflags 1.3.2",
"cairo-rs",
"cc",
"cocoa",
"cocoa 0.24.1",
"core-foundation",
"core-graphics 0.22.3",
"crossbeam-channel",
@@ -2822,7 +2839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77567d2b3b74de4588d544147142d02297f3eaa171a25a065252141d8597a516"
dependencies = [
"anyhow",
"cocoa",
"cocoa 0.24.1",
"dirs-next",
"dunce",
"embed_plist",
@@ -2952,7 +2969,7 @@ version = "0.14.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1989b3b4d611f5428b3414a4abae6fa6df30c7eb8ed33250ca90a5f7e5bb3655"
dependencies = [
"cocoa",
"cocoa 0.24.1",
"gtk",
"percent-encoding",
"rand 0.8.5",
@@ -3548,6 +3565,17 @@ 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 = "git+https://github.com/tauri-apps/window-shadows.git#48fa81bbd9553b1b69e61590b4669bfad8b13ec8"
dependencies = [
"cocoa 0.25.0",
"objc",
"raw-window-handle",
"windows-sys 0.52.0",
]
[[package]]
name = "windows"
version = "0.39.0"
@@ -3883,7 +3911,7 @@ checksum = "00711278ed357350d44c749c286786ecac644e044e4da410d466212152383b45"
dependencies = [
"base64 0.13.1",
"block",
"cocoa",
"cocoa 0.24.1",
"core-graphics 0.22.3",
"crossbeam-channel",
"dunce",

View File

@@ -11,10 +11,11 @@ edition = "2021"
tauri-build = { version = "1", features = [] }
[dependencies]
tauri = { version = "1", features = [ "window-set-decorations", "window-set-always-on-top", "shell-sidecar", "shell-open", "devtools"] }
tauri = { version = "1", features = [ "window-unmaximize", "window-close", "window-maximize", "window-minimize", "window-unminimize", "window-start-dragging", "window-set-decorations", "window-set-always-on-top", "shell-sidecar", "shell-open", "devtools"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
font-kit = "0.14.2"
window-shadows = { git = "https://github.com/tauri-apps/window-shadows.git" }
[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!

View File

@@ -3,19 +3,26 @@
// use tauri::command;
use tauri::Manager;
use window_shadows::set_shadow;
fn main() {
tauri::Builder::default()
.setup(|app| {
let main_window = app.get_window("main").unwrap(); // `main_window` is declared here for all builds
#[cfg(debug_assertions)]
app.get_window("main").unwrap().open_devtools(); // `main` is the first window from tauri.conf.json without an explicit label
{ main_window.open_devtools(); }
#[cfg(any(windows, target_os = "macos"))]
set_shadow(main_window, true).unwrap();
Ok(())
})
.invoke_handler(tauri::generate_handler![get_font_list])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
use font_kit::{source::SystemSource};
use std::collections::HashSet;

View File

@@ -13,8 +13,15 @@
"allowlist": {
"all": false,
"window": {
"all": false,
"setAlwaysOnTop": true,
"setDecorations": true
"setDecorations": true,
"close": true,
"maximize": true,
"minimize": true,
"unmaximize": true,
"unminimize": true,
"startDragging": true
},
"shell": {
"all": false,