Added custom close icon to touchbar

- Slightly refactored.
This commit is contained in:
23rd 2019-05-04 11:54:38 +03:00 committed by John Preston
parent 9873e6d75c
commit ba1691bf7e
2 changed files with 14 additions and 3 deletions

View File

@ -152,6 +152,9 @@ mediaPlayerPreviousButton: IconButton(mediaPlayerNextButton) {
mediaPlayerPreviousDisabledIcon: icon {
{ "player_next-flip_horizontal", mediaPlayerInactiveFg, mediaPlayerSkipIconPosition },
};
iconPlayerClose: icon {{ "player_close", windowFg }};
mediaPlayerClose: IconButton(mediaPlayerRepeatButton) {
width: 37px;
icon: icon {{ "player_close", menuIconFg, point(10px, 12px) }};

View File

@ -30,6 +30,7 @@
#include "ui/empty_userpic.h"
#include "observer_peer.h"
#include "styles/style_dialogs.h"
#include "styles/style_media_player.h"
#include "data/data_folder.h"
namespace {
@ -205,7 +206,7 @@ auto lifetime = rpl::lifetime();
Ui::EmptyUserpic::PaintSavedMessages(paint, 0, 0, s, s);
}
pix->setDevicePixelRatio(cRetinaFactor());
return static_cast<NSImage*>(qt_mac_create_nsimage(*pix));
return [qt_mac_create_nsimage(*pix) autorelease];
}
if (!self.peer) {
// Random picture.
@ -214,7 +215,7 @@ auto lifetime = rpl::lifetime();
self.waiting = !self.peer->userpicLoaded();
auto pixmap = self.peer->genUserpic(kIdealIconSize);
pixmap.setDevicePixelRatio(cRetinaFactor());
return static_cast<NSImage*>(qt_mac_create_nsimage(pixmap));
return [qt_mac_create_nsimage(pixmap) autorelease];
}
@ -264,7 +265,7 @@ auto lifetime = rpl::lifetime();
@"type": @"button",
@"name": @"Close Player",
@"cmd": [NSNumber numberWithInt:kClosePlayer],
@"image": [NSImage imageNamed:NSImageNameTouchBarExitFullScreenTemplate]
@"image": createImageFromStyleIcon(st::iconPlayerClose, NSMakeSize(kIdealIconSize / 3, kIdealIconSize / 3))
}],
currentPosition: [NSMutableDictionary dictionaryWithDictionary:@{
@"type": @"text",
@ -297,6 +298,13 @@ auto lifetime = rpl::lifetime();
return self;
}
NSImage *createImageFromStyleIcon(const style::icon &icon, NSSize size) {
const auto pixmap = icon.instance(QColor(255, 255, 255, 255), 100);
NSImage *image = [qt_mac_create_nsimage(QPixmap::fromImage(pixmap)) autorelease];
[image setSize:size];
return image;
}
- (void) createTouchBar {
_touchBarMain = [[NSTouchBar alloc] init];
_touchBarMain.delegate = self;