Skip to content

Commit

Permalink
Merge pull request #44 from tommoor/template-images
Browse files Browse the repository at this point in the history
Template Images (OSX dark mode compatibility)
  • Loading branch information
deivuh committed May 2, 2016
2 parents fefa0d5 + eed95b0 commit 30b29f8
Show file tree
Hide file tree
Showing 43 changed files with 244 additions and 174 deletions.
25 changes: 13 additions & 12 deletions DODropletManager/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ - (void) createMenuItems {
_statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];

_statusItem.title = @"";
_statusItem.alternateImage = [NSImage imageNamed:@"DropletStatusIconHighlighted"];
_statusItem.alternateImage = [NSImage imageNamed:@"dropletStatusIconHighlightedTemplate"];
_statusItem.highlightMode = YES;
menu = [[NSMenu alloc] init];
addItems = YES;
Expand All @@ -140,7 +140,7 @@ - (void) createMenuItems {
}
}

[self setStatusImage: @"DropletStatusIcon"];
[self setStatusImage: @"dropletStatusIconTemplate"];

int dropletMIIndex = 0;

Expand Down Expand Up @@ -175,45 +175,45 @@ - (void) createMenuItems {

NSMenuItem *viewOnWebMI = [[NSMenuItem alloc] initWithTitle:@"View on website" action:@selector(viewDropletOnBrowser:) keyEquivalent:@""];

[viewOnWebMI setImage:[NSImage imageNamed:@"info-icon"]];
[viewOnWebMI setImage:[NSImage imageNamed:@"infoIconTemplate"]];
[viewOnWebMI setRepresentedObject:droplet];

[submenu addItem:viewOnWebMI];

NSMenuItem *connectToDroplet = [[NSMenuItem alloc] initWithTitle:@"Connect to Droplet" action:@selector(establishSSHConnectionToDroplet:) keyEquivalent:@""];

[connectToDroplet setImage:[NSImage imageNamed:@"ssh-icon"]];
[connectToDroplet setImage:[NSImage imageNamed:@"sshIconTemplate"]];
[connectToDroplet setRepresentedObject:droplet];

[submenu addItem:connectToDroplet];

NSMenuItem *rebootMI = [[NSMenuItem alloc] initWithTitle:@"Reboot" action:@selector(confirmReboot:) keyEquivalent:@""];

[rebootMI setImage:[NSImage imageNamed:@"reboot-icon"]];
[rebootMI setImage:[NSImage imageNamed:@"rebootIconTemplate"]];
[rebootMI setRepresentedObject:droplet];

[submenu addItem:rebootMI];

if (droplet.active) {
NSMenuItem *shutdownMI = [[NSMenuItem alloc] initWithTitle:@"Shutdown" action:@selector(confirmShutdown:) keyEquivalent:@""];

[shutdownMI setImage:[NSImage imageNamed:@"power-icon"]];
[shutdownMI setImage:[NSImage imageNamed:@"powerIconTemplate"]];
[shutdownMI setRepresentedObject:droplet];

[submenu addItem:shutdownMI];

} else {

NSMenuItem *turnOnMI = [[NSMenuItem alloc] initWithTitle:@"Power On" action:@selector(turnOnDroplet:) keyEquivalent:@""];
[turnOnMI setImage:[NSImage imageNamed:@"power-icon"]];
[turnOnMI setImage:[NSImage imageNamed:@"powerIconTemplate"]];
[turnOnMI setRepresentedObject:droplet];

[submenu addItem:turnOnMI];
}

NSMenuItem *deleteDropletMI = [[NSMenuItem alloc] initWithTitle:@"Delete Droplet" action:@selector(confirmDropletDeletion:) keyEquivalent:@""];

[deleteDropletMI setImage:[NSImage imageNamed:@"trash-icon"]];
[deleteDropletMI setImage:[NSImage imageNamed:@"trashIconTemplate"]];
[deleteDropletMI setRepresentedObject:droplet];

[submenu addItem:deleteDropletMI];
Expand Down Expand Up @@ -465,16 +465,17 @@ - (void) refreshingTimerTick:(NSTimer*)timer {
delta = -delta;
}

NSImage *img1 = [NSImage imageNamed:@"DropletStatusIconHighlighted"];
NSImage *img2 = [NSImage imageNamed:@"DropletStatusIcon"];
NSImage *img1 = [NSImage imageNamed:@"dropletStatusIconHighlightedTemplate"];
NSImage *img2 = [NSImage imageNamed:@"dropletStatusIconTemplate"];
NSSize size = img1.size;
NSImage *img = [[NSImage alloc] initWithSize: size];
NSRect r = NSMakeRect(0, 0, size.width, size.height);
[img lockFocus];
[img1 drawInRect: r fromRect: r operation: NSCompositeCopy fraction: 1.0];
[img2 drawInRect: r fromRect: r operation: NSCompositeSourceOver fraction: fade];
[img unlockFocus];

[img setTemplate:YES];

_statusItem.image = img;
}

Expand All @@ -497,7 +498,7 @@ - (void) receivedNotification:(NSNotification *) notification
refreshMI.title = NSLocalizedString(@"Refresh", @"Refresh");
refreshMI.action = @selector(refresh:);

[self setStatusImage: @"DropletStatusIconFailed"];
[self setStatusImage: @"dropletStatusIconFailedTemplate"];

}
}
Expand Down
6 changes: 6 additions & 0 deletions DODropletManager/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "DropletStatusIconFailed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "DropletStatusIconHighlighted.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "DropletStatusIcon.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
File renamed without changes
18 changes: 0 additions & 18 deletions DODropletManager/Images.xcassets/info-icon.imageset/Contents.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "info-icon.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

This file was deleted.

18 changes: 0 additions & 18 deletions DODropletManager/Images.xcassets/power-icon.imageset/Contents.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "power-icon-highlighted.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
File renamed without changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "power-icon.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading

0 comments on commit 30b29f8

Please sign in to comment.