Defer updating scroller.

This commit is contained in:
Lukhnos Liu 2013-01-24 23:28:42 -08:00
parent ad6118e141
commit 55d2cb2868
1 changed files with 13 additions and 7 deletions

View File

@ -41,6 +41,7 @@ static const CGFloat kCandidateTextLeftMargin = 8.0;
- (BOOL)scrollPageByOne:(BOOL)forward; - (BOOL)scrollPageByOne:(BOOL)forward;
- (BOOL)moveSelectionByOne:(BOOL)forward; - (BOOL)moveSelectionByOne:(BOOL)forward;
- (void)layoutCandidateView; - (void)layoutCandidateView;
- (void)forceUpdateVerticalScroller;
@end @end
@implementation VTVerticalCandidateController @implementation VTVerticalCandidateController
@ -244,7 +245,7 @@ static const CGFloat kCandidateTextLeftMargin = 8.0;
// fix a subtle on 10.7 that, since we force the scroller to appear, scrolling sometimes shows a temporarily "broken" scroll bar (but quickly disappears) // fix a subtle on 10.7 that, since we force the scroller to appear, scrolling sometimes shows a temporarily "broken" scroll bar (but quickly disappears)
if ([_scrollView hasVerticalScroller]) { if ([_scrollView hasVerticalScroller]) {
[[_scrollView verticalScroller] setNeedsDisplay]; [self forceUpdateVerticalScroller];
} }
return attrString; return attrString;
@ -338,12 +339,6 @@ static const CGFloat kCandidateTextLeftMargin = 8.0;
} }
- (void)layoutCandidateView - (void)layoutCandidateView
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(deferredLayoutCandidateView) object:nil];
[self performSelector:@selector(deferredLayoutCandidateView) withObject:nil afterDelay:0.0];
}
- (void)deferredLayoutCandidateView
{ {
NSUInteger count = [_delegate candidateCountForController:self]; NSUInteger count = [_delegate candidateCountForController:self];
if (!count) { if (!count) {
@ -402,4 +397,15 @@ static const CGFloat kCandidateTextLeftMargin = 8.0;
[_scrollView setFrame:NSMakeRect(stripWidth + 1.0, 0.0, tableViewStartWidth, windowHeight)]; [_scrollView setFrame:NSMakeRect(stripWidth + 1.0, 0.0, tableViewStartWidth, windowHeight)];
[[self window] setFrame:frameRect display:YES]; [[self window] setFrame:frameRect display:YES];
} }
- (void)forceUpdateVerticalScroller
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(deferredForceUpdateVerticalScroller) object:nil];
[self performSelector:@selector(deferredForceUpdateVerticalScroller) withObject:nil afterDelay:0.0];
}
- (void)deferredForceUpdateVerticalScroller
{
[[_scrollView verticalScroller] setNeedsDisplay];
}
@end @end