From d9b327db836e72fe021bf7e9b75362a212dcf843 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Tue, 22 Mar 2011 13:43:42 -0400 Subject: [PATCH] Fix for splitview not repositioning subviews or removing divider when a subview is removed. --- AppKit/CPSplitView.j | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index fe14a67b8..5898616a9 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -259,6 +259,26 @@ var CPSplitViewHorizontalImage = nil, [self drawDividerInRect:[self rectOfDividerAtIndex:count]]; } } + +/*! + @ignore + Because we're use drawRect: to draw the dividers, but use DOM elements instead of CoreGraphics + We must remove those DOM elements (the splitters) when the subview is removed. +*/ +- (void)willRemoveSubview:(CPView)aView +{ +#if PLATFORM(DOM) + CPDOMDisplayServerRemoveChild(_DOMElement, _DOMDividerElements.pop()); +#endif + + _needsResizeSubviews = YES; + [self setNeedsLayout]; + [self setNeedsDisplay:YES]; + + // because we have to wait for the subview to ACTUALLY be removed, we need to wait until the next runloop to recalculate everything. + window.setTimeout(function(){[self _adjustSubviewsWithCalculatedSize]},0); +} + /*! Draws the divider at a given rect. @param aRect - the rect of the divider to draw.