diff options
Diffstat (limited to 'macosx/ttkMacOSXTheme.c')
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 7ea9448..b58a743 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -2347,7 +2347,13 @@ static void ThumbElementSize( int orientation = TTK_ORIENT_HORIZONTAL; Ttk_GetOrientFromObj(NULL, scrollbar->orientObj, &orientation); - *minHeight = *minWidth = 8; + if (orientation == TTK_ORIENT_VERTICAL) { + *minHeight = 18; + *minWidth = 8; + } else { + *minHeight = 8; + *minWidth = 18; + } } static void ThumbElementDraw( @@ -2368,15 +2374,11 @@ static void ThumbElementDraw( * able to display the thumb element at the size and location which the ttk * scrollbar widget requests. The algorithm that HIToolbox uses to * determine the thumb geometry from the input values of min, max, value - * and viewSize is, of course, undocumented. And this turns out to be a - * hard reverse engineering problem. A seemingly natural algorithm is - * implemented below, but it does not correctly compute the same thumb - * geometry as HITools (which also apparently does not agree with - * NSScrollbar). This code uses that algorithm for older OS versions, + * and viewSize is undocumented. A seemingly natural algorithm is + * implemented below. This code uses that algorithm for older OS versions, * because using HITools also handles drawing the buttons and 3D thumb used - * on those systems. The incorrect geometry is annoying but not completely - * unusable. For newer systems the cleanest approach is to just draw the - * thumb directly. + * on those systems. For newer systems the cleanest approach is to just + * draw the thumb directly. */ if ([NSApp macMinorVersion] > 8) { @@ -2404,7 +2406,7 @@ static void ThumbElementDraw( SolidFillRoundedRectangle(dc.context, thumbBounds, 4, thumbColor); END_DRAWING } else { - double thumbSize, trackSize, visibleSize, viewSize; + double thumbSize, trackSize, visibleSize, factor, fraction; MacDrawable *macWin = (MacDrawable *) Tk_WindowId(tkwin); CGRect troughBounds = {{macWin->xOff, macWin->yOff}, {Tk_Width(tkwin), Tk_Height(tkwin)}}; @@ -2418,7 +2420,6 @@ static void ThumbElementDraw( * largest int. */ - viewSize = RangeToFactor(100.0); HIThemeTrackDrawInfo info = { .version = 0, .bounds = troughBounds, @@ -2427,19 +2428,24 @@ static void ThumbElementDraw( kThemeTrackThumbRgnIsNotGhost, .enableState = kThemeTrackActive }; - info.trackInfo.scrollbar.viewsize = viewSize * .8; + factor = RangeToFactor(100.0); if (orientation == TTK_ORIENT_HORIZONTAL) { trackSize = troughBounds.size.width; thumbSize = b.width; - visibleSize = (thumbSize / trackSize) * viewSize; - info.max = viewSize - visibleSize; - info.value = info.max * (b.x / (trackSize - thumbSize)); + fraction = b.x / trackSize; } else { - thumbSize = b.height; trackSize = troughBounds.size.height; - visibleSize = (thumbSize / trackSize) * viewSize; - info.max = viewSize - visibleSize; - info.value = info.max * (b.y / (trackSize - thumbSize)); + thumbSize = b.height; + fraction = b.y / trackSize; + } + visibleSize = (thumbSize / trackSize) * factor; + info.max = factor - visibleSize; + info.trackInfo.scrollbar.viewsize = visibleSize; + if ([NSApp macMinorVersion] < 8 || + orientation == TTK_ORIENT_HORIZONTAL) { + info.value = factor * fraction; + } else { + info.value = info.max - factor * fraction; } if ((state & TTK_STATE_PRESSED) || (state & TTK_STATE_HOVER)) { @@ -3117,8 +3123,7 @@ static int AquaTheme_Init( /* * <<NOTE-TRACKS>> - * In some themes the Layouts for a progress bar has a trough element and - *a + * In some themes the Layouts for a progress bar has a trough element and a * pbar element. But in our case the appearance manager draws both parts * of the progress bar, so we just have a single element called ".track". */ |