Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
tint status bar items white instead of having separate resources
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed Dec 24, 2014
1 parent c907ead commit bd544a0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ NSString *HBTSNameForHandle(NSString *address) {
return handle._displayNameWithAbbreviation ?: address;
}

#pragma mark - Tint image

NSImage *HBTSTintImageWithColor(NSImage *image, NSColor *color) {
// https://stackoverflow.com/a/16138027/709376
NSImage *newImage = [[image copy] autorelease];
[newImage lockFocus];
[color set];
NSRectFillUsingOperation((NSRect){ NSZeroPoint, newImage.size }, NSCompositeSourceAtop);
[newImage unlockFocus];
return newImage;
}

#pragma mark - Status item stuff

void HBTSSetStatus(HBTSStatusBarType type, NSString *handle) {
Expand All @@ -57,11 +69,8 @@ void HBTSSetStatus(HBTSStatusBarType type, NSString *handle) {
ReadIcon.size = CGSizeMake(22.f, 22.f);

if (!IS_OSX_OR_NEWER(10_10)) {
TypingIconInverted = [[bundle imageForResource:@"TypingInverted.tiff"] retain];
TypingIconInverted.size = CGSizeMake(22.f, 22.f);

ReadIconInverted = [[bundle imageForResource:@"ReadInverted.tiff"] retain];
ReadIconInverted.size = CGSizeMake(22.f, 22.f);
TypingIconInverted = [HBTSTintImageWithColor(TypingIcon, [NSColor whiteColor]) retain];
ReadIconInverted = [HBTSTintImageWithColor(ReadIcon, [NSColor whiteColor]) retain];
}
});

Expand Down

0 comments on commit bd544a0

Please sign in to comment.