Revision: 12522 http://sourceforge.net/p/skim-app/code/12522 Author: hofman Date: 2021-11-04 17:56:46 +0000 (Thu, 04 Nov 2021) Log Message: ----------- Save/restore the graphics context rather than the class, no need to push the whole context on the stack
Modified Paths: -------------- trunk/SKLevelIndicatorCell.m Modified: trunk/SKLevelIndicatorCell.m =================================================================== --- trunk/SKLevelIndicatorCell.m 2021-11-04 17:53:21 UTC (rev 12521) +++ trunk/SKLevelIndicatorCell.m 2021-11-04 17:56:46 UTC (rev 12522) @@ -48,39 +48,40 @@ if (drawDiscreteContinuous) [self setLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle]; CGFloat cellHeight = [self cellSize].height; + NSGraphicsContext *context = [NSGraphicsContext currentContext]; if (fabs(NSHeight(cellFrame) - cellHeight) <= 0.0) { - [NSGraphicsContext saveGraphicsState]; + [context saveGraphicsState]; [[NSBezierPath bezierPathWithRect:cellFrame] addClip]; [super drawWithFrame:cellFrame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; + [context restoreGraphicsState]; } else if (RUNNING_BEFORE(10_13)) { NSRect frame = SKCenterRectVertically(cellFrame, cellHeight, 0.0, [controlView isFlipped]); - [NSGraphicsContext saveGraphicsState]; + [context saveGraphicsState]; [[NSBezierPath bezierPathWithRect:cellFrame] addClip]; [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; + [context restoreGraphicsState]; } else if (NSHeight(cellFrame) <= 2.0 * (cellHeight - EDGE_HEIGHT)) { NSRect topFrame, bottomFrame, frame = cellFrame; NSDivideRect(cellFrame, &topFrame, &bottomFrame, floor(0.5 * NSHeight(cellFrame)), NSMinYEdge); frame.size.height = cellHeight; - [NSGraphicsContext saveGraphicsState]; + [context saveGraphicsState]; [[NSBezierPath bezierPathWithRect:topFrame] addClip]; [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; - [NSGraphicsContext saveGraphicsState]; + [context restoreGraphicsState]; + [context saveGraphicsState]; [[NSBezierPath bezierPathWithRect:bottomFrame] addClip]; frame.origin.y = NSMaxY(bottomFrame) - cellHeight; [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; + [context restoreGraphicsState]; } else { NSRect topFrame, bottomFrame, restFrame, frame = cellFrame, midFrame; NSDivideRect(cellFrame, &topFrame, &bottomFrame, cellHeight - EDGE_HEIGHT, NSMinYEdge); NSDivideRect(bottomFrame, &bottomFrame, &restFrame, cellHeight - EDGE_HEIGHT, NSMaxYEdge); frame.size.height = cellHeight; - [NSGraphicsContext saveGraphicsState]; + [context saveGraphicsState]; [[NSBezierPath bezierPathWithRect:topFrame] addClip]; [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; + [context restoreGraphicsState]; do { NSDivideRect(restFrame, &midFrame, &restFrame, fmin(cellHeight - 2.0 * EDGE_HEIGHT, NSHeight(restFrame)), NSMinYEdge); [NSGraphicsContext saveGraphicsState]; @@ -90,10 +91,10 @@ [NSGraphicsContext restoreGraphicsState]; } while (NSHeight(restFrame) > 0.0); frame.origin.y = NSMaxY(bottomFrame) - cellHeight; - [NSGraphicsContext saveGraphicsState]; + [context saveGraphicsState]; [[NSBezierPath bezierPathWithRect:bottomFrame] addClip]; [super drawWithFrame:frame inView:controlView]; - [NSGraphicsContext restoreGraphicsState]; + [context restoreGraphicsState]; } if (drawDiscreteContinuous) [self setLevelIndicatorStyle:NSDiscreteCapacityLevelIndicatorStyle]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit