Re: NSAnimation to trigger live resize
Re: NSAnimation to trigger live resize
- Subject: Re: NSAnimation to trigger live resize
- From: Dominik Pich <email@hidden>
- Date: Sat, 30 Sep 2006 10:52:59 +0200
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:
This email sent to email@hidden