Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Dealt with dark BevelButtons and progress bars. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | bug-0d63621b6c |
Files: | files | file ages | folders |
SHA3-256: |
cf564e76871ec867ed89b2d0c5a8bd14 |
User & Date: | culler 2019-03-15 21:31:44.815 |
Context
2019-03-15
| ||
23:22 | Small corrections. check-in: f1d3c394 user: culler tags: bug-0d63621b6c | |
21:31 | Dealt with dark BevelButtons and progress bars. check-in: cf564e76 user: culler tags: bug-0d63621b6c | |
21:14 | Fix some conditional compilation misconfiguration. check-in: f1f399c4 user: culler tags: bug-0d63621b6c | |
Changes
Changes to library/ttk/aquaTheme.tcl.
︙ | ︙ | |||
34 35 36 37 38 39 40 | ttk::style map TCheckbutton \ -foreground { disabled systemDisabledControlTextColor} ttk::style map TRadiobutton \ -foreground { disabled systemDisabledControlTextColor} ttk::style configure Toolbutton -padding 4 | < < < < < | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | ttk::style map TCheckbutton \ -foreground { disabled systemDisabledControlTextColor} ttk::style map TRadiobutton \ -foreground { disabled systemDisabledControlTextColor} ttk::style configure Toolbutton -padding 4 # Workaround for #1100117: # Actually, on Aqua we probably shouldn't stipple images in # disabled buttons even if it did work... ttk::style configure . -stipple {} # Notebook ttk::style configure TNotebook -tabmargins {10 0} -tabposition n ttk::style configure TNotebook -padding {18 8 18 17} ttk::style configure TNotebook.Tab -padding {12 3 12 2} ttk::style configure TNotebook.Tab -foreground white ttk::style map TNotebook.Tab \ |
︙ | ︙ |
Changes to macosx/ttkMacOSXTheme.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * ttkMacOSXTheme.c -- * * Tk theme engine for Mac OSX, using the Appearance Manager API. * * Copyright (c) 2004 Joe English * Copyright (c) 2005 Neil Madden * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * Copyright 2009 Kevin Walzer/WordTech Communications LLC. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * See also: * * <URL: http://developer.apple.com/documentation/Carbon/Reference/ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * ttkMacOSXTheme.c -- * * Tk theme engine for Mac OSX, using the Appearance Manager API. * * Copyright (c) 2004 Joe English * Copyright (c) 2005 Neil Madden * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright 2008-2009, Apple Inc. * Copyright 2009 Kevin Walzer/WordTech Communications LLC. * Copyright 2019 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * See also: * * <URL: http://developer.apple.com/documentation/Carbon/Reference/ |
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #define BEGIN_DRAWING(d) { \ TkMacOSXDrawingContext dc; \ if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;} #define END_DRAWING \ TkMacOSXRestoreDrawingContext(&dc); } #define HIOrientation kHIThemeOrientationNormal #ifdef __LP64__ #define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum)) #else #define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum)) #endif /* __LP64__ */ | > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #define BEGIN_DRAWING(d) { \ TkMacOSXDrawingContext dc; \ if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;} #define END_DRAWING \ TkMacOSXRestoreDrawingContext(&dc); } #define HIOrientation kHIThemeOrientationNormal #define NoThemeMetric 0xFFFFFFFF #ifdef __LP64__ #define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum)) #else #define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum)) #endif /* __LP64__ */ |
︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | * Colors and gradients used in Dark Mode. */ static CGFloat darkButtonFace[4] = {112.0/255, 113.0/255, 115.0/255, 1.0}; static CGFloat darkDisabledButtonFace[4] = {86.0/255, 87.0/255, 89.0/255, 1.0}; static CGFloat darkInactiveSelectedTab[4] = {159.0/255, 160.0/255, 161.0/255, 1.0}; static CGFloat darkTabSeparator[4] = {0.0, 0.0, 0.0, 0.25}; static CGFloat darkTopGradient[8] = {1.0, 1.0, 1.0, 0.3, 1.0, 1.0, 1.0, 0.0}; static CGFloat darkBackgroundGradient[8] = {0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.25}; static CGFloat darkInactiveGradient[8] = {89.0/255, 90.0/255, 93.0/255, 1.0, 119.0/255, 120.0/255, 122.0/255, 1.0}; static CGFloat darkSelectedGradient[8] = {23.0/255, 111.0/255, 232.0/255, 1.0, | > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | * Colors and gradients used in Dark Mode. */ static CGFloat darkButtonFace[4] = {112.0/255, 113.0/255, 115.0/255, 1.0}; static CGFloat darkDisabledButtonFace[4] = {86.0/255, 87.0/255, 89.0/255, 1.0}; static CGFloat darkInactiveSelectedTab[4] = {159.0/255, 160.0/255, 161.0/255, 1.0}; static CGFloat darkTabSeparator[4] = {0.0, 0.0, 0.0, 0.25}; static CGFloat darkTrack[4] = {1.0, 1.0, 1.0, 0.25}; static CGFloat darkTopGradient[8] = {1.0, 1.0, 1.0, 0.3, 1.0, 1.0, 1.0, 0.0}; static CGFloat darkBackgroundGradient[8] = {0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.25}; static CGFloat darkInactiveGradient[8] = {89.0/255, 90.0/255, 93.0/255, 1.0, 119.0/255, 120.0/255, 122.0/255, 1.0}; static CGFloat darkSelectedGradient[8] = {23.0/255, 111.0/255, 232.0/255, 1.0, |
︙ | ︙ | |||
657 658 659 660 661 662 663 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED >101300 */ /*---------------------------------------------------------------------- * +++ Button element: Used for elements drawn with DrawThemeButton. */ | < | 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | #endif /* MAC_OS_X_VERSION_MIN_REQUIRED >101300 */ /*---------------------------------------------------------------------- * +++ Button element: Used for elements drawn with DrawThemeButton. */ typedef struct { ThemeButtonKind kind; ThemeMetric heightMetric; } ThemeButtonParams; static ThemeButtonParams |
︙ | ︙ | |||
694 695 696 697 698 699 700 | /* * computeButtonDrawInfo -- * Fill in an appearance manager HIThemeButtonDrawInfo record. */ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( | | > > | > > | > > > > > > > > > > > > > > > | < | 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | /* * computeButtonDrawInfo -- * Fill in an appearance manager HIThemeButtonDrawInfo record. */ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( ThemeButtonParams *params, Ttk_State state, Tk_Window tkwin) { /* * See ButtonElementDraw for the explanation of why we always draw * PushButtons in the active state. The deprecated BezelButton can be * faked to at least be usable in Dark Mode if it is always drawn as * inactive. */ SInt32 HIThemeState; switch (params->kind) { case kThemePushButton: HIThemeState = kThemeStateActive; break; case kThemeBevelButton: if (TkMacOSXInDarkMode(tkwin)) { HIThemeState = kThemeStateInactive; break; } default: HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state); break; } const HIThemeButtonDrawInfo info = { .version = 0, .state = HIThemeState, .kind = params ? params->kind : 0, .value = Ttk_StateTableLookup(ButtonValueTable, state), .adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state), }; return info; } |
︙ | ︙ | |||
731 732 733 734 735 736 737 | } static void ButtonElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; | | | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | } static void ButtonElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ThemeButtonParams *params = clientData; const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0, tkwin); static const CGRect scratchBounds = {{0, 0}, {100, 100}}; CGRect contentBounds; ButtonElementSizeNoPadding( clientData, elementRecord, tkwin, widthPtr, heightPtr, paddingPtr); /* |
︙ | ︙ | |||
758 759 760 761 762 763 764 | static void ButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { BEGIN_DRAWING(d) ThemeButtonParams *params = clientData; CGRect bounds = BoxToRect(d, b); | | > | 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | static void ButtonElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { BEGIN_DRAWING(d) ThemeButtonParams *params = clientData; CGRect bounds = BoxToRect(d, b); HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state, tkwin); bounds = NormalizeButtonBounds(params->heightMetric, bounds); if (TkMacOSXInDarkMode(tkwin)) { #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 switch (info.kind) { case kThemePushButton: case kThemePopupButton: DrawDarkButton(bounds, info.kind, state, dc.context); break; case kThemeCheckBox: DrawDarkCheckBox(bounds, state, dc.context); break; case kThemeRadioButton: DrawDarkRadioButton(bounds, state, dc.context); break; default: ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); } #endif } else { /* * Apple's PushButton and PopupButton do not change their (white) fill * color when the window is inactive although, except in 10.7 (Lion), * the color of the arrow button on a PopupButton does change. For * some reason HITheme fills inactive buttons with a transparent color |
︙ | ︙ | |||
1184 1185 1186 1187 1188 1189 1190 1191 1192 | /*---------------------------------------------------------------------- * +++ DrawThemeTrack-based elements -- * Progress bars and scales. (See also: <<NOTE-TRACKS>>) */ static Ttk_StateTable ThemeTrackEnableTable[] = { { kThemeTrackDisabled, TTK_STATE_DISABLED, 0 }, | > > > > > | | 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 | /*---------------------------------------------------------------------- * +++ DrawThemeTrack-based elements -- * Progress bars and scales. (See also: <<NOTE-TRACKS>>) */ /* * Apple does not change the appearance of a slider when the window * becomes inactive. So we shouldn't either. */ static Ttk_StateTable ThemeTrackEnableTable[] = { { kThemeTrackDisabled, TTK_STATE_DISABLED, 0 }, { kThemeTrackActive, TTK_STATE_BACKGROUND, 0 }, { kThemeTrackActive, 0, 0 } /* { kThemeTrackNothingToScroll, ?, ? }, */ }; typedef struct { /* TrackElement client data */ ThemeTrackKind kind; SInt32 thicknessMetric; |
︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 | .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state), .trackInfo.progress.phase = 0, }; if (info.kind == kThemeSlider) { info.trackInfo.slider.pressState = state & TTK_STATE_PRESSED ? kThemeThumbPressed : 0; | > > > | | | > > > > > > > > > > > > > > > > | 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state), .trackInfo.progress.phase = 0, }; if (info.kind == kThemeSlider) { info.trackInfo.slider.pressState = state & TTK_STATE_PRESSED ? kThemeThumbPressed : 0; if (state & TTK_STATE_ALTERNATE) { info.trackInfo.slider.thumbDir = kThemeThumbDownward; } else { info.trackInfo.slider.thumbDir = kThemeThumbPlain; } } BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 if (TkMacOSXInDarkMode(tkwin)) { CGRect bounds = BoxToRect(d, b); NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB components: darkTrack count: 4]; if (orientation == TTK_ORIENT_HORIZONTAL) { bounds = CGRectInset(bounds, 1, bounds.size.height/2 - 3); } else { bounds = CGRectInset(bounds, bounds.size.width/2 - 3, 1); } SolidFillButtonFace(dc.context, bounds, 3, trackColor); } #endif ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec TrackElementSpec = { TK_STYLE_VERSION_2, sizeof(TrackElement), |
︙ | ︙ | |||
1338 1339 1340 1341 1342 1343 1344 | static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { SInt32 size = 24; /* @@@ Check HIG for correct default */ ChkErr(GetThemeMetric, kThemeMetricLargeProgressBarThickness, &size); | | > | 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 | static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { SInt32 size = 24; /* @@@ Check HIG for correct default */ ChkErr(GetThemeMetric, kThemeMetricLargeProgressBarThickness, &size); // *widthPtr = *heightPtr = size; *heightPtr = size; } static void PbarElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state) { PbarElement *pbar = elementRecord; |
︙ | ︙ | |||
1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | (orientation == TTK_ORIENT_HORIZONTAL ? kThemeTrackHorizontal : 0), .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state), .trackInfo.progress.phase = phase, }; BEGIN_DRAWING(d) ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(PbarElement), | > > > > > > > > > > > > > > > | 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | (orientation == TTK_ORIENT_HORIZONTAL ? kThemeTrackHorizontal : 0), .enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state), .trackInfo.progress.phase = phase, }; BEGIN_DRAWING(d) #if MAC_OS_X_VERSION_MIN_REQUIRED > 101300 if (TkMacOSXInDarkMode(tkwin)) { CGRect bounds = BoxToRect(d, b); NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB components: darkTrack count: 4]; if (orientation == TTK_ORIENT_HORIZONTAL) { bounds = CGRectInset(bounds, 1, bounds.size.height/2 - 3); } else { bounds = CGRectInset(bounds, bounds.size.width/2 - 3, 1); } SolidFillButtonFace(dc.context, bounds, 3, trackColor); } #endif ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation); END_DRAWING } static Ttk_ElementSpec PbarElementSpec = { TK_STYLE_VERSION_2, sizeof(PbarElement), |
︙ | ︙ | |||
1818 1819 1820 1821 1822 1823 1824 | &DisclosureElementSpec, &DisclosureParams); Ttk_RegisterElementSpec(themePtr, "Treeheading.cell", &TreeHeaderElementSpec, &ListHeaderParams); Ttk_RegisterElementSpec(themePtr, "Notebook.tab", &TabElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Notebook.client", &PaneElementSpec, 0); | | | | | | | | | | 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 | &DisclosureElementSpec, &DisclosureParams); Ttk_RegisterElementSpec(themePtr, "Treeheading.cell", &TreeHeaderElementSpec, &ListHeaderParams); Ttk_RegisterElementSpec(themePtr, "Notebook.tab", &TabElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Notebook.client", &PaneElementSpec, 0); Ttk_RegisterElementSpec(themePtr, "Labelframe.border", &GroupElementSpec,0); Ttk_RegisterElementSpec(themePtr, "Entry.field", &EntryElementSpec,0); Ttk_RegisterElementSpec(themePtr, "Spinbox.field", &EntryElementSpec,0); Ttk_RegisterElementSpec(themePtr, "separator", &SeparatorElementSpec,0); Ttk_RegisterElementSpec(themePtr, "hseparator", &SeparatorElementSpec,0); Ttk_RegisterElementSpec(themePtr, "vseparator", &SeparatorElementSpec,0); Ttk_RegisterElementSpec(themePtr, "sizegrip", &SizegripElementSpec,0); /* * <<NOTE-TRACKS>> * The Progressbar widget adjusts the size of the pbar element. * In the Aqua theme, the appearance manager computes the bar geometry; * we do all the drawing in the ".track" element and leave the .pbar out. */ Ttk_RegisterElementSpec(themePtr,"Scale.trough", &TrackElementSpec, &ScaleData); Ttk_RegisterElementSpec(themePtr,"Scale.slider", &SliderElementSpec,0); Ttk_RegisterElementSpec(themePtr,"Progressbar.track", &PbarElementSpec, 0); /* * Layouts: */ Ttk_RegisterLayouts(themePtr, LayoutTable); |
︙ | ︙ |