Check-in [34a720b31d]
Not logged in

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

Overview
Comment:add tk upstream changes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 34a720b31d84bd128e2f906abf0b1d8212929357
User & Date: chw 2019-12-04 17:17:13
Context
2019-12-04
17:17
update awthemes to version 7.5 check-in: a32aea7c57 user: chw tags: trunk
17:17
add tk upstream changes check-in: 34a720b31d user: chw tags: trunk
09:39
add tip#496 implementation backported from tk trunk check-in: d2bff13257 user: chw tags: trunk
Changes

Changes to jni/sdl2tk/macosx/tkMacOSXColor.c.

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
...
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375

376
377

378
379
380

381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403

404
405
406
407
408

409

410
411
412
413
414
415
416
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
...
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static NSColorSpace* deviceRGB = NULL;
static CGFloat blueAccentRGBA[4] = {0, 122.0 / 255, 1.0, 1.0};
static CGFloat windowBackground[4] =
    {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};

static OSStatus
SetCGColorComponents(
    struct SystemColorMapEntry entry,
    unsigned long pixel,
................................................................................
    CGFloat rgba[4] = {0, 0, 0, 1};
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
    NSInteger colorVariant;
    static CGFloat graphiteAccentRGBA[4] =
	{152.0 / 255, 152.0 / 255, 152.0 / 255, 1.0};
#endif

    if (!deviceRGB) {
	deviceRGB = [NSColorSpace deviceRGBColorSpace];
    }

    /*
     * This function is called before our autorelease pool is set up,
     * so it needs its own pool.
     */

................................................................................
	 */

	if ([NSApp macMinorVersion] < 14) {
	    for (int i=0; i<3; i++) {
		rgba[i] = windowBackground[i];
	    }
	} else {
	    bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:
			    deviceRGB];
	    [bgColor getComponents: rgba];
	}
	if (rgba[0] + rgba[1] + rgba[2] < 1.5) {
	    for (int i=0; i<3; i++) {
		rgba[i] += entry.value*8.0 / 255.0;
	    }
	} else {
................................................................................
		rgba[i] -= entry.value*8.0 / 255.0;
	    }
	}
	break;
    case semantic:
	switch (entry.value) {
	case 0:
	    color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
	    break;
	case 1:
	    color = [[NSColor selectedTextColor] colorUsingColorSpace: deviceRGB];
	    break;
	case 2:
	    if ([NSApp macMinorVersion] > 9) {
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
		color = [[NSColor labelColor] colorUsingColorSpace: deviceRGB];
#endif
	    } else {
		color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];
	    }
	    break;
	case 3:
	    color = [[NSColor controlTextColor] colorUsingColorSpace:
			  deviceRGB];
	    break;
	case 4:
	    color = [[NSColor disabledControlTextColor] colorUsingColorSpace:
			  deviceRGB];

	    break;
	case 5:
	    if ([NSApp macMinorVersion] > 6) {
		color = [[NSColor whiteColor] colorUsingColorSpace:
						  deviceRGB];
	    } else {
		color = [[NSColor blackColor] colorUsingColorSpace:
						  deviceRGB];
	    }
	    break;
	case 6:
	    color = [[NSColor textBackgroundColor] colorUsingColorSpace:
			  deviceRGB];
	    break;
	case 7:
	    color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpace:
			  deviceRGB];

	    break;
	case 8:

#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
	    if (@available(macOS 10.14, *)) {
		color = [[NSColor controlAccentColor] colorUsingColorSpace:

							  deviceRGB];
	    } else {
		color = [NSColor colorWithColorSpace: deviceRGB
				 components: blueAccentRGBA
				 count: 4];
	    }
#else
	    colorVariant = [[NSUserDefaults standardUserDefaults]
			       integerForKey:@"AppleAquaColorVariant"];
	    if (colorVariant == 6) {
		color = [NSColor colorWithColorSpace: deviceRGB
				 components: graphiteAccentRGBA
				 count: 4];
	    } else {
		color = [NSColor colorWithColorSpace: deviceRGB
				 components: blueAccentRGBA
				 count: 4];
	    }
#endif
	    break;
	default:
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
	    if ([NSApp macMinorVersion] >= 10) {

		color = [[NSColor labelColor] colorUsingColorSpace:
			      deviceRGB];
		break;
	    }
#endif

	    color = [[NSColor textColor] colorUsingColorSpace: deviceRGB];

	    break;
	}
	[color getComponents: rgba];
	break;
    case clearColor:
	rgba[3]	= 0.0;
	break;
