mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-27 09:36:28 +08:00
fix(tray): Retina tray icon with template image for dark menu bar mode
This commit is contained in:
parent
74252d58d9
commit
3a16484d7d
4 changed files with 9 additions and 3 deletions
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
|
@ -75,11 +75,17 @@ class TrayStore extends NylasStore {
|
|||
const imgHandlers = {
|
||||
'darwin': ()=> {
|
||||
const img = new Image();
|
||||
// This is synchronous because it's a data url
|
||||
// toDataUrl always returns the @1x image data, so the assets/darwin/
|
||||
// contains an "@2x" image /without/ the @2x extension
|
||||
img.src = this._baseIcon.toDataUrl();
|
||||
const count = this._unreadCount || '';
|
||||
const canvas = canvasWithSystemTrayIconAndText(img, count.toString());
|
||||
return NativeImage.createFromDataUrl(canvas.toDataURL());
|
||||
const pngData = NativeImage.createFromDataUrl(canvas.toDataURL()).toPng();
|
||||
|
||||
// creating from a buffer allows us to specify that the image is @2x
|
||||
const out2x = NativeImage.createFromBuffer(pngData, 2);
|
||||
out2x.setTemplateImage(true);
|
||||
return out2x;
|
||||
},
|
||||
'default': ()=> {
|
||||
return unreadCount > 0 ? this._unreadIcon : this._baseIcon;
|
||||
|
|
|
@ -82,7 +82,7 @@ CanvasUtils =
|
|||
canvas = SystemTrayCanvas
|
||||
w = img.width
|
||||
h = img.height
|
||||
font = '14px Nylas-Pro, sans-serif'
|
||||
font = '26px Nylas-Pro, sans-serif'
|
||||
|
||||
textWidth = if text.length > 0 then CanvasUtils.measureTextInCanvas(text, font) + 2 else 0
|
||||
canvas.width = w + textWidth
|
||||
|
|
Loading…
Reference in a new issue