Skip to content

Commit

Permalink
Reindent + use setFrame:display: rather than setFrameOrigin: to fix 6…
Browse files Browse the repository at this point in the history
…4-bit nonanimating stuff.
  • Loading branch information
millenomi committed Apr 1, 2010
1 parent aab22e2 commit 0199433
Showing 1 changed file with 44 additions and 38 deletions.
82 changes: 44 additions & 38 deletions AfloatBadgeController.m
Expand Up @@ -54,8 +54,8 @@ - (void) setParentWindow:(NSWindow*) newParent {
if (newParent) {
[AfloatStorage setSharedValue:self window:newParent key:kAfloatBadgeControllerKey];

// [[NSNotificationCenter defaultCenter]
// addObserver:self selector:@selector(parentWindowDidResize:) name:NSWindowDidResizeNotification object:_parentWindow];
// [[NSNotificationCenter defaultCenter]
// addObserver:self selector:@selector(parentWindowDidResize:) name:NSWindowDidResizeNotification object:_parentWindow];


[newParent retain];
Expand Down Expand Up @@ -88,47 +88,53 @@ - (void) animateWithBadgeType:(AfloatBadgeType) type {
switch (type) {
case AfloatBadgeDidBeginKeepingAfloat:
[badgeView setImage:[[self class] didBeginKeepingAfloatBadge]];

//if (![[self window] isVisible]) {

{
NSPoint targetOrigin = [self middleOriginForParentWindow];
NSPoint startingOrigin = targetOrigin;
startingOrigin.y -= 20;

[[self window] setFrameOrigin:startingOrigin];
[[self window] makeKeyAndOrderFront:self];

[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.4];
[[[self window] animator] setFrameOrigin:targetOrigin];
[NSAnimationContext endGrouping];

enqueuedFades++;
[self performSelector:@selector(_fadeOut) withObject:nil afterDelay:0.7];
//}
NSPoint targetOrigin = [self middleOriginForParentWindow];
NSPoint startingOrigin = targetOrigin;
startingOrigin.y -= 20;

NSRect r = [[self window] frame];
r.origin = startingOrigin;
[[self window] setFrame:r display:NO];
[[self window] makeKeyAndOrderFront:self];

[NSAnimationContext beginGrouping];
{
[[NSAnimationContext currentContext] setDuration:0.4];
r.origin = targetOrigin;
[[[self window] animator] setFrame:r display:YES];
}
[NSAnimationContext endGrouping];

enqueuedFades++;
[self performSelector:@selector(_fadeOut) withObject:nil afterDelay:0.7];
}
break;

case AfloatBadgeDidEndKeepingAfloat:
[badgeView setImage:[[self class] didEndKeepingAfloatBadge]];

//if (![[self window] isVisible]) {
{
NSPoint targetOrigin = [self middleOriginForParentWindow];
NSPoint startingOrigin = targetOrigin;
targetOrigin.y -= 30;

[[self window] setFrameOrigin:startingOrigin];
[[self window] makeKeyAndOrderFront:self];

[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.4];
[[[self window] animator] setFrameOrigin:targetOrigin];
[NSAnimationContext endGrouping];

enqueuedFades++;
[self performSelector:@selector(_fadeOut) withObject:nil afterDelay:0.7];
//}
NSPoint targetOrigin = [self middleOriginForParentWindow];
NSPoint startingOrigin = targetOrigin;
targetOrigin.y -= 30;

NSRect r = [[self window] frame];
r.origin = startingOrigin;
[[self window] setFrame:r display:NO];
[[self window] makeKeyAndOrderFront:self];

[NSAnimationContext beginGrouping];
{
[[NSAnimationContext currentContext] setDuration:0.4];
r.origin = targetOrigin;
[[[self window] animator] setFrame:r display:YES];
}
[NSAnimationContext endGrouping];

enqueuedFades++;
[self performSelector:@selector(_fadeOut) withObject:nil afterDelay:0.7];
}
break;
}
Expand All @@ -146,7 +152,7 @@ - (void) _fadeOut {
fadingOut = YES;

[[NSAnimationContext currentContext] setDuration:0.2];
[[[self window] animator] setAlphaValue:0];
[[[self window] animator] setAlphaValue:0];
[NSAnimationContext endGrouping];

[AfloatStorage removeSharedValueForWindow:self.parentWindow key:kAfloatBadgeControllerKey];
Expand All @@ -169,7 +175,7 @@ + (NSImage*) didBeginKeepingAfloatBadge {

return image;
}

+ (NSImage*) didEndKeepingAfloatBadge {
static NSImage* image = nil; if (!image) {
NSBundle* bundle = [NSBundle bundleForClass:self];
Expand Down

0 comments on commit 0199433

Please sign in to comment.