Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Rafaj committed Oct 13, 2011
1 parent 3d4338f commit 42682f3
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 17 deletions.
Binary file added Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions iSplashIcon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -39,6 +40,7 @@
4CA226D21445DCD900C9B0AA /* FTDroppableImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTDroppableImageView.h; sourceTree = "<group>"; };
4CA226D31445DCD900C9B0AA /* FTDroppableImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FTDroppableImageView.m; sourceTree = "<group>"; };
4CA226D51445F35D00C9B0AA /* icon-dnd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-dnd.png"; sourceTree = "<group>"; };
4CB2A2DD14463A2400BEBF7F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
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; };
Expand Down Expand Up @@ -97,6 +99,7 @@
4CE77F161437312E00A5AEDA = {
isa = PBXGroup;
children = (
4CB2A2DD14463A2400BEBF7F /* Icon.png */,
4CE77F2B1437312E00A5AEDA /* iSplashIcon */,
4CE77F2C1437312E00A5AEDA /* Supporting Files */,
4CE77F241437312E00A5AEDA /* Frameworks */,
Expand Down Expand Up @@ -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;
};
Expand Down
Binary file not shown.
Binary file modified iSplashIcon/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions iSplashIcon/CTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
130 changes: 122 additions & 8 deletions iSplashIcon/CTAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -120,9 +179,11 @@ - (void)saveFilesToPath:(NSString *)path {
[self saveImage:self.iPhoneIcon114.image WithName:@"[email protected]" 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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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];
Expand Down
33 changes: 25 additions & 8 deletions iSplashIcon/en.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">1923</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1923</string>
<string key="NS.object.0">1938</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSMenuItem</string>
Expand Down Expand Up @@ -807,7 +807,6 @@
<string key="NSFrame">{{585, 16}, {204, 43}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:2269</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="642132356">
Expand Down Expand Up @@ -869,7 +868,7 @@
<reference key="NSSupport" ref="612542590"/>
<string key="NSCellIdentifier">_NS:717</string>
<reference key="NSControlView" ref="907285464"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags">1211945471</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage" id="66030753">
<string key="NSClassName">NSImage</string>
Expand Down Expand Up @@ -900,7 +899,7 @@
<reference key="NSSupport" ref="612542590"/>
<string key="NSCellIdentifier">_NS:717</string>
<reference key="NSControlView" ref="499178578"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags">1211945471</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="66030753"/>
<reference key="NSAlternateImage" ref="123812653"/>
Expand All @@ -926,7 +925,7 @@
<reference key="NSSupport" ref="612542590"/>
<string key="NSCellIdentifier">_NS:717</string>
<reference key="NSControlView" ref="93803404"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags">1211945471</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="66030753"/>
<reference key="NSAlternateImage" ref="123812653"/>
Expand All @@ -952,7 +951,7 @@
<reference key="NSSupport" ref="612542590"/>
<string key="NSCellIdentifier">_NS:717</string>
<reference key="NSControlView" ref="871755162"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags">1211945471</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="66030753"/>
<reference key="NSAlternateImage" ref="123812653"/>
Expand Down Expand Up @@ -1405,6 +1404,14 @@
</object>
<int key="connectionID">686</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">tickChangedOnBasicIcons:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="93803404"/>
</object>
<int key="connectionID">688</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand Down Expand Up @@ -2178,7 +2185,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">686</int>
<int key="maxID">688</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -2188,6 +2195,7 @@
<dictionary class="NSMutableDictionary" key="actions">
<string key="didClickResetButton:">id</string>
<string key="didClickSaveButton:">id</string>
<string key="tickChangedOnBasicIcons:">NSButton</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="didClickResetButton:">
Expand All @@ -2198,6 +2206,10 @@
<string key="name">didClickSaveButton:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="tickChangedOnBasicIcons:">
<string key="name">tickChangedOnBasicIcons:</string>
<string key="candidateClassName">NSButton</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="androidButton">NSButton</string>
Expand All @@ -2215,6 +2227,7 @@
<string key="mainIcon">FTDroppableImageView</string>
<string key="resetButton">NSButton</string>
<string key="saveButton">NSButton</string>
<string key="tickBasicIcons">NSButton</string>
<string key="window">NSWindow</string>
<string key="windowsButton">NSButton</string>
<string key="windowsIcon173">NSImageView</string>
Expand Down Expand Up @@ -2281,6 +2294,10 @@
<string key="name">saveButton</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBToOneOutletInfo" key="tickBasicIcons">
<string key="name">tickBasicIcons</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBToOneOutletInfo" key="window">
<string key="name">window</string>
<string key="candidateClassName">NSWindow</string>
Expand Down
2 changes: 1 addition & 1 deletion iSplashIcon/iSplashIcon-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<string>Icon.png</string>
<key>CFBundleIdentifier</key>
<string>com.fuerteint.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down

0 comments on commit 42682f3

Please sign in to comment.