From c230ccf1bd74831a9483787a9c30c1792583074d Mon Sep 17 00:00:00 2001 From: Don HO Date: Tue, 11 May 2021 03:44:48 +0200 Subject: [PATCH] Fix toolbar icons switching in dark mode makes incoherence in Preferences dialog ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9742#issuecomment-836757562 --- .../WinControls/Preference/preferenceDlg.cpp | 30 +++++++++++++++++++ .../WinControls/Preference/preferenceDlg.h | 2 ++ .../WinControls/Preference/preference_rc.h | 4 ++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 7ef99ec4a..77fc1ad43 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -214,6 +214,20 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM return TRUE; } + case PREF_MSG_ISCHECKED_GENERALPAGE: + { + if (!lParam) + return FALSE; + + bool isChecked = _generalSubDlg.isCheckedOrNot(wParam); + *((bool*)lParam) = isChecked; + return TRUE; + } + + case PREF_MSG_SETTOOLICONSFROMSTDTOSMALL: + _generalSubDlg.setToolIconsFromStdToSmall(); + return TRUE; + case WM_COMMAND : { if (LOWORD(wParam) == IDC_LIST_DLGTITLE) @@ -359,6 +373,13 @@ void PreferenceDlg::destroy() _delimiterSubDlg.destroy(); } +void GeneralSubDlg::setToolIconsFromStdToSmall() +{ + ::SendDlgItemMessage(_hSelf, IDC_RADIO_STANDARD, BM_SETCHECK, BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_RADIO_SMALLICON, BM_SETCHECK, BST_CHECKED, 0); + ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_REDUCE, 0); +} + INT_PTR CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { NppParameters& nppParam = NppParameters::getInstance(); @@ -806,6 +827,15 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM { case IDC_CHECK_DARKMODE_ENABLE: nppGUI._darkmode.enable = isCheckedOrNot(static_cast(wParam)); + + // if dark mode enabled & TB_STANDARD is selected, switch to TB_SMALL + if (nppGUI._darkmode.enable) + { + bool isStandardChecked = false; + ::SendMessage(_hParent, PREF_MSG_ISCHECKED_GENERALPAGE, IDC_RADIO_STANDARD, LPARAM(&isStandardChecked)); + if (isStandardChecked) + ::SendMessage(_hParent, PREF_MSG_SETTOOLICONSFROMSTDTOSMALL, 0, 0); + } changed = true; break; case IDC_CHECK_DARKMODE_ENABLE_EXPERIMENTAL: diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 206ceca6a..e1387ab12 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -37,6 +37,8 @@ class GeneralSubDlg : public StaticDialog { public : GeneralSubDlg() = default; + void setToolIconsFromStdToSmall(); + private : INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); }; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 4b1845d7f..944abd976 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -17,10 +17,12 @@ #ifndef PREFERENCE_RC_H #define PREFERENCE_RC_H + #define PREF_MSG_ISCHECKED_GENERALPAGE (WM_USER + 1) // wParam:checkbox/radiobutton ID in General page. lParam is type of "bool *" to get result + #define PREF_MSG_SETTOOLICONSFROMSTDTOSMALL (WM_USER + 2) + #define IDD_PREFERENCE_BOX 6000 #define IDC_BUTTON_CLOSE (IDD_PREFERENCE_BOX + 1) #define IDC_LIST_DLGTITLE (IDD_PREFERENCE_BOX + 2) - #define IDD_PREFERENCE_SUB_GENRAL 6100 //(IDD_PREFERENCE_BOX + 100) #define IDC_TOOLBAR_GB_STATIC (IDD_PREFERENCE_SUB_GENRAL + 1)