diff options
author | culler <culler> | 2019-07-01 19:57:58 (GMT) |
---|---|---|
committer | culler <culler> | 2019-07-01 19:57:58 (GMT) |
commit | 865691668477d52f751cefbf0c2c6bc5059d2ddd (patch) | |
tree | e9dd1d8819e8b72838fbc9f3187e2cc3d7aa5c3e /macosx/ttkMacOSXTheme.c | |
parent | 550866099de4398419d4c3d7d80365577b546fe8 (diff) | |
download | tk-865691668477d52f751cefbf0c2c6bc5059d2ddd.zip tk-865691668477d52f751cefbf0c2c6bc5059d2ddd.tar.gz tk-865691668477d52f751cefbf0c2c6bc5059d2ddd.tar.bz2 |
Improve scrollbar and ttk::scrollbar on OSX 10.8 and earlier.
Diffstat (limited to 'macosx/ttkMacOSXTheme.c')
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 129148f..b58a743 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -2374,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) { @@ -2410,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)}}; @@ -2424,7 +2420,6 @@ static void ThumbElementDraw( * largest int. */ - viewSize = RangeToFactor(100.0); HIThemeTrackDrawInfo info = { .version = 0, .bounds = troughBounds, @@ -2433,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)) { @@ -3123,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". */ |