diff --git a/AppController.m b/AppController.m index 9132f84..b8caf66 100755 --- a/AppController.m +++ b/AppController.m @@ -13,60 +13,14 @@ #import "SGHotKeyCenter.h" #import "SRRecorderCell.h" #import "UKLoginItemRegistry.h" - +#import "NSWindow+TrueCenter.h" #define _DISPLENGTH 40 -/*enum NSWindowCollectionBehavior { - NSWindowCollectionBehaviorDefault = 0, - NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0, - NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1 -} ; - */ - -//typedef unsigned NSWindowCollectionBehavior; - -@interface NSWindow (NSWindowCollectionBehavior) -- (void)setCollectionBehavior:(NSWindowCollectionBehavior)behavior; -@end - @implementation AppController - (id)init { - if ( ! [[NSUserDefaults standardUserDefaults] floatForKey:@"lastRun"] || [[NSUserDefaults standardUserDefaults] floatForKey:@"lastRun"] < 0.6 ) { - // A decent starting value for the main hotkey is control-option-V - [mainRecorder setKeyCombo:SRMakeKeyCombo(9, 1179648)]; - - // Something we'd really like is to transfer over info from 0.5x if we can get at it -- - if ( [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] ) { - // We need to pull out the relevant objects and stuff them in as proper preferences for the net.sf.Jumpcut domain - if ( [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"displayNum"] != nil ) - { - [[NSUserDefaults standardUserDefaults] setValue:[ [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"displayNum"] - forKey:@"displayNum"]; - } - if ( [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"savePreference"] != nil ) - { - if ( [[[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"savePreference"] isEqual:@"onChange"] ) - { - [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:2] - forKey:@"savePreference"]; - } - else if ( [[[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"savePreference"] isEqual:@"onExit"] ) - { - [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:1] - forKey:@"savePreference"]; - } - else - { - [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:0] - forKey:@"savePreference"]; - } // End save preference test - } // End savePreference test - } // End if/then that deals with 0.5x preferences - } // End new-to-version check - // If we don't have preferences defined, let's set some default values: [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:15], @"displayNum", @@ -95,21 +49,7 @@ - (void)awakeFromNib { - // Hotkey default value - if ( ! [[NSUserDefaults standardUserDefaults] floatForKey:@"lastRun"] || [[NSUserDefaults standardUserDefaults] floatForKey:@"lastRun"] < 0.6 ) { - // A decent starting value for the main hotkey is shift-command-V - [mainRecorder setKeyCombo:SRMakeKeyCombo(9, 1179648)]; - NSLog(@"Setting hotkey"); - if ( [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] ) { - NSLog(@"Pulling old preference"); - // We need to pull out the relevant objects and stuff them in as proper preferences for the net.sf.Jumpcut domain - if ( [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"hotkeyModifiers"] != nil ) - { - NSLog(@"Setting hotkey"); - [mainRecorder setKeyCombo:SRMakeKeyCombo(9, [[[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"Jumpcut"] objectForKey:@"hotkeyModifiers"] intValue])]; - } - } - } + // We no longer get autosave from ShortcutRecorder, so let's set the recorder by hand if ( [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"ShortcutRecorder mainHotkey"] ) { [mainRecorder setKeyCombo:SRMakeKeyCombo([[[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"ShortcutRecorder mainHotkey"] objectForKey:@"keyCode"] intValue], @@ -121,17 +61,16 @@ displaying:[[NSUserDefaults standardUserDefaults] integerForKey:@"displayNum"] withDisplayLength:_DISPLENGTH]; // Set up the bezel window - NSSize windowSize = NSMakeSize(325.0, 325.0); + NSSize screenSize = [[NSScreen mainScreen] frame].size; - NSRect windowFrame = NSMakeRect( (screenSize.width - windowSize.width) / 2, - (screenSize.height - windowSize.height) / 3, - windowSize.width, windowSize.height ); + NSSize bezelSize = NSMakeSize(screenSize.width/3, screenSize.height/3); + NSRect windowFrame = NSMakeRect( 0, 0, bezelSize.width, bezelSize.height); bezel = [[BezelWindow alloc] initWithContentRect:windowFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; [bezel setDelegate:self]; - [bezel setDelegate:self]; + [bezel trueCenter]; // Create our pasteboard interface jcPasteboard = [NSPasteboard generalPasteboard]; @@ -172,10 +111,6 @@ // Stack position starts @ 0 by default stackPosition = 0; - // Make sure we only run the 0.5x transition once - [[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithFloat:0.6] - forKey:@"lastRun"]; - [NSApp activateIgnoringOtherApps: YES]; } @@ -680,7 +615,7 @@ } saveDict = [NSMutableDictionary dictionaryWithCapacity:3]; - [saveDict setObject:@"0.6" forKey:@"version"]; + [saveDict setObject:@"0.7" forKey:@"version"]; [saveDict setObject:[NSNumber numberWithInt:[[NSUserDefaults standardUserDefaults] integerForKey:@"rememberNum"]] forKey:@"rememberNum"]; [saveDict setObject:[NSNumber numberWithInt:_DISPLENGTH] @@ -705,20 +640,16 @@ } } -- (void)setHotKeyPreferenceForRecorder:(SRRecorderControl *)aRecorder -{ - if (aRecorder == mainRecorder) - { +- (void)setHotKeyPreferenceForRecorder:(SRRecorderControl *)aRecorder { + if (aRecorder == mainRecorder) { [[NSUserDefaults standardUserDefaults] setObject: [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSNumber numberWithInt:[mainRecorder keyCombo].code],[NSNumber numberWithInt:[mainRecorder keyCombo].flags],nil] forKeys:[NSArray arrayWithObjects:@"keyCode",@"modifierFlags",nil]] forKey:@"ShortcutRecorder mainHotkey"]; } } -- (BOOL)shortcutRecorder:(SRRecorderControl *)aRecorder isKeyCode:(NSInteger)keyCode andFlagsTaken:(NSUInteger)flags reason:(NSString **)aReason -{ - if (aRecorder == mainRecorder) - { +- (BOOL)shortcutRecorder:(SRRecorderControl *)aRecorder isKeyCode:(NSInteger)keyCode andFlagsTaken:(NSUInteger)flags reason:(NSString **)aReason { + if (aRecorder == mainRecorder) { BOOL isTaken = NO; /* KeyCombo kc = [delegateDisallowRecorder keyCombo]; @@ -733,21 +664,18 @@ return NO; } -- (void)shortcutRecorder:(SRRecorderControl *)aRecorder keyComboDidChange:(KeyCombo)newKeyCombo -{ - if (aRecorder == mainRecorder) - { +- (void)shortcutRecorder:(SRRecorderControl *)aRecorder keyComboDidChange:(KeyCombo)newKeyCombo { + if (aRecorder == mainRecorder) { [self toggleMainHotKey: aRecorder]; [self setHotKeyPreferenceForRecorder: aRecorder]; } NSLog(@"code: %lu, flags: %lu", newKeyCombo.code, newKeyCombo.flags); } -- (void)applicationWillTerminate:(NSNotification *)notification -{ +- (void)applicationWillTerminate:(NSNotification *)notification { if ( [[NSUserDefaults standardUserDefaults] integerForKey:@"savePreference"] >= 1 ) { NSLog(@"Saving on exit"); - [self saveEngine] ; + [self saveEngine]; } //Unregister our hot key (not required) [[SGHotKeyCenter sharedCenter] unregisterHotKey: mainHotKey]; @@ -764,8 +692,7 @@ object:nil]; } -- (void) dealloc -{ +- (void) dealloc { [bezel release]; [srTransformer release]; [super dealloc]; diff --git a/English.lproj/MainMenu.nib/designable.nib b/English.lproj/MainMenu.nib/designable.nib index bb3e718..1bbaa99 100644 --- a/English.lproj/MainMenu.nib/designable.nib +++ b/English.lproj/MainMenu.nib/designable.nib @@ -160,13 +160,13 @@ {549, 471} - + YES net.sf.jumpcut.preferences.general.tiff - + 256 YES @@ -185,6 +185,7 @@ 256 {{14, 156}, {97, 18}} + YES @@ -217,6 +218,7 @@ 256 {{134, 56}, {152, 26}} + YES @@ -293,12 +295,13 @@ 256 {{14, 95}, {204, 18}} + YES 67239424 0 - Launch Jumpcut on login + Launch Flycut on login 1211912703 @@ -316,6 +319,7 @@ 256 {{13, 63}, {64, 17}} + YES @@ -349,6 +353,7 @@ 256 {{99, 62}, {33, 14}} + YES @@ -370,6 +375,7 @@ 256 {{70, 34}, {62, 14}} + YES @@ -387,6 +393,7 @@ 256 {{191, 34}, {95, 14}} + YES @@ -404,6 +411,7 @@ 256 {{136, 29}, {25, 22}} + YES @@ -494,6 +502,7 @@ 256 {{281, 29}, {24, 22}} + YES @@ -561,6 +570,7 @@ 256 {{161, 27}, {19, 27}} + YES @@ -580,7 +590,8 @@ 256 {{306, 27}, {19, 27}} - + + YES 917024 @@ -599,6 +610,7 @@ 256 {{14, 136}, {162, 18}} + YES @@ -621,6 +633,7 @@ 256 {{14, 116}, {162, 18}} + YES @@ -641,11 +654,13 @@ {555, 186} + {{-3, 299}, {555, 186}} + {0, 0} @@ -667,6 +682,8 @@ {549, 471} + + General @@ -716,7 +733,7 @@ 256 {{247, 48}, {281, 61}} - + YES 67239424 @@ -994,7 +1011,7 @@ com.generalarcade.flycut.32.png - + 256 YES @@ -1023,8 +1040,7 @@ 2322 {517, 308} - - + @@ -1162,7 +1178,6 @@ Y291cmFnZW1lbnQuA {{1, 1}, {517, 344}} - @@ -1199,7 +1214,6 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA -2147483392 {{-100, -100}, {15, 170}} - _doScroller: @@ -1211,7 +1225,6 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA -2147483392 {{-100, -100}, {87, 18}} - 1 @@ -1222,8 +1235,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {{16, 16}, {519, 346}} - - + 133122 @@ -1233,13 +1245,11 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {555, 376} - {{-3, 109}, {555, 376}} - {0, 0} @@ -1261,8 +1271,6 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {549, 471} - - Acknowledgements @@ -1270,14 +1278,14 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA - + 6 YES YES YES - + diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib index f456204..5b4bf28 100644 Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/Jumpcut.xcodeproj/project.pbxproj b/Flycut.xcodeproj/project.pbxproj similarity index 97% rename from Jumpcut.xcodeproj/project.pbxproj rename to Flycut.xcodeproj/project.pbxproj index 3d489d0..879a64e 100755 --- a/Jumpcut.xcodeproj/project.pbxproj +++ b/Flycut.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 773ABFB113E9AA1A00AE3969 /* NSWindow+TrueCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 773ABFAF13E9AA1A00AE3969 /* NSWindow+TrueCenter.h */; }; + 773ABFB213E9AA1A00AE3969 /* NSWindow+TrueCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 773ABFB013E9AA1A00AE3969 /* NSWindow+TrueCenter.m */; }; 7761C87C139BDE7F000FB3AB /* JumpcutClipping.h in Headers */ = {isa = PBXBuildFile; fileRef = 7761C878139BDE7F000FB3AB /* JumpcutClipping.h */; }; 7761C87D139BDE7F000FB3AB /* JumpcutClipping.m in Sources */ = {isa = PBXBuildFile; fileRef = 7761C879139BDE7F000FB3AB /* JumpcutClipping.m */; }; 7761C87E139BDE7F000FB3AB /* JumpcutStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 7761C87A139BDE7F000FB3AB /* JumpcutStore.h */; }; @@ -99,6 +101,8 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* Jumpcut_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Jumpcut_Prefix.pch; sourceTree = ""; }; + 773ABFAF13E9AA1A00AE3969 /* NSWindow+TrueCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSWindow+TrueCenter.h"; sourceTree = ""; }; + 773ABFB013E9AA1A00AE3969 /* NSWindow+TrueCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSWindow+TrueCenter.m"; sourceTree = ""; }; 7761C878139BDE7F000FB3AB /* JumpcutClipping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JumpcutClipping.h; sourceTree = ""; }; 7761C879139BDE7F000FB3AB /* JumpcutClipping.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JumpcutClipping.m; sourceTree = ""; }; 7761C87A139BDE7F000FB3AB /* JumpcutStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JumpcutStore.h; sourceTree = ""; }; @@ -293,6 +297,8 @@ 7761C88D139BDEAF000FB3AB /* RoundRecBezierPath.m */, 7761C88E139BDEAF000FB3AB /* RoundRecTextField.h */, 7761C88F139BDEAF000FB3AB /* RoundRecTextField.m */, + 773ABFAF13E9AA1A00AE3969 /* NSWindow+TrueCenter.h */, + 773ABFB013E9AA1A00AE3969 /* NSWindow+TrueCenter.m */, ); path = UI; sourceTree = ""; @@ -362,6 +368,7 @@ 7761C8AE139BDF12000FB3AB /* SRRecorderCell.h in Headers */, 7761C8B0139BDF12000FB3AB /* SRRecorderControl.h in Headers */, 7761C8B2139BDF12000FB3AB /* SRValidator.h in Headers */, + 773ABFB113E9AA1A00AE3969 /* NSWindow+TrueCenter.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -398,7 +405,7 @@ attributes = { LastUpgradeCheck = 0410; }; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Jumpcut" */; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Flycut" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 1; @@ -465,6 +472,7 @@ 7761C8AF139BDF12000FB3AB /* SRRecorderCell.m in Sources */, 7761C8B1139BDF12000FB3AB /* SRRecorderControl.m in Sources */, 7761C8B3139BDF12000FB3AB /* SRValidator.m in Sources */, + 773ABFB213E9AA1A00AE3969 /* NSWindow+TrueCenter.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -558,7 +566,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Jumpcut" */ = { + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Flycut" */ = { isa = XCConfigurationList; buildConfigurations = ( C01FCF4F08A954540054247B /* Debug */, diff --git a/Jumpcut.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Flycut.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 71% rename from Jumpcut.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Flycut.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 718d415..a89ae70 100644 --- a/Jumpcut.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/Flycut.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:Flycut.xcodeproj"> diff --git a/Jumpcut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/Flycut.xcscheme b/Flycut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/Flycut.xcscheme similarity index 91% rename from Jumpcut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/Flycut.xcscheme rename to Flycut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/Flycut.xcscheme index 23c3185..7515010 100644 --- a/Jumpcut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/Flycut.xcscheme +++ b/Flycut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/Flycut.xcscheme @@ -1,6 +1,6 @@ + version = "1.8"> @@ -16,7 +16,7 @@ BlueprintIdentifier = "8D1107260486CEB800E47090" BuildableName = "Flycut.app" BlueprintName = "Flycut" - ReferencedContainer = "container:Jumpcut.xcodeproj"> + ReferencedContainer = "container:Flycut.xcodeproj"> @@ -43,7 +43,7 @@ BlueprintIdentifier = "8D1107260486CEB800E47090" BuildableName = "Flycut.app" BlueprintName = "Flycut" - ReferencedContainer = "container:Jumpcut.xcodeproj"> + ReferencedContainer = "container:Flycut.xcodeproj"> @@ -62,7 +62,7 @@ BlueprintIdentifier = "8D1107260486CEB800E47090" BuildableName = "Flycut.app" BlueprintName = "Flycut" - ReferencedContainer = "container:Jumpcut.xcodeproj"> + ReferencedContainer = "container:Flycut.xcodeproj"> diff --git a/Jumpcut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/xcschememanagement.plist b/Flycut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/xcschememanagement.plist similarity index 100% rename from Jumpcut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/xcschememanagement.plist rename to Flycut.xcodeproj/xcuserdata/termit.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/UI/BezelWindow.m b/UI/BezelWindow.m index 93754d0..807d805 100755 --- a/UI/BezelWindow.m +++ b/UI/BezelWindow.m @@ -17,10 +17,6 @@ backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { - - contentRect.origin.y += contentRect.size.height/4; - contentRect.size.width += contentRect.size.width/2; - contentRect.origin.x -= (contentRect.size.width/3)/2; self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered @@ -34,7 +30,7 @@ [self setMovableByWindowBackground:NO]; [self setBackgroundColor:[self sizedBezelBackgroundWithRadius:25.0 withAlpha:[[NSUserDefaults standardUserDefaults] floatForKey:@"bezelAlpha"]]]; float lineHeight = 16; - NSRect textFrame = NSMakeRect(12, 36, [self frame].size.width - 24, 18 * lineHeight - 12); + NSRect textFrame = NSMakeRect(12, 36, self.frame.size.width - 24, self.frame.size.height - 50); textField = [[RoundRecTextField alloc] initWithFrame:textFrame]; [[self contentView] addSubview:textField]; [textField setEditable:NO]; @@ -54,14 +50,7 @@ [charField setDrawsBackground:YES]; [charField setBordered:NO]; [charField setAlignment:NSCenterTextAlignment]; - [self setInitialFirstResponder:textField]; - /*icon = [NSImage imageNamed:@"net.sf.jumpcut.ghost_scissors_small.png"]; - if ( [icon isValid] ) { - NSRect iconFrame = NSMakeRect( ([self frame].size.width - [icon size].width) / 2, [self frame].size.height - [icon size].height - 24, [icon size].width, [icon size].height); - iconView = [[NSImageView alloc] initWithFrame:iconFrame]; - [iconView setImage:icon]; - [[self contentView] addSubview:iconView]; - }*/ + [self setInitialFirstResponder:textField]; return self; } return nil; diff --git a/UI/NSWindow+TrueCenter.h b/UI/NSWindow+TrueCenter.h new file mode 100644 index 0000000..54bf2e2 --- /dev/null +++ b/UI/NSWindow+TrueCenter.h @@ -0,0 +1,15 @@ +// +// NSWindow+TrueCenter.h +// Jumpcut +// +// Created by Gennadii Potapov on 4/8/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import + +@interface NSWindow (TrueCenter) + +- (void)trueCenter; + +@end diff --git a/UI/NSWindow+TrueCenter.m b/UI/NSWindow+TrueCenter.m new file mode 100644 index 0000000..c7ba0c2 --- /dev/null +++ b/UI/NSWindow+TrueCenter.m @@ -0,0 +1,21 @@ +// +// NSWindow+TrueCenter.m +// Jumpcut +// +// Created by Gennadii Potapov on 4/8/11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import "NSWindow+TrueCenter.h" + +@implementation NSWindow (TrueCenter) + +- (void)trueCenter { + NSRect frame = [self frame]; + NSRect screen = [[self screen] frame]; + frame.origin.x = (screen.size.width - frame.size. width) / 2; + frame.origin.y = (screen.size.height - frame.size.height) / 2; + [self setFrameOrigin:frame.origin]; +} + +@end