Skip to content

Instantly share code, notes, and snippets.

@kybernetyk kybernetyk/blah.m
Created May 8, 2012

Embed
What would you like to do?
non ca animation
#ifdef ULTRAL33T_ANIM_OPTIMIZED
NSString *selectionDirection = [userInfo objectForKey: @"direction"];
NSString *outDirection = @"left";
NSString *inDirection = @"right";
NSWindowOrderingMode winpos = NSWindowAbove;
if ([selectionDirection isEqualToString: @"up"]) {
outDirection = @"right";
inDirection = @"left";
winpos = NSWindowBelow;
}
NSImage *img1 = [documentViewController imageForAnimation];
NSImage *fakeToolbar = [documentViewController toolbarImageForAnimation];
[ov resignFirstResponder];
[ov removeFromSuperview];
rightSideViewContainer.shadowOffset = NSMakeSize(2.0, -31.0);
documentViewController = [[DocumentViewController alloc] initWithDocument: document
frame: [rightSideViewContainer frame]];
NSImage *img2 = [documentViewController imageForAnimation];
if (!fakeToolbar)
fakeToolbar = [documentViewController toolbarImageForAnimation];
[documentViewController setDelegate: self];
[infoView setInfoText: [activeDocument title]];
[self createDocumentPlayerAndRecorder];
[self documentDidChangeWriteProtection: nil];
//img1 not allways != nil
NSSize sze = [img2 size];
sze.width += [img2 size].width;
NSImage *leftimg = img1;
NSImage *rightimg = img2;
if ([outDirection isEqualToString: @"right"]) {
leftimg = img2;
rightimg = img1;
}
NSImage *iall = [[NSImage alloc] initWithSize: sze];
[iall lockFocus];
[leftimg drawAtPoint: NSZeroPoint
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
NSPoint p = NSZeroPoint;
p.x = [img2 size].width;
[rightimg drawAtPoint: p
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
[iall unlockFocus];
NSRect frm = [documentViewController.view frame];
frm.size.width = [iall size].width;
NSImageView *iv = [[NSImageView alloc] initWithFrame: frm];
[iv setImage: iall];
[rightSideViewContainer addSubview: iv];
NSRect ffrm = NSZeroRect;
ffrm.size = [fakeToolbar size];
ffrm.origin.y = [rightSideViewContainer frame].size.height - ffrm.size.height;
NSImageView *fakeToolbarView = [[NSImageView alloc] initWithFrame: ffrm];
[fakeToolbarView setImage: fakeToolbar];
[rightSideViewContainer addSubview: fakeToolbarView positioned: NSWindowAbove
relativeTo: iv];
NSMutableDictionary *fadeout = [NSMutableDictionary dictionary];
[fadeout setObject: iv forKey: NSViewAnimationTargetKey];
NSRect r = [iv frame];
NSRect r2 = r;
if ([outDirection isEqualToString: @"right"]) {
r.origin.x = -[iv bounds].size.width/2.0;
r2.origin.x = 0;
}
if ([outDirection isEqualToString: @"left"]) {
r2.origin.x = -[iv bounds].size.width/2.0;
r.origin.x = 0;
}
[fadeout setObject: [NSValue valueWithRect: r] forKey: NSViewAnimationStartFrameKey];
[fadeout setObject: [NSValue valueWithRect: r2] forKey: NSViewAnimationEndFrameKey];
NSViewAnimation *anim = [[NSViewAnimation alloc] initWithViewAnimations: [NSArray arrayWithObjects: fadeout, nil]];
[anim setAnimationBlockingMode: NSAnimationBlocking];
// [anim setDuration: 0.2];
[anim startAnimation];
[fakeToolbarView removeFromSuperview];
[iv removeFromSuperview];
[rightSideViewContainer addSubview: documentViewController.view];
return;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.