Skip to content
Browse files

Show the close button when hovering anywhere on the pager.

Read the app version from Info.plist in warp_dmg.
  • Loading branch information...
1 parent 2a8e001 commit 6c3b95d099a85266d82385db4763c32a638dcac9 @ksuther committed Dec 15, 2008
Showing with 20 additions and 47 deletions.
  1. +1 −0 CloseButtonLayer.m
  2. +0 −15 FlippedView.h
  3. +0 −18 FlippedView.m
  4. +18 −7 PagerController.m
  5. +1 −1 Release/warp_dmg
  6. +0 −6 Warp.xcodeproj/project.pbxproj
View
1 CloseButtonLayer.m
@@ -32,6 +32,7 @@ - (void)mouseEntered:(NSEvent *)event
- (void)mouseExited:(NSEvent *)event
{
[_closeTimer invalidate];
+ _closeTimer = nil;
self.opacity = 0.0;
}
View
15 FlippedView.h
@@ -1,15 +0,0 @@
-//
-// FlippedView.h
-// Warp
-//
-// Created by Kent Sutherland on 12/14/08.
-// Copyright 2008 Kent Sutherland. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@interface FlippedView : NSView {
-
-}
-
-@end
View
18 FlippedView.m
@@ -1,18 +0,0 @@
-//
-// FlippedView.m
-// Warp
-//
-// Created by Kent Sutherland on 12/14/08.
-// Copyright 2008 Kent Sutherland. All rights reserved.
-//
-
-#import "FlippedView.h"
-
-@implementation FlippedView
-
-- (BOOL)isFlipped
-{
- return YES;
-}
-
-@end
View
25 PagerController.m
@@ -13,7 +13,6 @@
#import "MainController.h"
#import "CGSPrivate.h"
#import "CloseButtonLayer.h"
-#import "FlippedView.h"
extern OSStatus CGContextCopyWindowCaptureContentsToRect(CGContextRef ctx, CGRect rect, NSInteger cid, CGWindowID wid, NSInteger flags);
@@ -29,6 +28,7 @@ - (void)_createPager;
- (void)_updatePagerSize:(BOOL)animate;
- (void)_createSpacesLayers;
- (void)_updateActiveSpace;
+- (void)_resetTrackingArea;
- (void)_savePagerDefaults;
- (BOOL)_isWarpWindow:(CGSWindowID)wid;
@end
@@ -93,6 +93,7 @@ - (void)windowResized:(NSNotification *)note
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(_savePagerDefaults) object:nil];
[self performSelector:@selector(_savePagerDefaults) withObject:nil afterDelay:0.0];
+ [self _resetTrackingArea];
[_frameLayer setNeedsDisplay];
}
@@ -283,7 +284,7 @@ - (void)_createPager
styleMask:NSUtilityWindowMask | NSNonactivatingPanelMask
backing:NSBackingStoreBuffered defer:NO];
- NSView *contentView = [[[FlippedView alloc] initWithFrame:[_pagerPanel frame]] autorelease];
+ NSView *contentView = [[[NSView alloc] initWithFrame:[_pagerPanel frame]] autorelease];
[contentView setWantsLayer:YES];
[_pagerPanel setContentView:contentView];
@@ -293,9 +294,11 @@ - (void)_createPager
[_pagerPanel setOpaque:NO];
[_pagerPanel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
[_pagerPanel setLevel:NSStatusWindowLevel];
+
[_pagerPanel setDelegate:self];
NSRect layersRect = NSInsetRect([[_pagerPanel contentView] bounds], 8, 8);
+ layersRect.origin.y -= 8;
layersRect.size.width += 8;
layersRect.size.height += 8;
@@ -334,12 +337,8 @@ - (void)_createPager
url = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("closebox"), CFSTR("png"), nil);
provider = CGDataProviderCreateWithURL(url);
CGImageRef closeImage = CGImageCreateWithPNGDataProvider(provider, NULL, false, kCGRenderingIntentDefault);
- _closeLayer = [CloseButtonLayer layer];
-
- NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:NSMakeRect(5, 5, 20, 20) options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:_closeLayer userInfo:nil];
- [[_pagerPanel contentView] addTrackingArea:area];
- [area release];
+ _closeLayer = [CloseButtonLayer layer];
_closeLayer.frame = CGRectMake(0, _pagerPanel.frame.size.height - 30, 30, 30);
_closeLayer.autoresizingMask = kCALayerMinYMargin;
_closeLayer.contents = (id)closeImage;
@@ -354,6 +353,7 @@ - (void)_createPager
[self _createSpacesLayers];
[self _updateActiveSpace];
+ [self _resetTrackingArea];
[self performSelector:@selector(_savePagerDefaults) withObject:nil afterDelay:0.0];
@@ -468,6 +468,17 @@ - (void)_updateActiveSpace
[[_layersView layer] setNeedsLayout];
}
+- (void)_resetTrackingArea
+{
+ if (_closeTrackingArea) {
+ [[_pagerPanel contentView] removeTrackingArea:_closeTrackingArea];
+ [_closeTrackingArea release];
+ }
+
+ _closeTrackingArea = [[NSTrackingArea alloc] initWithRect:[[_pagerPanel contentView] bounds] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:_closeLayer userInfo:nil];
+ [[_pagerPanel contentView] addTrackingArea:_closeTrackingArea];
+}
+
- (void)_savePagerDefaults
{
[[NSUserDefaults standardUserDefaults] setObject:NSStringFromPoint([_pagerPanel frame].origin) forKey:@"PagerOrigin"];
View
2 Release/warp_dmg
@@ -3,7 +3,7 @@
# DMG creation script for Warp
#
-VERSION="1.2b1"
+VERSION=`defaults read /Users/kent/Programming/Warp/Info CFBundleVersion`
NAME="Warp $VERSION"
FINAL_NAME="Warp_$VERSION"
View
6 Warp.xcodeproj/project.pbxproj
@@ -42,7 +42,6 @@
3759DCD10EF5793D00A76FD0 /* resize_corner.png in Resources */ = {isa = PBXBuildFile; fileRef = 3759DCD00EF5793D00A76FD0 /* resize_corner.png */; };
3759DD1B0EF5824400A76FD0 /* closebox.png in Resources */ = {isa = PBXBuildFile; fileRef = 3759DD1A0EF5824400A76FD0 /* closebox.png */; };
3759DD4C0EF5C41C00A76FD0 /* CloseButtonLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3759DD4B0EF5C41C00A76FD0 /* CloseButtonLayer.m */; };
- 3759DD990EF5C9FD00A76FD0 /* FlippedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3759DD980EF5C9FD00A76FD0 /* FlippedView.m */; };
3790F6390CDA71C400A034FA /* MainController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3790F6380CDA71C400A034FA /* MainController.m */; };
3790F65B0CDA73C400A034FA /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3790F65A0CDA73C400A034FA /* Carbon.framework */; };
3790F76B0CDA804300A034FA /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3790F76A0CDA804300A034FA /* ApplicationServices.framework */; };
@@ -151,8 +150,6 @@
3759DD1A0EF5824400A76FD0 /* closebox.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = closebox.png; sourceTree = "<group>"; };
3759DD4A0EF5C41C00A76FD0 /* CloseButtonLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CloseButtonLayer.h; sourceTree = "<group>"; };
3759DD4B0EF5C41C00A76FD0 /* CloseButtonLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CloseButtonLayer.m; sourceTree = "<group>"; };
- 3759DD970EF5C9FD00A76FD0 /* FlippedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlippedView.h; sourceTree = "<group>"; };
- 3759DD980EF5C9FD00A76FD0 /* FlippedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlippedView.m; sourceTree = "<group>"; };
3759DE930EF6C8A500A76FD0 /* CGSPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGSPrivate.h; sourceTree = "<group>"; };
3790F6370CDA71C400A034FA /* MainController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainController.h; sourceTree = "<group>"; };
3790F6380CDA71C400A034FA /* MainController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainController.m; sourceTree = "<group>"; };
@@ -332,8 +329,6 @@
37532A880ED71904006805B3 /* PagerPanel.m */,
379D46C00ED79FA700751DB8 /* PagerView.h */,
379D46C10ED79FA700751DB8 /* PagerView.m */,
- 3759DD970EF5C9FD00A76FD0 /* FlippedView.h */,
- 3759DD980EF5C9FD00A76FD0 /* FlippedView.m */,
3759DD4A0EF5C41C00A76FD0 /* CloseButtonLayer.h */,
3759DD4B0EF5C41C00A76FD0 /* CloseButtonLayer.m */,
);
@@ -474,7 +469,6 @@
37532A890ED71904006805B3 /* PagerPanel.m in Sources */,
379D46C20ED79FA700751DB8 /* PagerView.m in Sources */,
3759DD4C0EF5C41C00A76FD0 /* CloseButtonLayer.m in Sources */,
- 3759DD990EF5C9FD00A76FD0 /* FlippedView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 6c3b95d

Please sign in to comment.
Something went wrong with that request. Please try again.