Re: NSSplitView similar to Xcode's editor/debug area split view
Re: NSSplitView similar to Xcode's editor/debug area split view
- Subject: Re: NSSplitView similar to Xcode's editor/debug area split view
- From: Chuck Soper <email@hidden>
- Date: Wed, 03 Jul 2013 17:26:29 -0700
- Thread-topic: NSSplitView similar to Xcode's editor/debug area split view
Hi Andy,
Thanks for this code snippet. It was exactly what I was asking for, but it
didn't fit for my specific situation. I now have a split view with three
subviews with different holding priorities. The only way I could get this
to work was to use constraints, and animate them. It's mostly
straightforward, but care needs to be taken to avoid breaking the
constraints.
Basically, when the lower pane is showing, I only have these constraints:
@"V:[lowerView(>=80,<=200)]"
and when the lower pane is hiding, I only have this constraint:
@"V:[lowerView(==0)]"
To animate the height, one can use this:
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
[context setDuration:0.15];
[lowerPaneFixedHeightConstraint.animator setConstant:newHeight];
} completionHandler:nil];
I'm interested to hear if anyone else is using constraints to animate a
subview of an NSSplitView.
Chuck
On 6/28/13 4:58 AM, "Andy Lee" <email@hidden> wrote:
>Hi Chuck,
>
>On Jun 26, 2013, at 8:30 PM, Chuck Soper <email@hidden> wrote:
>> 2. How should I animate the showing or hiding of the 'debug area' view?
>
>I do by sending setFrame: to the two subviews' animator proxies instead
>of to the view itself.
>
>// Assumes the split view has two subviews, one above the other.
>- (void)_setTopSubviewHeight:(CGFloat)newHeight
> forTwoPaneSplitView:(NSSplitView *)splitView
> animate:(BOOL)shouldAnimate
>{
> NSView *viewOne = [[splitView subviews] objectAtIndex:0];
> NSRect frameOne = [viewOne frame];
> NSView *viewTwo = [[splitView subviews] objectAtIndex:1];
> NSRect frameTwo = [viewTwo frame];
>
> frameOne.size.height = newHeight;
> frameTwo.size.height = ([splitView bounds].size.height
> - [splitView dividerThickness]
> - newHeight);
> if (shouldAnimate)
> {
> [NSAnimationContext beginGrouping];
> [[NSAnimationContext currentContext] setDuration:0.1];
> {{
> [[viewOne animator] setFrame:frameOne];
> [[viewTwo animator] setFrame:frameTwo];
> }}
> [NSAnimationContext endGrouping];
> }
> else
> {
> [viewOne setFrame:frameOne];
> [viewTwo setFrame:frameTwo];
> }
>}
>
>There may be a better way, but this seems to work.
>
>--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden