#How do I actually use the window-vibrancy plugin..?

2 messages · Page 1 of 1 (latest)

royal bay
#

I've never touched Rust before so I'm completely lost ^^'
My window is already transparent and I'm trying to make a toggle for the blur effect.
I should be able to handle the ts part, but I'd definitely like some help for the rust part.
Here is my main.rs

// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::Manager;
use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial, NSVisualEffectState};

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

fn main() {
    tauri::Builder::default()
        .setup(|app| {
        let window = app.get_window("main").unwrap();
  
        #[cfg(target_os = "macos")]
        apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, Some(NSVisualEffectState::Active), None)
          .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

        Ok(())
         })
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

and here the error
error[E0432]: unresolved import `window_vibrancy` --> src/main.rs:5:5 | 5 | use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial, NSVisualEffectState}; | ^^^^^^^^^^^^^^^ use of undeclared crate or module `window_vibrancy

elder urchin
#

You also need to add the plugin to your Cargo.toml file:

[dependencies]
tauri = { version = "1.5", features = ["shell-open"] }
window-vibrancy = "0.4"