From 176ecb74ff792d3e8d76afdd0d7fbb98e5853399 Mon Sep 17 00:00:00 2001 From: Lukhnos Liu Date: Tue, 4 Sep 2012 00:52:13 -0700 Subject: [PATCH] Use IconMaker to create retina icon. --- Source/IconMaker/BopomofoIconRenderView.h | 13 ++++ Source/IconMaker/BopomofoIconRenderView.m | 56 ++++++++++++++++ Source/IconMaker/IconMakerAppDelegate.m | 8 ++- Source/IconMaker/en.lproj/MainMenu.xib | 82 +++++++++++++++++------ 4 files changed, 138 insertions(+), 21 deletions(-) create mode 100644 Source/IconMaker/BopomofoIconRenderView.h create mode 100644 Source/IconMaker/BopomofoIconRenderView.m diff --git a/Source/IconMaker/BopomofoIconRenderView.h b/Source/IconMaker/BopomofoIconRenderView.h new file mode 100644 index 00000000..08fe6ee4 --- /dev/null +++ b/Source/IconMaker/BopomofoIconRenderView.h @@ -0,0 +1,13 @@ +// +// BopomofoIconRenderView.h +// Lettuce +// +// Created by Lukhnos D. Liu on 9/3/12. +// +// + +#import + +@interface BopomofoIconRenderView : NSView + +@end diff --git a/Source/IconMaker/BopomofoIconRenderView.m b/Source/IconMaker/BopomofoIconRenderView.m new file mode 100644 index 00000000..3a888065 --- /dev/null +++ b/Source/IconMaker/BopomofoIconRenderView.m @@ -0,0 +1,56 @@ +// +// BopomofoIconRenderView.m +// Lettuce +// +// Created by Lukhnos D. Liu on 9/3/12. +// +// + +#import "BopomofoIconRenderView.h" + +@implementation BopomofoIconRenderView +- (void)drawRect:(NSRect)dirtyRect +{ + NSAffineTransform *transform = [NSAffineTransform transform]; + [transform scaleBy:[self bounds].size.width / 16.0]; + [transform concat]; + + NSRect boundsRect = NSMakeRect(0.0, 0.0, 16.0, 16.0); + + if ([self bounds].size.width > 16.0) { + boundsRect.origin.x += 0.5; + } + + boundsRect.size.width -= 1.0; + + [NSGraphicsContext saveGraphicsState]; + + NSColor *darkGrayColor = [NSColor colorWithDeviceWhite:0.3 alpha:1.0]; + [darkGrayColor setFill]; + [[NSBezierPath bezierPathWithRoundedRect:boundsRect xRadius:2.0 yRadius:2.0] fill]; + [NSGraphicsContext restoreGraphicsState]; + + + NSInteger fontSize = ([self bounds].size.width > 16.0) ? 14.0 : 13.5; + + NSString *text = @"ㄅ"; + NSString *fontName = @"BiauKai"; + + NSColor *textColor = nil; + textColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + NSMutableDictionary *attrDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: + textColor, NSForegroundColorAttributeName, + [NSFont fontWithName:fontName size:fontSize], NSFontAttributeName, + nil]; + NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:text attributes:attrDict]; + + NSRect textBounds = [attrString boundingRectWithSize:boundsRect.size options:NSStringDrawingUsesLineFragmentOrigin]; + + NSPoint textOrigin; + textOrigin.x = boundsRect.origin.x + (boundsRect.size.width - textBounds.size.width) / 2.0; + textOrigin.y = boundsRect.origin.y; + + attrString = [[NSAttributedString alloc] initWithString:text attributes:attrDict]; + [attrString drawAtPoint:textOrigin]; +} +@end diff --git a/Source/IconMaker/IconMakerAppDelegate.m b/Source/IconMaker/IconMakerAppDelegate.m index c7c6aa1f..51d56a25 100644 --- a/Source/IconMaker/IconMakerAppDelegate.m +++ b/Source/IconMaker/IconMakerAppDelegate.m @@ -71,8 +71,12 @@ faviconRenderView.selected = YES; [faviconRenderView setNeedsDisplay:YES]; - [self makeIconForObject:@"TISIconRendererView" size:NSMakeSize(16, 16) filename:@"/tmp/Bopomofo.tiff"]; - [self makeIconForObject:selectedTISIconRendererView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoSelected.tiff"]; +// [self makeIconForObject:@"TISIconRendererView" size:NSMakeSize(16, 16) filename:@"/tmp/Bopomofo.tiff"]; +// [self makeIconForObject:selectedTISIconRendererView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoSelected.tiff"]; + [self makeIconForObject:@"BopomofoIconRenderView" size:NSMakeSize(16, 16) filename:@"/tmp/Bopomofo.tiff"]; + [self makeIconForObject:@"BopomofoIconRenderView" size:NSMakeSize(32, 32) filename:@"/tmp/Bopomofo@2x.tiff"]; + [self makeIconForObject:@"BopomofoIconRenderView" size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoSelected.tiff"]; + [self makeIconForObject:faviconRenderView size:NSMakeSize(16, 16) filename:@"/tmp/BopomofoFavicon.tiff"]; diff --git a/Source/IconMaker/en.lproj/MainMenu.xib b/Source/IconMaker/en.lproj/MainMenu.xib index aa90a2db..859c8d83 100644 --- a/Source/IconMaker/en.lproj/MainMenu.xib +++ b/Source/IconMaker/en.lproj/MainMenu.xib @@ -2,22 +2,22 @@ 1070 - 11A2063 - 1910 - 1138.1 - 566.00 + 11E53 + 2549 + 1138.47 + 569.00 com.apple.InterfaceBuilder.CocoaPlugin - 1910 + 2549 YES + NSCustomObject NSCustomView - NSWindowTemplate - NSView NSMenu NSMenuItem - NSCustomObject + NSView + NSWindowTemplate YES @@ -1337,13 +1337,22 @@ TISIconRendererView + + + 268 + {{20, 188}, {16, 16}} + + + + BopomofoIconRenderView + 268 {{44, 148}, {128, 128}} - + AppIconRendererView @@ -1352,6 +1361,7 @@ {{180, 20}, {256, 256}} + AppIconRendererView @@ -1360,7 +1370,7 @@ {{20, 236}, {16, 16}} - + TISIconRendererView @@ -1369,8 +1379,18 @@ {{20, 212}, {16, 16}} + TISIconRendererView + + + 268 + {{20, 108}, {32, 32}} + + + + BopomofoIconRenderView + {451, 296} @@ -2649,6 +2669,8 @@ + + @@ -3163,6 +3185,16 @@ + + 540 + + + + + 541 + + + @@ -3313,6 +3345,8 @@ 535.IBPluginDependency 536.IBPluginDependency 538.IBPluginDependency + 540.IBPluginDependency + 541.IBPluginDependency 56.IBPluginDependency 57.IBPluginDependency 58.IBPluginDependency @@ -3329,7 +3363,7 @@ 83.IBPluginDependency 92.IBPluginDependency - + YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3490,6 +3524,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin @@ -3504,7 +3540,7 @@ - 539 + 541 @@ -3517,6 +3553,14 @@ ./Classes/AppIconRendererView.h + + BopomofoIconRenderView + NSView + + IBProjectSource + ./Classes/BopomofoIconRenderView.h + + IconMakerAppDelegate NSObject @@ -3528,7 +3572,7 @@ selectedTISIconRendererView window - + YES TISIconRendererView TISIconRendererView @@ -3543,7 +3587,7 @@ selectedTISIconRendererView window - + YES faviconRenderView @@ -3577,7 +3621,7 @@ saveDocumentAs: saveDocumentTo: - + YES id id @@ -3598,7 +3642,7 @@ saveDocumentAs: saveDocumentTo: - + YES printDocument: @@ -3656,10 +3700,10 @@ NSMenuCheckmark NSMenuMixedState - + YES - {9, 8} - {7, 2} + {11, 11} + {10, 3}