Conversation
fb91aa2 to
859b1b2
Compare
|
Hello, I notice new tray_icon have the code snippest fn create_button_with_icon(&self) {
const ICON_WIDTH: f64 = 18.0;
const ICON_HEIGHT: f64 = 18.0;
let icon = self.icon.inner.to_png();
unsafe {
let status_item = self.ns_status_bar;
let button = status_item.button();
// build our icon
let nsdata = NSData::dataWithBytes_length_(
nil,
icon.as_ptr() as *const std::os::raw::c_void,
icon.len() as u64,
);
let nsimage = NSImage::initWithData_(NSImage::alloc(nil), nsdata);
let new_size = NSSize::new(ICON_WIDTH, ICON_HEIGHT);
button.setImage_(nsimage);
let _: () = msg_send![nsimage, setSize: new_size];
let is_template = match self.icon_is_template {
true => YES,
false => NO,
};
let _: () = msg_send![nsimage, setTemplate: is_template];
}
}but commnet tell me ,icon is from // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
//! **UNSTABLE** -- The `SystemTray` struct and associated types.
//!
//! Use [SystemTrayBuilder][tray_builder] to create your tray instance.
//!
//! [ContextMenu][context_menu] is used to created a Window menu on Windows and Linux. On macOS it's used in the menubar.
//!
//! ```rust,ignore
//! # let icon_rgba = Vec::<u8>::new();
//! # let icon_width = 0;
//! # let icon_height = 0;
//! let mut tray_menu = ContextMenu::new();
//! let icon = Icon::from_rgba(icon_rgba, icon_width, icon_height);
//!
//! tray_menu.add_item(MenuItemAttributes::new("My menu item"));
//!
//! let mut system_tray = SystemTrayBuilder::new(icon, Some(tray_menu))
//! .build(&event_loop)
//! .unwrap();
//! ```
//!
//! # Linux
//! A menu is required or the tray return an error containing `assertion 'G_IS_DBUS_CONNECTION (connection)'`.
//!
//! [tray_builder]: crate::system_tray::SystemTrayBuilder
//! [menu_bar]: crate::menu::MenuBar
//! [context_menu]: crate::menu::ContextMenu
the mean will only set_icon lenght and height only "18.0" on macOS, because it not use Icon.hegith and Icon.width, and it will don't let user create canvas icon (bigger than 18.0) |
|
@awkj ideal sizes for tray icons, are |
macos tray allow set any weight icon, network speed app use it to complete a rectangle icon, I thinke should open the API |
|
That's not an icon, that's a text, which is a different api. |
859b1b2 to
12a0d68
Compare
12a0d68 to
9aa91e8
Compare

Version Updates
Merging this PR will release new versions of the following packages based on your change files.
tao
[0.11.0]
SystemTrayBuilder::newandSystemTray::set_iconnow takessystem_tray::Iconon all platforms.Window::set_ignore_cursor_eventsWindow::set_ignore_cursor_events, closes #184 (#421) on 2022-06-13