Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src-tauri/Cargo.lock

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

2 changes: 2 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ objc2-foundation = "0.3"
objc2-user-notifications = "0.3"
# 菜单栏自己持有 NSStatusItem 和 NSMenu(见 `menubar/macos.rs`)。和 Tauri 用的是同一版
objc2-app-kit = "0.3"
# 菜单栏上的流光是图层遮罩上的动画(见 `menubar/macos.rs` 的 `glow`)
objc2-quartz-core = { version = "0.3", default-features = false, features = ["std", "objc2-core-graphics", "CABase", "CALayer", "CAAnimation", "CAMediaTiming", "CATransaction"] }
# 菜单开着时主线程在事件跟踪模式,更新要走 GCD 的主队列才执行得到
dispatch2 = "0.3"
# 更新包是 DMG,而更新器插件只装 `.app.tar.gz`:挂上映像,把里面的 `.app`
Expand Down
20 changes: 20 additions & 0 deletions src-tauri/examples/menubar_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! cargo run --manifest-path src-tauri/Cargo.toml --example menubar_preview -- --png <目录>
//! # 再加上菜单栏那一块的三档
//! cargo run --manifest-path src-tauri/Cargo.toml --example menubar_preview -- --png <目录> --bars
//! # 只导出有请求在跑时的流光,一圈 54 帧(30 帧/秒)
//! cargo run --manifest-path src-tauri/Cargo.toml --example menubar_preview -- --png <目录> --glow
//! # 挂到菜单栏上,点开看真的菜单。Ctrl-C 退出
//! cargo run --manifest-path src-tauri/Cargo.toml --example menubar_preview -- busy
//! ```
Expand Down Expand Up @@ -62,6 +64,24 @@ fn main() {
}
}
}
if args.iter().any(|a| a == "--glow") {
// 有请求在跑时菜单栏那一块的流光,一圈按 30 帧/秒导出成一串
let bar = model::build(&snapshot("busy"), style).0;
for i in 0..54 {
let phase = f64::from(i) / 30.0 / 1.3;
for dark in [true, false] {
let path = dir.join(format!(
"glow-{}-{i:02}.png",
if dark { "dark" } else { "light" }
));
macos::preview::write_png(
&macos::preview::preview_frame(&bar, &[], dark, phase),
&path,
);
}
}
return;
}
if !args.iter().any(|a| a == "--bars") {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/examples/menubar_shots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn main() {
// 菜单栏上的那一块:一段菜单栏底色,模板图照系统的样子染成黑或白
let (bar, _) = model::build(&snapshot(), model::Style::Full);
for dark in [false, true] {
let item = macos::bar_image(&bar);
let item = macos::bar_image(&bar, Some(0.5));
let size = item.size();
let (w, h) = ((size.width + 28.0).ceil(), 32.0);
let block = RcBlock::new(move |_: NSRect| -> Bool {
Expand Down
Loading
Loading