diff options
author | culler <culler> | 2019-10-30 22:12:31 (GMT) |
---|---|---|
committer | culler <culler> | 2019-10-30 22:12:31 (GMT) |
commit | 2aa1aaba6fa81c640f8a8f8b58f78b57edd7dcb3 (patch) | |
tree | 8b685be56de43a5c5fabf5181a39866371bf5ef0 /macosx/tkMacOSXScrlbr.c | |
parent | 77775c835c3b0cd6ad4ab4075cc55b76c069c2d6 (diff) | |
parent | 8e9e7cb41c0f5540842a7ee8d87c413d586b88fe (diff) | |
download | tk-2aa1aaba6fa81c640f8a8f8b58f78b57edd7dcb3.zip tk-2aa1aaba6fa81c640f8a8f8b58f78b57edd7dcb3.tar.gz tk-2aa1aaba6fa81c640f8a8f8b58f78b57edd7dcb3.tar.bz2 |
Fix [de579935a9]: Assertion error when drawing a Tk scrollbar on macOS
Diffstat (limited to 'macosx/tkMacOSXScrlbr.c')
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 66619c2..dff6cc9 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -214,12 +214,20 @@ static void drawMacScrollbar( CGContextStrokeLineSegments(context, outer, 2); /* - * Do not display the thumb unless scrolling is possible. + * Do not display the thumb unless scrolling is possible, in accordance + * with macOS behavior. + * + * Native scrollbars and Ttk scrollbars are always 15 pixels wide, but we + * allow Tk scrollbars to have any width, even if it looks bad. To prevent + * sporadic assertion errors when drawing skinny thumbs we must make sure + * the radius is at most half the width. */ if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) { CGRect thumbBounds = {thumbOrigin, thumbSize}; - path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL); + int width = scrollPtr->vertical ? thumbSize.width : thumbSize.height; + int radius = width >= 8 ? 4 : width >> 1; + path = CGPathCreateWithRoundedRect(thumbBounds, radius, radius, NULL); CGContextBeginPath(context); CGContextAddPath(context, path); if (msPtr->info.trackInfo.scrollbar.pressState != 0) { |