Tk Source Code

Check-in [a82cd76e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix geometry of horizontal ttk scrollbars; hide thumb when no scrolling is possible.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-8476b75781
Files: files | file ages | folders
SHA3-256: a82cd76ed5b6eb60a005ff3333b702d4584758ae103b2436bf8df61f4c0648e3
User & Date: culler 2019-06-30 14:35:13
Context
2019-07-01
15:09
Fix layout bugs. check-in: b3e3fa37 user: culler tags: bug-8476b75781
2019-06-30
14:35
Fix geometry of horizontal ttk scrollbars; hide thumb when no scrolling is possible. check-in: a82cd76e user: culler tags: bug-8476b75781
02:15
Update documentation on do script Apple Event command check-in: a09f0e45 user: kevin_walzer tags: bug-8476b75781
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXScrlbr.c.

85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
typedef struct ScrollbarMetrics {
    SInt32 width, minThumbHeight;
    int minHeight, topArrowHeight, bottomArrowHeight;
    NSControlSize controlSize;
} ScrollbarMetrics;

static ScrollbarMetrics metrics = {
    15, 54, 26, 14, 14, kControlSizeNormal /* kThemeScrollBarMedium */

};

/*
 * Declarations of static functions defined later in this file:
 */

static void		ScrollbarEventProc(ClientData clientData,







|
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
typedef struct ScrollbarMetrics {
    SInt32 width, minThumbHeight;
    int minHeight, topArrowHeight, bottomArrowHeight;
    NSControlSize controlSize;
} ScrollbarMetrics;

static ScrollbarMetrics metrics = {
    /* kThemeScrollBarMedium */
    15, MIN_SLIDER_LENGTH, 26, 14, 14, kControlSizeNormal
};

/*
 * Declarations of static functions defined later in this file:
 */

static void		ScrollbarEventProc(ClientData clientData,
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

























211
212
213
214
215
216
217
218
219
220
221

222
223
224
225
226
227
228
    MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin);
    NSView *view = TkMacOSXDrawableView(macWin);
    CGPathRef path;
    CGPoint inner[2], outer[2];
    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);
    CGContextSetGrayStrokeColor(context, 232.0 / 255, 1.0);
    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);
    }
    CGContextSetShouldAntialias(context, true);
    CGContextFillPath(context);
    CFRelease(path);

}
#endif
	       
void
TkpDisplayScrollbar(
    ClientData clientData)	/* Information about window. */
{







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
>







179
180
181
182
183
184
185



















186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
    MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin);
    NSView *view = TkMacOSXDrawableView(macWin);
    CGPathRef path;
    CGPoint inner[2], outer[2];
    CGRect troughBounds = msPtr->info.bounds, thumbBounds;
    troughBounds.origin.y = [view bounds].size.height -
	(troughBounds.origin.y + troughBounds.size.height);



















    CGContextSetShouldAntialias(context, false);
    CGContextSetGrayFillColor(context, 250.0 / 255, 1.0);
    CGContextFillRect(context, troughBounds);
    CGContextSetGrayStrokeColor(context, 232.0 / 255, 1.0);
    CGContextStrokeLineSegments(context, inner, 2);
    CGContextSetGrayStrokeColor(context, 238.0 / 255, 1.0);
    CGContextStrokeLineSegments(context, outer, 2);

    /*
     * 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);
    }
}
#endif
	       
void
TkpDisplayScrollbar(
    ClientData clientData)	/* Information about window. */
{

Changes to macosx/ttkMacOSXTheme.c.

2343
2344
2345
2346
2347
2348
2349

2350
2351




2352
2353
2354
2355
2356
2357
2358
    int *minHeight,
    Ttk_Padding *paddingPtr)
{
    ScrollbarElement *scrollbar = elementRecord;
    int orientation = TTK_ORIENT_HORIZONTAL;

    Ttk_GetOrientFromObj(NULL, scrollbar->orientObj, &orientation);

    *minHeight = 18;
    *minWidth = 8;




}

static void ThumbElementDraw(
    void *clientData,
    void *elementRecord,
    Tk_Window tkwin,
    Drawable d,







>
|
|
>
>
>
>







2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
    int *minHeight,
    Ttk_Padding *paddingPtr)
{
    ScrollbarElement *scrollbar = elementRecord;
    int orientation = TTK_ORIENT_HORIZONTAL;

    Ttk_GetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
    if (orientation == TTK_ORIENT_VERTICAL) {
	*minHeight = 18;
	*minWidth = 8;
    } else {
	*minHeight = 8;
	*minWidth = 18;
    }	
}

static void ThumbElementDraw(
    void *clientData,
    void *elementRecord,
    Tk_Window tkwin,
    Drawable d,