Skip to content

Commit

Permalink
fix(macos/menu): set native image height to 18 (#746)
Browse files Browse the repository at this point in the history
* fix(macos/menu): set native image height to 18

closes tauri-apps/tauri#7077

* Update menu.rs
  • Loading branch information
amrbashir authored Jun 5, 2023
1 parent 8132901 commit 5af3da4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/macos-native-image-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On macOS, force `NativeImage` height to be `18` to have consistent size for all icons and match custom icons.
8 changes: 5 additions & 3 deletions src/platform_impl/macos/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ impl MenuItemAttributes {
// Available only with CustomMenuItemExtMacOS
pub fn set_native_image(&mut self, icon: NativeImage) {
unsafe {
let ns_image: id = icon.get_ns_image();
let image_ref: id = msg_send![class!(NSImage), imageNamed: ns_image];
let () = msg_send![self.1, setImage: image_ref];
let named_img: id = icon.get_ns_image();
let nsimage: id = msg_send![class!(NSImage), imageNamed: named_img];
let size = NSSize::new(18.0, 18.0);
let _: () = msg_send![nsimage, setSize: size];
let _: () = msg_send![self.1, setImage: nsimage];
}
}
}
Expand Down

0 comments on commit 5af3da4

Please sign in to comment.