2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-26 12:18:01 +00:00

30 lines
837 B
Plaintext
Raw Normal View History

2020-07-04 14:52:18 +03:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/mac/touchbar/mac_touchbar_common.h"
2020-10-27 13:32:09 +03:00
#include "base/platform/mac/base_utilities_mac.h"
2020-07-04 14:52:18 +03:00
2020-10-27 13:32:09 +03:00
#import <AppKit/NSTextField.h>
2020-07-04 14:52:18 +03:00
namespace TouchBar {
int WidthFromString(NSString *s) {
return (int)ceil(
[[NSTextField labelWithString:s] frame].size.width) * 1.2;
}
NSImage *CreateNSImageFromStyleIcon(const style::icon &icon, int size) {
2020-10-27 13:32:09 +03:00
auto instance = icon.instance(QColor(255, 255, 255, 255), 100);
instance.setDevicePixelRatio(cRetinaFactor());
NSImage *image = Platform::Q2NSImage(instance);
2020-07-04 14:52:18 +03:00
[image setSize:NSMakeSize(size, size)];
return image;
}
} // namespace TouchBar