diff --git a/Icon.png b/Icon.png new file mode 100644 index 0000000..4873a61 Binary files /dev/null and b/Icon.png differ diff --git a/iSplashIcon.xcodeproj/project.pbxproj b/iSplashIcon.xcodeproj/project.pbxproj index 52d6555..77fd06f 100644 --- a/iSplashIcon.xcodeproj/project.pbxproj +++ b/iSplashIcon.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 4CA226CF1445D64200C9B0AA /* bcg-button-windows.png in Resources */ = {isa = PBXBuildFile; fileRef = 4CA226CE1445D64200C9B0AA /* bcg-button-windows.png */; }; 4CA226D41445DCD900C9B0AA /* FTDroppableImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA226D31445DCD900C9B0AA /* FTDroppableImageView.m */; }; 4CA226D61445F35D00C9B0AA /* icon-dnd.png in Resources */ = {isa = PBXBuildFile; fileRef = 4CA226D51445F35D00C9B0AA /* icon-dnd.png */; }; + 4CB2A2DE14463A2400BEBF7F /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4CB2A2DD14463A2400BEBF7F /* Icon.png */; }; 4CE77F261437312E00A5AEDA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CE77F251437312E00A5AEDA /* Cocoa.framework */; }; 4CE77F301437312E00A5AEDA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4CE77F2E1437312E00A5AEDA /* InfoPlist.strings */; }; 4CE77F321437312E00A5AEDA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE77F311437312E00A5AEDA /* main.m */; }; @@ -39,6 +40,7 @@ 4CA226D21445DCD900C9B0AA /* FTDroppableImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTDroppableImageView.h; sourceTree = ""; }; 4CA226D31445DCD900C9B0AA /* FTDroppableImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FTDroppableImageView.m; sourceTree = ""; }; 4CA226D51445F35D00C9B0AA /* icon-dnd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-dnd.png"; sourceTree = ""; }; + 4CB2A2DD14463A2400BEBF7F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; 4CE77F211437312E00A5AEDA /* iSplashIcon.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iSplashIcon.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4CE77F251437312E00A5AEDA /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 4CE77F281437312E00A5AEDA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; @@ -97,6 +99,7 @@ 4CE77F161437312E00A5AEDA = { isa = PBXGroup; children = ( + 4CB2A2DD14463A2400BEBF7F /* Icon.png */, 4CE77F2B1437312E00A5AEDA /* iSplashIcon */, 4CE77F2C1437312E00A5AEDA /* Supporting Files */, 4CE77F241437312E00A5AEDA /* Frameworks */, @@ -227,6 +230,7 @@ 4CA226CD1445D63B00C9B0AA /* bcg-button-ios.png in Resources */, 4CA226CF1445D64200C9B0AA /* bcg-button-windows.png in Resources */, 4CA226D61445F35D00C9B0AA /* icon-dnd.png in Resources */, + 4CB2A2DE14463A2400BEBF7F /* Icon.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iSplashIcon.xcodeproj/project.xcworkspace/xcuserdata/rafiki270.xcuserdatad/UserInterfaceState.xcuserstate b/iSplashIcon.xcodeproj/project.xcworkspace/xcuserdata/rafiki270.xcuserdatad/UserInterfaceState.xcuserstate index cd27cca..251659d 100644 Binary files a/iSplashIcon.xcodeproj/project.xcworkspace/xcuserdata/rafiki270.xcuserdatad/UserInterfaceState.xcuserstate and b/iSplashIcon.xcodeproj/project.xcworkspace/xcuserdata/rafiki270.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iSplashIcon/.DS_Store b/iSplashIcon/.DS_Store index 9e939ee..ce790b9 100644 Binary files a/iSplashIcon/.DS_Store and b/iSplashIcon/.DS_Store differ diff --git a/iSplashIcon/CTAppDelegate.h b/iSplashIcon/CTAppDelegate.h index a054ec2..9fb3b9c 100644 --- a/iSplashIcon/CTAppDelegate.h +++ b/iSplashIcon/CTAppDelegate.h @@ -55,10 +55,14 @@ typedef enum { @property (nonatomic, strong) IBOutlet NSButton *androidButton; @property (nonatomic, strong) IBOutlet NSButton *windowsButton; +@property (nonatomic, strong) IBOutlet NSButton *tickBasicIcons; +// Button actions - (IBAction)didClickSaveButton:(id)sender; - (IBAction)didClickResetButton:(id)sender; +- (IBAction)tickChangedOnBasicIcons:(NSButton *)sender; + - (void)reset; diff --git a/iSplashIcon/CTAppDelegate.m b/iSplashIcon/CTAppDelegate.m index 18447da..18b4303 100644 --- a/iSplashIcon/CTAppDelegate.m +++ b/iSplashIcon/CTAppDelegate.m @@ -10,7 +10,44 @@ #import "FTFilesystemIO.h" -#define kISMainViewControllerUnusedIconAlpha 0.15f +#define kISMainViewControllerUnusedIconAlpha 0.15f +#define kISMainViewControllerTickBasicIcons @"ISMainViewControllerTickBasicIcons" + + +static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight) { + float fw, fh; + if (ovalWidth == 0 || ovalHeight == 0) { + CGContextAddRect(context, rect); + return; + } + CGContextSaveGState(context); + CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect)); + CGContextScaleCTM (context, ovalWidth, ovalHeight); + fw = CGRectGetWidth (rect) / ovalWidth; + fh = CGRectGetHeight (rect) / ovalHeight; + CGContextMoveToPoint(context, fw, fh/2); + CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1); + CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1); + CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1); + CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); + CGContextClosePath(context); + CGContextRestoreGState(context); +} + +static CGImageRef CGImageCreateWithNSImage(NSImage *image) { + NSSize imageSize = [image size]; + + CGContextRef bitmapContext = CGBitmapContextCreate(NULL, imageSize.width, imageSize.height, 8, 0, [[NSColorSpace genericRGBColorSpace] CGColorSpace], kCGBitmapByteOrder32Host|kCGImageAlphaPremultipliedFirst); + + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:bitmapContext flipped:NO]]; + [image drawInRect:NSMakeRect(0, 0, imageSize.width, imageSize.height) fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; + [NSGraphicsContext restoreGraphicsState]; + + CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext); + CGContextRelease(bitmapContext); + return cgImage; +} @implementation CTAppDelegate @@ -35,15 +72,37 @@ @implementation CTAppDelegate @synthesize appleButton; @synthesize androidButton; @synthesize windowsButton; +@synthesize tickBasicIcons; + + +#pragma mark Persistent data + +- (void)saveInt:(NSInteger)value forKey:(NSString *)key { + [[NSUserDefaults standardUserDefaults] setInteger:value forKey:key]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +- (NSInteger)getIntForKey:(NSString *)key { + return [[NSUserDefaults standardUserDefaults] integerForKey:key]; +} + +- (void)saveBool:(BOOL)value forKey:(NSString *)key { + [[NSUserDefaults standardUserDefaults] setBool:value forKey:key]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +- (NSInteger)getBoolForKey:(NSString *)key { + return [[NSUserDefaults standardUserDefaults] boolForKey:key]; +} #pragma mark Buttons handling - (void)enableButtons:(BOOL)enabled { [self.saveButton setEnabled:enabled]; [self.resetButton setEnabled:enabled]; - [self.appleButton setEnabled:enabled]; - [self.androidButton setEnabled:enabled]; - [self.windowsButton setEnabled:enabled]; +// [self.appleButton setEnabled:enabled]; +// [self.androidButton setEnabled:enabled]; +// [self.windowsButton setEnabled:enabled]; } #pragma mark App delegate methods @@ -120,9 +179,11 @@ - (void)saveFilesToPath:(NSString *)path { [self saveImage:self.iPhoneIcon114.image WithName:@"Icon@2x.png" toFolder:@"iOS" withPath:path]; [self saveImage:self.iPhoneIcon72.image WithName:@"Icon72.png" toFolder:@"iOS" withPath:path]; [self saveImage:self.iPhoneIcon57.image WithName:@"Icon.png" toFolder:@"iOS" withPath:path]; - [self saveImage:self.iPhoneIcon58.image WithName:@"Icon58.png" toFolder:@"iOS" withPath:path]; - [self saveImage:self.iPhoneIcon50.image WithName:@"Icon50.png" toFolder:@"iOS" withPath:path]; - [self saveImage:self.iPhoneIcon29.image WithName:@"Icon29.png" toFolder:@"iOS" withPath:path]; + if (self.tickBasicIcons.state == NSOffState) { + [self saveImage:self.iPhoneIcon58.image WithName:@"Icon58.png" toFolder:@"iOS" withPath:path]; + [self saveImage:self.iPhoneIcon50.image WithName:@"Icon50.png" toFolder:@"iOS" withPath:path]; + [self saveImage:self.iPhoneIcon29.image WithName:@"Icon29.png" toFolder:@"iOS" withPath:path]; + } } else if (self.deviceType == ISMainViewControllerDeviceTypeAndroid) { [self saveImage:self.iPhoneIcon72.image WithName:@"Icon72.png" toFolder:@"Android" withPath:path]; @@ -152,6 +213,7 @@ - (void)resizeForIOS:(NSImage *)image { [self.iPhoneIcon114 setAlphaValue:alpha]; [self.iPhoneIcon72 setAlphaValue:alpha]; [self.iPhoneIcon57 setAlphaValue:alpha]; + if (self.tickBasicIcons.state == NSOnState) alpha = kISMainViewControllerUnusedIconAlpha; [self.iPhoneIcon58 setAlphaValue:alpha]; [self.iPhoneIcon50 setAlphaValue:alpha]; [self.iPhoneIcon29 setAlphaValue:alpha]; @@ -197,11 +259,18 @@ - (void)resizeForAllPlatforms:(NSImage *)image { - (void)reset { imagePresent = NO; - //self.deviceType = ISMainViewControllerDeviceTypeNone; + self.deviceType = ISMainViewControllerDeviceTypeNone; [self resizeForAllPlatforms:[NSImage imageNamed:@"not-used.png"]]; [self moveDeviceTypeIndicaterToButtonPosition:self.logoView]; [self enableButtons:NO]; [self.mainIcon setImage:[NSImage imageNamed:@"icon-dnd.png"]]; + + // Tick boxes + [self.tickBasicIcons setEnabled:NO]; + + // Restore tick values + BOOL is = [self getBoolForKey:kISMainViewControllerTickBasicIcons]; + [self.tickBasicIcons setState:(is ? NSOnState : NSOffState)]; } #pragma mark Button action methods @@ -210,18 +279,27 @@ - (IBAction)didClickAppleButton:(NSButton *)sender { self.deviceType = ISMainViewControllerDeviceTypeIOS; [self resizeForAllPlatforms:self.mainIcon.image]; [self moveDeviceTypeIndicaterToButtonPosition:sender]; + + // Tick boxes + [self.tickBasicIcons setEnabled:YES]; } - (IBAction)didClickAndroidButton:(NSButton *)sender { self.deviceType = ISMainViewControllerDeviceTypeAndroid; [self resizeForAllPlatforms:self.mainIcon.image]; [self moveDeviceTypeIndicaterToButtonPosition:sender]; + + // Tick boxes + [self.tickBasicIcons setEnabled:NO]; } - (IBAction)didClickWindowsButton:(NSButton *)sender { self.deviceType = ISMainViewControllerDeviceTypeWindows; [self resizeForAllPlatforms:self.mainIcon.image]; [self moveDeviceTypeIndicaterToButtonPosition:sender]; + + // Tick boxes + [self.tickBasicIcons setEnabled:NO]; } - (IBAction)didClickSaveButton:(id)sender { @@ -248,6 +326,41 @@ - (IBAction)didClickResetButton:(id)sender { [self reset]; } +- (void)tickChangedOnBasicIcons:(NSButton *)sender { + [self resizeForAllPlatforms:self.mainIcon.image]; + [self saveBool:(self.tickBasicIcons.state == NSOnState) forKey:kISMainViewControllerTickBasicIcons]; +} + +#pragma mark Adding photo effects + +- (NSImage *)roundedCornersImageFromImage:(NSImage *)img withCornerWidth:(CGFloat)cornerWidth andCornerHeight:(CGFloat)cornerHeight { + NSImage * newImage = nil; + if( nil != img) { + int w = img.size.width; + int h = img.size.height; + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst); + + CGContextBeginPath(context); + CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height); + addRoundedRectToPath(context, rect, cornerWidth, cornerHeight); + CGContextClosePath(context); + CGContextClip(context); + + CGContextDrawImage(context, CGRectMake(0, 0, w, h), CGImageCreateWithNSImage(img)); + + CGImageRef imageMasked = CGBitmapContextCreateImage(context); + CGContextRelease(context); + CGColorSpaceRelease(colorSpace); + + NSData *pixelData = (__bridge_transfer NSData *)CGDataProviderCopyData(CGImageGetDataProvider(imageMasked)); + newImage = [[NSImage alloc] initWithData:pixelData]; + CGImageRelease(imageMasked); + } + return newImage; +} + #pragma mark Droppable delegate methods - (void)selectActualTab { @@ -266,6 +379,7 @@ - (void)selectActualTab { - (void)droppableImageView:(FTDroppableImageView *)droppableView didLoadImage:(NSImage *)image { imagePresent = NO; + //image = [self roundedCornersImageFromImage:image withCornerWidth:20 andCornerHeight:10]; [self resizeForAllPlatforms:image]; [self enableButtons:YES]; [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(selectActualTab) userInfo:nil repeats:NO]; diff --git a/iSplashIcon/en.lproj/MainMenu.xib b/iSplashIcon/en.lproj/MainMenu.xib index 55faf6f..028e51a 100644 --- a/iSplashIcon/en.lproj/MainMenu.xib +++ b/iSplashIcon/en.lproj/MainMenu.xib @@ -3,12 +3,12 @@ 1070 11B26 - 1923 + 1938 1138 566.00 com.apple.InterfaceBuilder.CocoaPlugin - 1923 + 1938 NSMenuItem @@ -807,7 +807,6 @@ {{585, 16}, {204, 43}} - _NS:2269 YES @@ -869,7 +868,7 @@ _NS:717 - 1211912703 + 1211945471 2 NSImage @@ -900,7 +899,7 @@ _NS:717 - 1211912703 + 1211945471 2 @@ -926,7 +925,7 @@ _NS:717 - 1211912703 + 1211945471 2 @@ -952,7 +951,7 @@ _NS:717 - 1211912703 + 1211945471 2 @@ -1405,6 +1404,14 @@ 686 + + + tickChangedOnBasicIcons: + + + + 688 + @@ -2178,7 +2185,7 @@ - 686 + 688 @@ -2188,6 +2195,7 @@ id id + NSButton @@ -2198,6 +2206,10 @@ didClickSaveButton: id + + tickChangedOnBasicIcons: + NSButton + NSButton @@ -2215,6 +2227,7 @@ FTDroppableImageView NSButton NSButton + NSButton NSWindow NSButton NSImageView @@ -2281,6 +2294,10 @@ saveButton NSButton + + tickBasicIcons + NSButton + window NSWindow diff --git a/iSplashIcon/iSplashIcon-Info.plist b/iSplashIcon/iSplashIcon-Info.plist index fe0e3fb..3b9c2fb 100644 --- a/iSplashIcon/iSplashIcon-Info.plist +++ b/iSplashIcon/iSplashIcon-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile - + Icon.png CFBundleIdentifier com.fuerteint.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion