Skip to content

Commit

Permalink
feat: add a semi-transparent frosted glass effect to the window
Browse files Browse the repository at this point in the history
  • Loading branch information
swordtraveller committed Jan 28, 2025
1 parent 0acf4e4 commit d673a22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ tauri-plugin-shell = "2"
tauri-plugin-fs = "2"
lnk = "0.5.1"
windows-icons = "0.1.1"
window-vibrancy = "0.5.2"
15 changes: 15 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use std::path::Path;
use std::process::Command;
use tauri_plugin_log::{Target, TargetKind};
use tauri::Manager;
use lnk::ShellLink;
use windows_icons::get_icon_base64_by_path;
use window_vibrancy::{apply_blur, apply_vibrancy, apply_mica, apply_acrylic, NSVisualEffectMaterial};

// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
Expand Down Expand Up @@ -47,6 +49,19 @@ fn is_shortcut(path: &str) -> bool {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
let window = app.get_webview_window("main").unwrap();

// #[cfg(target_os = "macos")]
// apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None)
// .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

#[cfg(target_os = "windows")]
apply_acrylic(&window, Some((0, 0, 0, (256.0_f64 * 0.2_f64).round() as u8)))
.expect("Unsupported platform! 'apply_acrylic' is only supported on Windows");

Ok(())
})
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
{
"title": "app-launcher",
"width": 800,
"height": 600
"height": 600,
"transparent": true
}
],
"security": {
Expand Down

0 comments on commit d673a22

Please sign in to comment.