Index: Source/NSSplitView.m =================================================================== --- Source/NSSplitView.m (revision 28272) +++ Source/NSSplitView.m (working copy) @@ -167,8 +167,6 @@ - (void) mouseDown: (NSEvent*)theEvent { NSApplication *app = [NSApplication sharedApplication]; - static NSRect oldRect; //only one can be dragged at a time - static BOOL lit = NO; NSPoint p, op; NSEvent *e; NSRect r, r1, bigRect, vis; @@ -345,12 +343,8 @@ } } - oldRect = NSZeroRect; - [self lockFocus]; - [[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode]; - [_dividerColor set]; r.size.width = divHorizontal; r.size.height = divVertical; e = [app nextEventMatchingMask: eventMask @@ -363,12 +357,13 @@ constrainImp = (floatIMP)[_delegate methodForSelector: constrainSel]; } - // Save the old position - op = p; - // user is moving the knob loop until left mouse up while ([e type] != NSLeftMouseUp) { + + // Save the old position + op = p; + p = [self convertPoint: [e locationInWindow] fromView: nil]; if (delegateConstrains) { @@ -410,148 +405,7 @@ r.origin.x = p.x - (divHorizontal/2.); r.origin.y = NSMinY(vis); } - if (NSEqualRects(r, oldRect) == NO) - { - NSDebugLLog(@"NSSplitView", @"drawing divider at address@hidden", - NSStringFromRect(r)); - [_dividerColor set]; - - - if (lit == YES) - { - if (_isVertical == NO) - { - if ((NSMinY(r) > NSMaxY(oldRect)) - || (NSMaxY(r) < NSMinY(oldRect))) - // the two rects don't intersect - { - NSHighlightRect(oldRect); - NSHighlightRect(r); - } - else - // the two rects intersect - { - if (NSMinY(r) > NSMinY(oldRect)) - { - NSRect onRect, offRect; - onRect.size.width = r.size.width; - onRect.origin.x = r.origin.x; - offRect.size.width = r.size.width; - offRect.origin.x = r.origin.x; - offRect.origin.y = NSMinY(oldRect); - offRect.size.height = - NSMinY(r) - NSMinY(oldRect); - - onRect.origin.y = NSMaxY(oldRect); - onRect.size.height = - NSMaxY(r) - NSMaxY(oldRect); - - NSHighlightRect(onRect); - NSHighlightRect(offRect); - - //NSLog(@"on : %@", NSStringFromRect(onRect)); - //NSLog(@"off : %@", NSStringFromRect(offRect)); - //NSLog(@"old : %@", NSStringFromRect(oldRect)); - //NSLog(@"r : %@", NSStringFromRect(r)); - } - else - { - NSRect onRect, offRect; - onRect.size.width = r.size.width; - onRect.origin.x = r.origin.x; - offRect.size.width = r.size.width; - offRect.origin.x = r.origin.x; - - offRect.origin.y = NSMaxY(r); - offRect.size.height = - NSMaxY(oldRect) - NSMaxY(r); - - onRect.origin.y = NSMinY(r); - onRect.size.height = - NSMinY(oldRect) - NSMinY(r); - - NSHighlightRect(onRect); - NSHighlightRect(offRect); - - //NSLog(@"on : %@", NSStringFromRect(onRect)); - //NSLog(@"off : %@", NSStringFromRect(offRect)); - //NSLog(@"old : %@", NSStringFromRect(oldRect)); - //NSLog(@"r : %@", NSStringFromRect(r)); - } - } - } - else - { - if ((NSMinX(r) > NSMaxX(oldRect)) - || (NSMaxX(r) < NSMinX(oldRect))) - // the two rects don't intersect - { - NSHighlightRect(oldRect); - NSHighlightRect(r); - } - else - // the two rects intersect - { - if (NSMinX(r) > NSMinX(oldRect)) - { - NSRect onRect, offRect; - onRect.size.height = r.size.height; - onRect.origin.y = r.origin.y; - offRect.size.height = r.size.height; - offRect.origin.y = r.origin.y; - - offRect.origin.x = NSMinX(oldRect); - offRect.size.width = - NSMinX(r) - NSMinX(oldRect); - - onRect.origin.x = NSMaxX(oldRect); - onRect.size.width = - NSMaxX(r) - NSMaxX(oldRect); - - NSHighlightRect(onRect); - NSHighlightRect(offRect); - } - else - { - NSRect onRect, offRect; - onRect.size.height = r.size.height; - onRect.origin.y = r.origin.y; - offRect.size.height = r.size.height; - offRect.origin.y = r.origin.y; - - offRect.origin.x = NSMaxX(r); - offRect.size.width = - NSMaxX(oldRect) - NSMaxX(r); - - onRect.origin.x = NSMinX(r); - onRect.size.width = - NSMinX(oldRect) - NSMinX(r); - - NSHighlightRect(onRect); - NSHighlightRect(offRect); - } - } - - } - } - else - { - NSHighlightRect(r); - } - [_window flushWindow]; - /* - if (lit == YES) - { - NSHighlightRect(oldRect); - lit = NO; - } - NSHighlightRect(r); - */ - lit = YES; - oldRect = r; - } - { NSEvent *ee; @@ -584,96 +438,82 @@ } } - } + // If the splitview was moved, we resize the subviews + if ((_isVertical == YES && p.x != op.x) + || (_isVertical == NO && p.y != op.y)) + { + + [nc postNotificationName: NSSplitViewWillResizeSubviewsNotification + object: self]; - if (lit == YES) - { - [_dividerColor set]; - NSHighlightRect(oldRect); - lit = NO; - } + /* resize the subviews accordingly */ + r = [prev frame]; + if (_isVertical == NO) + { + r.size.height = p.y - NSMinY(bigRect) - (divVertical/2.); + if (NSHeight(r) < 1.) + { + r.size.height = 1.; + } + } + else + { + r.size.width = p.x - NSMinX(bigRect) - (divHorizontal/2.); + if (NSWidth(r) < 1.) + { + r.size.width = 1.; + } + } + + [prev setFrame: r]; + NSDebugLLog(@"NSSplitView", @"drawing PREV at x: %d, y: %d, w: %d, h: %d\n", + (int)NSMinX(r),(int)NSMinY(r),(int)NSWidth(r),(int)NSHeight(r)); - [self unlockFocus]; + r1 = [v frame]; + if (_isVertical == NO) + { + r1.origin.y = p.y + (divVertical/2.); + if (NSMinY(r1) < 0.) + { + r1.origin.y = 0.; + } + r1.size.height = NSHeight(bigRect) - NSHeight(r) - divVertical; + if (NSHeight(r) < 1.) + { + r.size.height = 1.; + } + } + else + { + r1.origin.x = p.x + (divHorizontal/2.); + if (NSMinX(r1) < 0.) + { + r1.origin.x = 0.; + } + r1.size.width = NSWidth(bigRect) - NSWidth(r) - divHorizontal; + if (NSWidth(r1) < 1.) + { + r1.size.width = 1.; + } + } - // Divider position hasn't changed don't try to resize subviews - if (_isVertical == YES && p.x == op.x) - { - [self setNeedsDisplay: YES]; - return; - } - else if (_isVertical == NO && p.y == op.y) - { - [self setNeedsDisplay: YES]; - return; - } + [v setFrame: r1]; + NSDebugLLog(@"NSSplitView", @"drawing LAST at x: %d, y: %d, w: %d, h: %d\n", + (int)NSMinX(r1),(int)NSMinY(r1),(int)NSWidth(r1), + (int)NSHeight(r1)); - [nc postNotificationName: NSSplitViewWillResizeSubviewsNotification - object: self]; + [_window invalidateCursorRectsForView: self]; - /* resize the subviews accordingly */ - r = [prev frame]; - if (_isVertical == NO) - { - r.size.height = p.y - NSMinY(bigRect) - (divVertical/2.); - if (NSHeight(r) < 1.) - { - r.size.height = 1.; - } - } - else - { - r.size.width = p.x - NSMinX(bigRect) - (divHorizontal/2.); - if (NSWidth(r) < 1.) - { - r.size.width = 1.; - } - } - [prev setFrame: r]; - NSDebugLLog(@"NSSplitView", @"drawing PREV at x: %d, y: %d, w: %d, h: %d\n", - (int)NSMinX(r),(int)NSMinY(r),(int)NSWidth(r),(int)NSHeight(r)); + [nc postNotificationName: NSSplitViewDidResizeSubviewsNotification + object: self]; - r1 = [v frame]; - if (_isVertical == NO) - { - r1.origin.y = p.y + (divVertical/2.); - if (NSMinY(r1) < 0.) - { - r1.origin.y = 0.; + [self setNeedsDisplay: YES]; + } - r1.size.height = NSHeight(bigRect) - NSHeight(r) - divVertical; - if (NSHeight(r) < 1.) - { - r.size.height = 1.; - } } - else - { - r1.origin.x = p.x + (divHorizontal/2.); - if (NSMinX(r1) < 0.) - { - r1.origin.x = 0.; - } - r1.size.width = NSWidth(bigRect) - NSWidth(r) - divHorizontal; - if (NSWidth(r1) < 1.) - { - r1.size.width = 1.; - } - } - [v setFrame: r1]; - NSDebugLLog(@"NSSplitView", @"drawing LAST at x: %d, y: %d, w: %d, h: %d\n", - (int)NSMinX(r1),(int)NSMinY(r1),(int)NSWidth(r1), - (int)NSHeight(r1)); - [_window invalidateCursorRectsForView: self]; - - [nc postNotificationName: NSSplitViewDidResizeSubviewsNotification - object: self]; - [self _autosaveSubviewProportions]; - [self setNeedsDisplay: YES]; - - //[self display]; } - (void) _adjustSubviews: (NSSize)oldSize