From 2a99edc7d020a0f8c2ffbba2ff470655e483d898 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 6 Apr 2020 16:15:18 +0100 Subject: [PATCH] Dark Mode tryouts --- .vs/rufus.vcxproj | 16 +- src/checksum.c | 2 + src/format_ext.c | 3 +- src/rufus.c | 513 ++++++++++++++++++++++++++++++++++++- src/rufus.h | 19 +- src/rufus.rc | 10 +- src/stdlg.c | 29 ++- src/ui.c | 628 ++++++++++++++++++++++++++++++++++++++++++++-- src/ui.h | 82 +++++- 9 files changed, 1236 insertions(+), 66 deletions(-) diff --git a/.vs/rufus.vcxproj b/.vs/rufus.vcxproj index 35bb2422..fd2bc2ad 100644 --- a/.vs/rufus.vcxproj +++ b/.vs/rufus.vcxproj @@ -133,7 +133,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) RequireAdministrator true Windows @@ -157,7 +157,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator true Windows @@ -183,7 +183,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator true Windows @@ -214,7 +214,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) RequireAdministrator true Windows @@ -239,7 +239,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) RequireAdministrator false Windows @@ -264,7 +264,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator false Windows @@ -291,7 +291,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator false Windows @@ -321,7 +321,7 @@ /utf-8 %(AdditionalOptions) - advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;comdlg32.lib;crypt32.lib;gdi32.lib;ole32.lib;setupapi.lib;shell32.lib;shlwapi.lib;uxtheme.lib;wintrust.lib;psapi.lib;%(AdditionalDependencies) RequireAdministrator false Windows diff --git a/src/checksum.c b/src/checksum.c index c51e6702..12910f72 100644 --- a/src/checksum.c +++ b/src/checksum.c @@ -57,6 +57,7 @@ #include "resource.h" #include "msapi_utf8.h" #include "localization.h" +#include "ui.h" #undef BIG_ENDIAN_HOST @@ -787,6 +788,7 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); apply_localization(IDD_CHECKSUM, hDlg); hDC = GetDC(hDlg); hFont = CreateFontA(-MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72), diff --git a/src/format_ext.c b/src/format_ext.c index 7fbd7849..c149d1f9 100644 --- a/src/format_ext.c +++ b/src/format_ext.c @@ -361,8 +361,9 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP ext2fs->super->s_max_mnt_count = -1; ext2fs->super->s_creator_os = EXT2_OS_WINDOWS; ext2fs->super->s_errors = EXT2_ERRORS_CONTINUE; - if (Label != NULL) + if ((Label != NULL) && (Label[0] != 0)) { static_strcpy(ext2fs->super->s_volume_name, Label); + } r = ext2fs_allocate_tables(ext2fs); if (r != 0) { diff --git a/src/rufus.c b/src/rufus.c index d1428f51..45eb1ee4 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -82,9 +82,10 @@ static unsigned int timer; static char uppercase_select[2][64], uppercase_start[64], uppercase_close[64], uppercase_cancel[64]; extern HANDLE update_check_thread; -extern BOOL enable_iso, enable_joliet, enable_rockridge; +extern BOOL enable_iso, enable_joliet, enable_rockridge, darkmode_toggle; extern BYTE* fido_script; extern HWND hFidoDlg; +extern HTHEME hTheme; extern uint8_t* grub2_buf; extern long grub2_len; extern char* szStatusMessage; @@ -918,6 +919,7 @@ BOOL CALLBACK LogCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) EXT_DECL(log_ext, "rufus.log", __VA_GROUP__("*.log"), __VA_GROUP__("Rufus log")); switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); apply_localization(IDD_LOG, hDlg); hLog = GetDlgItem(hDlg, IDC_LOG_EDIT); @@ -1929,6 +1931,485 @@ out: return ret; } +static wchar_t* imlist[] = +{ +L"ImmersiveStartBackground", +L"ImmersiveStartDesktopTilesBackground", +L"ImmersiveStartDesktopTilesText", +L"ImmersiveStartSystemTilesBackground", +L"ImmersiveStartFocusRect", +L"ImmersiveStartBackgroundDisabled", +L"ImmersiveStartPrimaryText", +L"ImmersiveStartSecondaryText", +L"ImmersiveStartDisabledText", +L"ImmersiveStartSelectionBackground", +L"ImmersiveStartSelectionPrimaryText", +L"ImmersiveStartHoverBackground", +L"ImmersiveStartHoverPrimaryText", +L"ImmersiveStartHighlight", +L"ImmersiveStartInlineErrorText", +L"ImmersiveStartControlLink", +L"ImmersiveStartControlLinkVisited", +L"ImmersiveStartControlLinkDisabled", +L"ImmersiveStartControlLinkPressed", +L"ImmersiveStartControlLinkMouseHover", +L"ImmersiveStartControlLinkForegroundPressed", +L"ImmersiveStartControlLinkBackgroundPressed", +L"ImmersiveStartCommandRowRest", +L"ImmersiveStartCommandRowHover", +L"ImmersiveStartCommandRowPressed", +L"ImmersiveStartCommandRowDisabled", +L"ImmersiveStartCommandRowHighlight", +L"ImmersiveStartFolderBackground", +L"ImmersiveStartThumbnailPlaceholder", +L"ImmersiveStartDefaultDarkFocusRect", +L"ImmersiveStartDefaultLightFocusRect", +L"ImmersiveSaturatedBackground", +L"ImmersiveSaturatedBackgroundDisabled", +L"ImmersiveSaturatedFocusRectDark", +L"ImmersiveSaturatedFocusRect", +L"ImmersiveSaturatedDefaultDarkFocusRect", +L"ImmersiveSaturatedDefaultLightFocusRect", +L"ImmersiveSaturatedPrimaryText", +L"ImmersiveSaturatedSecondaryText", +L"ImmersiveSaturatedSelectionBackground", +L"ImmersiveSaturatedSelectionPrimaryText", +L"ImmersiveSaturatedSelectionSecondaryText", +L"ImmersiveSaturatedHoverBackground", +L"ImmersiveSaturatedHoverPrimaryText", +L"ImmersiveSaturatedHoverSecondaryText", +L"ImmersiveSaturatedDivider", +L"ImmersiveSaturatedHighlight", +L"ImmersiveSaturatedInlineErrorText", +L"ImmersiveSaturatedControlLink", +L"ImmersiveSaturatedControlLinkVisited", +L"ImmersiveSaturatedControlLinkDisabled", +L"ImmersiveSaturatedControlLinkPressed", +L"ImmersiveSaturatedControlLinkMouseHover", +L"ImmersiveSaturatedControlLinkForegroundPressed", +L"ImmersiveSaturatedControlLinkBackgroundPressed", +L"ImmersiveSaturatedSystemToastBackground", +L"ImmersiveSaturatedDesktopToastBackground", +L"ImmersiveSaturatedFolderBackground", +L"ImmersiveSaturatedThumbnailPlaceholder", +L"ImmersiveSaturatedAltTabBackground", +L"ImmersiveSaturatedAltTabHoverRect", +L"ImmersiveSaturatedAltTabPressedRect", +L"ImmersiveSaturatedCommandRowRest", +L"ImmersiveSaturatedCommandRowHover", +L"ImmersiveSaturatedCommandRowPressed", +L"ImmersiveSaturatedCommandRowDisabled", +L"ImmersiveSaturatedCommandRowHighlight", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonText", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonTextHover", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonTextPressed", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonTextSelected", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonTextDisabled", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonRest", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonHover", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonPressed", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonSelected", +L"ImmersiveSaturatedSettingCharmSystemPaneButtonDisabled", +L"ImmersiveSaturatedBackButtonBar", +L"ImmersiveLightFocusRect", +L"ImmersiveLightBackground", +L"ImmersiveLightBackgroundDisabled", +L"ImmersiveLightTitleText", +L"ImmersiveLightPrimaryText", +L"ImmersiveLightSecondaryText", +L"ImmersiveLightTabText", +L"ImmersiveLightSelectedTabText", +L"ImmersiveLightSelectionBackground", +L"ImmersiveLightSelectionPrimaryText", +L"ImmersiveLightSelectionSecondaryText", +L"ImmersiveLightHoverBackground", +L"ImmersiveLightHoverPrimaryText", +L"ImmersiveLightHoverSecondaryText", +L"ImmersiveLightHighlight", +L"ImmersiveLightInlineErrorText", +L"ImmersiveLightWUNormal", +L"ImmersiveLightWUWarning", +L"ImmersiveLightWUError", +L"ImmersiveLightControlLink", +L"ImmersiveLightControlLinkVisited", +L"ImmersiveLightControlLinkDisabled", +L"ImmersiveLightControlLinkPressed", +L"ImmersiveLightControlLinkMouseHover", +L"ImmersiveLightControlLinkForegroundPressed", +L"ImmersiveLightControlLinkBackgroundPressed", +L"ImmersiveHardwarePrimaryText", +L"ImmersiveHardwareClockBackground", +L"ImmersiveHardwareClockText", +L"ImmersiveHardwareCharmsBarBackground", +L"ImmersiveHardwareCharmsBarBackgroundRest", +L"ImmersiveHardwareCharmsBarBackgroundHotTrack", +L"ImmersiveHardwareCharmsBarBackgroundPressed", +L"ImmersiveHardwareCharmsBarText", +L"ImmersiveHardwareCharmsBarTextDisabled", +L"ImmersiveHardwareGutterRest", +L"ImmersiveHardwareGutterDown", +L"ImmersiveHardwareSettingCharmSystemPaneButtonText", +L"ImmersiveHardwareSettingCharmSystemPaneButtonTextHover", +L"ImmersiveHardwareSettingCharmSystemPaneButtonTextPressed", +L"ImmersiveHardwareSettingCharmSystemPaneButtonTextSelected", +L"ImmersiveHardwareSettingCharmSystemPaneButtonTextDisabled", +L"ImmersiveHardwareSettingCharmSystemPaneButtonRest", +L"ImmersiveHardwareSettingCharmSystemPaneButtonHover", +L"ImmersiveHardwareSettingCharmSystemPaneButtonPressed", +L"ImmersiveHardwareSettingCharmSystemPaneButtonSelected", +L"ImmersiveHardwareSettingCharmSystemPaneButtonDisabled", +L"ImmersiveHardwareKeyboardBackground", +L"ImmersiveHardwareKeyboardKeyBackgroundDisabled", +L"ImmersiveHardwareKeyboardKeyPrimaryTextDisabled", +L"ImmersiveHardwareKeyboardKeySecondaryTextDisabled", +L"ImmersiveHardwareKeyboardKeyBackgroundRest", +L"ImmersiveHardwareKeyboardKeyPrimaryTextRest", +L"ImmersiveHardwareKeyboardKeySecondaryTextRest", +L"ImmersiveHardwareKeyboardKeyBackgroundPressed", +L"ImmersiveHardwareKeyboardKeyPrimaryTextPressed", +L"ImmersiveHardwareKeyboardKeySecondaryTextPressed", +L"ImmersiveHardwareKeyboardKeyBackgroundHover", +L"ImmersiveHardwareKeyboardDarkSpaceKeyBackgroundPressed", +L"ImmersiveHardwareDefaultKeyboardKeyBackgroundRest", +L"ImmersiveHardwareDefaultKeyboardKeyPrimaryTextRest", +L"ImmersiveHardwareDefaultKeyboardKeySecondaryTextRest", +L"ImmersiveHardwareDefaultKeyboardKeyBackgroundHover", +L"ImmersiveHardwareKeyboardNumberKeyBackground", +L"ImmersiveHardwareKeyboardNumberKeyBackgroundHover", +L"ImmersiveHardwareKeyboardNumberKeyText", +L"ImmersiveHardwareKeyboardFunctionKeyBackground", +L"ImmersiveHardwareKeyboardFunctionKeyBackgroundHover", +L"ImmersiveHardwareKeyboardFunctionKeyText", +L"ImmersiveHardwareKeyboardFunctionKeyTextDisabled", +L"ImmersiveHardwareKeyboardChildPanelBackground", +L"ImmersiveHardwareKeyboardChildPanelKeyBackground", +L"ImmersiveHardwareKeyboardChildKeyKeyText", +L"ImmersiveHardwareKeyboardKeyBorder", +L"ImmersiveHardwareHandwritingPanelBorder", +L"ImmersiveHardwareHandwritingPanelKanjiConversionText", +L"ImmersiveHardwareHandwritingPanelKanjiConversionBackground", +L"ImmersiveHardwareHandwritingPanelInsertModeCharacter", +L"ImmersiveHardwareHandwritingPanelSuggestedWord", +L"ImmersiveHardwareHandwritingPanelCorrectionText", +L"ImmersiveHardwareHandwritingPanelMatchedText", +L"ImmersiveHardwareHandwritingPanelButtonRest", +L"ImmersiveHardwareHandwritingPanelButtonHover", +L"ImmersiveHardwareHandwritingPanelButtonPress", +L"ImmersiveHardwareHandwritingPanelButtonBorder", +L"ImmersiveHardwareHandwritingPanelConversionSelectedBackground", +L"ImmersiveHardwareHandwritingPanelConversionUnselectedBackground", +L"ImmersiveHardwareHandwritingPanelConversionSelectedText", +L"ImmersiveHardwareHandwritingPanelConversionUnselectedText", +L"ImmersiveHardwareTextPredictionBackgroundRest", +L"ImmersiveHardwareTextPredictionBackgroundPressed", +L"ImmersiveHardwareTextPredictionBorder", +L"ImmersiveHardwareTextPredictionTextRest", +L"ImmersiveHardwareTextPredictionTextPressed", +L"ImmersiveHardwareControlLink", +L"ImmersiveHardwareControlLinkVisited", +L"ImmersiveHardwareControlLinkDisabled", +L"ImmersiveHardwareControlLinkPressed", +L"ImmersiveHardwareControlLinkMouseHover", +L"ImmersiveControlTransparent", +L"ImmersiveControlDarkRoundButtonOutlineDisabled", +L"ImmersiveControlDarkRoundButtonOutlineLayerRest", +L"ImmersiveControlDarkRoundButtonOutlineLayerHover", +L"ImmersiveControlDarkRoundButtonOutlineLayerPressed", +L"ImmersiveControlDarkRoundButtonGlyphDisabled", +L"ImmersiveControlDarkRoundButtonGlyphLayerRest", +L"ImmersiveControlDarkRoundButtonGlyphLayerHover", +L"ImmersiveControlDarkRoundButtonGlyphLayerPressed", +L"ImmersiveControlDarkRoundButtonFillLayerDisabled", +L"ImmersiveControlDarkRoundButtonFillLayerRest", +L"ImmersiveControlDarkRoundButtonFillLayerHover", +L"ImmersiveControlDarkRoundButtonFillLayerPressed", +L"ImmersiveControlLightRoundButtonOutlineDisabled", +L"ImmersiveControlLightRoundButtonOutlineLayerRest", +L"ImmersiveControlLightRoundButtonOutlineLayerHover", +L"ImmersiveControlLightRoundButtonOutlineLayerPressed", +L"ImmersiveControlLightRoundButtonGlyphDisabled", +L"ImmersiveControlLightRoundButtonGlyphLayerRest", +L"ImmersiveControlLightRoundButtonGlyphLayerHover", +L"ImmersiveControlLightRoundButtonGlyphLayerPressed", +L"ImmersiveControlLightRoundButtonFillLayerDisabled", +L"ImmersiveControlLightRoundButtonFillLayerRest", +L"ImmersiveControlLightRoundButtonFillLayerHover", +L"ImmersiveControlLightRoundButtonFillLayerPressed", +L"ImmersiveControlRadioButtonBackgroundSelected", +L"ImmersiveControlRadioButtonBackgroundDisabledSelected", +L"ImmersiveControlRadioButtonBackgroundDisabledHover", +L"ImmersiveControlRadioButtonBackgroundDisabledPressed", +L"ImmersiveControlRadioButtonTextDisabledSelected", +L"ImmersiveControlRadioButtonTextDisabledHover", +L"ImmersiveControlRadioButtonTextDisabledPressed", +L"ImmersiveControlRadioButtonTextSelected", +L"ImmersiveControlRadioButtonBorder", +L"ImmersiveControlRadioButtonSeparator", +L"ImmersiveControlDarkCheckboxLabelRest", +L"ImmersiveControlDarkCheckboxBackgroundRest", +L"ImmersiveControlDarkCheckboxBackgroundPressed", +L"ImmersiveControlDarkCheckboxBackgroundDisabled", +L"ImmersiveControlDarkCheckboxBackgroundHover", +L"ImmersiveControlDarkCheckboxLabelHover", +L"ImmersiveControlDarkCheckboxBorderRest", +L"ImmersiveControlDarkCheckboxBorderPressed", +L"ImmersiveControlDarkCheckboxBorderDisabled", +L"ImmersiveControlDarkCheckboxBorderHover", +L"ImmersiveControlDarkCheckboxLabelPressed", +L"ImmersiveControlDarkCheckboxLabelDisabled", +L"ImmersiveControlDarkCheckboxGlyphPressed", +L"ImmersiveControlDarkCheckboxGlyphHover", +L"ImmersiveControlDarkCheckboxGlyphRest", +L"ImmersiveControlDarkCheckboxGlyphDisabled", +L"ImmersiveControlLightCheckboxLabelPressed", +L"ImmersiveControlLightCheckboxLabelRest", +L"ImmersiveControlLightCheckboxBackgroundRest", +L"ImmersiveControlLightCheckboxBackgroundPressed", +L"ImmersiveControlLightCheckboxBackgroundDisabled", +L"ImmersiveControlLightCheckboxBackgroundHover", +L"ImmersiveControlLightCheckboxLabelHover", +L"ImmersiveControlLightCheckboxBorderRest", +L"ImmersiveControlLightCheckboxBorderPressed", +L"ImmersiveControlLightCheckboxBorderDisabled", +L"ImmersiveControlLightCheckboxBorderHover", +L"ImmersiveControlLightCheckboxLabelDisabled", +L"ImmersiveControlLightCheckboxGlyphPressed", +L"ImmersiveControlLightCheckboxGlyphHover", +L"ImmersiveControlLightCheckboxGlyphRest", +L"ImmersiveControlLightCheckboxGlyphDisabled", +L"ImmersiveControlDarkButtonBorderDisabled", +L"ImmersiveControlDarkButtonTextDisabled", +L"ImmersiveControlDarkButtonBorderPressed", +L"ImmersiveControlDarkButtonTextHover", +L"ImmersiveControlDarkButtonBorderHover", +L"ImmersiveControlDarkButtonTextPressed", +L"ImmersiveControlDarkButtonBorderRest", +L"ImmersiveControlDarkButtonTextRest", +L"ImmersiveControlDarkButtonBackgroundRest", +L"ImmersiveControlDarkButtonBackgroundPressed", +L"ImmersiveControlDarkButtonBackgroundDisabled", +L"ImmersiveControlDarkButtonBackgroundHover", +L"ImmersiveControlLightButtonBorderPressed", +L"ImmersiveControlLightButtonBackgroundPressed", +L"ImmersiveControlLightButtonBorderRest", +L"ImmersiveControlLightButtonBackgroundRest", +L"ImmersiveControlLightButtonBorderHover", +L"ImmersiveControlLightButtonBorderDisabled", +L"ImmersiveControlLightButtonBackgroundHover", +L"ImmersiveControlLightButtonBackgroundDisabled", +L"ImmersiveControlLightButtonTextHover", +L"ImmersiveControlLightButtonTextDisabled", +L"ImmersiveControlLightButtonTextPressed", +L"ImmersiveControlLightButtonTextRest", +L"ImmersiveControlDefaultDarkButtonTextPressed", +L"ImmersiveControlDefaultDarkButtonTextHover", +L"ImmersiveControlDefaultDarkButtonBorderRest", +L"ImmersiveControlDefaultDarkButtonTextRest", +L"ImmersiveControlDefaultDarkButtonBackgroundRest", +L"ImmersiveControlDefaultDarkButtonBackgroundPressed", +L"ImmersiveControlDefaultDarkButtonBorderHover", +L"ImmersiveControlDefaultDarkButtonBorderPressed", +L"ImmersiveControlDefaultDarkButtonBorderDisabled", +L"ImmersiveControlDefaultDarkButtonTextDisabled", +L"ImmersiveControlDefaultDarkButtonBackgroundDisabled", +L"ImmersiveControlDefaultDarkButtonBackgroundHover", +L"ImmersiveControlDefaultLightButtonBorderDisabled", +L"ImmersiveControlDefaultLightButtonTextDisabled", +L"ImmersiveControlDefaultLightButtonBorderPressed", +L"ImmersiveControlDefaultLightButtonTextPressed", +L"ImmersiveControlDefaultLightButtonTextRest", +L"ImmersiveControlDefaultLightButtonTextHover", +L"ImmersiveControlDefaultLightButtonBorderHover", +L"ImmersiveControlDefaultLightButtonBorderRest", +L"ImmersiveControlDefaultLightButtonBackgroundRest", +L"ImmersiveControlDefaultLightButtonBackgroundHover", +L"ImmersiveControlDefaultLightButtonBackgroundPressed", +L"ImmersiveControlDefaultLightButtonBackgroundDisabled", +L"ImmersiveControlDarkSelectBorderRest", +L"ImmersiveControlDarkSelectBackgroundHover", +L"ImmersiveControlDarkSelectBorderHover", +L"ImmersiveControlDarkSelectBackgroundPressed", +L"ImmersiveControlDarkSelectBorderPressed", +L"ImmersiveControlDarkSelectBackgroundDisabled", +L"ImmersiveControlDarkSelectTextRest", +L"ImmersiveControlDarkSelectTextPressed", +L"ImmersiveControlDarkSelectTextHover", +L"ImmersiveControlDarkSelectGlyphDisabled", +L"ImmersiveControlDarkSelectTextDisabled", +L"ImmersiveControlDarkSelectBorderDisabled", +L"ImmersiveControlDarkSelectGlyphRest", +L"ImmersiveControlDarkSelectTextHighlighted", +L"ImmersiveControlDarkSelectHighlightedTextPressed", +L"ImmersiveControlDarkSelectHighlightPressed", +L"ImmersiveControlDarkSelectHighlightSelected", +L"ImmersiveControlDarkSelectHighlightHover", +L"ImmersiveControlDarkSelectBackgroundRest", +L"ImmersiveControlDarkSelectSecondaryTextPressed", +L"ImmersiveControlDarkSelectSecondaryTextHighlighted", +L"ImmersiveControlDarkSelectSecondaryTextHover", +L"ImmersiveControlDarkSelectHighlightedSecondaryTextPressed", +L"ImmersiveControlLightSelectBorderRest", +L"ImmersiveControlLightSelectBackgroundRest", +L"ImmersiveControlLightSelectBackgroundHover", +L"ImmersiveControlLightSelectBorderHover", +L"ImmersiveControlLightSelectBackgroundPressed", +L"ImmersiveControlLightSelectBorderPressed", +L"ImmersiveControlLightSelectBackgroundDisabled", +L"ImmersiveControlLightSelectTextPressed", +L"ImmersiveControlLightSelectGlyphDisabled", +L"ImmersiveControlLightSelectTextDisabled", +L"ImmersiveControlLightSelectBorderDisabled", +L"ImmersiveControlLightSelectGlyphRest", +L"ImmersiveControlLightSelectTextHighlighted", +L"ImmersiveControlLightSelectHighlightedTextPressed", +L"ImmersiveControlLightSelectHighlightPressed", +L"ImmersiveControlLightSelectHighlightSelected", +L"ImmersiveControlLightSelectTextHover", +L"ImmersiveControlLightSelectTextRest", +L"ImmersiveControlLightSelectHighlightHover", +L"ImmersiveControlDarkRichEditBackgroundRest", +L"ImmersiveControlDarkRichEditBorderRest", +L"ImmersiveControlDarkRichEditBorderPressed", +L"ImmersiveControlDarkRichEditBorderFocus", +L"ImmersiveControlDarkRichEditBackgroundPressed", +L"ImmersiveControlDarkRichEditBackgroundFocus", +L"ImmersiveControlDarkRichEditBackgroundHover", +L"ImmersiveControlDarkRichEditBackgroundDisabled", +L"ImmersiveControlDarkRichEditBorderHover", +L"ImmersiveControlDarkRichEditTextHelper", +L"ImmersiveControlDarkRichEditTextRest", +L"ImmersiveControlDarkRichEditTextFocus", +L"ImmersiveControlDarkRichEditTextHighlighted", +L"ImmersiveControlDarkRichEditTextDisabled", +L"ImmersiveControlDarkRichEditBorderDisabled", +L"ImmersiveControlDarkRichEditTextHover", +L"ImmersiveControlDarkRichEditButtonBackgroundRest", +L"ImmersiveControlDarkRichEditButtonBackgroundHover", +L"ImmersiveControlDarkRichEditButtonBackgroundPressed", +L"ImmersiveControlDarkRichEditButtonGlyphRest", +L"ImmersiveControlDarkRichEditButtonGlyphHover", +L"ImmersiveControlDarkRichEditButtonGlyphPressed", +L"ImmersiveControlDarkRichEditHighlight", +L"ImmersiveControlLightRichEditBackgroundRest", +L"ImmersiveControlLightRichEditBorderRest", +L"ImmersiveControlLightRichEditBorderPressed", +L"ImmersiveControlLightRichEditBorderFocus", +L"ImmersiveControlLightRichEditBackgroundPressed", +L"ImmersiveControlLightRichEditBackgroundFocus", +L"ImmersiveControlLightRichEditBackgroundHover", +L"ImmersiveControlLightRichEditBackgroundDisabled", +L"ImmersiveControlLightRichEditBorderHover", +L"ImmersiveControlLightRichEditTextHelper", +L"ImmersiveControlLightRichEditTextRest", +L"ImmersiveControlLightRichEditTextFocus", +L"ImmersiveControlLightRichEditTextDisabled", +L"ImmersiveControlLightRichEditBorderDisabled", +L"ImmersiveControlLightRichEditTextHover", +L"ImmersiveControlLightRichEditButtonBackgroundRest", +L"ImmersiveControlLightRichEditButtonBackgroundHover", +L"ImmersiveControlLightRichEditButtonBackgroundPressed", +L"ImmersiveControlLightRichEditButtonGlyphRest", +L"ImmersiveControlLightRichEditButtonGlyphHover", +L"ImmersiveControlLightRichEditButtonGlyphPressed", +L"ImmersiveControlLightRichEditHighlight", +L"ImmersiveControlTooltipBackground", +L"ImmersiveControlTooltipDomainText", +L"ImmersiveControlTooltipText", +L"ImmersiveControlSliderTooltipText", +L"ImmersiveControlTooltipBorder", +L"ImmersiveControlDarkProgressBackground", +L"ImmersiveControlDarkProgressForeground", +L"ImmersiveControlLightProgressBackground", +L"ImmersiveControlLightProgressForeground", +L"ImmersiveControlProgressBorder", +L"ImmersiveControlDarkToggleLabelDisabled", +L"ImmersiveControlLightToggleLabelDisabled", +L"ImmersiveControlDarkToggleOnOffTextDisabled", +L"ImmersiveControlDarkToggleOnOffTextEnabled", +L"ImmersiveControlLightToggleOnOffTextDisabled", +L"ImmersiveControlLightToggleOnOffTextEnabled", +L"ImmersiveControlDarkToggleThumbDisabled", +L"ImmersiveControlLightToggleThumbDisabled", +L"ImmersiveControlDarkToggleTrackBackgroundDisabled", +L"ImmersiveControlLightToggleTrackBackgroundDisabled", +L"ImmersiveControlDarkToggleTrackBorderDisabled", +L"ImmersiveControlLightToggleTrackBorderDisabled", +L"ImmersiveControlDarkToggleTrackFillDisabled", +L"ImmersiveControlLightToggleTrackFillDisabled", +L"ImmersiveControlDarkToggleTrackGutterDisabled", +L"ImmersiveControlLightToggleTrackGutterDisabled", +L"ImmersiveControlDarkSliderThumbDisabled", +L"ImmersiveControlDarkSliderThumbHover", +L"ImmersiveControlDarkSliderThumbPressed", +L"ImmersiveControlDarkSliderThumbRest", +L"ImmersiveControlLightSliderThumbDisabled", +L"ImmersiveControlLightSliderThumbHover", +L"ImmersiveControlLightSliderThumbPressed", +L"ImmersiveControlLightSliderThumbRest", +L"ImmersiveControlDarkSliderTickMark", +L"ImmersiveControlLightSliderTickMark", +L"ImmersiveControlDarkSliderTrackBackgroundDisabled", +L"ImmersiveControlDarkSliderTrackBackgroundHover", +L"ImmersiveControlDarkSliderTrackBackgroundPressed", +L"ImmersiveControlDarkSliderTrackBackgroundRest", +L"ImmersiveControlLightSliderTrackBackgroundDisabled", +L"ImmersiveControlLightSliderTrackBackgroundHover", +L"ImmersiveControlLightSliderTrackBackgroundPressed", +L"ImmersiveControlLightSliderTrackBackgroundRest", +L"ImmersiveControlDarkSliderTrackBufferingDisabled", +L"ImmersiveControlDarkSliderTrackBufferingHover", +L"ImmersiveControlDarkSliderTrackBufferingPressed", +L"ImmersiveControlDarkSliderTrackBufferingRest", +L"ImmersiveControlLightSliderTrackBufferingDisabled", +L"ImmersiveControlLightSliderTrackBufferingHover", +L"ImmersiveControlLightSliderTrackBufferingPressed", +L"ImmersiveControlLightSliderTrackBufferingRest", +L"ImmersiveControlDarkSliderTrackFillDisabled", +L"ImmersiveControlDarkSliderTrackFillHover", +L"ImmersiveControlDarkSliderTrackFillPressed", +L"ImmersiveControlDarkSliderTrackFillRest", +L"ImmersiveControlLightSliderTrackFillDisabled", +L"ImmersiveControlLightSliderTrackFillHover", +L"ImmersiveControlLightSliderTrackFillPressed", +L"ImmersiveControlLightSliderTrackFillRest", +L"ImmersiveControlDarkToggleLabelEnabled", +L"ImmersiveControlLightToggleLabelEnabled", +L"ImmersiveControlDarkToggleThumbEnabled", +L"ImmersiveControlLightToggleThumbEnabled", +L"ImmersiveControlDarkToggleTrackBackgroundEnabled", +L"ImmersiveControlLightToggleTrackBackgroundEnabled", +L"ImmersiveControlDarkToggleTrackBorderEnabled", +L"ImmersiveControlLightToggleTrackBorderEnabled", +L"ImmersiveControlDarkToggleTrackFillEnabled", +L"ImmersiveControlLightToggleTrackFillEnabled", +L"ImmersiveControlDarkToggleTrackGutterEnabled", +L"ImmersiveControlLightToggleTrackGutterEnabled", +L"ImmersiveControlDefaultFocusRectDark", +L"ImmersiveControlDefaultFocusRectLight", +L"ImmersiveControlContextMenuBackgroundRest", +L"ImmersiveControlContextMenuBackgroundPressed", +L"ImmersiveControlContextMenuBackgroundHover", +L"ImmersiveControlContextMenuTextRest", +L"ImmersiveControlContextMenuTextPressed", +L"ImmersiveControlContextMenuSeparator", +L"ImmersiveBootBackground", +L"ImmersiveBootTitleText", +L"ImmersiveBootPrimaryText", +L"ImmersiveBootSecondaryText", +L"ImmersiveBootConfirmationButton", +L"ImmersiveBootMenuButtonGlyphBackground", +L"ImmersiveBootMenuButtonMouseHover", +L"ImmersiveBootMenuButtonPressedHighlight", +L"ImmersiveBootMenuButtonFocusRect", +L"ImmersiveBootProgressText", +L"ImmersiveBootErrorText", +L"ImmersiveBootEditBackground", +L"ImmersiveBootTextLinkRest", +L"ImmersiveBootTextLinkHover", +L"ImmersiveBootTextLinkPressed", +}; +extern void GenerateImmersiveColorList(void); + /* * Main dialog callback */ @@ -1964,8 +2445,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case WM_COMMAND: #ifdef RUFUS_TEST if (LOWORD(wParam) == IDC_TEST) { - DWORD DriveIndex = (DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)); - uprintf("label = '%s'", GetExtFsLabel(DriveIndex, 1)); + //darkmode_toggle = TRUE; + //EnableDarkMode(hDlg); + //RefreshTitleBar(hDlg); break; } #endif @@ -2429,6 +2911,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; case WM_INITDIALOG: + hTheme = OpenThemeData(hDlg, L"BUTTON"); + EnableDarkMode(hDlg); // Make sure fScale is set before the first call to apply localization, so that move/resize scale appropriately hDC = GetDC(hDlg); fScale = GetDeviceCaps(hDC, LOGPIXELSX) / 96.0f; @@ -2482,12 +2966,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA SetBkMode(pDI->hDC, TRANSPARENT); switch (pDI->itemID) { case SB_SECTION_LEFT: - SetTextColor(pDI->hDC, GetSysColor(COLOR_BTNTEXT)); + SetTextColor(pDI->hDC, GetThemeSysColor(hTheme, COLOR_BTNTEXT)); DrawTextExU(pDI->hDC, szStatusMessage, -1, &pDI->rcItem, DT_LEFT | DT_END_ELLIPSIS | DT_PATH_ELLIPSIS, NULL); return (INT_PTR)TRUE; case SB_SECTION_RIGHT: - SetTextColor(pDI->hDC, GetSysColor(COLOR_3DSHADOW)); + SetTextColor(pDI->hDC, GetThemeSysColor(hTheme, COLOR_3DSHADOW)); DrawTextExA(pDI->hDC, szTimer, -1, &pDI->rcItem, DT_LEFT, NULL); return (INT_PTR)TRUE; } @@ -2506,8 +2990,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA SetBkMode((HDC)wParam, TRANSPARENT); CreateStaticFont((HDC)wParam, &hyperlink_font, FALSE); SelectObject((HDC)wParam, hyperlink_font); - SetTextColor((HDC)wParam, TOOLBAR_ICON_COLOR); - return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + SetTextColor((HDC)wParam, GetColor(COLOR_TOOLBAR_ICON)); + return (INT_PTR)CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_BTNFACE)); case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { @@ -2581,6 +3065,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } break; + case WM_SETTINGCHANGE: + if (wcscmp((WCHAR*)lParam, L"ImmersiveColorSet") == 0) + EnableDarkMode(hDlg); + break; + // This is >>>SUPER WEIRD<<<. After a successful ISO or DD write (e.g. Arch 2016.01) // we no longer receive WM_QUERYENDSESSION messages, only WM_ENDSESSION. // But if we do a FreeDOS format, WM_QUERYENDSESSION is still sent to us alright. @@ -3225,6 +3714,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine uprintf("Failed to enable AutoMount"); } + // Init dark mode + InitDarkMode(); + relaunch: ubprintf("Localization set to '%s'", selected_locale->txt[0]); right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT); @@ -3257,6 +3749,7 @@ relaunch: MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid); goto out; } + SetThemeColours(hDlg); if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536)) SetWindowPos(hDlg, HWND_TOP, relaunch_rc.left, relaunch_rc.top, 0, 0, SWP_NOSIZE); @@ -3316,7 +3809,10 @@ relaunch: // Ctrl-T => Alternate Test mode that doesn't require a full rebuild if ((ctrl_without_focus || ((GetKeyState(VK_CONTROL) & 0x8000) && (msg.message == WM_KEYDOWN))) && (msg.wParam == 'T')) { - uprintf("TEST"); + ctrl_without_focus = FALSE; + darkmode_toggle = TRUE; + EnableDarkMode(hDlg); + RefreshTitleBar(hDlg); continue; } #endif @@ -3588,6 +4084,7 @@ out: DestroyAllTooltips(); ClrAlertPromptHook(); exit_localization(); + CloseThemeData(hTheme); safe_free(image_path); safe_free(locale_name); safe_free(update.download_url); diff --git a/src/rufus.h b/src/rufus.h index eba48a1a..92d05624 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -16,6 +16,7 @@ * along with this program. If not, see . */ #include +#include #include #include @@ -637,6 +638,7 @@ extern uint16_t OpenedLibrariesHandleSize; static __inline HMODULE GetLibraryHandle(char* szLibraryName) { HMODULE h = NULL; if ((h = GetModuleHandleA(szLibraryName)) == NULL) { + assert(OpenedLibrariesHandleSize < MAX_LIBRARY_HANDLES); if (OpenedLibrariesHandleSize >= MAX_LIBRARY_HANDLES) { uprintf("Error: MAX_LIBRARY_HANDLES is too small\n"); } else { @@ -647,15 +649,20 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) { } return h; } -#define PF_TYPE(api, ret, proc, args) typedef ret (api *proc##_t)args -#define PF_DECL(proc) static proc##_t pf##proc = NULL -#define PF_TYPE_DECL(api, ret, proc, args) PF_TYPE(api, ret, proc, args); PF_DECL(proc) -#define PF_INIT(proc, name) if (pf##proc == NULL) pf##proc = \ +#define PF_TYPE(api, ret, proc, args) typedef ret (api *proc##_t)args +#define PF_DECL(proc) static proc##_t pf##proc = NULL +#define PF_TYPE_DECL(api, ret, proc, args) PF_TYPE(api, ret, proc, args); PF_DECL(proc) +#define PF_INIT(proc, name) if (pf##proc == NULL) pf##proc = \ (proc##_t) GetProcAddress(GetLibraryHandle(#name), #proc) -#define PF_INIT_OR_OUT(proc, name) do {PF_INIT(proc, name); \ +#define PF_INIT_ID(proc, name, id) if (pf##proc == NULL) pf##proc = \ + (proc##_t) GetProcAddress(GetLibraryHandle(#name), MAKEINTRESOURCEA(id)) +#define PF_INIT_OR_OUT(proc, name) do {PF_INIT(proc, name); \ if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \ #proc, #name, WindowsErrorString()); goto out;} } while(0) -#define PF_INIT_OR_SET_STATUS(proc, name) do {PF_INIT(proc, name); \ +#define PF_INIT_ID_OR_OUT(proc, name, id) do {PF_INIT_ID(proc, name, id); \ + if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \ + #proc, #name, WindowsErrorString()); goto out;} } while(0) +#define PF_INIT_OR_SET_STATUS(proc, name) do {PF_INIT(proc, name); \ if ((pf##proc == NULL) && (NT_SUCCESS(status))) status = STATUS_NOT_IMPLEMENTED; } while(0) /* Custom application errors */ diff --git a/src/rufus.rc b/src/rufus.rc index edaf2b36..57a3cca6 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.10.1639" +CAPTION "Rufus 3.10.1640" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -395,8 +395,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,10,1639,0 - PRODUCTVERSION 3,10,1639,0 + FILEVERSION 3,10,1640,0 + PRODUCTVERSION 3,10,1640,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -414,13 +414,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.10.1639" + VALUE "FileVersion", "3.10.1640" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-3.10.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.10.1639" + VALUE "ProductVersion", "3.10.1640" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 32364410..5d4a7e97 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "rufus.h" #include "missing.h" @@ -61,6 +62,7 @@ static WNDPROC update_original_proc = NULL; static HWINEVENTHOOK ap_weh = NULL; static char title_str[3][128], button_str[128]; HWND hFidoDlg = NULL; +HTHEME hTheme; BOOL close_fido_cookie_prompts = FALSE; static int update_settings_reposition_ids[] = { @@ -527,6 +529,7 @@ INT_PTR CALLBACK LicenseCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM HWND hLicense; switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); hLicense = GetDlgItem(hDlg, IDC_LICENSE_TEXT); apply_localization(IDD_LICENSE, hDlg); CenterDialog(hDlg, NULL); @@ -571,6 +574,7 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); resized_already = FALSE; // Execute dialog localization apply_localization(IDD_ABOUTBOX, hDlg); @@ -600,7 +604,7 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP SendMessageA(hEdit[i], EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)edit_text[i]); SendMessage(hEdit[i], EM_SETSEL, -1, -1); SendMessage(hEdit[i], EM_SETEVENTMASK, 0, ENM_LINK|((i==0)?ENM_REQUESTRESIZE:0)); - SendMessage(hEdit[i], EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE)); + SendMessage(hEdit[i], EM_SETBKGNDCOLOR, 0, (LPARAM)GetThemeSysColor(hTheme, COLOR_BTNFACE)); } // Need to send an explicit SetSel to avoid being positioned at the end of richedit control when tabstop is used SendMessage(hEdit[1], EM_SETSEL, 0, 0); @@ -677,6 +681,7 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); // Get the system message box font. See http://stackoverflow.com/a/6057761 ncm.cbSize = sizeof(ncm); // If we're compiling with the Vista SDK or later, the NONCLIENTMETRICS struct @@ -699,9 +704,9 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP } apply_localization(IDD_NOTIFICATION, hDlg); - background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); - separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT)); - buttonface_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + background_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_WINDOW)); + separator_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_3DLIGHT)); + buttonface_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_BTNFACE)); SetTitleBarIcon(hDlg); CenterDialog(hDlg, NULL); // Change the default icon @@ -873,6 +878,7 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); // Don't overflow our max radio button if (nDialogItems > (IDC_SELECTION_CHOICEMAX - IDC_SELECTION_CHOICE1 + 1)) { uprintf("Warning: Too many options requested for Selection (%d vs %d)", @@ -892,8 +898,8 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA SendMessage(GetDlgItem(hDlg, IDNO), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); apply_localization(IDD_SELECTION, hDlg); - background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); - separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT)); + background_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_WINDOW)); + separator_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_3DLIGHT)); SetTitleBarIcon(hDlg); CenterDialog(hDlg, NULL); // Change the default icon and set the text @@ -1006,6 +1012,7 @@ INT_PTR CALLBACK ListCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); // Don't overflow our max radio button if (nDialogItems > (IDC_LIST_ITEMMAX - IDC_LIST_ITEM1 + 1)) { uprintf("Warning: Too many items requested for List (%d vs %d)", @@ -1025,8 +1032,8 @@ INT_PTR CALLBACK ListCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa SendMessage(GetDlgItem(hDlg, IDNO), WM_SETFONT, (WPARAM)hDlgFont, MAKELPARAM(TRUE, 0)); apply_localization(IDD_LIST, hDlg); - background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); - separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT)); + background_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_WINDOW)); + separator_brush = CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_3DLIGHT)); SetTitleBarIcon(hDlg); CenterDialog(hDlg, NULL); // Change the default icon and set the text @@ -1406,6 +1413,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); resized_already = FALSE; hUpdatesDlg = hDlg; apply_localization(IDD_UPDATE_POLICY, hDlg); @@ -1451,7 +1459,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l SendMessageA(hPolicy, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update_policy_text); SendMessage(hPolicy, EM_SETSEL, -1, -1); SendMessage(hPolicy, EM_SETEVENTMASK, 0, ENM_LINK|ENM_REQUESTRESIZE); - SendMessageA(hPolicy, EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE)); + SendMessageA(hPolicy, EM_SETBKGNDCOLOR, 0, (LPARAM)GetThemeSysColor(hTheme, COLOR_BTNFACE)); SendMessage(hPolicy, EM_REQUESTRESIZE, 0, 0); break; case WM_NOTIFY: @@ -1636,6 +1644,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR switch (message) { case WM_INITDIALOG: + EnableDarkMode(hDlg); apply_localization(IDD_NEW_VERSION, hDlg); download_status = 0; SetTitleBarIcon(hDlg); @@ -1665,7 +1674,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR CreateStaticFont((HDC)wParam, &hyperlink_font, TRUE); SelectObject((HDC)wParam, hyperlink_font); SetTextColor((HDC)wParam, RGB(0,0,125)); // DARK_BLUE - return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + return (INT_PTR)CreateSolidBrush(GetThemeSysColor(hTheme, COLOR_BTNFACE)); case WM_COMMAND: switch (LOWORD(wParam)) { case IDCLOSE: diff --git a/src/ui.c b/src/ui.c index 72a21e90..af6b180f 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * UI-related function calls - * Copyright © 2018-2019 Pete Batard + * Copyright © 2018-2020 Pete Batard * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,10 @@ #include #include #include +#include #include +#include +#include #include "rufus.h" #include "drive.h" @@ -44,6 +47,8 @@ UINT_PTR UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU; HIMAGELIST hUpImageList, hDownImageList; extern BOOL enable_fido, use_vds; +BOOL darkmode_supported = FALSE, darkmode_enabled = FALSE, darkmode_toggle = FALSE; +HTHEME hTheme = NULL; int update_progress_type = UPT_PERCENT; int advanced_device_section_height, advanced_format_section_height; // (empty) check box width, (empty) drop down width, button height (for and without dropdown match) @@ -67,6 +72,582 @@ static int nb_slots[OP_MAX]; static float slot_end[OP_MAX+1]; // shifted +1 so that we can subtract 1 to OP indexes static float previous_end; +// Dark theme functions + +PF_TYPE_DECL(WINAPI, BOOL, AllowDarkModeForWindow, (HWND, BOOL)); +PF_TYPE_DECL(WINAPI, BOOL, SetPreferredAppMode, (PreferredAppMode)); +PF_TYPE_DECL(WINAPI, BOOL, ShouldAppsUseDarkMode, (VOID)); +PF_TYPE_DECL(WINAPI, VOID, RefreshImmersiveColorPolicyState, (VOID)); +PF_TYPE_DECL(WINAPI, HRESULT, DwmSetWindowAttribute, (HWND, DWORD, LPCVOID, DWORD)); +PF_TYPE_DECL(WINAPI, DWORD, GetImmersiveUserColorSetPreference, (BOOL, BOOL)); +PF_TYPE_DECL(WINAPI, DWORD, GetImmersiveColorTypeFromName, (LPCWSTR)); +PF_TYPE_DECL(WINAPI, DWORD, GetImmersiveColorFromColorSetEx, (DWORD, DWORD, BOOL, DWORD)); +PF_TYPE_DECL(WINAPI, LPWSTR*, GetImmersiveColorNamedTypeByIndex, (DWORD)); + +COLORREF ThemeWindowColor = RGB(0, 0xff, 00); +COLORREF ThemeBackgroundColor = RGB(32, 32, 32); + +COLORREF ThemeTextColor = RGB(0xff, 0, 0); +COLORREF ThemeEdgeLightColor = RGB(0x0, 0xff, 0); +COLORREF ThemeEdgeHighlightColor = RGB(0x0, 0, 0xff); +COLORREF ThemeEdgeShadowColor = RGB(0xff, 0, 0); +COLORREF ThemeEdgeDarkShadowColor = RGB(0x0, 0xff, 0xff); +COLORREF ThemeEdgeFillColor = RGB(0x0, 0, 0xff); +COLORREF ThemeGlowColor = RGB(0xff, 0, 0); +COLORREF ThemeTextBorderColor = RGB(0x0, 0xff, 0); +COLORREF ThemeFillColorHint = RGB(0x0, 0, 0xff); +COLORREF ThemeBorderColorHint = RGB(0xff, 0, 0); +COLORREF ThemeAccentColorHint = RGB(0x0, 0xff, 0); + +HFONT PhpTabControlFontHandle = NULL; +HFONT PhpToolBarFontHandle = NULL; +HFONT PhpHeaderFontHandle = NULL; +HFONT PhpListViewFontHandle = NULL; +HFONT PhpMenuFontHandle = NULL; +HFONT PhpGroupboxFontHandle = NULL; +HFONT PhpStatusBarFontHandle = NULL; + +typedef struct _PH_WINDOW_PROPERTY_CONTEXT +{ + ULONG PropertyHash; + HWND WindowHandle; + PVOID Context; +} PH_WINDOW_PROPERTY_CONTEXT, *PPH_WINDOW_PROPERTY_CONTEXT; + +#define MAX_PROC_TABLE 64 + +struct { + HWND dlg; + WNDPROC proc; +} proc_table[MAX_PROC_TABLE] = { 0 }; + +static inline void insert_proc(HWND hDlg, WNDPROC WinProc) +{ + int i; + for (i = 0; i < MAX_PROC_TABLE; i++) { + if (proc_table[i].dlg == NULL) { + proc_table[i].dlg = hDlg; + proc_table[i].proc = WinProc; + return; + } + } + uprintf("Warning: Exceeded Windows proc table storage for dark mode"); +} + +static inline WNDPROC get_proc(HWND hDlg) +{ + int i; + for (i = 0; i < MAX_PROC_TABLE; i++) { + if (hDlg == proc_table[i].dlg) + return proc_table[i].proc; + } + return NULL; +} + +static inline void del_proc(HWND hDlg) +{ + int i; + for (i = 0; i < MAX_PROC_TABLE; i++) { + if (hDlg == proc_table[i].dlg) { + proc_table[i].proc = NULL; + proc_table[i].dlg = NULL; + return; + } + } +} + +LRESULT CALLBACK PhpThemeWindowSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + WCHAR className[MAX_PATH]; + LPNMCUSTOMDRAW customDraw; + WNDPROC old_proc = get_proc(hWnd); + + old_proc = get_proc(hWnd); + assert(old_proc != NULL); + + switch (uMsg) { + case WM_DESTROY: + SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)old_proc); + break; + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code != (UINT)NM_CUSTOMDRAW) + break; + customDraw = (LPNMCUSTOMDRAW)lParam; + if (!GetClassName(customDraw->hdr.hwndFrom, className, RTL_NUMBER_OF(className))) + className[0] = UNICODE_NULL; + +// uprintf("NM_CUSTOMDRAW: %S\r\n", className); + +// if (PhEqualStringZ(className, L"Button", FALSE)) { +// return PhpThemeWindowDrawButton(customDraw); +// } + //else if (PhEqualStringZ(className, L"ReBarWindow32", FALSE)) { + // return PhThemeWindowDrawRebar(customDraw); + //} else if (PhEqualStringZ(className, L"ToolbarWindow32", FALSE)) { + // return PhThemeWindowDrawToolbar((LPNMTBCUSTOMDRAW)customDraw); + //} else if (PhEqualStringZ(className, L"SysListView32", FALSE)) { + // LPNMLVCUSTOMDRAW listViewCustomDraw = (LPNMLVCUSTOMDRAW)customDraw; + + // if (listViewCustomDraw->dwItemType == LVCDI_GROUP) { + // return PhpThemeWindowDrawListViewGroup(listViewCustomDraw); + // } + //} + break; + case WM_CTLCOLOREDIT: + SetBkMode((HDC)wParam, TRANSPARENT); + SetTextColor((HDC)wParam, ThemeTextColor); + SetDCBrushColor((HDC)wParam, ThemeBackgroundColor); + return (INT_PTR)GetStockBrush(DC_BRUSH); +// case WM_CTLCOLORBTN: + case WM_CTLCOLORDLG: + case WM_CTLCOLORSTATIC: + case WM_CTLCOLORLISTBOX: + SetBkMode((HDC)wParam, TRANSPARENT); + SetTextColor((HDC)wParam, ThemeTextColor); + SetDCBrushColor((HDC)wParam, ThemeBackgroundColor); + return (INT_PTR)GetStockBrush(DC_BRUSH); + //case WM_MEASUREITEM: + // if (PhThemeWindowMeasureItem(hWnd, (LPMEASUREITEMSTRUCT)lParam)) + // return TRUE; + // break; + //case WM_DRAWITEM: + // if (PhThemeWindowDrawItem((LPDRAWITEMSTRUCT)lParam)) + // return TRUE; + // break; + } + + return CallWindowProc(old_proc, hWnd, uMsg, wParam, lParam); +} + +#if 0 +BOOLEAN CALLBACK PhpThemeWindowEnumChildWindows( + _In_ HWND WindowHandle, + _In_opt_ PVOID Context + ) +{ + WCHAR windowClassName[MAX_PATH]; + +// EnumChildWindows(WindowHandle, (WNDENUMPROC)PhpThemeWindowEnumChildWindows, NULL); + +// if (PhGetWindowContext(WindowHandle, SHRT_MAX)) // HACK +// return TRUE; + + if (!GetClassName(WindowHandle, windowClassName, RTL_NUMBER_OF(windowClassName))) + windowClassName[0] = UNICODE_NULL; + + //uprintf("PhpThemeWindowEnumChildWindows: %S\r\n", windowClassName); + + if (PhEqualStringZ(windowClassName, L"#32770", TRUE)) { + PhInitializeWindowTheme(WindowHandle, TRUE); + } else if (PhEqualStringZ(windowClassName, WC_BUTTON, FALSE)) { + if ((PhGetWindowStyle(WindowHandle) & BS_GROUPBOX) == BS_GROUPBOX) { + PhInitializeThemeWindowGroupBox(WindowHandle); + } + } else if (PhEqualStringZ(windowClassName, WC_TABCONTROL, FALSE)) { + PhInitializeThemeWindowTabControl(WindowHandle); + } else if (PhEqualStringZ(windowClassName, STATUSCLASSNAME, FALSE)) { + PhInitializeWindowThemeStatusBar(WindowHandle); + } else if (PhEqualStringZ(windowClassName, WC_EDIT, TRUE)) { + PhInitializeThemeWindowEditControl(WindowHandle); + } else if (PhEqualStringZ(windowClassName, WC_SCROLLBAR, FALSE)) { + if (nWindowsVersion >= WINDOWS_10) { + PhSetControlTheme(WindowHandle, L"DarkMode_Explorer"); + break; + } + } else if (PhEqualStringZ(windowClassName, WC_HEADER, TRUE)) { + PhInitializeThemeWindowHeader(WindowHandle); + } else if (PhEqualStringZ(windowClassName, WC_LISTVIEW, FALSE)) { + if (WindowsVersion >= WINDOWS_10_RS5) { + HWND tooltipWindow = ListView_GetToolTips(WindowHandle); + + switch (PhpThemeColorMode) { + case 0: // New colors + PhSetControlTheme(WindowHandle, L"explorer"); + PhSetControlTheme(tooltipWindow, L""); + break; + case 1: // Old colors + PhSetControlTheme(WindowHandle, L"DarkMode_Explorer"); + PhSetControlTheme(tooltipWindow, L"DarkMode_Explorer"); + break; + } + } + + if (PhpThemeBorderEnable) { + PhSetWindowStyle(WindowHandle, WS_BORDER, WS_BORDER); + PhSetWindowExStyle(WindowHandle, WS_EX_CLIENTEDGE, WS_EX_CLIENTEDGE); + } else { + PhSetWindowStyle(WindowHandle, WS_BORDER, 0); + PhSetWindowExStyle(WindowHandle, WS_EX_CLIENTEDGE, 0); + } + + SetWindowPos(WindowHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + + switch (PhpThemeColorMode) { + case 0: // New colors + ListView_SetBkColor(WindowHandle, RGB(0xff, 0xff, 0xff)); + ListView_SetTextBkColor(WindowHandle, RGB(0xff, 0xff, 0xff)); + ListView_SetTextColor(WindowHandle, RGB(0x0, 0x0, 0x0)); + break; + case 1: // Old colors + ListView_SetBkColor(WindowHandle, RGB(30, 30, 30)); + ListView_SetTextBkColor(WindowHandle, RGB(30, 30, 30)); + ListView_SetTextColor(WindowHandle, PhpThemeWindowTextColor); + break; + } + + //InvalidateRect(WindowHandle, NULL, FALSE); + } else if (PhEqualStringZ(windowClassName, WC_TREEVIEW, FALSE)) { + if (WindowsVersion >= WINDOWS_10_RS5) { + HWND tooltipWindow = TreeView_GetToolTips(WindowHandle); + + switch (PhpThemeColorMode) { + case 0: // New colors + PhSetControlTheme(tooltipWindow, L""); + break; + case 1: // Old colors + PhSetControlTheme(tooltipWindow, L"DarkMode_Explorer"); + break; + } + } + + switch (PhpThemeColorMode) { + case 0: // New colors + break; + case 1: // Old colors + TreeView_SetBkColor(WindowHandle, RGB(30, 30, 30)); + //TreeView_SetTextBkColor(WindowHandle, RGB(30, 30, 30)); + TreeView_SetTextColor(WindowHandle, PhpThemeWindowTextColor); + break; + } + + //InvalidateRect(WindowHandle, NULL, FALSE); + } else if (PhEqualStringZ(windowClassName, L"RICHEDIT50W", FALSE)) { + if (PhpThemeBorderEnable) + PhSetWindowStyle(WindowHandle, WS_BORDER, WS_BORDER); + else + PhSetWindowStyle(WindowHandle, WS_BORDER, 0); + + SetWindowPos(WindowHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + +#define EM_SETBKGNDCOLOR (WM_USER + 67) + switch (PhpThemeColorMode) { + case 0: // New colors + SendMessage(WindowHandle, EM_SETBKGNDCOLOR, 0, RGB(0xff, 0xff, 0xff)); + break; + case 1: // Old colors + SendMessage(WindowHandle, EM_SETBKGNDCOLOR, 0, RGB(30, 30, 30)); + break; + } + + //InvalidateRect(WindowHandle, NULL, FALSE); + } else if (PhEqualStringZ(windowClassName, L"PhTreeNew", FALSE)) { + if (WindowsVersion >= WINDOWS_10_RS5) { + HWND tooltipWindow = TreeNew_GetTooltips(WindowHandle); + + switch (PhpThemeColorMode) { + case 0: // New colors + PhSetControlTheme(tooltipWindow, L""); + break; + case 1: // Old colors + PhSetControlTheme(tooltipWindow, L"DarkMode_Explorer"); + break; + } + } + + if (PhpThemeBorderEnable) + PhSetWindowExStyle(WindowHandle, WS_EX_CLIENTEDGE, WS_EX_CLIENTEDGE); + else + PhSetWindowExStyle(WindowHandle, WS_EX_CLIENTEDGE, 0); + + SetWindowPos(WindowHandle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + + switch (PhpThemeColorMode) { + case 0: // New colors + TreeNew_ThemeSupport(WindowHandle, FALSE); + break; + case 1: // Old colors + TreeNew_ThemeSupport(WindowHandle, TRUE); + break; + } + + //InvalidateRect(WindowHandle, NULL, TRUE); + } + + return TRUE; +} +#endif + +#define GET_COLOR(type, name) (pfGetImmersiveColorFromColorSetEx(pfGetImmersiveUserColorSetPreference(FALSE, FALSE), \ + pfGetImmersiveColorTypeFromName(darkmode_enabled ? (L"Immersive" type L"Dark" name) : (L"Immersive" type L"Light" name)), \ + FALSE, 0) & 0xffffff) + +#define GET_COLOR2(type, name) (pfGetImmersiveColorFromColorSetEx(pfGetImmersiveUserColorSetPreference(FALSE, FALSE), \ + pfGetImmersiveColorTypeFromName(L"Immersive" type name), \ + FALSE, 0) & 0xffffff) + +#define GET_DARK_COLOR(name) (pfGetImmersiveColorFromColorSetEx(pfGetImmersiveUserColorSetPreference(FALSE, FALSE), \ + pfGetImmersiveColorTypeFromName(L"ImmersiveControlDark" name), FALSE, 0) & 0xffffff) + +static __inline const wchar_t* GetImmersiveColorName(BOOL darkmode, DWORD ColorId) +{ + switch (ColorId) { + case COLOR_BTNTEXT: + case COLOR_PROGRESS_NORMAL_TEXT: + return darkmode ? L"ImmersiveControlDarkButtonTextRest" : L"ImmersiveControlLightButtonTextRest"; + case COLOR_BTNFACE: + case COLOR_PROGRESS_INVERTED_TEXT: + return darkmode ? L"ImmersiveControlDarkButtonBackgroundRest" : L"ImmersiveControlLightButtonBackgroundRest"; + case COLOR_PROGRESS_NORMAL: + return darkmode ? L"ImmersiveControlDarkProgressForeground" : L"ImmersiveControlLightProgressForeground"; + case COLOR_PROGRESS_BACKGROUND: + return darkmode ? L"ImmersiveControlDarkProgressBackground" : L"ImmersiveControlLightProgressBackground"; + case COLOR_PROGRESS_BOX: + return darkmode ? L"ImmersiveControlDarkButtonBorderRest" : L"ImmersiveControlLightButtonBorderRest"; + case COLOR_PROGRESS_PAUSED: + return L"ImmersiveLightWUWarning"; + case COLOR_PROGRESS_ERROR: + return L"ImmersiveLightWUError"; + case COLOR_TOOLBAR_ICON: + return L"ImmersiveStartBackground"; + default: + assert(TRUE); + return NULL; + } +} + +#define ABGR2RGB(color) (((color & 0xFF0000) >> 16) | (color & 0x00FF00) | ((color & 0x0000FF) << 16)) + +void GenerateImmersiveColorList(void) +{ + wchar_t name[128], **named_type; + int i = 0; + DWORD ci; + COLORREF color; + for (i = 0; ; i++) { + named_type = pfGetImmersiveColorNamedTypeByIndex(i); + if (named_type == NULL) + break; + wcscpy(name, L"Immersive"); + wcscat(name, *named_type); + ci = pfGetImmersiveColorTypeFromName(name); + color = pfGetImmersiveColorFromColorSetEx(pfGetImmersiveUserColorSetPreference(FALSE, FALSE), + pfGetImmersiveColorTypeFromName(name), FALSE, 0); + color = ((color & 0x0000ff) << 16) | (color & 0x00ff00) | ((color & 0xff0000) >> 16); + uprintf("0x%04x 0x%04x %-70S 0x%06x", i, ci, name, color); + } + // uprintf("Index = %d", pfGetImmersiveColorTypeFromName(L"ImmersiveControlDarkButtonTextRest")); + + + //COLORREF color = pfGetImmersiveColorFromColorSetEx(pfGetImmersiveUserColorSetPreference(FALSE, FALSE), + // pfGetImmersiveColorTypeFromName(name), FALSE, 0); + //return ((color & 0x0000ff) << 16) | (color & 0x00ff00) | ((color & 0xff0000) >> 16); +} + +COLORREF GetColor(DWORD ColorId) +{ + const wchar_t* name = NULL; + + if (!darkmode_supported) { + if (ColorId <= COLOR_MENUBAR) + return GetThemeSysColor(hTheme, ColorId); + switch (ColorId) { + case COLOR_PROGRESS_NORMAL_TEXT: + return RGB(0x00, 0x00, 0x00); + case COLOR_PROGRESS_INVERTED_TEXT: + return RGB(0xFF, 0xFF, 0xFF); + case COLOR_PROGRESS_BACKGROUND: + return RGB(0xE6, 0xE6, 0xE6); + case COLOR_PROGRESS_BOX: + return RGB(0xBC, 0xBC, 0xBC); + case COLOR_PROGRESS_NORMAL: + return RGB(0x06, 0xB0, 0x25); + case COLOR_PROGRESS_PAUSED: + return RGB(0xDA, 0xCB, 0x26); + case COLOR_PROGRESS_ERROR: + return RGB(0xDA, 0x26, 0x26); + case COLOR_TOOLBAR_ICON: + return RGB(0x29, 0x80, 0xB9); + default: + assert(TRUE); + return RGB(0xFF, 0x00, 0x00); + } + } + + // Default "Lightmode" colours can be gotten through GetThemeSysColor() + if (!darkmode_enabled && (ColorId <= COLOR_MENUBAR)) + return GetThemeSysColor(hTheme, ColorId); + + // All the other colors are obtained through GetImmersiveColorFromColorSetEx() + return pfGetImmersiveColorFromColorSetEx(pfGetImmersiveUserColorSetPreference(FALSE, FALSE), + pfGetImmersiveColorTypeFromName(GetImmersiveColorName(darkmode_enabled, ColorId)), FALSE, 0) & 0xffffff; +} + +void SetThemeColours(HWND hDlg) +{ + static int last_mode = -1; + int new_mode = darkmode_enabled ? 1 : 0; + + // No need to go through this if we aren's switching modes + if (new_mode == last_mode) + return; + last_mode = new_mode; + + CloseThemeData(hTheme); + hTheme = GetWindowTheme(GetDlgItem(hDlg, IDCANCEL)); + +// ThemeBackgroundColor = darkmode_enabled ? RGB(32, 32, 32) : GetThemeSysColor(hTheme, COLOR_MENU); +// ThemeBackgroundColor = GetThemeSysColor(hTheme, COLOR_MENU); + + ThemeTextColor = GetColor(COLOR_BTNTEXT); + ThemeBackgroundColor = GetColor(COLOR_BTNFACE); +#if 0 + DWORD colorsetpref = pfGetImmersiveUserColorSetPreference(FALSE, FALSE); + DWORD colortype = pfGetImmersiveColorTypeFromName(L"ImmersiveControlTransparent"); +// ThemeBackgroundColor = pfGetImmersiveColorFromColorSetEx(colorsetpref, colortype, FALSE, 0) & 0xffffff; + ThemeTextColor = GET_COLOR(L"Control", L"ButtonTextRest"); // color & 0xffffff; + // ImmersiveControlDefaultDarkButtonBackgroundRest + ThemeBackgroundColor = darkmode_enabled ? GET_DARK_COLOR(L"ButtonBackgroundRest") : GetThemeSysColor(hTheme, COLOR_BTNFACE); // GET_COLOR2(L"Control", L"ContextMenuBackgroundRest"); // GET_COLOR(L"Control", L"ButtonBackgroundHover"); +// uprintf("colorsetpref = 0x%08x, colortype = 0x%08x, color = 0x%08x", colorsetpref, colortype, color); +#endif + +// var colour = Color.FromArgb((byte)((0xFF000000 & colorSetEx) >> 24), (byte)(0x000000FF & colorSetEx), +// (byte)((0x0000FF00 & colorSetEx) >> 8), (byte)((0x00FF0000 & colorSetEx) >> 16)); + +// ThemeBackgroundColor = GetThemeSysColor(hTheme, COLOR_MENU); + +// hTheme = OpenThemeData(hDlg, L"Button"); +// uprintf("hTheme1 = %p", hTheme); + +// PhpThemeBackgroundColor = GetThemeSysColor(hTheme, COLOR_WINDOW); + // These are the only solid colours we can get from the APIs + // since GetThemeSysColor() is f£$%^&*ing useless!!! +// GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_TEXTCOLOR, &ThemeTextColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_EDGELIGHTCOLOR, &ThemeEdgeLightColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_EDGEHIGHLIGHTCOLOR, &ThemeEdgeHighlightColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_EDGESHADOWCOLOR, &ThemeEdgeShadowColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_EDGEDKSHADOWCOLOR, &ThemeEdgeDarkShadowColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_EDGEFILLCOLOR, &ThemeEdgeFillColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_GLOWCOLOR, &ThemeGlowColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_TEXTBORDERCOLOR, &ThemeTextBorderColor); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_FILLCOLORHINT, &ThemeFillColorHint); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_BORDERCOLORHINT, &ThemeBorderColorHint); + GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_ACCENTCOLORHINT, &ThemeAccentColorHint); + //for (int i = 3800; i < 3900; i++) + // if (GetThemeColor(hTheme, WP_CAPTION, CS_ACTIVE, i, &PhpThemeBackgroundColor) == 0) + // uprintf("MATCH %d", i); + +// GetThemeColor(hTheme, BP_PUSHBUTTON, PBS_NORMAL, TMT_ACCENTCOLORHINT, &PhpThemeBackgroundColor); + +// HTHEME hTheme2 = GetWindowTheme(GetDlgItem(hMainDialog, IDC_LIST_USB_HDD)); +// r = GetThemeColor(hTheme2, BP_CHECKBOX, CBS_CHECKEDNORMAL, TMT_TEXTCOLOR, &PhpThemeWindowColor); +// uprintf("theme = %p, r = 0x%08X", hTheme, r); +// PhpThemeWindowTextColor = RGB(0xff, 0xff, 0xff); // GetThemeSysColor(hTheme, COLOR_BTNTEXT); +// PhpThemeWindowColor = GetThemeSysColor(hTheme, COLOR_WINDOW); +// PhpThemeBackgroundColor = GetThemeSysColor(hTheme, COLOR_BACKGROUND); +} + +#define SET_THEME(id) SetWindowTheme(GetDlgItem(hDlg, id), theme_str, NULL) + +void EnableDarkMode(HWND hDlg) +{ + WCHAR* theme_str = NULL; + WNDPROC proc; + BOOL use_immersive_dark_mode; + + if ((!darkmode_supported) || ((darkmode_enabled == pfShouldAppsUseDarkMode()) && !darkmode_toggle)) + return; + + // Hack. Without this the app starts in dark mode for reasons that only Microsoft knows! + Sleep(100); + +// uprintf("EnableDarkMode: darkmode_enabled1 = %s", darkmode_enabled ? "true" : "false"); + darkmode_enabled = darkmode_toggle ? !darkmode_enabled : pfShouldAppsUseDarkMode(); + darkmode_toggle = FALSE; + use_immersive_dark_mode = darkmode_enabled; + theme_str = darkmode_enabled ? L"Darkmode_Explorer" : L"Explorer"; + +// SetWindowTheme(hDlg, theme_str, NULL); + SET_THEME(IDOK); + SET_THEME(IDCANCEL); + SET_THEME(IDC_DEVICE); + SET_THEME(IDC_SAVE); + SET_THEME(IDC_TEST); + SET_THEME(IDS_BOOT_SELECTION_TXT); + SET_THEME(IDC_BOOT_SELECTION); + SET_THEME(IDC_SELECT); + SET_THEME(IDC_IMAGE_OPTION); + SET_THEME(IDC_START); + SET_THEME(IDC_LOG_CLEAR); + SET_THEME(IDC_LOG_SAVE); + SET_THEME(IDC_ABOUT_LICENSE); + SET_THEME(IDC_LIST_USB_HDD); +// SetWindowTheme(GetDlgItem(hDlg, IDCANCEL), theme_str, NULL); +// SetWindowTheme(GetDlgItem(hDlg, IDC_START), theme_str, NULL); +// SetWindowTheme(GetDlgItem(hDlg, IDC_SELECT), theme_str, NULL); +// SetWindowTheme(GetDlgItem(hDlg, IDS_DRIVE_PROPERTIES_TXT), theme_str, NULL); + +// return; + + SetThemeColours(hDlg); + + if (FAILED(pfDwmSetWindowAttribute(hDlg, DWMWA_USE_IMMERSIVE_DARK_MODE, &use_immersive_dark_mode, sizeof(BOOL)))) + pfDwmSetWindowAttribute(hDlg, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, &use_immersive_dark_mode, sizeof(BOOL)); + + proc = (WNDPROC)GetWindowLongPtr(hDlg, GWLP_WNDPROC); + + if (proc != PhpThemeWindowSubclassProc) { + insert_proc(hDlg, proc); + SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)PhpThemeWindowSubclassProc); + } + +// EnumChildWindows(hDlg, (WNDENUMPROC)PhpThemeWindowEnumChildWindows, NULL); + + InvalidateRect(hDlg, NULL, FALSE); // HACK + + EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB); +} + +BOOL IsHighContrast() +{ + HIGHCONTRASTW highContrast = { sizeof(highContrast) }; + if (SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(highContrast), &highContrast, FALSE)) + return highContrast.dwFlags & HCF_HIGHCONTRASTON; + return FALSE; +} + +// More or less stolen from Process Hacker. +// Why do I feel like I'm always playing catch up to Steven... ;) +void InitDarkMode(void) +{ + darkmode_supported = FALSE; + + // Dark mode require Windows 10 1809 or later + if ((nWindowsVersion < WINDOWS_10) || (nWindowsBuildNumber < 17763)) + return; + + PF_INIT_ID_OR_OUT(GetImmersiveColorFromColorSetEx, UxTheme, 95); + PF_INIT_ID_OR_OUT(GetImmersiveColorTypeFromName, UxTheme, 96); + PF_INIT_ID_OR_OUT(GetImmersiveUserColorSetPreference, UxTheme, 98); + PF_INIT_ID_OR_OUT(GetImmersiveColorNamedTypeByIndex, UxTheme, 100); + PF_INIT_ID_OR_OUT(RefreshImmersiveColorPolicyState, UxTheme, 104); + PF_INIT_ID_OR_OUT(ShouldAppsUseDarkMode, UxTheme, 132); + PF_INIT_ID_OR_OUT(AllowDarkModeForWindow, UxTheme, 133); + PF_INIT_ID_OR_OUT(SetPreferredAppMode, UxTheme, 135); + PF_INIT_OR_OUT(DwmSetWindowAttribute, DwmApi); + + darkmode_supported = TRUE; + + pfSetPreferredAppMode(PreferredAppModeDarkOnDark); + pfRefreshImmersiveColorPolicyState(); + + darkmode_enabled = pfShouldAppsUseDarkMode(); /// && !IsHighContrast(); + uprintf("InitDarkMode: darkmode_enabled = %s", darkmode_enabled ? "true" : "false"); + + +out: + return; +} + // Set the combo selection according to the data void SetComboEntry(HWND hDlg, int data) { @@ -503,6 +1084,19 @@ static void ResizeDialogs(int shift) Edit_Scroll(hLog, 0, Edit_GetLineCount(hLog)); } +// Hack to get Windows to *properly* refresh a dialog's title bar +void RefreshTitleBar(HWND hDlg) +{ + RECT rc; + POINT point; + + GetWindowRect(hMainDialog, &rc); + point.x = (rc.right - rc.left); + point.y = (rc.bottom - rc.top); + MoveWindow(hMainDialog, rc.left, rc.top, point.x, point.y + 1, TRUE); + MoveWindow(hMainDialog, rc.left, rc.top, point.x, point.y, TRUE); +} + // Thanks to Microsoft atrocious DPI handling, we must adjust for low DPI void AdjustForLowDPI(HWND hDlg) { @@ -875,20 +1469,20 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam wchar_t winfo[128]; static BOOL marquee_mode = FALSE; static uint32_t pos = 0, min = 0, max = 0xFFFF; - static COLORREF color = PROGRESS_BAR_NORMAL_COLOR; + COLORREF color = GetColor(COLOR_PROGRESS_NORMAL); switch (message) { case PBM_SETSTATE: switch (wParam) { case PBST_NORMAL: - color = PROGRESS_BAR_NORMAL_COLOR; + color = GetColor(COLOR_PROGRESS_NORMAL); break; case PBST_PAUSED: - color = PROGRESS_BAR_PAUSED_COLOR; + color = GetColor(COLOR_PROGRESS_PAUSED); break; case PBST_ERROR: - color = PROGRESS_BAR_ERROR_COLOR; + color = GetColor(COLOR_PROGRESS_ERROR); break; } return (INT_PTR)TRUE; @@ -912,7 +1506,7 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam if ((wParam == TRUE) && (!marquee_mode)) { marquee_mode = TRUE; pos = min; - color = PROGRESS_BAR_NORMAL_COLOR; + color = GetColor(COLOR_PROGRESS_NORMAL); SetTimer(hCtrl, TID_MARQUEE_TIMER, MARQUEE_TIMER_REFRESH, NULL); InvalidateRect(hProgress, NULL, TRUE); } else if ((wParam == FALSE) && (marquee_mode)) { @@ -953,7 +1547,7 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam // Optional first segment if (pos + ((max - min) / 5) > max) { rc.right = MulDiv(pos + ((max - min) / 5) - max, rc.right, max - min); - SetTextColor(hDC, PROGRESS_BAR_INVERTED_TEXT_COLOR); + SetTextColor(hDC, GetColor(COLOR_PROGRESS_INVERTED_TEXT)); SetBkColor(hDC, color); ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, winfo, (int)wcslen(winfo), NULL); @@ -963,8 +1557,8 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam // Optional second segment if (pos > min) { rc.right = MulDiv(pos - min, rc.right, max - min); - SetTextColor(hDC, PROGRESS_BAR_NORMAL_TEXT_COLOR); - SetBkColor(hDC, PROGRESS_BAR_BACKGROUND_COLOR); + SetTextColor(hDC, GetColor(COLOR_PROGRESS_NORMAL_TEXT)); + SetBkColor(hDC, GetColor(COLOR_PROGRESS_BACKGROUND)); ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, winfo, (int)wcslen(winfo), NULL); rc.left = rc.right; @@ -972,14 +1566,14 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam } // Second to last segment rc.right = MulDiv(pos - min + ((max - min) / 5), rc.right, max - min); - SetTextColor(hDC, PROGRESS_BAR_INVERTED_TEXT_COLOR); + SetTextColor(hDC, GetColor(COLOR_PROGRESS_INVERTED_TEXT)); SetBkColor(hDC, color); ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, winfo, (int)wcslen(winfo), NULL); } else { // First segment rc.right = (pos > min) ? MulDiv(pos - min, rc.right, max - min) : rc.left; - SetTextColor(hDC, PROGRESS_BAR_INVERTED_TEXT_COLOR); + SetTextColor(hDC, GetColor(COLOR_PROGRESS_INVERTED_TEXT)); SetBkColor(hDC, color); ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, winfo, (int)wcslen(winfo), NULL); @@ -987,12 +1581,12 @@ static INT_PTR CALLBACK ProgressCallback(HWND hCtrl, UINT message, WPARAM wParam // Last segment rc.left = rc.right; rc.right = full_right; - SetTextColor(hDC, PROGRESS_BAR_NORMAL_TEXT_COLOR); - SetBkColor(hDC, PROGRESS_BAR_BACKGROUND_COLOR); + SetTextColor(hDC, GetColor(COLOR_PROGRESS_NORMAL_TEXT)); + SetBkColor(hDC, GetColor(COLOR_PROGRESS_BACKGROUND)); ExtTextOut(hDC, (full_right - size.cx) / 2, (rc.bottom - size.cy) / 2, ETO_CLIPPED | ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, winfo, (int)wcslen(winfo), NULL); // Bounding rectangle - SetDCPenColor(hDC, PROGRESS_BAR_BOX_COLOR); + SetDCPenColor(hDC, GetColor(COLOR_PROGRESS_BOX)); Rectangle(hDC, rc2.left, rc2.top, rc2.right, rc2.bottom); EndPaint(hCtrl, &ps); return (INT_PTR)TRUE; @@ -1029,8 +1623,8 @@ void CreateAdditionalControls(HWND hDlg) // Fetch the up and down expand icons for the advanced options toolbar hDll = GetLibraryHandle("ComDlg32"); - hIconDown = (HICON)LoadImage(hDll, MAKEINTRESOURCE(577), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); - hIconUp = (HICON)LoadImage(hDll, MAKEINTRESOURCE(578), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); + hIconDown = (HICON)LoadImage(hDll, MAKEINTRESOURCE(darkmode_enabled ? 579 : 577), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); + hIconUp = (HICON)LoadImage(hDll, MAKEINTRESOURCE(darkmode_enabled ? 580 : 578), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED); // Fallback to using Shell32 if we can't locate the icons we want in ComDlg32 hDll = GetLibraryHandle("Shell32"); if (hIconUp == NULL) @@ -1568,7 +2162,7 @@ void SetBootTypeDropdownWidth(void) void OnPaint(HDC hdc) { int i; - HPEN hp = CreatePen(0, (fScale < 1.5f) ? 2 : 3, RGB(0, 0, 0)); + HPEN hp = CreatePen(0, (fScale < 1.5f) ? 2 : 3, ThemeEdgeDarkShadowColor); SelectObject(hdc, hp); for (i = 0; i < ARRAYSIZE(section_vpos); i++) { MoveToEx(hdc, mw + 10, section_vpos[i], NULL); diff --git a/src/ui.h b/src/ui.h index be8a4489..da5d12c5 100644 --- a/src/ui.h +++ b/src/ui.h @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * UI-related function calls - * Copyright © 2018 Pete Batard + * Copyright © 2018-2020 Pete Batard * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,17 +23,71 @@ #pragma once -// Progress bar colors -#define PROGRESS_BAR_NORMAL_TEXT_COLOR RGB(0x00, 0x00, 0x00) -#define PROGRESS_BAR_INVERTED_TEXT_COLOR RGB(0xFF, 0xFF, 0xFF) -#define PROGRESS_BAR_BACKGROUND_COLOR RGB(0xE6, 0xE6, 0xE6) -#define PROGRESS_BAR_BOX_COLOR RGB(0xBC, 0xBC, 0xBC) -#define PROGRESS_BAR_NORMAL_COLOR RGB(0x06, 0xB0, 0x25) -#define PROGRESS_BAR_PAUSED_COLOR RGB(0xDA, 0xCB, 0x26) -#define PROGRESS_BAR_ERROR_COLOR RGB(0xDA, 0x26, 0x26) +typedef enum _WINDOWCOMPOSITIONATTRIB +{ + WCA_UNDEFINED = 0, + WCA_NCRENDERING_ENABLED = 1, + WCA_NCRENDERING_POLICY = 2, + WCA_TRANSITIONS_FORCEDISABLED = 3, + WCA_ALLOW_NCPAINT = 4, + WCA_CAPTION_BUTTON_BOUNDS = 5, + WCA_NONCLIENT_RTL_LAYOUT = 6, + WCA_FORCE_ICONIC_REPRESENTATION = 7, + WCA_EXTENDED_FRAME_BOUNDS = 8, + WCA_HAS_ICONIC_BITMAP = 9, + WCA_THEME_ATTRIBUTES = 10, + WCA_NCRENDERING_EXILED = 11, + WCA_NCADORNMENTINFO = 12, + WCA_EXCLUDED_FROM_LIVEPREVIEW = 13, + WCA_VIDEO_OVERLAY_ACTIVE = 14, + WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15, + WCA_DISALLOW_PEEK = 16, + WCA_CLOAK = 17, + WCA_CLOAKED = 18, + WCA_ACCENT_POLICY = 19, + WCA_FREEZE_REPRESENTATION = 20, + WCA_EVER_UNCLOAKED = 21, + WCA_VISUAL_OWNER = 22, + WCA_HOLOGRAPHIC = 23, + WCA_EXCLUDED_FROM_DDA = 24, + WCA_PASSIVEUPDATEMODE = 25, + WCA_USEDARKMODECOLORS = 26, + WCA_LAST = 27 +} WINDOWCOMPOSITIONATTRIB; -// Toolbar icons main color -#define TOOLBAR_ICON_COLOR RGB(0x29, 0x80, 0xB9) +typedef struct _WINDOWCOMPOSITIONATTRIBDATA +{ + WINDOWCOMPOSITIONATTRIB Attrib; + PVOID pvData; + SIZE_T cbData; +} WINDOWCOMPOSITIONATTRIBDATA; + +typedef enum _PreferredAppMode +{ + PreferredAppModeDisabled, + PreferredAppModeDarkOnDark, + PreferredAppModeDarkAlways +} PreferredAppMode; + +// Additional DWMWINDOWATTRIBUTE modes +#define DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 19 +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +// Colors +extern COLORREF cWindow, cButtonFace, cButtonText, c3DLight, c3DShadow; +extern COLORREF cProgressNormalText, cProgressInvertedText, cProgressBackground, cProgressBox; +extern COLORREF cProgressNormalSolid, cProgressPausedSolid, cProgressErrorSolid, cToolbarIcon; + +#define COLOR_PROGRESS_NORMAL_TEXT 1000 +#define COLOR_PROGRESS_INVERTED_TEXT 1001 +#define COLOR_PROGRESS_BACKGROUND 1002 +#define COLOR_PROGRESS_BOX 1003 +#define COLOR_PROGRESS_NORMAL 1004 +#define COLOR_PROGRESS_PAUSED 1005 +#define COLOR_PROGRESS_ERROR 1006 +#define COLOR_TOOLBAR_ICON 1007 // Toolbar default style #define TOOLBAR_STYLE ( WS_CHILD | WS_TABSTOP | WS_VISIBLE | \ @@ -75,6 +129,7 @@ extern HWND hMultiToolbar, hSaveToolbar, hHashToolbar, hAdvancedDeviceToolbar, h extern HFONT hInfoFont; extern UINT_PTR UM_LANGUAGE_MENU_MAX; extern BOOL advanced_mode_device, advanced_mode_format, force_large_fat32, app_changed_size; +extern BOOL darkmode_supported; extern loc_cmd* selected_locale; extern uint64_t persistence_size; extern const char *sfd_name, *flash_type[BADLOCKS_PATTERN_TYPES]; @@ -83,12 +138,17 @@ extern int advanced_device_section_height, advanced_format_section_height; extern int windows_to_go_selection, persistence_unit_selection; extern int selection_default, cbw, ddw, ddbh, bh, update_progress_type; +extern COLORREF GetColor(DWORD ColorId); +extern void SetThemeColours(HWND hDlg); +extern void InitDarkMode(void); +extern void EnableDarkMode(HWND hDlg); extern void SetComboEntry(HWND hDlg, int data); extern void GetBasicControlsWidth(HWND hDlg); extern void GetMainButtonsWidth(HWND hDlg); extern void GetHalfDropwdownWidth(HWND hDlg); extern void GetFullWidth(HWND hDlg); extern void PositionMainControls(HWND hDlg); +extern void RefreshTitleBar(HWND hDlg); extern void AdjustForLowDPI(HWND hDlg); extern void SetSectionHeaders(HWND hDlg); extern void SetPersistencePos(uint64_t pos); -- 2.45.2.windows.1