Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAnimation to trigger live resize



Hi,

For days I'm trying to resize 2 subviews of a NSSplitView programticly. It kinda works but the views are too slow drawing themselves. I somehow think I should trigger a live resize so the subviews no they gotta be fast (they are optimized for it and it works just fine when manually moving the divider.

here is the code I use to resize my views. I still hope, people can help me:

// right aligned -> right view is repositioned and only for vertical splitter
//BUGBUG: Enable liveResize
-(void) resizeForLeft:(NSSize)leftSizeAtTheEnd RightSide:(NSSize) rightSizeAtTheEnd withAnimation:(BOOL)flag {
[self releaseAnimationAndReset:YES];

NSView *leftView, *rightView;
NSRect bounds, leftEndFrame, rightEndFrame;
NSDictionary *animationParameters1, *animationParameters2;

bounds = [self bounds];


	leftView = [[self subviews] objectAtIndex:0];
	rightView = [[self subviews] objectAtIndex:1];

	leftEndFrame = [leftView frame];
	rightEndFrame = [rightView frame];

	if( rightEndFrame.size.width == round(rightSizeAtTheEnd.width) )
		return;

	leftEndFrame.size.width = leftSizeAtTheEnd.width;
	
	rightEndFrame.origin.x -= rightSizeAtTheEnd.width;
	rightEndFrame.size.width = rightSizeAtTheEnd.width;

if(flag) {
animationParameters1 = [NSDictionary dictionaryWithObjectsAndKeys:
leftView, NSViewAnimationTargetKey,
[NSValue valueWithRect: leftEndFrame], NSViewAnimationEndFrameKey,
nil];
animationParameters2 = [NSDictionary dictionaryWithObjectsAndKeys:
rightView, NSViewAnimationTargetKey,
[NSValue valueWithRect: rightEndFrame], NSViewAnimationEndFrameKey,
nil];


_animation = [[PGSplitViewAnimation alloc] initWithViewAnimations: [NSArray arrayWithObjects:animationParameters1, animationParameters2]];

		[_animation setAnimationBlockingMode:NSAnimationNonblocking];
		[_animation setDelegate:self];		
		[_animation startAnimation];

	} else {
		[leftView setFrame:leftEndFrame];
		[rightView setFrame:rightEndFrame];
		[self adjustSubviews];
		[self setNeedsDisplay:YES];
	}
}

// Override NSAnimation's -setCurrentProgress: method
- (void)setCurrentProgress:(NSAnimationProgress)progress {
    [super setCurrentProgress:progress];
	[[self delegate] adjustSubviews];
	[[self delegate] display];
}

Regards,
Dominik
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSAnimation to trigger live resize (From: Dominik Pich <email@hidden>)
 >Re: NSAnimation to trigger live resize (From: "I. Savant" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.