Re: Animated split view collapsing
Re: Animated split view collapsing
- Subject: Re: Animated split view collapsing
- From: "Greg Herlihy" <email@hidden>
- Date: Mon, 24 Apr 2006 21:29:44 -0700
There are two problems with the original animating split view code. First,
the original routine did not check the orientation of the split view to
determine whether it is the width or the height of the target view that
should be adjusted. Second, the distance that the divider has to move in
order to completely cover the target frame is clearly dependent on the
view's current size - and could not be represented as a hard-coded constant.
And the actual disntance to move the divider has to be slightly less than
the view's current dimension, because reducing the width or height of the
target's view to a zero seems to make it disappear permanently.
The overall result once the NSAnimation is working is quite smooth (a
revised implementation is below). In contast, I found RBSplitView's
animation (which does not use an NSAnimationView) to be jerkier and suffer
from "tearing" when I last tried it out.
Finally, to make the divider disappear when a pane is collapsed, simply
override drawDividerInRect: and have it call its super only when none of its
subview's dimensions are close to zero.
Greg
-(void)animate:(id)sender
{
NSView *targetView;
// use first view as an example
targetView = [[self subviews] objectAtIndex:0];
NSRect endFrame;
endFrame = [targetView frame];
if (![self isVertical])
endFrame.size.height = 1.0;
else
endFrame.size.width = 1.0;
NSDictionary *windowResize;
windowResize = [NSDictionary dictionaryWithObjectsAndKeys: targetView,
NSViewAnimationTargetKey,
[NSValue valueWithRect: endFrame], NSViewAnimationEndFrameKey, nil];
NSViewAnimation *animation = [[NSViewAnimation alloc]
initWithViewAnimations:[NSArray arrayWithObject:windowResize]];
[animation setAnimationBlockingMode:NSAnimationBlocking];
[animation setDuration:0.5];
[animation startAnimation];
[animation release];
}
Greg
----- Original Message -----
From: "Lawrence Sanbourne" <email@hidden>
To: "I. Savant" <email@hidden>
Cc: <email@hidden>
Sent: Sunday, April 23, 2006 3:10 PM
Subject: Re: Animated split view collapsing
Thanks for the help. Here's what I get when the code runs:
*** NSTimer discarding exception '*** -[NSCFArray objectAtIndex:]:
index (1) beyond bounds (0)' that raised during firing of timer with
target 3b9990 and selector '_advanceTime'
_advanceTime is called by NSViewAnimation code.
That error is repeated over and over, seemingly forever. I tried
switching it to NSAnimationNonblocking, and this fixed the hang but
caused weird drawing behavior. (No animation, just elements inside the
split view jumping to weird positions.)
Here's the modified code I'm using:
- (IBAction)animateSplitView:(id)sender
{
static float s_delta = DELTA;
/* Parameters (to be refactored) */
NSView *targetView = widgetInfoViewBezel;
NSView *splitView = sourceInfoSplitView;
/* End parameters */
NSRect frame = [targetView frame];
frame.origin.y += s_delta;
frame.size.height -= s_delta;
NSDictionary *windowResize;
windowResize = [NSDictionary dictionaryWithObjectsAndKeys:
targetView, NSViewAnimationTargetKey,
[NSValue valueWithRect: frame],
NSViewAnimationEndFrameKey,
nil];
NSViewAnimation *animation = [[NSViewAnimation alloc]
initWithViewAnimations:[NSArray arrayWithObject:windowResize]];
[animation setAnimationBlockingMode:NSAnimationBlocking];
[animation setDuration:0.5];
[animation startAnimation];
[animation release];
s_delta *= -1;
s_delta += 1;
[splitView display];
}
Any ideas?
Regarding the split view divider thickness, I actually want it to
disappear only when the split pane is collapsed. Try clicking the info
button in iCal to see what I mean.
Larry
On 4/23/06, I. Savant <email@hidden> wrote:
Regarding the CocoaDev code you referenced, can you post the
specific error(s) you are receiving? Have you used the debugger to
determine why the code loops?
Regarding making the splitter bar disappear, check the NSSplitView
documentation and look at the -dividerThickness method. You can
subclass and override this to make the divider any size you want,
including, I believe, zero.
--
I.S.
On Apr 23, 2006, at 3:22 PM, Lawrence Sanbourne wrote:
> Hello,
>
> Does anyone have any code for collapsing a pane of a split view, using
> NSViewAnimation or other means? There's some CocoaDev code for this,
> but it causes an infinite loop and lots of array bounds exceptions:
>
> http://www.cocoadev.com/index.pl?AnimatedNSSplitView
>
> I'd like the splitter bar to disappear entirely when the view is
> collapsed. (This is the behavior in iCal and other Apple apps.)
>
> Larry
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40gmail.com
>
> This email sent to email@hidden
_______________________________________________
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
_______________________________________________
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