Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon is not visible on OS X Yosemite dark menu bar #2476

Closed
benbarth opened this issue Oct 17, 2014 · 8 comments
Closed

Icon is not visible on OS X Yosemite dark menu bar #2476

benbarth opened this issue Oct 17, 2014 · 8 comments

Comments

@benbarth
Copy link

Steps to reproduce:

  1. Use a black tray icon
  2. Enable "Use dark menu bar and Dock" under System Preferences > General
    screen shot 2014-10-17 at 10 35 30 am

Expected Result:
The icon is displayed and matches the theme in grayscale. (inverted to white)

Actual Result:
The icon is not visible.

From what I've read, it looks like the image needs to be a template image.
I recommend a flag is added to the Tray object that enables this functionality.

@yoshuawuyts
Copy link

You could also use this package to detect conditionally if dark mode is enabled -- https://github.com/sindresorhus/node-dark-mode

@benbarth
Copy link
Author

That would allow us to detect the mode on application start, but it doesn't look like there is an event for detecting changes during runtime.

@yoshuawuyts
Copy link

An ugly hack would be to use setInterval to continuously check for changes. I agree that platform support would be much nicer, but this should hopefully provide an acceptable solution until then.

@reggi
Copy link

reggi commented Oct 31, 2014

There's a couple of issues I describe here with node-dark-mode preventing this from working.

var darkMode = require('dark-mode');
var darkMenuCheckup = function(iconWhite, iconBlack){
  var darkTray = function(){
    tray.icon =  iconWhite;
    tray.alticon = iconBlack;
  };
  var checkDark = function(){
    darkMode.isDark(function(err, isDark){
      if(!err && isDark) darkTray();
    });
  }
  setInterval(checkDark, 500);
}

@mrfabbri
Copy link
Member

mrfabbri commented Dec 8, 2014

I think the cleanest solution would be to have an isTemplate option in the new Tray(options) constructor. This option would be used to call setTemplate: on the NSImage image in NSStatusItem (and discarded on platforms other than OS X).

/cc @rogerwang what's your take on this?

mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Dec 9, 2014
Add boolean property (defaults to `true`) `iconsAreTemplates` to `Tray` objects
to allow for proper display of icons in Mac OS X (Yosemite) Dark Menus.

When `iconsAreTemplates` is set to true, both `icon` and `altIcon` are treated
as "templates" and the system automatically ensures proper styling according to
the various states of the status item (e.g. dark menu, light menu, etc.).
Template images should consist only of black and clear colours and can use the
alpha channel in the image to adjust the opacity of black content.

See [Dark Menus in AppKit Release Notes for OS X v10.10](https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/#10_10DarkMenus)
and [`NSImage setTemplate:`](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/index.html#//apple_ref/occ/instm/NSImage/setTemplate:).

On Linux and Windows setting the property has no effect.

FIX nwjs#2476
@mikejramsey56
Copy link

Why not use a multi-color icon so that no matter what the styling it is visible?

@mrfabbri
Copy link
Member

@mikejramsey56 you will end-up with a sub-optimal result on both backgrounds; using a Template image is the recommended way (by OS X Human Interface Guidelines) to achieve a proper look in both light and dark appearance, (as a plus Template icons allow for proper rendering of other menu item statuses like disabled, selected...). The great majority of apps on OS X use template icons (e.g. Dropbox changed from it's iconic blue icon to a dark, on light, one).

@reggi
Copy link

reggi commented Dec 11, 2014

I agree with @mrfabbri, white icon on black black bar and/or black icon on white black bar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants