From a9c23f7485e537db25b18419afcbe5e709e7117d Mon Sep 17 00:00:00 2001 From: CaS Date: Mon, 11 Feb 2002 14:06:00 +0000 Subject: [PATCH] Add patch to avoid unnecessary redrawing. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12490 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSMenuView.m | 35 +++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d58d5cf1..d73701429 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-02-10 Michael Hanni + + * Source/NSMenuView.m ([-drawRect:]): make this more efficent, + only redraw cells that we clip. + Mon Feb 11 00:35:19 2002 Nicola Pero * Source/NSLayoutManager.m ([-dealloc]): Modified to work for diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index 9ca2e9991..43b4ad75b 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -463,7 +463,7 @@ if (![_menu _ownedByPopUp]) _cellSize.width = accumulatedOffset + 3; // Add the border width - if (!_horizontal) + if (_horizontal == NO) { [self setFrameSize: NSMakeSize(_cellSize.width + 1, (howMany * _cellSize.height))]; @@ -527,7 +527,7 @@ - (NSRect) innerRect { - if (!_horizontal) + if (_horizontal == NO) { return NSMakeRect(_bounds.origin.x + 1, _bounds.origin.y, _bounds.size.width - 1, _bounds.size.height); @@ -543,10 +543,11 @@ { NSRect theRect; - if (_needsSizing) - [self sizeToFit]; - - if (!_horizontal) + if (_needsSizing == YES) + { + [self sizeToFit]; + } + if (_horizontal == NO) { theRect.origin.y = _bounds.size.height - (_cellSize.height * (index + 1)); theRect.origin.x = 1; @@ -572,7 +573,7 @@ NSRect aRect = [self rectOfItemAtIndex: i]; // Add the border to the rectangle - if (!_horizontal) + if (_horizontal == NO) { aRect.origin.x--; aRect.size.width++; @@ -594,7 +595,7 @@ { NSRect aRect = [self rectOfItemAtIndex: index]; - if (!_horizontal) + if (_horizontal == NO) { aRect.origin.x--; aRect.size.width++; @@ -677,7 +678,7 @@ { float f; - if (!_horizontal) + if (_horizontal == NO) { f = screenRect.size.height * (items - 1); screenFrame.size.height += f; @@ -696,7 +697,7 @@ // Compute position for popups, if needed if (selectedItemIndex > -1) { - if (!_horizontal) + if (_horizontal == NO) { screenFrame.origin.y += screenRect.size.height * selectedItemIndex; } @@ -731,7 +732,7 @@ DPSgsave(ctxt); DPSsetlinewidth(ctxt, 1); DPSsetgray(ctxt, NSDarkGray); - if (!_horizontal) + if (_horizontal == NO) { DPSmoveto(ctxt, NSMinX(_bounds), NSMinY(_bounds)); DPSrlineto(ctxt, 0, _bounds.size.height); @@ -747,13 +748,15 @@ // Draw the menu cells. for (i = 0; i < howMany; i++) { - NSRect aRect; - NSMenuItemCell *aCell; + NSRect aRect; + NSMenuItemCell *aCell; aRect = [self rectOfItemAtIndex: i]; - // FIXME: Should check if rect overlapps aRect - aCell = [_itemCells objectAtIndex: i]; - [aCell drawWithFrame: aRect inView: self]; + if (NSIntersectsRect(rect, aRect) == YES) + { + aCell = [_itemCells objectAtIndex: i]; + [aCell drawWithFrame: aRect inView: self]; + } } }