diff options
author | culler <culler> | 2019-06-30 14:35:13 (GMT) |
---|---|---|
committer | culler <culler> | 2019-06-30 14:35:13 (GMT) |
commit | d618c08d920a191a902d8270166ea76a2b17d4cb (patch) | |
tree | c25e462c3dd69aa0fe5b099542c5c9ffd0ca091a | |
parent | 89357088ac798f9bc97064cfe566d05438b5e6c5 (diff) | |
download | tk-d618c08d920a191a902d8270166ea76a2b17d4cb.zip tk-d618c08d920a191a902d8270166ea76a2b17d4cb.tar.gz tk-d618c08d920a191a902d8270166ea76a2b17d4cb.tar.bz2 |
Fix geometry of horizontal ttk scrollbars; hide thumb when no scrolling is possible.
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 68 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 9 |
2 files changed, 45 insertions, 32 deletions
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index c0fd704..6c5558d 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -89,7 +89,8 @@ typedef struct ScrollbarMetrics { } ScrollbarMetrics; static ScrollbarMetrics metrics = { - 15, 54, 26, 14, 14, kControlSizeNormal /* kThemeScrollBarMedium */ + /* kThemeScrollBarMedium */ + 15, MIN_SLIDER_LENGTH, 26, 14, 14, kControlSizeNormal }; /* @@ -182,25 +183,6 @@ static void drawMacScrollbar( CGRect troughBounds = msPtr->info.bounds, thumbBounds; troughBounds.origin.y = [view bounds].size.height - (troughBounds.origin.y + troughBounds.size.height); - if (scrollPtr->vertical) { - thumbBounds.origin.x = troughBounds.origin.x + MIN_GAP; - thumbBounds.origin.y = troughBounds.origin.y + scrollPtr->sliderFirst; - thumbBounds.size.width = troughBounds.size.width - 2*MIN_GAP + 1; - thumbBounds.size.height = scrollPtr->sliderLast - scrollPtr->sliderFirst; - inner[0] = troughBounds.origin; - inner[1] = CGPointMake(inner[0].x, inner[0].y + troughBounds.size.height); - outer[0] = CGPointMake(inner[0].x + troughBounds.size.width - 1, inner[0].y); - outer[1] = CGPointMake(outer[0].x, inner[1].y); - } else { - thumbBounds.origin.x = troughBounds.origin.x + scrollPtr->sliderFirst + MIN_GAP; - thumbBounds.origin.y = troughBounds.origin.x + MIN_GAP; - thumbBounds.size.width = scrollPtr->sliderLast - scrollPtr->sliderFirst; - thumbBounds.size.height -= troughBounds.size.height - 2*MIN_GAP; - inner[0] = troughBounds.origin; - inner[1] = CGPointMake(inner[0].x + troughBounds.size.width, inner[0].y); - outer[0] = CGPointMake(inner[0].x, inner[0].y + troughBounds.size.height); - outer[1] = CGPointMake(inner[1].x, outer[0].y); - } CGContextSetShouldAntialias(context, false); CGContextSetGrayFillColor(context, 250.0 / 255, 1.0); CGContextFillRect(context, troughBounds); @@ -208,17 +190,43 @@ static void drawMacScrollbar( CGContextStrokeLineSegments(context, inner, 2); CGContextSetGrayStrokeColor(context, 238.0 / 255, 1.0); CGContextStrokeLineSegments(context, outer, 2); - path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL); - CGContextBeginPath(context); - CGContextAddPath(context, path); - if (msPtr->info.trackInfo.scrollbar.pressState != 0) { - CGContextSetGrayFillColor(context, 133.0 / 255, 1.0); - } else { - CGContextSetGrayFillColor(context, 200.0 / 255, 1.0); + + /* + * Do not display the thumb unless scrolling is possible. + */ + + if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) { + if (scrollPtr->vertical) { + thumbBounds.origin.x = troughBounds.origin.x + MIN_GAP; + thumbBounds.origin.y = troughBounds.origin.y + scrollPtr->sliderFirst; + thumbBounds.size.width = troughBounds.size.width - 2*MIN_GAP + 1; + thumbBounds.size.height = scrollPtr->sliderLast - scrollPtr->sliderFirst; + inner[0] = troughBounds.origin; + inner[1] = CGPointMake(inner[0].x, inner[0].y + troughBounds.size.height); + outer[0] = CGPointMake(inner[0].x + troughBounds.size.width - 1, inner[0].y); + outer[1] = CGPointMake(outer[0].x, inner[1].y); + } else { + thumbBounds.origin.x = troughBounds.origin.x + scrollPtr->sliderFirst + MIN_GAP; + thumbBounds.origin.y = troughBounds.origin.y + MIN_GAP; + thumbBounds.size.width = scrollPtr->sliderLast - scrollPtr->sliderFirst; + thumbBounds.size.height = troughBounds.size.height - 2*MIN_GAP + 1; + inner[0] = troughBounds.origin; + inner[1] = CGPointMake(inner[0].x + troughBounds.size.width, inner[0].y); + outer[0] = CGPointMake(inner[0].x, inner[0].y + troughBounds.size.height); + outer[1] = CGPointMake(inner[1].x, outer[0].y); + } + path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL); + CGContextBeginPath(context); + CGContextAddPath(context, path); + if (msPtr->info.trackInfo.scrollbar.pressState != 0) { + CGContextSetGrayFillColor(context, 133.0 / 255, 1.0); + } else { + CGContextSetGrayFillColor(context, 200.0 / 255, 1.0); + } + CGContextSetShouldAntialias(context, true); + CGContextFillPath(context); + CFRelease(path); } - CGContextSetShouldAntialias(context, true); - CGContextFillPath(context); - CFRelease(path); } #endif diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 2c2c266..129148f 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -2347,8 +2347,13 @@ static void ThumbElementSize( int orientation = TTK_ORIENT_HORIZONTAL; Ttk_GetOrientFromObj(NULL, scrollbar->orientObj, &orientation); - *minHeight = 18; - *minWidth = 8; + if (orientation == TTK_ORIENT_VERTICAL) { + *minHeight = 18; + *minWidth = 8; + } else { + *minHeight = 8; + *minWidth = 18; + } } static void ThumbElementDraw( |