Only delay redrawing if the plotview has resized

This commit is contained in:
anthony 2020-12-01 19:47:41 +00:00
parent 3c52822637
commit 2d0555cf74
2 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@
BOOL reallyDraw;
BOOL isDragging;
NSPoint dragStart;
NSSize lastSize;
}
-(void)setBrowser: (void*)aBrowser;

View File

@ -276,7 +276,9 @@ static const struct plotter_table gnustep_plotters = {
*/
-(void)drawRect: (NSRect)rect {
NSLog(@"Drawing plotview");
if (!reallyDraw) {
BOOL sizeChanged = rect.size.width != lastSize.width ||
rect.size.width != lastSize.width;
if (!reallyDraw && sizeChanged) {
[NSObject cancelPreviousPerformRequestsWithTarget: self];
[self performSelector: @selector(reallyTriggerDraw) withObject: nil
afterDelay: 0.01];
@ -294,6 +296,7 @@ static const struct plotter_table gnustep_plotters = {
.y1 = NSMaxY(rect)
};
browser_window_redraw(browser, 0, 0, &clip, &ctx);
lastSize = rect.size;
}
-(void)reallyTriggerDraw {