................................................................................
     */

    case HIText:
    case HIBackground:
    default:
	break;
    }
    *c = CGColorCreate(deviceRGB.CGColorSpace, rgba);
    [pool drain];
    return err;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
{
    OSStatus err = noErr;
    CGColorRef cgColor = nil;
    struct SystemColorMapEntry entry;
    CGRect rect;
    int code = (pixel >> 24) & 0xff;
    HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};
    static CGColorSpaceRef deviceRGBSpace = NULL;

    if (!deviceRGBSpace) {
	deviceRGBSpace = CGColorSpaceCreateDeviceRGB();
    }
    if (code < FIRST_SEMANTIC_COLOR) {
	cgColor = CopyCachedColor(gc, pixel);
    }
    if (!cgColor && GetEntryFromPixelCode(code, &entry)) {
	switch (entry.type) {
	case HIBrush:
	    err = ChkErr(HIThemeSetFill, entry.value, NULL, context,







|
<







 







|
|







 







|
<







 







|


|




|


|



|
<


|
<
>



|
<

|
<



|
<


|
<
>


>

<
|
>
|

|
|
|

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


<

>
|
<
<
<

>
|
>







 







|







 







<

<
<
<







262
263
264
265
266
267
268
269

270
271
272
273
274
275
276
...
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
...
313
314
315
316
317
318
319
320

321
322
323
324
325
326
327
...
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351

352
353
354

355
356
357
358
359

360
361

362
363
364
365

366
367
368

369
370
371
372
373

374
375
376
377
378
379
380
381













382
383

384
385
386



387
388
389
390
391
392
393
394
395
396
397
...
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
666
667
668
669
670
671
672

673



674
675
676
677
678
679
680
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

static NSColorSpace* sRGB = NULL;

static CGFloat windowBackground[4] =
    {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};

static OSStatus
SetCGColorComponents(
    struct SystemColorMapEntry entry,
    unsigned long pixel,
................................................................................
    CGFloat rgba[4] = {0, 0, 0, 1};
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
    NSInteger colorVariant;
    static CGFloat graphiteAccentRGBA[4] =
	{152.0 / 255, 152.0 / 255, 152.0 / 255, 1.0};
#endif

    if (!sRGB) {
	sRGB = [NSColorSpace sRGBColorSpace];
    }

    /*
     * This function is called before our autorelease pool is set up,
     * so it needs its own pool.
     */

................................................................................
	 */

	if ([NSApp macMinorVersion] < 14) {
	    for (int i=0; i<3; i++) {
		rgba[i] = windowBackground[i];
	    }
	} else {
	    bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB];

	    [bgColor getComponents: rgba];
	}
	if (rgba[0] + rgba[1] + rgba[2] < 1.5) {
	    for (int i=0; i<3; i++) {
		rgba[i] += entry.value*8.0 / 255.0;
	    }
	} else {
................................................................................
		rgba[i] -= entry.value*8.0 / 255.0;
	    }
	}
	break;
    case semantic:
	switch (entry.value) {
	case 0:
	    color = [[NSColor textColor] colorUsingColorSpace:sRGB];
	    break;
	case 1:
	    color = [[NSColor selectedTextColor] colorUsingColorSpace:sRGB];
	    break;
	case 2:
	    if ([NSApp macMinorVersion] > 9) {
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
		color = [[NSColor labelColor] colorUsingColorSpace:sRGB];
#endif
	    } else {
		color = [[NSColor textColor] colorUsingColorSpace:sRGB];
	    }
	    break;
	case 3:
	    color = [[NSColor controlTextColor] colorUsingColorSpace:sRGB];

	    break;
	case 4:
	    color = [[NSColor disabledControlTextColor]

			colorUsingColorSpace:sRGB];
	    break;
	case 5:
	    if ([NSApp macMinorVersion] > 6) {
		color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];

	    } else {
		color = [[NSColor blackColor] colorUsingColorSpace:sRGB];

	    }
	    break;
	case 6:
	    color = [[NSColor textBackgroundColor] colorUsingColorSpace:sRGB];

	    break;
	case 7:
	    color = [[NSColor selectedTextBackgroundColor]

			colorUsingColorSpace:sRGB];
	    break;
	case 8:
	    if ([NSApp macMinorVersion] >= 14) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400

		color = [[NSColor controlAccentColor]
			    colorUsingColorSpace:sRGB];
#endif
	    } else {
		color = [[NSColor
			    colorForControlTint:[NSColor currentControlTint]]
			        colorUsingColorSpace: sRGB];
	    }













	    break;
	default:

	    if ([NSApp macMinorVersion] >= 10) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
		color = [[NSColor labelColor] colorUsingColorSpace:sRGB];



#endif
	    } else {
		color = [[NSColor textColor] colorUsingColorSpace:sRGB];
	    }
	    break;
	}
	[color getComponents: rgba];
	break;
    case clearColor:
	rgba[3]	= 0.0;
	break;
................................................................................
     */

    case HIText:
    case HIBackground:
    default:
	break;
    }
    *c = CGColorCreate(sRGB.CGColorSpace, rgba);
    [pool drain];
    return err;
}
 
/*
 *----------------------------------------------------------------------
 *
................................................................................
{
    OSStatus err = noErr;
    CGColorRef cgColor = nil;
    struct SystemColorMapEntry entry;
    CGRect rect;
    int code = (pixel >> 24) & 0xff;
    HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};





    if (code < FIRST_SEMANTIC_COLOR) {
	cgColor = CopyCachedColor(gc, pixel);
    }
    if (!cgColor && GetEntryFromPixelCode(code, &entry)) {
	switch (entry.type) {
	case HIBrush:
	    err = ChkErr(HIThemeSetFill, entry.value, NULL, context,