@@ -1275,9 +1275,18 @@ void MAC_Handler(OnScroll, NSNotification *nscr) {
12751275uint32_t SysColor (NSColor * sclr ) {
12761276 CGFloat rgba [4 ];
12771277 auto conv = colorUsingColorSpaceName_ (sclr , NSDeviceRGBColorSpace );
1278- getRed_green_blue_alpha_ (conv , & rgba [0 ], & rgba [1 ], & rgba [2 ], & rgba [3 ]);
1279- return ((uint8_t )(rgba [2 ] * 255 ) << 0 ) | ((uint8_t )(rgba [1 ] * 255 ) << 8 )
1280- | ((uint8_t )(rgba [0 ] * 255 ) << 16 ) | ((uint8_t )(rgba [3 ] * 255 ) << 24 );
1278+ getRed_green_blue_alpha_ (conv , & rgba [2 ], & rgba [1 ], & rgba [0 ], & rgba [3 ]);
1279+ if (currentControlTint (_ (NSColor )) == NSGraphiteControlTint )
1280+ rgba [2 ] = rgba [1 ] = rgba [0 ] =
1281+ 0.2126 * rgba [2 ] + 0.7152 * rgba [1 ] + 0.0722 * rgba [0 ];
1282+ return ((uint8_t )(rgba [0 ] * 255 ) << 0 ) | ((uint8_t )(rgba [1 ] * 255 ) << 8 )
1283+ | ((uint8_t )(rgba [2 ] * 255 ) << 16 ) | ((uint8_t )(rgba [3 ] * 255 ) << 24 );
1284+ }
1285+
1286+ uint32_t DimmerColor (uint32_t csrc , CGFloat fdim ) {
1287+ union { uint32_t u ; uint8_t b [4 ]; } c = {.u = csrc };
1288+ return ((uint8_t )(fdim * c .b [0 ]) << 0 ) | ((uint8_t )(fdim * c .b [1 ]) << 8 )
1289+ | ((uint8_t )(fdim * c .b [2 ]) << 16 ) | ((uint8_t )(c .b [3 ]) << 24 );
12811290}
12821291
12831292void MAC_Handler (PBoxDraw , NSRect rect ) {
@@ -1294,13 +1303,13 @@ void MAC_Handler(PBoxDraw, NSRect rect) {
12941303 ydim = mult * rect .size .height ,
12951304 xthr = 1 + (xdim - 1 ) * ctrl -> priv [1 ] / ctrl -> priv [2 ];
12961305 const bool iskw = isKeyWindow (window (self ));
1297- const uint32_t scbe = SysColor (disabledControlTextColor (_ (NSColor ))), /// border, empty, enabled+disabled
1298- scbf = (iskw )? SysColor (keyboardFocusIndicatorColor (_ (NSColor ))) /// border, filled, enabled
1299- : SysColor (headerTextColor (_ (NSColor ))), /// border, filled, disabled
1300- scae = SysColor (gridColor (_ (NSColor ))), /// area, empty, enabled+disabled
1301- scaf = (iskw )? SysColor (selectedControlColor (_ (NSColor ))) /// area, filled, enabled
1302- : SysColor (disabledControlTextColor (_ (NSColor ))); /// area, filled, disabled
1306+ const uint32_t scae = SysColor (gridColor (_ (NSColor ))),
1307+ scaf = (iskw )? SysColor (selectedControlColor (_ (NSColor )))
1308+ : SysColor (disabledControlTextColor (_ (NSColor ))),
1309+ scbe = DimmerColor (scae , 0.85 ),
1310+ scbf = DimmerColor (scaf , 0.85 );
13031311 uint32_t * bptr = calloc (xdim * ydim , sizeof (uint32_t ));
1312+ /// [sc: syscolor][a/b: area/border][e/f: empty/filled]
13041313 for (unsigned y = 2 ; y < ydim - 2 ; y ++ )
13051314 for (unsigned x = 2 ; x < xdim - 2 ; x ++ )
13061315 bptr [xdim * y + x ] = (x < xthr )? scaf : scae ;
0 commit comments